akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fto(i,a,b) for(int i=a; i<=b; ++i)
#define fdto(i,a,b) for(int i=a; i>=b; --i)
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define st first
#define nd second
#define maxn
#define Ntu "bai1"

using namespace std;
int m,d;
bool kt(int z)
{
    while (z>0)
    {
        if (z%10<2) return false;
        z/=10;
    }
    return true;
}
int main()
{
    ios_base::sync_with_stdio(0);
    //freopen(Ntu".inp","r",stdin);
    //freopen(Ntu".out","w",stdout);
    cin.tie(NULL);cout.tie(NULL);
    cin >> m >> d;
    int rs=0;
    int x,y;
    fto(i,1,m)
    fto(j,10,d)
    {
        if (!kt(j)) continue;
        x=j;y=1;
        while (x>0) y*=x%10,x/=10;
        if (y==i) ++rs;
    }
    cout << rs;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int a,b;
    scanf("%d%d",&a,&b);
    int s=0;
    for(int i=a;i<=b;i++){
        if((i/10000==i%10)&&(i/1000%10==i%100/10))
            s++;
    }
    printf("%d\n",s);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <complex>
#include <numeric>
#define _for(i,n) for(int i = 0; i < n; i++)
#define ll long long

using namespace std;

template <typename T>
vector<size_t> sort_indexes(const vector<T> &v) {

  // initialize original index locations
  vector<size_t> idx(v.size());
  iota(idx.begin(), idx.end(), 0);

  // sort indexes based on comparing values in v
  sort(idx.begin(), idx.end(), [&v](size_t i1, size_t i2) {return v[i1] < v[i2];});

  return idx;
}

int main() {
  ll n,k;
  cin >> n >> k;
  vector<ll> a(n);
  vector<ll> b(n);
  _for(i,n) cin >> a[i] >> b[i];
  ll bsum = 1;
  for(auto i: sort_indexes(a)) {
    bsum += b[i];
    if (k<bsum) {
      cout << a[i] << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 2560
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    
    cin>>a>>b;
    
    if(a<b) cout<<"a < b"<<endl;
    else if(a>b) cout<<"a > b"<<endl;
    else cout<<"a == b"<<endl;
    
    return 0;
}



Measured memory_bytes: 3060
import qualified Data.ByteString.Char8 as BC8
import qualified Data.Maybe as M
-- import qualified Data.IntMap.Lazy as M
import Control.Monad
import Data.List
import Debug.Trace

main :: IO ()
main = do
    [n, m] <- map (fst . M.fromJust . BC8.readInt) . BC8.words <$> BC8.getLine
    edges <- replicateM m ((\[a, b]->(a,b)) . map (fst . M.fromJust . BC8.readInt) . BC8.words <$> BC8.getLine)
    -- print edges
    print . length $ filter (\i -> not (isConnectedGraph (edges \\ [edges!!i]) n)) [0..m-1]

isConnectedGraph :: [(Int, Int)] -- グラフ
                 -> Int          -- 頂点の数
                 -> Bool
isConnectedGraph graph n = (==0) . length $ [1..n] \\ isConnectedGraph' (graph++map (\(f,t)->(t,f)) graph) [] (fst $ head graph)

isConnectedGraph' :: [(Int, Int)] -> [Int] -> Int -> [Int]
isConnectedGraph' [] already pos = pos:already
isConnectedGraph' graph already pos = let
    ns = filter (\(f,t)->pos==f && not (elem t already)) graph
    in if null ns
        then nub $ pos:already
        else nub . foldr (++) [] $  map (\(f,t) -> isConnectedGraph' graph (nub $ pos:already ++ map snd ns) t) ns 

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

void solve(){
  int n; cin >> n;
  long long ans = 0;
  for(int i = 0; i <= n; i++){
    if(i % 3 != 0 && i % 5 != 0) ans += i;
  }
  cout << ans << endl;
  return;
}
int main(){
  solve();
  return 0;
}


Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        long X = sc.nextLong();
        long deposit = 100;
        long cnt = 0;

        while (X > deposit) {
            deposit *= 1.01;
            cnt++;
        }

        System.out.println(cnt);
    }

}





Measured memory_bytes: 35852
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<string>

int main() {
	std::string a, b, c;
	std::cin>> a >> b >> c;
	transform(a.begin(), a.end(), a.begin(), toupper);
	transform(b.begin(), b.end(), b.begin(), toupper);
	transform(c.begin(), c.end(), c.begin(), toupper);
	std::cout << a[0] << b[0] << c[0] << std::endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  string s;
  cin >> s;
  int t[26] = {};
  for (int i = 0; i < s.size(); i++) {
    t[s[i] - 'a']++;
  }
  for (int i = 0; i < 26; i++) {
    if (t[i] % 2) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include"iomanip"
#include"iostream"
#include"limits"
#include"cmath"
#include"vector"
#include"algorithm"
#include"list"
#include"queue"
#include"stack"
#include"set"
#include"unordered_set"
#include"map"
#include"unordered_map"
#include"string"
#include"cstring"
#include"assert.h"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define mp make_pair
#define pb push_back
#define mset(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	string x;
	cin>>x;
	int n=x.length();
	string tt="";
	vector<int>pp;
	int co=0;
	for(int i=0;i<n;++i)
	{
		if(x[i]!='x')
		{
			tt.pb(x[i]);
			pp.pb(co);
			co=0;
		}
		else
		{
			co++;
		}
	}
	pp.pb(co);
	int nn=tt.length();
	assert(pp.size()==nn+1);
	for(int i=0;i<tt.length();++i)
	{
		if(tt[i]!=tt[tt.length()-1-i])
		{
			cout<<"-1\n";
			return 0;
		}
	}

	int ans=0;
	for(int i=0;i<pp.size()/2;++i)
	{
		ans+=abs(pp[i]-pp[pp.size()-1-i]);
	}
	cout<<ans<<'\n';

}















Measured memory_bytes: 1104
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>
#include<numeric>

#define PB push_back
#define all(a)  (a).begin(),(a).end()
#define ALL(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define V vector<int>
#define VV vector<V>
#define VVV vector<VV>

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int inf = (int)1e9;
const ll INF = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;

int n, k;
int x[100001];

int main() {
	cin >> n >> k;
	rep(i, n) cin >> x[i];

	ll ans = INF;
	for (int i = 0; i < n - k + 1; i++) {
		int l = i;
		int r = i + k - 1;

		//原点から左端までのコスト＋左端から右端までのコスト
		ll p1 = abs(x[l]) + abs(x[r] - x[l]); //l -> r
		ll p2 = abs(x[r]) + abs(x[l] - x[r]); //r -> l

		ans = min(ans, min(p1, p2));
	}

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


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

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cerr << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

const int MN = 40010;

template<class T>
class BIT {
	T bit[MN];
	int n;

public:
	BIT() {
		n = MN;
		memset(bit, 0, sizeof(bit));
	}

	T sum(int i) {
		++i;
		T s = 0;
		while (i > 0) {
			s += bit[i];
			i -= i & -i;
		}
		return s;
	}

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

typedef long double R;

const R eps = 1e-12;

int main() {
	int N; cin >> N;
	V<pair<pii,int>> vec(N);

	rep(i, N) {
		int A, B, C;
		cin >> A >> B >> C;
		vec[i] = mp(mp(A, B), C);
	}

	int num = (N*(N-1)/2+1)/2; 

	R sx, sy;

	rep(_, 2) {
		sort(ALL(vec), [&](const pair<pii,int> &p, const pair<pii,int> &q) {
			return -(R)p.fi.fi / p.fi.se > -(R)q.fi.fi / q.fi.se;
		});

		R lo = -2e9, hi = 2e9;

		rep(tt, 100) {
			R x = lo + (hi - lo) / 2;

			BIT<int> T;
			V<R> pos(N), ps;
			rep(i, N) {
				pos[i] = (vec[i].se - vec[i].fi.fi * x) / vec[i].fi.se;
			}
			ps = pos;
			sort(ALL(ps));

			int s = 0;
			rep(i, N) {
				int p = lower_bound(ALL(ps), pos[i] - eps) - ps.begin();
				s += i - T.sum(p);
				T.add(p, 1);
			}
			if (s >= num) {
				hi = x;
			} else {
				lo = x;
			}
		}
		if (_ == 0) {
			sy = lo;
		} else {
			sx = lo;
		}

		rep(i, N) swap(vec[i].fi.fi, vec[i].fi.se);
	}

	printf("%.10Lf %.10Lf\n", sy, sx);

	return 0;
}

Measured memory_bytes: 2180
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <vector>
typedef long long ll;
const int maxn = 1e5 + 5;
const ll mod = 1e9 + 7;
const double PI = acos(-1.0);
int n, m, k;
int vis[maxn], sum[maxn];
std::vector<int> v[maxn];
std::set<int> s[maxn];

double GetS(double r) {
  return 4.0/3*PI*r*r*r;
}

int bfs(int u, int num) {
  std::queue<int> q;
  q.push(u);
  vis[u] = num;

  int ans = 1;
  while(!q.empty()) {
    int cur = q.front();
    q.pop();

    for (int i=0; i < v[cur].size(); i++) {
      if (vis[v[cur][i]] == 0) {
         q.push(v[cur][i]);
         vis[v[cur][i]] = num;
         ans++;
      }
    }
  }
  return ans;
}

int main (int argc, char **argv) {
  std::cin >> n >> m >> k;
  int x, y;
  for (int i=1; i <= m; i++) {
    std::cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x); 
  }

  memset(vis, 0, sizeof(vis));
  int num = 1;
  for (int i=1; i <= n; i++) {
    if (!vis[i]) {
      sum[num] = bfs(i, num);
      num++;
    }
  }

  for (int i=1; i <= k; i++) {
    std::cin >> x >> y;
    s[x].insert(y);
    s[y].insert(x);
  }

  bool flag = true;
  for (int i=1; i <= n; i++) {
    int ans = 0;
    if (v[i].size() != 0) {
      ans = sum[vis[i]] - (v[i].size() + 1);
      for (auto& it: s[i]) {
        if (vis[it] == vis[i]) {
          ans--;
        }
      }
    }
    
    if (flag) {
      std::cout << ans;
      flag = false;
    } else {
      std::cout << " " << ans;
    }
  }
  std::cout << std::endl;
  return 0;
}

Measured memory_bytes: 20760
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;
const ll MOD = 1e9 + 7;


bool solve(vector<int> v, int g, char mode){
    const int lim = 8010;
    vector<vector<bool>> dp(2, vector<bool>(2*lim+100));

    if(mode == 'x') dp[1][lim + v[0]] = true;
    if(mode == 'y') dp[0][lim] = true;

    rep(i, v.size()){
        rep(j, 2*lim){
            if(!dp[i%2][j]) continue;
            dp[i%2][j] = false;
            int m = v[i];
            dp[(i+1)%2][j + m] = true;
            dp[(i+1)%2][j - m] = true;
        }
    }

    return dp[v.size()%2][g + lim];
}

int main(){
    string s;
    int x, y;
    cin >> s >> x >> y;

    int f = 0;
    vector<int> v;
    rep(i, s.size()){
        if(s[i] == 'T'){
            v.push_back(f);
            f = 0;
        }
        else f++;
    }
    if(s[s.size()-1] != 'T') v.push_back(f);

    vector<int> vx, vy;
    rep(i, v.size()){
        if(i%2 == 0) vx.push_back(v[i]);
        else vy.push_back(v[i]);
    }

    if(solve(vx, x, 'x') && solve(vy, y, 'y')) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

int main()
{
    int Q;
    cin>>Q;
    priority_queue<long long> QL, QR;
    long long AL = 0;
    long long AR = 0;
    long long B = 0;

    for (int i=0; i<Q; i++)
    {
        int q;
        cin>>q;
        if (q==1)
        {
            long long a, b;
            cin>>a>>b;
            if (QL.empty() || a<=QL.top())
            {
                QL.push(a);
                AL += a;
            }
            else
            {
                QR.push(-a);
                AR += a;
            }
            if (QL.size() > QR.size()+1)
            {
                a = QL.top();
                QL.pop();
                AL -= a;
                QR.push(-a);
                AR += a;
            }
            if (QR.size() > QL.size())
            {
                a = -QR.top();
                QR.pop();
                AR -= a;
                QL.push(a);
                AL += a;
            }
            B += b;
        }
        else
        {
            long long x = QL.top();
            long long f = QL.size()*x - AL + AR - QR.size()*x + B;
            cout<<x<<" "<<f<<endl;
        }
    }
}


Measured memory_bytes: 4460
#include<bits/stdc++.h>
#define INF 2147483640
using namespace std;
int main()
{
	//freopen("out.txt","w",stdout);
	string a,b;
	int ans=0;
	cin >> a >> b;
	for(int i=0; i<a.size(); i++) ans+=(a[i]!=b[i]);
	cout << ans;
	return 0;
}

Measured memory_bytes: 3800
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
typedef pair<int, int> P;
const int INF = 100000000;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

int main()
{
	int i, j, k, l, m, sum0,sumn, N, M,X,Y,B,C;
	cin >> N>>M>>X;
	sum0 = sumn = 0;
	vector<int>A(M);
	for (i = 0; i<M; i++) {
		cin >> A[i];
	}
	for (i = 0; i < M; i++) {
		if (A[i] <= X)
			sum0++;
		else if (A[i] >= X)
			sumn++;
	}
	cout << fmin(sum0, sumn) << endl;
	
	
	return 0;
}



Measured memory_bytes: 256
// Love and Freedom.
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#define maxn 500
using namespace std;

int a[110000],b[110000];
bool dead[maxn],g[maxn][maxn];

int main()
{
	int n,i,m,j,k,x,y,ans=0;
	scanf("%d%d",&n,&m);
	for(i=1;i<=m;i++)	scanf("%d%d",&a[i],&b[i]);
	for(i=1;i<=n;i++)
	{
		g[i][i]=1;
		for(j=m;j;j--)
		{
			x=g[i][a[j]];y=g[i][b[j]];
			if(x&&y)
			{
				dead[i]=1;
				break;
			}
			else
			{
				if(x)	g[i][b[j]]=1;
				if(y)	g[i][a[j]]=1;
			}
		}
	}
	for(i=1;i<n;i++)
	{
		if(dead[i])	continue;
		for(j=i+1;j<=n;j++)
		{
			if(dead[j])	continue;
			int cur=1;
			for(k=1;k<=n;k++)
				if(g[i][k]&&g[j][k])
				{
					cur=0;
					break;
				}
			ans+=cur;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
#define N 10000500
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n;
ll ans;
int p[N>>2],pn,d[N],num[N];
bool ntp[N];
void init(int n){
	ntp[1]=1,d[1]=1;
	for(register int i=2;i<=n;++i){
		if(!ntp[i])p[++pn]=i,d[i]=2,num[i]=1;
		for(int j=1;j<=pn&&p[j]*i<=n;++j){
			ntp[p[j]*i]=true;
			if(i%p[j]==0){
				d[p[j]*i]=d[i]/(num[i]+1)*(num[i]+2);
				num[p[j]*i]=num[i]+1;
				break;
			}
			else{
				d[p[j]*i]=(d[i]<<1);
				num[p[j]*i]=1;
			}
		}
	}
}
int main(){
	n=read();
	init(n);
	for(int i=1;i<=n;++i){
		ans+=1LL*i*d[i];
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 94088
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

  int h, a;
  cin >> h >> a;
  cout << (h+a-1)/a << endl;

	return 0;
}

Measured memory_bytes: 256
/*input 
141421 356237
*/ 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long int ll;
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
#define ld double
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll maxn=5e5+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e16;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
ll mult(ll a,ll b){
    return ((a%MOD)*(b%MOD))%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=mult(res,a);
        a=mult(a,a);
        b>>=1;
    }
    return res;
}
ll fac[maxn];
ll inv[maxn];
ll in(int x){
    return mypow(x,MOD-2);
}
ll c(int n,int m){
    return mult(fac[n],mult(inv[n-m],inv[m]));
}
ll p(int n,int m){
    return mult(fac[n],inv[n-m]);
}
int main(){
    ios::sync_with_stdio(false),cin.tie(0);
    int n,m;
    cin>>n>>m;
    fac[0]=inv[0]=1;
    REP1(i,maxn-1){
        fac[i]=mult(fac[i-1],i);
        inv[i]=in(fac[i]);
    }
    ll ans=p(m,n);
    REP1(i,n){
        ll cur=mult(p(m-i,n-i),c(n,i));
        if(i%2) ans-=cur;
        else ans+=cur;
        ans=(ans%MOD+MOD)%MOD;
    }
    ans=mult(ans,p(m,n));
    cout<<ans;
} 


Measured memory_bytes: 11352
#include <cstdio>
#include <cmath>
#include <algorithm>

long double pi = acosl(-1.0L);

int main() {
  long double a, b, x;
  scanf("%Lf %Lf %Lf", &a, &b, &x);

  long double h = x / a / a;

  long double lb = 0.0;
  long double ub = 90.0 / (180.0L / pi);
  for (int i = 0; i < 100; ++i) {
    long double mid = 0.5L * (lb+ub);
    long double z = a * std::tan(mid);
    long double y = h - 0.5 * z;
    if (y < 0.0L) {
      y = 0.0;
      z = std::sqrt(2*a*h*std::tan(mid));
    }
    ((y+z < b)? lb: ub) = mid;
  }

  long double theta = lb * 180.0L / pi;
  printf("%.20Lf\n", theta);
}


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

int main(){
  int n,k;
  cin>>n>>k;
  vector<long long> x(n),y(n);
  vector<long long> xa,ya;

  for(int i=0;i<n;i++){
    cin>>x[i]>>y[i];
    xa.push_back(x[i]);
    ya.push_back(y[i]);
  }

  sort(xa.begin(),xa.end());
  sort(ya.begin(),ya.end());

  long long ans=(xa[n-1]-xa[0])*(ya[n-1]-ya[0]);
  for(int xi=0;xi<n;xi++){
    for(int xj=xi+1;xj<n;xj++){
      for(int yi=0;yi<n;yi++){
        for(int yj=yi+1;yj<n;yj++){
          int num=0;
          for(int i=0;i<n;i++){
            if(xa[xi]<=x[i]&&xa[xj]>=x[i]&&ya[yi]<=y[i]&&ya[yj]>=y[i]) num++;
          }
          if(num>=k){
            ans=min(ans,(xa[xj]-xa[xi])*(ya[yj]-ya[yi]));
          }
        }
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a, b, c;
    cin >> a >> b >> c;
    cout << a + b + c - ( max( max( a, b ), c ) ) << endl;
    return 0;
}


Measured memory_bytes: 256
/*            AUTHOR - SHIVAM GUPTA
                       Jalpaiguri Govt. Engg College             */
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
vector<ll> tree(4*200005,0);

ll query(ll v, ll l, ll r, ll tl, ll tr)
{
    if(tl>r or tr<l)
        return -1;
    if(tl>=l and tr<=r)
        return tree[v];
    ll tm = (tl + tr) / 2;
    return max( query(2*v, l, r, tl, tm) , query(2*v+1, l, r, tm+1, tr) );
}

void update(ll v, ll tl, ll tr, ll pos, ll new_val) {
    if (tl == tr){
        tree[v] = new_val;
    }
    else 
    {
        ll tm = (tl + tr) / 2;
        if (pos <= tm)
            update(v*2, tl, tm, pos, new_val);
        else
            update(v*2+1, tm+1, tr, pos, new_val);
        tree[v] = max(tree[v*2] , tree[v*2+1]);
    }
}

void solve()
{
    vector<ll> dp(200005,0);       
    ll n=0,m=0,i=0,j=0,k=0,c=0,l=1,r=0,p=0,q=0,x=0,y=0,z=0,flag=0,sum=0;
    ll a[200005]={0},h[200005]={0};
    cin>>n; 
    for(i=0;i<n;i++)
        cin>>h[i];
    for(i=0;i<n;i++)
        cin>>a[i];
    for(i=0;i<n;i++)
    {
        x = query(1, 1, h[i], 1, n);
        dp[h[i]] = max( dp[h[i]], a[i]+x );
        update(1, 1, n, h[i], dp[h[i]]);
    }
    for(i=1;i<=n;i++)
    z=max(dp[i],z);
    
    cout<<z<<endl;
}
bool imp=false;int main()
{
    fio;
    int t=1;
    if(imp)
	cin>>t;
	ll j=t;
    while(t--){
    // cout<<"Case #"<<j-t<<": ";
    solve();}
    return 0;
}

Measured memory_bytes: 11264
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>

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

using namespace std;

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

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

void trace(int A[], int N) {
    for (int i = 0; i < N; ++i) {
        if (i > 0) cout << " ";
        cout << A[i];
    }
    cout << endl;
}

using ll = long long;
using P = pair<int, int>;

const unsigned long long INF = 1LL << 60;

////////////////////////////////////////////////////////////


int main() {
    vector<char> chars = {'S', 'H', 'C', 'D'};
    map<char, map<int, bool>> cards;
    for (char c:chars) {
        for (int i = 1; i <= 13; i++) {
            cards[c][i] = false;
        }
    }

    {
        int n, r;
        char c;
        cin >> n;
        for (int i = 0; i < n; i++) {
            cin >> c >> r;
            cards[c][r] = true;
        }
    }

    for (char c:chars) {
        for (int i = 1; i <= 13; i++) {
            if (!cards[c][i]) {
                printf("%c %d\n", c, i);
            }
        }
    }
}



Measured memory_bytes: 3132
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdlib>
#include <cmath> 
#include <vector> 

using ll = long long;
using namespace std;
const ll mod=1e9+7;
ll ans;
int N;
int main() {
  ans=0;
  cin>>N;
  int M;cin>>M;
  vector<bool> kiken(N,true);
  int a;a=0;
  for(int i=0;i<M;i++){
      cin>>a;
      kiken[a]=false;
  }
  vector<ll> dp(N+1);
  dp[0]=1;
  for(int now=0;now<N;++now){
      for(int next=now+1;next<=min(N,now+2);++next){
          if(kiken[next]){
              dp[next]+=dp[now];
              dp[next]%=mod;
          }
      }

  }

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


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
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 (b<a) { a=b; return 1; } return 0; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}



signed main(){

  int n,a,b;
  string str;

  int c;
  cin >>a >> b>> c;
  if(c-b==b-a) cout <<"YES\n";
  else cout <<"NO\n";
  return 0;
}



struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;



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

using namespace std;

int A[32];

int getMini(int idx, int costA, int costB)
{
	if (idx == -1) return (abs(costA - costB));
	
	return (min(getMini(idx - 1, costA + A[idx], costB),
				getMini(idx - 1, costA, costB + A[idx])));
}

int main()
{
	int n;
	
	while (scanf("%d", &n) && n){
		for (int i = 0; i < n; i++){
			scanf("%d", A + i);
		}
		
		printf("%d\n", getMini(n - 1, 0, 0));
	}
	
	return (0);
}

Measured memory_bytes: 1032
def inpl(): return list(map(int, input().split()))
N, L = inpl()
S = [L+i for i in range(N)]

if (L <= 0) and (0 <= N+L-1):
    print(sum(S))
elif N+L-1<0:
    print(sum(S[:N-1]))
else:
    print(sum(S[1:]))

Measured memory_bytes: 38484
import sys
from collections import deque
def input(): return sys.stdin.readline().strip()


def main():
    N, M = map(int, input().split())
    repn = [[] for _ in range(N)]
    for _ in range(M):
        a, b = map(int, input().split())
        repn[a - 1].append(b - 1)
        repn[b - 1].append(a - 1)

    """
    幅優先探索
    """

    parent = [-1] * N
    parent[0] = 0
    q = deque([0])

    while q:
        u = q.popleft()
        for v in repn[u]:
            if parent[v] != -1:
                continue
            parent[v] = u
            q.append(v)
    print("Yes")
    for i in range(1, N):
        print(parent[i] + 1)



if __name__ == "__main__":
    main()


Measured memory_bytes: 91840
#include <bits/stdc++.h>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;
const ll Lmax=ll(1e18);
const ll INF=1e9;
const int Bmax=2e5;
const int Nd=61;


int main(){
  int x; cin>>x;
  int a =x/200;

  cout<<10-a;


}


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

#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define fr(i,k,n) for (int i = k; i < n; ++i)
#define fri(i,k,n) for (int i = k; i >= n; --i)
#define INF (int)1e9
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define all(arr) arr.begin(),arr.end()

void boost(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

void solve(){
	int n;
	cin>>n;
	string s;
	int cnt1=0,cnt2=0,cnt3=0,cnt4=0;
	fr(i,0,n){
		cin>>s;
		if(s=="AC")
			cnt1++;
		else if(s=="WA")
			cnt2++;
		else if(s=="TLE")
			cnt3++;
		else
			cnt4++;
	}
	cout<<"AC x "<<cnt1<<endl;
	cout<<"WA x "<<cnt2<<endl;
	cout<<"TLE x "<<cnt3<<endl;
	cout<<"RE x "<<cnt4<<endl;
	return;
}

int main()
{
	boost();
	
	int tc=1;
	//cin>>tc;
	while(tc--)
		solve();
	return 0;
}

Measured memory_bytes: 3628
import sys

lines = sys.stdin.readlines()
n = int(lines[0])
arr = list(map(int, lines[1].split()))
arr_with_index = []
for idx, val in enumerate(arr):
    arr_with_index.append((val, idx))
arr_with_index.sort()
sorted_arr = map(lambda t: str(t[1] + 1), arr_with_index)
print(' '.join(sorted_arr))

Measured memory_bytes: 24988
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  int s, t;
  int p, q, m;
  int y;
  cin >> s >> t >> p >> q >> m >> y;
  cout << (y ^ s ^ t) << '\n';
  return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
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(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    vll a(n);
    rep(i, n){
        cin >> a[i];
    }
    sort(ALL(a));
    reverse(ALL(a));
    ll idx = 0;
    ld m = INF;
    repr(i, 1, n){
        if(chmin(m, abs(ld(a[0])/2-a[i]))){
            idx = i;
        }
    }
    cout << a[0] << " " << a[idx] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fi first
#define se second
#define maxn 300005
#define mod 1000000007
#define pb push_back
using namespace std;
typedef long long LL;
typedef pair<int,int> pi;

int n,k,ans;
int ar[maxn];
int tree[4*maxn];

void update(int cx , int cy , int q , int val , int id) {
	if(cy < q || q < cx)
		return;
	tree[id] = max( tree[id] , val );
	if(cx == cy)
		return;
	int mid = (cx+cy) >> 1;
	update(cx,mid,q,val,id*2);
	update(mid+1,cy,q,val,id*2+1);
}

int query(int cx , int cy , int qx , int qy , int id) {
	if(qy < cx || cy < qx)
		return 0;
	if(qx <= cx && cy <= qy)
		return tree[id];
	int mid = (cx+cy) >> 1;
	return max( query(cx,mid,qx,qy,id*2) , query(mid+1,cy,qx,qy,id*2+1) );
}

int main() {
	scanf("%d%d",&n,&k);
	for( int i = 1 , x ; i <= n ; i++ ) {
		scanf("%d",&x);
		int a = max(x-k,0);
		int b = min(x+k,maxn-5);
		int val = query(0,maxn-5,a,b,1) + 1;
		update(0,maxn-5,x,val,1);
		ans = max(ans,val);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 7912
n = int(input())
a = sorted([int(input()) for i in range(n)])
l = n//2

if n % 2 == 0:
    small = a[:l]
    big = a[l:]
    ans = sum(big) * 2 - sum(small) * 2  - big[0] + small[-1]
    print(ans)

else:
    small = a[:l]
    big = a[l+1:]
    ans = sum(big) * 2 - sum(small) * 2 - min(a[l] - small[-1], big[0] - a[l])
    print(ans)


Measured memory_bytes: 8284
#include<stdio.h>

int main(){
 int x, y, itizi, amari = -1;

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

 if (y >= x){
   itizi = x;
   x   = y;
   y   = itizi;
 } 

 amari = x % y;
 if(amari == 0){
   printf("%d\n", y);
 }else {
    while( (y % amari) != 0){
       x = y;
       y = amari;
       amari = x % y;
    }
    printf("%d\n", amari);
 }
 
 return 0;
}

Measured memory_bytes: 1848
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  (w : h : x : y : _) <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  putStrLn $ show (fromRational $ toRational (w * h) / toRational 2) ++ " " ++ (if w == 2 * x && h == 2 * y then "1" else "0")

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 508
using System;
using System.Collections.Generic;

class p
{
    static void Main(string[] args)
    {
        long N = long.Parse(Console.ReadLine());
        string[] input = Console.ReadLine().Split();
        long[] A = new long[N];
        long ans = 1;

        for(long i = 0; i < N; i++)
        {
            A[i] = long.Parse(input[i]);
        }

        Array.Sort(A);//昇順
        Array.Reverse(A);//降順

        long sum = 0;
        for(long i = 0; i < N; i++)
        {
            sum += A[i];
        }

        for (long i = 0; i < N - 1; i++)
        {
            sum -= A[i];
            if (sum * 2 >= A[i]) ans++;
            else break;
        }

        Console.WriteLine(ans);

    }   
}

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

int main(){
  int n, m;
  cin >> n >> m;
  vector<vector<pair<int, int>>> vp(n);
  rep(i, m){
    int p, y;
    cin >> p >> y;
    vp.at(p-1).push_back(make_pair(y, i));
  }
  vector<pair<int, int>> ans(m);
  rep(ken, n){
    auto v = vp.at(ken);
    sort(v.begin(), v.end());
    rep(i, v.size()){
      auto p = v.at(i);
      ans.at(p.second) = make_pair(ken+1, i+1);
    }
  }
  rep(i, m){
    auto p = ans.at(i);
    printf("%06d%06d\n", p.first, p.second);
  }
  return 0;
}

Measured memory_bytes: 7680
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    while(true){
      int H = sc.nextInt();
      int W = sc.nextInt();
      if(H==0&&W==0) break;
      for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
          System.out.printf("#");
        }
        System.out.printf("\n");
      }
     System.out.printf("\n");
    }
  }
}

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

int main() {
  int N;
  cin >> N;
  int ans = 100000;
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    int divider = 0;
    while (A % 2 == 0) {
      A /= 2;
      divider++;
    }
    if (divider < ans) {
      ans = divider;
    }
  }
  cout << ans;
}

Measured memory_bytes: 3612
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;
typedef pair<int,int> ii;
int n;
vector<ii> coord;
vector<int> towns;
inline double sq(double i){return i*i;}
double d(int i,int j){
    return sqrt( sq(coord[i].first-coord[j].first)+sq(coord[i].second-coord[j].second) );
}
int fac(int i){
    if (i==1) return 1;
    else return i*fac(i-1);
}
int main(){
    scanf("%d",&n);
    int a,b;
    for (int x=0;x<n;x++){
        scanf("%d%d",&a,&b);
        towns.push_back(x);
        coord.push_back(ii(a,b));
    }

    long double dist=0;
    do{
        for (int x=1;x<n;x++){
            dist+=d(towns[x-1],towns[x]);
        }
    } while (next_permutation(towns.begin(),towns.end()));

    printf("%.8Lf\n",dist/fac(n));
}


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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;


int main(){

    int a, b;
    bool ok = false;
    cin >> a >> b;
    if(a%3 == 0) ok = true;
    if(b%3 == 0) ok = true;
    if((a+b)%3 == 0) ok = true;

    if(ok) cout << "Possible" << endl;
    else cout << "Impossible" << endl;

    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define uni(q) unique(all(q)),q.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;



int main(){
    string s; cin >> s;
    ll k; cin >> k;
    char ans;
    rep(i,s.size()){
        if(s[i] != '1'){
            ans = s[i];
            break;
        }
        if(s[i] == '1' && k == i+1){
            ans = '1';
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
#include<cstring>
#include<cstdlib>
using namespace std;
int main(void)
{ 
	int n,i,ans=0,s[201];
	cin >> n;
	n=n*2;
	for(i=0;i<n;i++) cin >> s[i];
	sort(s,s+n);
	for(i=n-1;i>=0;i=i-2){
		ans+=s[n-i-1];
		//printf("a\n");
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        int count = 0;
        for(int i = 0; i < S.length()/2; i++) {
            if(S.charAt(i) != S.charAt(S.length() - 1 - i)) {
                count++;
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 23252
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
class p{
public:
	int num;
	int co;
};
int N,M;
vector<int> ans;
vector<int> co;
vector<int> line;
bool compare(p a,p b){
	return a.co>b.co;
}
pair<int,int> mkp(int a,int b){
	if(a>b){
		swap(a,b);
	}
	return pair<int,int>(a,b);
}
void add(map<pair<int,int>,int >&ma,pair<int,int> num){
	map<pair<int,int>,int>::iterator itr;
	itr = ma.find(num);
	if(itr!=ma.end()){
		++ma[num];
	}else{
		ma[num]=1;
	}
}

bool find(map<pair<int,int>,int>&ma,pair<int,int> num){
	map<pair<int,int>,int>::iterator itr;
	itr = ma.find(num);
	return itr!=ma.end();
}
void func(int place){
	map<pair<int,int>,int> ma;
	for(int i=place;i+1<line.size();i+=2){
		pair<int,int> pa = mkp(line[i],line[i+1]);
		add(ma,pa);
	}
	for(int i=place;i+1<line.size();i+=2){
		if(line[i]==line[i+1]){
			ans[line[i]]=min(ans[line[i]],N-co[line[i]]);
		}else{
			pair<int,int> pa = mkp(line[i],line[i+1]);
			int num = N-(co[line[i]]+co[line[i+1]]-ma[pa]);
			ans[line[i]]=min(ans[line[i]],num);
			ans[line[i+1]]=min(ans[line[i+1]],num);
		}
	}
	vector<p> li(M);
	for(int i=0;i<M;++i){
		li[i].num=i+1;
		li[i].co = co[i+1];
	}
	sort(li.begin(),li.end(),compare);
	for(int i=0;i<li.size();++i){
		int j;
		for(j=0;j<li.size();++j){
			if(i==j){
				continue;
			}
			pair<int,int> pa;
			pa = mkp(li[i].num,li[j].num);
			if(!find(ma,pa)){
				break;
			}
		}
		if(j==li.size()){
			continue;
		}
		int num = N-(li[i].co+li[j].co);
		ans[li[i].num] = min(ans[li[i].num],num);
		ans[li[j].num]=min(ans[li[j].num],num);
	}
}
int main(){
	cin>>N>>M;
	line.resize(N);
	for(int i=0;i<N;++i){
		cin>>line[i];
	}
	ans.resize(M+1,INT32_MAX);
	co.resize(M+1,0);
	for(int i=0;i<line.size();++i){
		++co[line[i]];
	}
	if(M==1){
		for(int i=1;i<ans.size();++i){
			ans[i]=0;
		}
	}else{
		func(0);
		func(1);
	}
	for(int i=1;i<ans.size();++i){
		cout<<ans[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 53440
#include <bits/stdc++.h>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}
int main(void){
    int n,m;
    cin>>n>>m;
    vector<vector<int>> a(2e5+1);
    rep(i,0,m){
        int in1,in2;
        cin>>in1>>in2;
        a[in1].push_back(in2);
    }
    rep(i,0,a[1].size()){
        int tmp=a[1][i];
        if(tmp==n){
            cout<<"POSSIBLE"<<endl;
            return 0;
        }
        rep(j,0,a[tmp].size()){
            if(a[tmp][j]==n){
                cout<<"POSSIBLE"<<endl;
                return 0;
            }
        }
    }
    cout<<"IMPOSSIBLE"<<endl;
    return 0;
}

Measured memory_bytes: 8576
N = input()
lst_N = list(N)

while 1:

    if lst_N[0] == lst_N[1] == lst_N[2]:
        break

    N = ''.join(lst_N)
    N = int(N)
    N += 1
    N = str(N)
    lst_N = list(N)

print(int(N))

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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

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

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)
#define lower_bound_idx(V,c) distance(V.begin(),lower_bound(V.begin(),V.end(),c))

typedef struct{
    int i;
    int to;
} ed;

int U[100000];
int ans=0;
vector<queue<ed>> eda(100000);
void tree(int pos,int d){
    int cdx=0;
    while(!eda[pos].empty()){
        cdx++;
        if(cdx==d)cdx++;
        tree(eda[pos].front().to,cdx);
        //cout<<"-"<<d<<" "<<cdx<<endl;
        U[eda[pos].front().i]=cdx;
        eda[pos].pop();
    }
    chmax(ans,cdx);
    return;
}


int main() {
    ios::sync_with_stdio(false);//stdoutとcoutの同期解除
    cin.tie(nullptr);//cinとcoutの同期解除
    
    int N;
    cin >>N;

    vector<int> T(N,0),a(N-1),b(N-1);
    rep(i,N-1){
        cin >> a[i]>>b[i];
        a[i]--;b[i]--;
        T[a[i]]++;
        T[b[i]]++;
        eda[a[i]].push({i,b[i]});
    }
    //-----------------------------------
    ans=eda[0].size();
    int i=1;
    while(!eda[0].empty()){
        tree(eda[0].front().to,i);
        U[eda[0].front().i]=i;
        eda[0].pop();
        i++;
    }
    cout << ans <<endl;
    rep(i,N-1){
        cout<<U[i]<<endl;
    }
    return (0);
}

Measured memory_bytes: 71168
package main

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

var ARRAY = []int{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}

func main() {
	sc := newInputScanner(true, 64)
	K := sc.nextInt()
	fmt.Println(ARRAY[K-1])
}

type inputScanner struct {
	*bufio.Scanner
}

func newInputScanner(enabledScanWords bool, sizeInKB int) *inputScanner {
	scanner := bufio.NewScanner(os.Stdin)
	if enabledScanWords {
		scanner.Split(bufio.ScanWords)
	}
	capacity := sizeInKB * 1024
	buf := make([]byte, capacity)
	scanner.Buffer(buf, capacity)
	return &inputScanner{
		Scanner: scanner,
	}
}

func (inputSc *inputScanner) nextInt() int {
	i, e := strconv.Atoi(inputSc.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (inputSc *inputScanner) nextUInt64() uint64 {
	i, e := strconv.ParseUint(inputSc.nextStr(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

func (inputSc *inputScanner) nextStr() string {
	inputSc.Scan()
	return inputSc.Text()
}


Measured memory_bytes: 640
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let (N, M) = read!(usize, usize);
    let T = read![[i64]; M];
    let P = read![[i64]];

    let mut G = vec![vec![false; N]; M];
    for i in 0..M {
        for &j in &T[i][1..] {
            G[i][j as usize - 1] = true;
        }
    }

    let mut count = 0;
    for s in 0..(1 << N) {
        let mut ok = true;

        for i in 0..M {
            let mut n = 0_i64;
            for j in 0..N {
                if G[i][j] && ((s >> j) & 1) == 1 {
                    n += 1;
                }
            }
            if n % 2 != P[i] {
                ok = false;
                break;
            }
        }

        if ok {
            count += 1;
        }
    }

    println!("{}", count)
}


Measured memory_bytes: 4352
#include <stdio.h>
#define MAX 100000
 
int A[MAX];
 
int partition(int p,int r){
    int x=A[r];
    int i=p-1;
    int j,store;
    for(j=p;j<r;j++){
        if(A[j]<=x){
            i+=1;
            store=A[i];
            A[i]=A[j];
            A[j]=store;
        }
    }
    store=A[i+1];
    A[i+1]=A[r];
    A[r]=store;
    return i+1;
}
 
int main(){
    int n,i;
    int prt;
    scanf("%d",&n);
     
    for(i=0;i<n;i++){
        scanf("%d",&A[i]);
    }
    prt=partition(0,n-1);
     
    for(i=0;i<n;i++){
        if(i==prt) printf("[%d]",A[i]);
        else printf("%d",A[i]);
        if(i>=0&&i<n-1) printf(" ");
    }
    printf("\n");
     
    return 0;
}

Measured memory_bytes: 992