akhauriyash/Code-Regression huggingface dataset:
// Aizu Vol-1 0108: Operation of Frequency of Appearance
// 2017.8.2

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>

char *gets(char *);
char buf[200], *p;

int getInt(void)
{
	int n = 0;
	while (isspace(*p)) p++;
	while (isdigit(*p)) n = 10 * n + (*p++ - '0');
	return n;
}

#define MAX 100
char f[MAX+5];
char a[2][15];

int main()
{
	int i, n, k, cnt, k2;

	while (1) {
		gets(p = buf);
		if (!(n = getInt())) break;
		gets(p = buf);
		for (i = 0; i < n; i++) a[0][i] = getInt();
		for (k = cnt = 0; ; k = k2, cnt++) {
			for (i = 0; i < n; i++) f[a[k][i]]++;
			for (i = 0, k2 = !k; i < n; i++) a[k2][i] = f[a[k][i]];
			for (i = 0; i < n; i++) f[a[k][i]] = 0;
			if (!memcmp(a[0], a[1], n)) break;
		}
		printf("%d\n%d", cnt, a[0][0]);
		for (i = 1; i < n; i++) printf(" %d", a[0][i]);
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 536
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#include <cassert>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define Cout(x) cout << x << endl;
#define check(v) rep(i,v.size()) cout << v[i] << endl;
#define vint(x) vector<int> x
#define vll(x) vector<long long> x
#define vstr(x) vector<string> x
const long long LLINF = 1LL<<60;
const int INF = 1e9;
const long long MOD = 1000000007;
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; }
typedef long long ll;
#define pint pair<int,int>
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m; cin >> n >> m;
    if(n==m) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
char c[12];
int a[12],ans=0;
int main()
{
	for(int i=0;i<10;i++)
		cin>>c[i];
	for(int i=0;i<4;i++)
	{
		a[i] = c[i]-'0';
		ans*=10;
		ans+=a[i];
	}
	if(ans<2019)
		cout<<"Heisei"<<endl;
	else if(ans>2019)
		cout<<"TBD"<<endl;
	else
	{
		ans=0;
		for(int i=5;i<7;i++)
		{
			a[i] =c[i]-'0';
			ans*=10;
			ans+=a[i];
		}
		if(ans<4)
			cout<<"Heisei"<<endl;
		else if(ans>4)
			cout<<"TBD"<<endl;
		else
		{
			ans=0;
			for(int i=8;i<10;i++)
			{
				a[i] =c[i]-'0';
				ans*=10;
				ans+=a[i];
			}
			if(ans<=30)
				cout<<"Heisei"<<endl;
			else
				cout<<"TBD"<<endl;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
	int one, all, i;
	double many, heikin;
	
	all = 0;
	
	i = 0;
	
	while(scanf("%d,%lf", &one, &many) != EOF)
	{
		
		all += one * many;
		
		heikin += many;
		
		i++;
	
	}
	
	printf("%d\n%.f\n", all, (heikin / i + 0.5)); 
		
	
    return 0;
}

Measured memory_bytes: 1228
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <string>

using namespace std;

int main() {
  string s,t;
  cin >> s >> t;

  int ans = 0;

  for (int i=0; i<3; i++)
    if (s[i] == t[i]) ans++;

  cout << ans << endl;
}


Measured memory_bytes: 504
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;
#define all(x) x.begin(),x.end()
const ll INF = 1e9;
const ll mod = 1e9 + 7;
 
int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}
 
ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

bool is_prime(long long N){
    if (N == 1) return false;
    for (long long i = 2;i * i <= N;i++){
        if (N % i == 0) return false;
    }
    return true;
}
 
ll lcm(ll a,ll b){
    return ((a * b == 0)) ? 0 : (a / gcd(a,b) * b);
}
 
double DegreeToRadian(double degree){
    return degree * M_PI / 180.0;
}
 
 
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
 
 
///////////////////////////////////////////////////////////////////////////////////

bool ok(string S, string T){
    for (int i = 0;i < S.size();i++){
        if (S[i] != '?' && S[i] != T[i]){
            return false;
        }
    }

    return true;
}

int main(){
    string s,t,out = "~";
    cin >> s >> t;
    if (s.size() < t.size()){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    for (int i = 0;i <= s.size() - t.size();i++){
        string tmp = s.substr(i, t.size());
        if (ok(tmp, t)){
            string rep = s;
            for (int j = 0;j < i;j++){
                if (rep[j] == '?'){
                    rep[j] = 'a';
                }
            }
            for (int j = i;j < i + t.size();j++){
                rep[j] = t[j-i];
            }
            for (int j = i + t.size();j < rep.size();j++){
                if (rep[j] == '?'){
                    rep[j] = 'a';
                }
            }
            out = min(out, rep);
        }
    }

    if (out == "~"){
        cout << "UNRESTORABLE" << endl;
    }
    else {
        cout << out << endl;
    }
}

Measured memory_bytes: 3516
#include<stdio.h>
int main(void){
int i;
int counti,countj;
char a[10000];

while(scanf("%s",a)!=EOF){
counti=0;
countj=0;
for(i=0;a[i]!='\0';i++){
if(a[i+1]=='O'&&a[i+2]=='I'){
if(a[i]=='I')counti++;
if(a[i]=='J')countj++;
}
}
printf("%d\n%d\n",countj,counti);
}
return 0;}

Measured memory_bytes: 552
#include "bits/stdc++.h"
#define LF '\n'
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() { cin.tie(nullptr); ios_base::sync_with_stdio(false); }
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
template<class Itr> void dump(Itr begin, Itr end) { for (;begin != end; ++begin) clog << *begin << LF; }

signed main()
{
  int a,b,c;
  cin>>a>>b>>c;
  int ans;
  if (a == b) {
    ans = c;
  } else if (a == c) {
    ans = b;
  } else {
    ans = a;
  }

  cout << ans << LF;

  return 0;
}



Measured memory_bytes: 256
N = gets.to_i
XYs = readlines.map{|l| l.split.map(&:to_i)}
E = 1e-8

class Circle
  attr_accessor :r
  
  def initialize(zs)
    case zs.size
    when 2
      @c = zs.inject(:+) / 2
      @r = (@c - zs[0]).abs
    when 3
      x = zs.cycle.each_cons(3).take(3).inject(Complex(0)){|s, (a, b, c)| s + (a - b)*c.abs*c.abs}
      y = zs.cycle.each_cons(3).take(3).inject(Complex(0)){|s, (a, b, c)| s + (a - b)*c.conj}
      @c = x / y
      @r = (@c - zs[0]).abs
    end
  end

  def in?(z)
    (@c - z).abs <= @r + E
  end
end

zs = XYs.shuffle.map{|x, y| Complex(x, y)}
c = Circle.new(zs[0, 2])
(2 ... N).each do |i|
  c = Circle.new([zs[0], zs[i]]) unless c.in?(zs[i])
  (1 ... i).each do |j|
    c = Circle.new([zs[i], zs[j]]) unless c.in?(zs[j])
    (0 .. j).each do |k|
      c = Circle.new([zs[i], zs[j], zs[k]]) unless c.in?(zs[k])
    end
  end
end
puts c.r.to_f

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100//000000000
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,P>
#define T tuple<int,int,int> 
using namespace std;

struct eratosthenes{
    int n;
    vector<int> l;
    eratosthenes(int n=1):n(n),l(n+1,0){
        for(int i=2; i<=sqrt(n); i++){
            if(l[i]) continue;
            int j=2;
            while(i*j<=n){
                l[i*j]=i;
                j++;
            }
        }
    }
    vector<int> ps(int m){
        vector<int> res;
        int now=m;
        while(l[now]){
            res.push_back(l[now]);
            int d=l[now];
            while(now%d==0) now/=d;
        }
        if(now!=1) res.push_back(now);
        //reverse(all(res));
        return res;
    }
    vector<int> up(int m){ // m以下の素数全列挙
        vector<int> res;
        for(int i=2; i<=m; i++){
            if(!l[i]) res.push_back(i);
        }
        reverse(all(res));
        return res;
    }
};

int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    eratosthenes e(1000020);
    vector<vector<int> > primes(n);
    rep(i,n){
        primes[i]=e.ps(a[i]);
    }
    vector<int> ca(1000020,0);
    for(vector<int> x : primes){
        for(int y : x){
            //cout << y << endl;
            ca[y]++;
        }
    }
    bool ok=true;
    rep(i,1000020){
        if(ca[i]>1){
            ok=false;
            break;
        }
    }
    if(ok){
        cout << "pairwise coprime" << endl;
        return 0;
    }

    int now=a[0];
    rep(i,n-1) now=gcd(now,a[i+1]);
    if(now==1) cout << "setwise coprime" << endl;
    else cout << "not coprime" << endl;
return 0;
}

Measured memory_bytes: 83728
// Author: getharshkumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll M = 1e9 + 7, N = 1e6 + 5;
ll fac[N];
ll power(ll x, ll y)
{
    ll res = 1;
    x %= M;
    while (y)
    {
        if (y % 2)
            res = (res * x) % M;
        x = (x * x) % M;
        y /= 2;
    }
    return res;
}
ll ncr(ll n, ll r)
{
    if (r == 0)
        return 1;
    return ((((fac[n] * power(fac[r], M - 2)) % M) * power(fac[n - r], M - 2)) % M) % M;
}
int main()
{
    fac[0] = 1;
    for (ll i = 1; i < N; i++)
        fac[i] = (fac[i - 1] * i) % M;
    ll x, y;
    cin >> x >> y;
    ll a = (x + y) / 3;
    if ((x + y) % 3 || y > 2 * a || y < a)
        cout << 0;
    else
        cout << ncr(a, y - a);
    return 0;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

const int mod = 1000000007;
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*(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;
  }
};

mint dp[3000][3000];
int main() {
  int  h,w;
  cin >> h >> w;
  vector<string> M(h);
  rep(i,h)cin >> M[i];
  dp[0][0] = 1;
  const int dx[] = {1,0};
  const int dy[] = {0,1};
  auto inside = [&](int i, int j) { return i >= 0 && i < h && j >= 0 && j < w; };
  auto encode = [&](int i, int j) { return i * w + j; };

  rep(i,h){
    rep(j,w){
      if(M[i][j]=='#')continue;
      rep(k,2){
        int nh = i+dy[k];
        int nw = j+dx[k];
        if(!inside(nh,nw))continue;
        if(M[nh][nw]=='#')continue;
        dp[nh][nw] += dp[i][j];
      }
    }
  }
  cout<<dp[h-1][w-1].x<<endl;
  return 0;
}

Measured memory_bytes: 71552
module Geometry = struct

  type t = { x : float; y : float }

  let make x y = { x; y }

  let eps = 1e-10

  let diff a b = { x = a.x -. b.x; y = a.y -. b.y }

  let norm p = p.x *. p.x +. p.y *. p.y

  let dot a b = a.x *. b.x +. a.y *. b.y

  let cross a b = a.x *. b.y -. a.y *. b.x

  let ccw p0 p1 p2 =
    let a = diff p1 p0 in
    let b = diff p2 p0 in
    let c = cross a b in
    if c > eps then 1 (* COUNTER_CLOCKWISE *)
    else if c < (-. eps) then (-1) (* CLOCKWISE *)
    else if dot a b < (-. eps) then 2 (* ONLINE_BACK *)
    else if norm a < norm b then (-2) (* ONLINE_FRONT *)
    else 0 (* ON_SEGMENT *)

  let convex_p p0 p1 p2 p3 =
    let c = ccw p0 p1 p2 in
    List.for_all (fun e -> c = e) [ccw p1 p2 p3; ccw p2 p3 p0; ccw p3 p0 p1]

end

module G = Geometry

let () =
  try
    while true do
      let (xa, ya, xb, yb, xc, yc, xd, yd) =
        Scanf.scanf "%f,%f,%f,%f,%f,%f,%f,%f " (fun xa ya xb yb xc yc xd yd ->
          xa, ya, xb, yb, xc, yc, xd, yd) in
      print_endline
        (if G.convex_p (G.make xa ya) (G.make xb yb) (G.make xc yc) (G.make xd yd)
         then "YES"
         else "NO")
    done
  with _ -> ()

Measured memory_bytes: 2324
import java.util.Scanner;
import java.util.TreeSet;

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

		long sum = 0;
		TreeSet<Long> tree = new TreeSet<>();
		tree.add(pos[N]);
		for ( int i = N - 1 ; i >= 1 ; i-- ) {
			Long lower = tree.lower(pos[i]);
			Long higher = tree.higher(pos[i]);
			if ( lower == null ) {
				Long higher2 = tree.higher(higher);
				if ( higher2 == null ) {
					sum += pos[i] * ( N - higher + 1) * i;
				} else {
					sum += pos[i] * ( higher2 - higher) * i;
				}
			} else if ( higher == null ) {
				Long lower2 = tree.lower(lower);
				if ( lower2 == null ) {
					sum += lower * (N - pos[i] + 1) * i;
				} else {
					sum += (lower - lower2) * (N - pos[i] + 1) * i;
				}
			} else {
				Long lower2 = tree.lower(lower);
				Long higher2 = tree.higher(higher);
				if ( lower2 == null ) {
					if ( higher2 == null ) {
						sum += lower * (higher - pos[i]) * i;
						sum += (pos[i] - lower) * (N - higher + 1) * i;
					} else {
						sum += lower * (higher - pos[i]) * i;
						sum += (pos[i] - lower) * (higher2 - higher) * i;
					}
				} else {
					if ( higher2 == null ) {
						sum += (lower - lower2) * (higher - pos[i]) * i;
						sum += (pos[i] - lower) * (N - higher + 1) * i;
					} else {
						sum += (lower - lower2) * (higher - pos[i]) * i;
						sum += (pos[i] - lower) * (higher2 - higher) * i;
					}
				}
			}
			tree.add(pos[i]);
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 62744
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int main() {
    ll n, k;
    cin >> n >> k;
    int ans = 0;
    while(n != 0) {
        n /= k;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;
 
typedef long long ll;
#define eps 1e-10
#define LL_INF 0x3fffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
 
const int maxn = 1e5 + 10;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
ll po(ll a, ll b,ll mod) { ll res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
ll gcd(ll a,ll b){ if(a==0){return b;}else{ return gcd(b%a,a);}}
int n;
int val[maxn];
void solve()
{
	sa(n);
	repp(i,1,n)
	{
		sa(val[i]);
	}
	ll res = val[1]-1;
	int maxx=2;
	repp(i,2,n)
	{
		if(val[i]>maxx)
		{
			int k=val[i]/maxx-(val[i]%maxx==0);
			res+=k;
		}
		else if(val[i]==maxx)
		{
			maxx++;
		}
	}
	cout<<res<<endl;
}
int main()
{
    solve();
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<tuple>
#include<cmath>
#include<set>


#define MOD 1000000007
#define rep(i,k,N) for(ll i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back

typedef long long ll;

using namespace std;

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

bool prime(ll n){
    bool a = true;
    rep(i,2,n){
        if(n % i == 0)a = false;
    }
    return a;
}

ll gcd(ll x,ll y){
    while(y > 0){
        ll tmp = y;
        y = x % y;
        x = tmp;
    }
    return x;
}

ll lcm(ll x, ll y){
    return x / gcd(x,y) * y;
}

int main(){
    ll A,B;
    cin>>A>>B;

    set <ll> s;
    ll AB = gcd(A,B);
    rep(i,2,1000000){
        while(AB % i == 0){
            AB /=i;
            s.insert(i); 
        }
        if(AB == 1)break;
    }
    if(AB> 1)s.insert(AB);
    cout<<s.size()+1;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>
#include <set>
#include <map>

using namespace std;

typedef long long ll;

int main()
{
  double l;
  cin >> l;
  l /= 3;
  printf("%.10lf\n", l * l * l);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define SORT(x) (sort(x.begin(),x.end()))
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
    int A[5];
    int y=0,mi=10;
    rep(i,5){
        cin >> A[i];
        if(A[i]%10!=0){
            if(mi>A[i]%10){
                mi=A[i]%10;
            }
            A[i]=(A[i]/10+1)*10;
        }
        y+=A[i];
    }
    cout << (mi!=10 ? y-(10-mi) : y ) << endl;
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i = (a); i <= (b); ++ i)
#define rrp(i,a,b) for (int i = (a); i >= (b); -- i)
#define gc() getchar()
#define fir first
#define sec second
typedef pair<int,int> pii;
typedef double db;
typedef long long ll;
template <typename tp>
inline void read(tp& x) {
  x = 0; char tmp; bool key = 0;
  for (tmp = gc(); !isdigit(tmp); tmp = gc())
    key = (tmp == '-');
  for (; isdigit(tmp); tmp = gc()) 
    x = (x << 3) + (x << 1) + (tmp ^ '0');
  if (key) x = -x;
}
template <typename tp>
inline void ckmn(tp& x,tp y) {
  x = x < y ? x : y;
}
template <typename tp>
inline void ckmx(tp& x,tp y) {
  x = x < y ? y : x;
}

int calc(int n,int k) {
  while (n % k != 0) {
    int tmp = n / k;
    int lim = n - tmp * k;
    n -= (tmp + 1) * ((lim + tmp) / (tmp + 1));
  }
  return n / k;
}
int main() {
  int n,a,b,ans = 0;
  read(n);
  rep (i, 1, n) {
    read(a), read(b);
    ans ^= calc(a, b);
  }
  if (ans) puts("Takahashi");
  else puts("Aoki");
  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    private int cal(String s, char c) {
        int n = s.length();
        int m = n - 1;
        int ans = 0;
        for (int i = 0; i < n; i++) {
            if (s.charAt(i) == c && (m & i) == i) {
                ans ^= 1;
            }
        }
        return ans;
    }

    private void solve() {
        int n = sc.nextInt();
        String s = sc.next();
        StringBuilder sb = new StringBuilder();
        for (int i = 1; i < n; i++) {
            sb.append(Math.abs(s.charAt(i) - s.charAt(i - 1)));
        }

        if (n == 2) {
            out.println(sb.charAt(0));
            return;
        }

        s = sb.toString();
        if (s.contains("1")) {
            out.println(cal(s, '1'));
        } else {
            out.println(cal(s, '2') * 2);
        }
    }

    private static PrintWriter out;
    private static MyScanner sc;

    private static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        private MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

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

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

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

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

    public static void main(String[] args) {
        out = new PrintWriter(new BufferedOutputStream(System.out));
        sc = new MyScanner();
        new Main().solve();
        out.close();
    }
}


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

using namespace std;

class Solve {
    private:
    void merge(string *s, int l, int mid, int r) {
        int rl = r-mid;
        int ll = mid-l+1;
        string rs[rl], ls[ll];
        for(int i = 0; i < rl; i++) {
            rs[i] = s[mid+i+1];
        }
        for(int i = 0; i < ll; i++) {
            ls[i] = s[l+i];
        }
        int ir = 0, il = 0, k = l;
        while(ir < rl && il < ll) {
            if(rs[ir] <= ls[il]) {
                s[k++] = rs[ir];
                ir++;
            } else {
                s[k++] = ls[il];
                il++; 
            }
        }
        while(ir < rl) {
            s[k++] = rs[ir++];
        }
        while(il < ll) {
            s[k++] = ls[il++];
        }
    }
    void sortString(string *s, int l, int r) {
        if(l < r) {
            int mid = (l+r)/2;
            sortString(s, l, mid);
            sortString(s, mid+1, r);
            merge(s, l, mid, r);
        }
    }
    void solve(string *s, int len) {
        sortString(s,0,len-1);
        for(int i = 0; i < len; i++) {
            cout<<s[i];
        }
        cout<<endl;
    }
    public:
    void takeInput() {
        int n, l;
        cin>>n>>l;
        string s[n];
        for(int i = 0; i < n; i++) {
            cin>>s[i];
        }
        solve(s, n);
    }
};

int main() {
    Solve s;
    s.takeInput();
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
  double a,b,h,m;
  cin>>a>>b>>h>>m;
  double tan=h*30+0.5*m;
  double tyo=m*6;
  double r=abs(tyo-tan);
  double ans=b*b+a*a-2*b*a*cos(M_PI/180.0*r);
  cout<<fixed<<setprecision(20)<<sqrt(ans);
}


Measured memory_bytes: 4164
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define MOD 1000000007
int main()
{
   int N,M;
   cin>>N>>M;
   int a[N+1];
   memset(a,0,sizeof(a));
   for(int i=0;i<M;i++)
   {
       int l,r;
       cin>>l>>r;
       a[l]++;
       a[r+1]--;
   }
   int cnt=0;
   for(int i=1;i<=N;i++)
   {
       a[i]+=a[i-1];
       if(a[i]==M)
       cnt++;
       //cout<<a[i]<<" ";
   }
   cout<<cnt;
    return 0;

    
}

Measured memory_bytes: 640
#include<iostream>
#include<cstring>
#include<string>
using namespace std;
string a[100];
int b[100];
int c[100];
int main()
{
	int n,m;
	cin>>n>>m;
	getchar();
	memset(b,0,sizeof(b));
	memset(c,0,sizeof(c));
	for(int i=0;i<n;i++)
	getline(cin,a[i]);
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
	{
	if(a[i][j]=='#')
	{
		b[i]=1;
		c[j]=1;
	}
	}
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
	{
		if(b[i]==0)
		break;
		if(c[j]==0)
		continue;
		if(a[i][j]=='#')cout<<"#";
	else cout<<".";
	
	}
	if(b[i]==1)
	cout<<endl; 
	}


return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
	int n,i,cnt;
	char s[100];
	scanf("%s",s);
	n=strlen(s);
	cnt=0;
	for(i=0;i<n/2;i++){
		if(s[i]!=s[n-i-1])	cnt++;
	}
	printf("%d\n",cnt);
	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

//this implements the bin search which return the position if find, otherwise negative
public class Main {
	public static int bin_search(int[] arr, int elem) {
		int lo = 0;
		int hi = arr.length-1;
		
		while(lo <= hi) {
			if(lo == hi) {
				return (arr[lo] == elem)? lo: -1; 
			}
			
			int mid =  lo + (hi - lo) /2;
			if(arr[mid]> elem) {
				hi = mid;
			}else if(arr[mid] < elem) {
				lo = mid+1;
			}else {
				return mid;
			}
			
		}
		
		return -1;
	}
	
	public static void main(String[] args) {
			Scanner cin = new Scanner(System.in);
			int n = cin.nextInt();
			int [] S = new int[n];
			for(int i = 0; i < n; i++) {
				S[i] = cin.nextInt();
			}
			
			int  m = cin.nextInt();
			int x_i = 0;
			int count =  0;
			for(int i = 0; i < m; i++) {
				x_i = cin.nextInt();
				count += (bin_search(S, x_i) >=0)? 1:0;
			}
			
			
			System.out.println(count);
	}

}

Measured memory_bytes: 68896
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
#define SIZE 2000
class unionfind
{
public:
	int par[SIZE];
	int ran[SIZE];
	int ren[SIZE];
	void init()
	{
		for (int i = 0; i<SIZE; i++)
		{
			par[i] = i;
			ran[i] = 0;
			ren[i] = 1;
		}
	}
	int find(int a)
	{
		if (a == par[a])return a;
		else return par[a] = find(par[a]);
	}
	void unite(int a, int b)
	{
		a = find(a);
		b = find(b);
		if (a == b)return;
		if (ran[a]>ran[b])
		{
			par[b] = a;
			ren[a] += ren[b];
		}
		else
		{
			par[a] = b;
			ren[b] += ren[a];
		}
		if (ran[a] == ran[b])ran[b]++;
	}
};
unionfind uf;
int d[777][777];
typedef pair<int, int>pii;
int cnt1[2000],cnt2[2000];
int dp[777][2020];
bool flag[2020];
int main()
{
	int num, way;
	scanf("%d%d", &num, &way);
	for (int i = 0; i < num; i++)for (int j = 0; j < num; j++)if (i != j)d[i][j] = 1;
	for (int i = 0; i < way; i++)
	{
		int za, zb;
		scanf("%d%d", &za, &zb);
		za--, zb--;
		d[za][zb] = d[zb][za] = 0;
	}
	uf.init();
	for (int i = 0; i < num; i++)for (int j = 0; j < num; j++)if (d[i][j])uf.unite(i * 2, j * 2 + 1), uf.unite(i * 2 + 1, j * 2);
	for (int i = 0; i < num; i++)
	{
		if (uf.find(i * 2) == uf.find(i * 2 + 1))
		{
			printf("-1\n");
			return 0;
		}
		cnt1[uf.find(i * 2)]++, cnt2[uf.find(i * 2 + 1)]++;
	}
	vector<pii>v;
	for (int i = 0; i < num * 2; i++)
	{
		int s = cnt1[uf.find(i)], t = cnt2[uf.find(i)];
		if (!flag[uf.find(i)])
		{
			v.push_back(make_pair(s, t));
			flag[uf.find(i)] = flag[uf.find(i % 2 ? i - 1 : i + 1)] = true;
		}
	}
	dp[0][0] = 1;
	for (int i = 0; i < v.size(); i++)for (int j = 0; j <= num; j++)if (dp[i][j])dp[i + 1][j + v[i].first] = dp[i + 1][j + v[i].second] = 1;
	int mini = 1000000000;
	for (int i = 0; i <= num; i++)if (dp[v.size()][i])mini = min(mini, i*(i - 1) / 2 + (num - i)*(num - i - 1) / 2);
	printf("%d\n", mini);
}

Measured memory_bytes: 7680
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T & a, U & ... b) { cin >> a; IN_(b ...); };
template<typename T> void OUT(T && a) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

int main() {
	IN(int, k);
	const int n = 10;
	string s = string(n + 1, '-');
	inc(kk, k) {
		int p = 0;
		inc(i, n) {
			p = i;
			if(s[i] == '-') { s[i] = '1'; break; }
			s[i]++;
			if(s[i] <= '9' && (s[i + 1] == '-' || abs(s[i] - s[i + 1]) <= 1)) { break; }
		}
		dec(i, p) {
			assert(s[i + 1] != '-');
			s[i] = max('0' + 0, s[i + 1] - 1);
		}
	}
	while(s.BA == '-') { s.pop_back(); }
	reverse(ALL(s));
	OUT(s);
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>




using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const int INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
const ll mod = 1000 * 1000 * 1000 + 7;

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

void solve() {
    int m, n, sz;
    cin >> m >> n >> sz;
    int stx, sty;
    cin >> stx >> sty;
    string s1, s2;
    cin >> s1 >> s2;
    vector<int> a(4, 0);
    vector<int> a1(sz), a2(sz);
    map<char, int> mp;
    mp['D'] = 0;
    mp['R'] = 1;
    mp['U'] = 2;
    mp['L'] = 3;

    for (int i = 0; i < sz; ++i) {
        a1[i] = mp[s1[i]];
        a2[i] = mp[s2[i]];
    }
    a[mp[s1[sz - 1]]] = 1;
    for (int i = sz - 2; i >= 0; --i) {
        if ((a[0] + a[2] >= m) || (a[1] + a[3] >= n)) {
            cout << "NO\n";
            return;
        }
        if (a1[i] == a2[i]) {
            ++a[a1[i]];
            a[(a2[i] + 2) % 4] = max(0, a[(a2[i] + 2) % 4] - 1);
            continue;
        }
        if (((a1[i] + a2[i]) % 2) == 0) {
            a[a1[i]] = max(1, a[a1[i]]);
            //a[a2[i]] = max(0, a[(a2[i] + 2) % 4] - 1);
            continue;
        }
        ++a[a1[i]];
        a[(a2[i] + 2) % 4] = max(0, a[(a2[i] + 2) % 4] - 1);
    }
    if ((stx <= a[2]) || (sty <= a[3]) || (m - stx + 1 <= a[0]) || (n - sty + 1 <= a[1]))
        cout << "NO\n";
    else {
        cout << "YES\n";
    }
    

}

//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    solve();


#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}


Measured memory_bytes: 2456
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,a, b) for (int i = (a); i < (b); i++ )

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

const int INF = 100000000;
const double PI=acos(-1);

int main () {
    int N;
    cin >> N ;
    vector<pair<int,int>> p;

    rep(i,0,N) {
        int a,b;
        cin >> a >> b;
        p.push_back(make_pair(b,a));
    }

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

    int now = 0;
    string ans = "Yes";

    rep(i,0,N) {
        //int need = p[i].second-p[i].first;
        //cout << p[i].first << " " << p[i].second << endl;
        now+= p[i].second;
        if (now>p[i].first) {
            ans = "No";
        }

    }
    cout << ans << endl;
}

Measured memory_bytes: 2420
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right
from copy import deepcopy

def solve():
    H, W, K = MI()
    C = np.array(LLS(H))
    D = np.zeros_like(C, np.int)

    for i, c in enumerate(C):
        for j, cc in enumerate(c):
            if cc == '#':
                D[i, j] = 1
            else:
                D[i, j] = 0
    # print(D, D.dtype)

    h_zero = np.zeros(H)
    w_zero = np.zeros(W)

    ans = 0
    for i in range(1 << H):
        tmp1 = []
        for j in range(H):
            if (i >> j) & 1:
                tmp1.append(j)

        G = D.copy()
        for b1 in tmp1:
            G[b1, :] = w_zero.copy()

        for k in range(1 << W):
            tmp2 = []
            G2 = G.copy()
            for l in range(W):
                if (k >> l) & 1:
                    tmp2.append(l)

            for b2 in tmp2:
                G2[:, b2] = h_zero.copy()
            
            if np.sum(G2) == K:
                ans += 1

    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 27288
//
//  main.cpp
//  ALDS1_3_C
//
//  Created by ptyuan on 2018/10/20.
//  Copyright © 2018 Sy. All rights reserved.
//

#include <iostream>
#include <cstring>
#include <cstdio>

struct Node {
    int value;
    Node *next;
    Node *prev;
};

struct List {
    Node *head = NULL;
    List() {
        head = new Node();
        head->next = head;
        head->prev = head;
    }
    void insert(int x) {
        Node *newNode = new Node();
        newNode->value = x;
        newNode->next = NULL;
        newNode->prev = NULL;
        
        newNode->next = head->next;
        head->next->prev = newNode;
        head->next = newNode;
        newNode->prev = head;
    }
    
    void deleteNode(Node *n) {
        if (NULL == n) return;
        Node *prev = n->prev;
        Node *next = n->next;
        prev->next = next;
        next->prev = prev;
        delete n;
    }
    
    Node *search(int x) {
        Node *head = this->head;
        Node *cur = head->next;
        while (cur != head) {
            if (cur->value == x) {
                return cur;
            }
            cur = cur->next;
        }
        return NULL;
    }
    
    void deletex(int x) {
        Node *t = search(x);
        deleteNode(t);
    }
    
    void deleteFirst() {
        deleteNode(head->next);
    }
    
    void deleteLast() {
        deleteNode(head->prev);
    }
};



int main(int argc, const char * argv[]) {
    List list;
    int n = 0;
    scanf("%d", &n);
    
    
    while (n > 0) {
        char command[16];
        int value = -1;
        scanf("%s", command);
        if ('i'  == command[0]) {
            scanf("%d", &value);
            list.insert(value);
        } else if ('d' == command[0]) {
            if (strlen(command) > 6) {
                if ('L' == command[6]) {
                    list.deleteLast();
                } else if ('F' == command[6]) {
                    list.deleteFirst();
                }
            } else {
                scanf("%d", &value);
                list.deletex(value);
            }
        }
        n--;
    }
    
    Node *cur = list.head->next;
    Node *head = list.head;
    int count = 0;
    while (cur != head) {
        if (count > 0) {
            printf(" ");
        }
        printf("%d", cur->value);
        cur = cur->next;
        count++;
    }
    printf("\n");
    return 0;
}



Measured memory_bytes: 34472
def main():
    s = input().split('T')
    x, y = map(int, input().split())

    # x軸方向の移動について
    # 1回目の移動はxの正方向のみ
    here_x = [len(s[0])]

    for i in s[2::2]:
        move = len(i)
        here_x = [i + move for i in here_x] + [i - move for i in here_x]
        here_x = set(here_x)

    # y軸方向の移動について
    here_y = [0]

    for i in s[1::2]:
        move = len(i)
        here_y = [i + move for i in here_y] + [i - move for i in here_y]
        here_y = set(here_y)

    if x in here_x and y in here_y:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

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

vector<pair<string, int> > scores (100);

static bool sortcity(int a, int b) {
	if(scores[a].first != scores[b].first)
		return scores[a].first < scores[b].first;
	else return scores[a].second > scores[b].second;
}

int main() {
	int n;
	cin >> n;
	vector<int> num (n);
	for(int i = 0; i < n; i++) {
		cin >> scores[i].first >> scores[i].second;
		num[i] = i;
	}
	sort(num.begin(), num.end(), sortcity);
	for(int i = 0; i < n; i++) {
		cout << num[i] + 1 << endl;
	}
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll x, k, d;

int main() {	
    ios::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cin >> x >> k >> d;
    ll step = abs(x / d);
    if(step >= k) {
        if(x > 0)
            cout << abs(x - k * d);
        else cout << abs(x + k * d);
    }
    else {
        ll pos1 = x % d, pos2;
        if(x > 0)
            pos2 = x % d - d;
        else pos2 = x % d + d;
        ll tmp = (x - pos1) / d;
        if((k - tmp) & 1) cout << abs(pos2);
        else cout << abs(pos1);
    }
    return 0;
}

Measured memory_bytes: 3644
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;



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


    vi a;
    int j = 1;
    while(n) {
        if(n%(1LL<<j)) {
            a.push_back(1);
            --j;
            if(j&1) {
                n += 1LL<<j;
            } else {
                n -= 1LL<<j;
            }
            ++j;
        } else {
            a.push_back(0);
        }
        ++j;
    }

    if(a.empty()) {
        cout << 0 << endl;
    } else {
        rep(i, a.size()) {
            cout << a[a.size()-1-i];
        }
        cout << '\n';
    }
}

Measured memory_bytes: 256
# Problem C - Bugged

# input
N = int(input())

# initialization
max_score = 0
score_list = []
for i in range(N):
    tmp = int(input())
    score_list.append(tmp)
score_list = sorted(score_list, reverse=True)

# score update
min_score = 10**4 + 1
for score in score_list:
    max_score += score
    if score%10!=0 and min_score>score:
        min_score = score

# output
ans = max_score
if max_score%10==0:
    ans = max(0, max_score-min_score)
print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define LL long long
#define RG register
#define R RG int
using namespace std;
const int N=100009;
int a[N],s[N];
int main(){
	R n,i,mx1=0,mx2=0,s1,ans;
	ios::sync_with_stdio(0);
	cin>>n;
	for(i=1;i<=n;++i)cin>>a[i];
	for(i=1;i<=n;i+=2)++s[a[i]];
	for(i=1;i<N;++i)if(s[mx1]<s[i])mx1=i;
	s1=s[mx1];
	memset(s,0,sizeof(s));
	for(i=2;i<=n;i+=2)++s[a[i]];
	for(i=1;i<N;++i)if(s[mx2]<s[i]&&mx1!=i)mx2=i;
	ans=n-s1-s[mx2];
	
	mx1=mx2=0;
	memset(s,0,sizeof(s));
	for(i=2;i<=n;i+=2)++s[a[i]];
	for(i=1;i<N;++i)if(s[mx1]<s[i])mx1=i;
	s1=s[mx1];
	memset(s,0,sizeof(s));
	for(i=1;i<=n;i+=2)++s[a[i]];
	for(i=1;i<N;++i)if(s[mx2]<s[i]&&mx1!=i)mx2=i;
	ans=min(ans,n-s1-s[mx2]);
	
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
int main() {
	int N;
	cin >> N;
	long long V = 0;
	long long E = 0;
	for (int i = 1; i <= N; ++i) {
		V += (long long)i*(N - i + 1);
	}
	for (int n = 0; n < N - 1; ++n) {
		int a, b;
		cin >> a >> b;
		if (a>b) {
			swap(a, b);
		}
		E += (long long)a*(N - b + 1);
	}
	long long ans = V - E;
	cout << ans << endl;
	return 0;
}


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

using namespace std;

string solve(int A, int B)
{
    int dist = abs(A - B);

    if (dist % 2)
        return "IMPOSSIBLE";

    return to_string(min(A, B) + dist / 2);
}

int main()
{
    ios::sync_with_stdio(false);

    int A, B;
    cin >> A >> B;

    auto ans = solve(A, B);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 3696
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{

    class Atcoderrrrrrr
    {
        static void Main(string[] args)
        {
          string[] s = Console.ReadLine().Split(' ');
          Console.WriteLine(
              s[0].Substring(0,1).ToUpper()+s[1].Substring(0,1).ToUpper()+s[2].Substring(0,1).ToUpper()
          );
        }
    }
}


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

uint32_t pow(uint32_t a, uint32_t b) {
  uint32_t ans = 1;
  for (uint32_t i = 0; i < b; i++) ans *= a;
  return ans;
}

bool get(uint32_t flag, uint32_t pos) { return (flag >> pos) & 1; }

int main() {
  uint32_t N = 0, M = 0, X = 0;
  std::cin >> N >> M >> X;
  std::vector<uint32_t> C(N);
  std::vector<std::vector<uint32_t>> A(N);
  for (size_t n = 0; n < N; n++) {
    std::cin >> C[n];
    A[n] = std::vector<uint32_t>(M, 0);
    for (size_t m = 0; m < M; m++) std::cin >> A[n][m];
  }

  uint32_t min_cost = -1;
  for (size_t i = 0; i < pow(2, N); i++) {
    uint32_t cost = 0;
    std::vector<uint32_t> A_sum(M, 0);
    for (size_t n = 0; n < N; n++) {
      if (get(i, n)) {
        for (size_t m = 0; m < M; m++) A_sum[m] += A[n][m];
        cost += C[n];
      }
    }
    if (cost >= min_cost) continue;

    bool ok = true;
    for (size_t m = 0; m < M && ok; m++) {
      if (A_sum[m] < X) ok = false;
    }
    if (ok) min_cost = cost;
  }

  std::cout << (min_cost == (uint32_t)-1 ? -1 : (int32_t)min_cost) << std::endl;

  return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        float avg = (a + b) / 2.0f;
        int res = (int) avg;
        if (avg * 10 % 10 > 0) {
            res++;
        }

        System.out.println(res);
        scanner.close();
    }
}


Measured memory_bytes: 27144
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)

int W, H, x, y;

int main() {

	scanf("%d%d%d%d", &W, &H, &x, &y);

	printf("%f ", (double)W * H / 2.0);
	if (x * 2 == W && y * 2 == H) printf("1\n");
	else printf("0\n");

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<ll,ll>
#define poly vector<ll>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x.size()))
#define re resize
#define PB pop_back
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
ll rnd(){
	ull ans=0;
	For(i,0,4)ans=ans<<15^rand();
	return ans%((ull)1<<63);
}
const ll fm=1e9;
int n;
ll ans;
map<pair<PI,PI>,ll> M;
bool zc(PI a,PI b){
	return a.fi>=b.fi&&a.se>=b.se;
}
bool bao(pair<PI,PI> a,pair<PI,PI> b){
	return zc(a.fi,b.se)&&zc(b.fi,a.se);
}
PI get(ll t){
	PI a=mp(0,0);
	while(t%2==0){
		t/=2; a.fi++;
	}
	while(t%5==0){
		t/=5; a.se++;
	}
	return a;
}
int main(){
	#ifdef Brollan
		freopen("1.in","r",stdin);
	#endif
	n=read();
	For(i,1,n){
		ll a;
		cin>>a;
		a=a*fm;
		if(getchar()=='.'){
			ll b=0;
			string s;
			cin>>s;
			For(j,0,s.size()-1)b=b*10+s[j]-'0';
			For(j,1,9-s.size())b*=10;
			a+=b;
		}
		ll x=a,gc=__gcd(x,fm),y=fm/gc;
		x/=gc;
		PI X=get(x),Y=get(y);
		M[mp(X,Y)]++;
		if(y==1)ans--;
	}
	for(auto i:M){
		for(auto j:M)if(bao(i.fi,j.fi)){
			ans+=i.se*j.se;
		}
	}
	cout<<ans/2<<endl;
}


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

int max(int x,int y){
	int z;
	(x > y) ? (z = x) : (z = y);
	return z;
}

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	if(a == b || a == c || b == c){
		cout << "No" << endl;
		return 0;
	}
	if( c == max(max(a,b),c)){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}	

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


int main() {

  long long n;
  cin >> n;
  vector<int> a(n);

  for(int i = 0; i < n; i=(i+1)|0) { cin >> a.at(i); }

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

  for(int i = 1; i < n; i=(i+1)|0) {
    int tmp = i - 1;
    if(a.at(tmp) == a.at(i)) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}


Measured memory_bytes: 1152