akhauriyash/Code-Regression huggingface dataset:
/*
 ▓█████▄  ▄████▄  ▓██   ██▓ ██▓███   ██░ ██ ▓█████  ██▀███
▒██▀ ██▌▒██▀ ▀█   ▒██  ██▒▓██░  ██▒▓██░ ██▒▓█   ▀ ▓██ ▒ ██▒
 ░██   █▌▒▓█    ▄   ▒██ ██░▓██░ ██▓▒▒██▀▀██░▒███   ▓██ ░▄█ ▒
 ░▓█▄   ▌▒▓▓▄ ▄██▒  ░ ▐██▓░▒██▄█▓▒ ▒░▓█ ░██ ▒▓█  ▄ ▒██▀▀█▄
 ░▒████▓ ▒ ▓███▀ ░  ░ ██▒▓░▒██▒ ░  ░░▓█▒░██▓░▒████▒░██▓ ▒██▒
  ▒▒▓  ▒ ░ ░▒ ▒  ░   ██▒▒▒ ▒▓▒░ ░  ░ ▒ ░░▒░▒░░ ▒░ ░░ ▒▓ ░▒▓░
  ░ ▒  ▒   ░  ▒    ▓██ ░▒░ ░▒ ░      ▒ ░▒░ ░ ░ ░  ░  ░▒ ░ ▒░
  ░ ░  ░ ░         ▒ ▒ ░░  ░░        ░  ░░ ░   ░     ░░   ░
    ░    ░ ░       ░ ░               ░  ░  ░   ░  ░   ░
  ░      ░         ░ ░
*/
//focus less on how much problem you should solve within a fixed time and focus more on getting the problem solved and
//learning something from it
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define per(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vii vector <pair<ll,ll> >
#define sedes set <ll, greater <ll> >
#define seasc set <ll>
#define pb push_back
#define mkp make_pair
#define ff first
#define ss second
#define MOD 1000000007
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define umap unordered_map<ll, ll>
#define map map<ll, ll>
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define mems(a, i) memset(a, i, sizeof(a))
#define endl '\n'
#define all(v) v.begin(),v.end()
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define deba(a) cout << #a << " " <<a << endl;
bool comp(const pair<ll, ll>a, const pair<ll, ll>b )
{
	if (a.ss == b.ss)
		return a.ff < b.ff;
	else
		return a.ss < b.ss;
}
int main()
{
	fast;
#ifndef ONLINE_JUDGE
	freopen("D:\\input.txt", "r", stdin);
	freopen("D:\\output.txt", "w", stdout);
#endif
	int t = 1;
	// cin >> t;
	while (t--)
	{
		ll n;
		cin >> n;
		ll h = n;
		vi c, d;
		while (h--)
		{
			ll x, y;
			cin >> x >> y;
			c.pb(x + y);
			d.pb((x - y));
		}
		sort(all(c));
		sort(all(d));
		ll a3 = abs(c[0] - c[n - 1]);
		ll a4 = abs(d[0] - d[n - 1]);
		cout << max(a3, a4);
	}
	return 0;
}

Measured memory_bytes: 6620
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var n, m, k int
	con.Scan(&n, &m, &k)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		con.Scan(&a[i])
	}
	b := make([]int, m)
	for i := 0; i < m; i++ {
		con.Scan(&b[i])
	}
	sum := 0
	max := 0
	p := 0
	q := 0
	for p < len(a) && sum+a[p] <= k {
		sum += a[p]
		p++
	}
	for q < len(b) && sum+b[q] <= k {
		sum += b[q]
		q++
	}
	max = p + q
	for p > 0 {
		p--
		sum -= a[p]
		for q < len(b) && sum+b[q] <= k {
			sum += b[q]
			q++
		}
		if p+q > max {
			max = p + q
		}
	}
	for q < len(b) && sum+b[q] <= k {
		sum += b[q]
		q++
	}
	if p+q > max {
		max = p + q
	}
	con.Println(max)
	return nil
}


Measured memory_bytes: 7976
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
int main()
{
    int x, a, b;
    cin >> x >> a >> b;

    if (abs(x - a) > abs(x - b)) cout << "B" << endl;
    else cout << "A" << endl;
    return 0;
}

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

string D[4] = {"dream", "dreamer", "erase", "eraser"};

int main(void) {
  string S; cin >> S;
  reverse(S.begin(), S.end());
  for (int i = 0; i < 4; i++) {
    reverse(D[i].begin(), D[i].end());
  }

  while (true) {
    // cout << S << endl;
    bool tried = true;
    for (int i = 0; i < 4; i++) {
      bool flag = true;
      for (int k = 0; k < D[i].size(); k++) {
        if (S[k] != D[i][k]) {
          flag = false;
          break;
        }
      }
      if (flag) {
        S.erase(0, D[i].size());
        tried = false;
        break;
      }
    }
    if (tried || S.empty())
      break;
  }
  cout << (S.empty() ? "YES" : "NO") << endl;
}


Measured memory_bytes: 512
N,K = map(int,input().split())
p = list(map(int,input().split()))
x = sum(p[:K])
max_x = x
for i in range(K,N):
    x = x - p[i-K] + p[i]
    max_x = max(x,max_x)
print((max_x+K)/2)


Measured memory_bytes: 71792
#include <stdio.h>

#define N 102
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define INF 999999

int n,adj[N][N],color[N],d[N],Q[N],head=1,tail=1;

int Queempty(){
  if (head==tail){
    return 1;
  } else {
    return 0;
  }
}

void Enqueue(int r){
  int i;
  Q[tail] = r;
  tail++;
}

int Dequeue(){
  int i;
  i = Q[head];
  Q[head] = -1;
  head++;
  return i;
}

void BFS(int s){
  int u,v;
  color[s]=GRAY;
  d[s]=0;
  Enqueue(s);
  while(Queempty()==0){
    u = Dequeue();
    for (v=1;v<=n;v++){
      if (color[v]==WHITE&&adj[u][v]==1){
	color[v]=GRAY;
	d[v]=d[u]+1;
	Enqueue(v);
      }
    }
    color[u]=BLACK;
  }
  
}

int main() {
  int i,j,u,k,v,s=1;
  //ini
  for (i=1;i<N;i++){
    for (j=1;j<N;j++){
      adj[i][j]=0;
    }
    Q[i]=-1;
    color[i]=WHITE;
    d[i]=INF;
  }
  //

  scanf ("%d",&n);
  for (i=1;i<=n;i++){
    scanf ("%d%d",&u,&k);
    for (j=1;j<=k;j++){
      scanf("%d",&v);
      adj[u][v]=1;
    }
  }

  BFS(s);
  for (i=1;i<=n;i++){
    if (d[i]==INF) {
      d[i]=-1;
    }
    printf("%d %d\n",i,d[i]);
  }
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  for(int i=0;i<1002;++i){
    if(i*8/100==a && i/10==b){
      cout<<i;
      break;
    }
    else if(i==1001){
      cout<<"-1";
  }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
            #include<iostream>
            #include<cstdio>
            #include<vector>
            #include<queue>
            #include<map>
            #include<cstring>
            #include<string>
            #include <math.h>
            #include<algorithm>
        //    #include <boost/multiprecision/cpp_int.hpp>
            #include<functional>
          #define int long long
            #define inf  1000000007
            #define pa pair<int,int>
    #define ll long long
            #define pal pair<double,int>
            #define ppa pair<int,pa>
             #define ssa pair<string,int>
            #define  mp make_pair
            #define  pb push_back
            #define EPS (1e-10)
            #define equals(a,b) (fabs((a)-(b))<EPS)
     
            using namespace std;
     //priority_queue<int, vector<int>, greater<int> > que;
            class Point{
            	public:
            	double x,y;
            	Point(double x=0,double y=0):x(x),y(y) {}
            	Point operator + (Point p) {return Point(x+p.x,y+p.y);}
            	Point operator - (Point p) {return Point(x-p.x,y-p.y);}
            	Point operator * (double a) {return Point(x*a,y*a);}
            	Point operator / (double a) {return Point(x/a,y/a);}
            	double absv() {return sqrt(norm());}
            	double norm() {return x*x+y*y;}
            	bool operator < (const Point &p) const{
            		return x != p.x ? x<p.x: y<p.y;
            	}
            	bool operator == (const Point &p) const{
            		return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
            	}
            };
            typedef Point Vector;
     
            struct Segment{
            Point p1,p2;
            };
     
        double hen(Vector a){
        if(fabs(a.x)<EPS && a.y>0) return acos(0);
        else if(fabs(a.x)<EPS && a.y<0) return 3*acos(0);
        else if(fabs(a.y)<EPS && a.x<0) return 2*acos(0);
        else if(fabs(a.y)<EPS && a.x>0) return 0.0;
        else if(a.y>0) return acos(a.x/a.absv());
        else return 2*acos(0)+acos(-a.x/a.absv());
     
        }
     
int gcd(int v,int b){
	if(v>b) return gcd(b,v);
	if(v==b) return b;
	if(b%v==0) return v;
	return gcd(v,b%v);
}
            double dot(Vector a,Vector b){
            	return a.x*b.x+a.y*b.y;
            }
            double cross(Vector a,Vector b){
            	return a.x*b.y-a.y*b.x;
            }
        
double distans(double x1,double y1,double x2,double y2){
	double rr=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
	return sqrt(rr);
	
}
            //----------------kokomade tenpure------------

    signed  main(){
    	
    	int n,k,x,y;
    	cin>>n>>k>>x>>y;
    	
    	int ans=0;
    	ans = n*x;
    	ans += max(0ll,n-k)*(y-x);

    	cout<<ans<<endl;
  //  	printf("%.10f\n",ans[n-1]);
    	return 0;
    }

Measured memory_bytes: 256
N = int(input())
li=[int(it) for it in input().split()]
lia=li[::2]
lib=li[1::2]

import collections
ca = list(collections.Counter(lia).items())
cb = list(collections.Counter(lib).items())
na = len(lia)
nb = len(lib)
ca.sort(key=lambda x:-x[1])
cb.sort(key=lambda x:-x[1])
s = 0
if ( ca[0][0] != cb[0][0] ):
  s += na - ca[0][1]
  s += nb - cb[0][1]
else:
  if ( ca[0][1] > cb[0][1]   ):
    s += na - ca[0][1]
    if ( len(cb)>1 ):
      s += nb - cb[1][1]
    else:
      s += nb
  elif (ca[0][1] < cb[0][1]) :
    s += nb - cb[0][1]
    if ( len(ca)>1 ):
      s += na - ca[1][1]
    else:
      s += na
  else:
    p1 = cb[0][1]
    p2 = ca[0][1]
    if (len(ca)>1):
      p1+=ca[1][1]
    if (len(cb)>1):
      p2+=cb[1][1]
    s += na + nb - max(p1,p2)
    
print (s)
  


Measured memory_bytes: 20956
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define v vector<ll> 
#define vv vector<v>
#define p pair<ll,ll>
#define mid (start+end)/2
#define fi first
#define se second
ll MOD=1e9+7;
int LIM=1e6+10;	
vv adj(LIM);
void dfs(int n,v &visited,v &stk,v &dp,bool &f)
{
	visited[n]=1;
	dp[n]=1;
	for (int i=0; i<adj[n].size(); i++)
	{
		if (visited[adj[n][i]]==0)
		{
			dfs(adj[n][i],visited,stk,dp,f);
		}
		dp[n]=max(dp[adj[n][i]]+1,dp[n]);
		// cout<<dp[n]<<" "<<n<<endl;	
	}
}

bool dfs2(int n,v &visited,v &stk,v &dp,bool &f)
{
	if (visited[n]==1)
	{
		stk[n]=0;
		return 0;
	}
	visited[n]=1;
	stk[n]=1;
	for (int i=0; i<adj[n].size(); i++)
	{
		if (visited[adj[n][i]]==0 && dfs2(adj[n][i],visited,stk,dp,f) )
		{
			return true;
		}
		else if (stk[adj[n][i]]==1)
			return true;

	}
	stk[n]=0;
	return 0;
}

int main() {
	int n;
	cin>>n;
	for (int i=1; i<=n; i++)
	{
		v arr;
		int temp;
		cin>>temp;
		arr.push_back(temp);
		for (int j=2; j<n; j++)
		{
			cin>>temp;
			arr.push_back(temp);
			int j1=(int)arr.size()-1;
			int a=(i-1)*n+arr[j1]-1;
			int c=(arr[j1]-1)*n+i-1;
			int b=(i-1)*n+arr[j1-1]-1;
			int d=(arr[j1-1]-1)*n+i-1;
			adj[b].push_back(a);
			adj[b].push_back(c);
			adj[d].push_back(a);
			adj[d].push_back(c);
		}	
	}
	v visited(LIM,0);
	bool f=0;
	v dp(LIM,0);
	v stk(LIM,0);
	// cout<<adj[7][1]<<"b"<<endl;
	v visited2(LIM,0);
	for (int i=0; i<n*n; i++)
	{
		if (dfs2(i,visited2,stk,dp,f))
		{
			f=1;
			break;
		}
	}
	if (f)
	{
		cout<<-1<<endl;
		return 0;
	}

	for (int i=0; i<n*n; i++)
	{
		if (visited[i]==0)
		{
			dfs(i,visited,stk,dp,f);
		}
	}
		// cout<<dp[6]<<"a"<<endl;
	if (f)
	{
		cout<<-1<<endl;
	}
	else
	{
		ll ans=-1;
		for (int i=0;i<n*n; i++)
		{
			ans=max(ans,dp[i]);
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 104960
#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;
int main(){
  int n,w;
  cin >>n>>w;
  vector<int> lot;
  for(int i=0; i<n; i++) lot.push_back(i+1);
  while(w--){
    int a,b,c;
    scanf("%d,%d",&a,&b);
    c = lot[a-1];
    lot[a-1] = lot[b-1];
    lot[b-1] = c;
  }
  for(int i=0; i<n; i++) cout <<lot[i]<<endl;
  return 0;
}

Measured memory_bytes: 1260
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N; cin>>N;
    vector<int> H(N);
    int maximum=0;
    int count=0;
    for(int i=0;i<N;i++){
        cin>>H[i];
        if(maximum<=H[i]){
            count++;
        }
        maximum=max(maximum,H[i]);
    }
    cout<<count;
    return 0;
}

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

int X, A, B;

int main(void){
	
	scanf("%d %d %d", &X, &A, &B);
	A = -A;
	if(A + B <= 0) printf("delicious\n");
	else if(A + B <= X) printf("safe\n");
	else printf("dangerous\n");
	
	
    return 0;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  int N; cin >> N;
  vector<int> A(N), B(N);
  REP(i, N) cin >> A[i];
  REP(i, N) cin >> B[i];
  vector<ll> tmp(N); REP(i, N) tmp[i] = 0;
  vector<ll> dif(N); REP(i, N) dif[i] = 0;
  vector<ll> dif_a_b;
  ll ans = 0;
  if(accumulate(all(A), 0LL) < accumulate(all(B), 0LL)) {
    ans = -1;
  } else {
    REP(i, N) {
      if(A[i] < B[i]) {
        tmp[i] = 1;
        dif[i] = B[i] - A[i];
      } else {
        dif_a_b.push_back(A[i] - B[i]);
      }
    }
    sort(all(dif_a_b), greater<int>());
    ll cnt = 0;
    ll cnt_dif = 0;
    REP(i, N) {
      if(tmp[i] == 1) {
        cnt++;
        cnt_dif += dif[i];
      }
    }
    REP(i, dif_a_b.size()) {
      if(cnt_dif <= 0) break;
      cnt++;
      cnt_dif -= dif_a_b[i];
    }
    ans = cnt;
  }

  cout << ans << endl;
}


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

int main(){
    int K,S;
    cin >>K >>S;
    int cnt=0;
    for (int x=0;x<=K;x++){
        for (int y=0;y<=K;y++){
            
                    if(S-x-y>=0 && S-x-y<=K) cnt++;
            
        }
    }
    cout <<cnt <<endl;
}

Measured memory_bytes: 256
rank = [0, 48, 51, 54, 57, 60, 64, 69, 75, 81, 91, 1 << 30]
rank_name = ['light fly',
             'fly',
             'bantam',
             'feather',
             'light',
             'light welter',
             'welter',
             'light middle',
             'middle',
             'light heavy',
             'heavy', ]

while 1:
    try:
        weight = input()
        for i in xrange(len(rank_name)):
            if rank[i] < weight <= rank[i + 1]:
                print rank_name[i]
                break
    except EOFError:
        break

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

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = (long long)1e9 + 7; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}

#define MAX 110000

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int Q, N;
	static int sum[MAX] = {};
	cin>>Q;
	
	for(int i = 2; i < MAX; i++){
		int num = i;
		int con = 1;
		
		for(int j = 2; j*j <= num; j++){
			int t = 1;
			
			while(num%j == 0){
				num /= j;
				t++;
			}
			con *= t;
		}
		if(num != 1) con *= 2;
		// cout<<"i = "<<i<<" "<<con<<endl;
		if(con >= 5) sum[i] = 1;
		sum[i] += sum[i-1];
	}
	
	for(int i = 0; i < Q; i++){
		cin>>N;
		cout<<sum[N]<<endl;
	}
	
	
	
	return 0;
}


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

int main() {
	int N;
	int ans = 0;

	cin >> N;
	for (int i = 0;i < N;i++) {
		int x;
		cin >> x;

		while (x % 2 == 0) {
			ans++;
			x /= 2;
		}
	}
	cout << ans << endl;
}

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

using namespace std;

int main(){
    long long x;
    cin >> x;
    long long count = 0;
    long long num = 100;
    while(1){
      	num *= 1.01;
          count++;
        if(x <= num){
            break;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gya[200010];
ll kai[200010];
ll beki(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k%2==1){
            ret*=now;
            ret%=mod;
        }
        now*=now;
        now%=mod;
        k/=2;
    }
    return ret;
}
ll gyaku(ll n){
    return beki(n,mod-2);
}
void nckinit(ll n){
    kai[0]=1;
    kai[1]=1;
    for(int i=2;i<=n;i++){
        kai[i]=kai[i-1]*i;
        kai[i]%=mod;
    }
    gya[n]=gyaku(kai[n]);
    for(int i=n-1;i>=1;i--){
        gya[i]=gya[i+1]*(i+1);
        gya[i]%=mod;
    }
    gya[0]=1;
}
ll nck(ll n,ll k){
    if(k<0)return 0;
    if(k==0||n==k)return 1;
    ll ret=kai[n];
    ret*=gya[n-k];
    ret%=mod;
    ret*=gya[k];
    ret%=mod;
    return ret;
}
ll npk(ll n,ll k){
    if(k<0)return 0;
    if(k==0)return 1;
    ll ret=kai[n];
    ret*=gya[n-k];
    ret%=mod;
    return ret;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;cin>>n>>m;
    vector<int> v[n+1];
    rep(i,0,m){
        int a,b;cin>>a>>b;
        v[a].push_back(b);
        
    }
    int s,t;cin>>s>>t;
    int d[n+1][3];
    rep(i,0,n+1)rep(j,0,3)d[i][j]=-1;
    queue<pii> q;
    d[s][0]=0;
    q.push(make_pair(s,0));
    while(q.size()>0){
        pii p=q.front();q.pop();
        int now=p.first,dis=p.second;
        rep(i,0,v[now].size()){
            int ne=v[now][i];
            if(d[ne][(dis+1)%3]==-1){
                d[ne][(dis+1)%3]=dis+1;
                q.push(make_pair(ne,dis+1));
            }
        }
    }
    if(d[t][0]==-1)cout<<-1<<endl;
    else cout<<d[t][0]/3<<endl;
    
}


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

typedef long long ll;

static const int MAX = 1e5+1;
static const int NIL = -1;
static const ll INF = 1<<21;
static const ll MOD = 1e9 + 7;

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) {
    return arg1.first > arg2.first;
}

int main(void) {
    string L;
    cin >> L;

    ll dp[100010][2];
    dp[0][0] = 2;//2
    dp[0][1] = 1;//1
    for(int i=1;i<L.size();i++) {
        if(L.at(i)=='1') { 
            dp[i][0] = ((2*dp[i-1][0])%MOD);//今の桁は1で、忠実にLに合わせる
            dp[i][1] = ((((dp[i-1][0])%MOD)+((3*dp[i-1][1])%MOD))%MOD);//今の桁は1で、元よりも小さくする
        }
        else { 
            dp[i][0] = ((dp[i-1][0])%MOD);//今の桁は0で、忠実にLに合わせる
            dp[i][1] = ((3*dp[i-1][1])%MOD);//今の桁は0で、元よりも小さくする
        }
            dp[i][0] %= MOD;
            dp[i][1] %= MOD;
    }

    cout << (dp[L.size()-1][0]+dp[L.size()-1][1])%MOD << endl;

    return (0);
}


Measured memory_bytes: 2048
import Data.List
sortDesc = sortBy (flip compare)

main :: IO()
main = do
    n <- readLn :: IO Int
    xs <- map read . words <$> getLine :: IO [Int]
    print $ solve $ sortDesc $ xs

solve :: [Int] -> Int
solve a = loop (sum a) a 1
    where
        loop total [] ans = ans
        loop total (x:xs) ans
            | x > (total - x) * 2 = ans
            | otherwise = loop (total - x) xs (ans + 1)

Measured memory_bytes: 43388
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
#include <map>
#include<string>
using namespace std;
typedef long long ll;


int main()
{
  string s1,s2;
  cin >> s1 >> s2;



  cout << s2 << s1 << endl;
 return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int MAX = 1e5+1;
const long long int inf = 1e16;

int main(){
    while(1){
        int n;
        cin >> n;
        if(n==0) break;
        vector<int> hp(n);
        for(int i=0; i<n; i++) cin >> hp[i];
        
        int m;
        cin >> m;
        vector<long long int> mp(m), range(m), damage(m);
        for(int i=0; i<m; i++){
            string name, r;
            cin >> name >> mp[i] >> r >> damage[i];
            if(r=="Single"){
                range[i] = 0;
            }else{
                range[i] = 1;
            }
        }
        
        vector<vector<long long int> > dp(2, vector<long long int>(MAX, inf));
        for(int d=0; d<2; d++){
            dp[d][0] = 0;
            for(int i=0; i<m; i++){
                if(range[i]!=d || damage[i]==0) continue;
                for(int j=0; j<MAX; j++){
                    dp[d][j] = min(dp[d][j], (j+damage[i]-1)/damage[i]*mp[i]);
                    if(j-damage[i]>0){
                        dp[d][j] = min(dp[d][j], dp[d][j-damage[i]] +mp[i]);
                    }
                }
            }
        }

        long long int ans = inf;
        for(int i=0; i<MAX; i++){
            long long int cost = dp[1][i];
            for(int j=0; j<n; j++){
                if(hp[j]-i > 0){
                    cost += dp[0][hp[j]-i];
                }
            }
            ans = min(ans, cost);
        }
        cout << ans << endl;   
    }
    return 0;
}



Measured memory_bytes: 5176
//By Tushar Gautam
#pragma GCC optimize ("-O2")
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define memreset(a) memset(a,0,sizeof(a))
#define testcase(t) int t;cin>>t;while(t--)
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e;++i)
#define forsn(i,s,e) for(int i = s; i < e;++i)
#define rforn(i,s) for(int i = s; i >= 0;--i)
#define rforsn(i,s,e) for(int i = s; i >= e;--i)
#define bitcount(a) __builtin_popcount(a) // set bits (add ll)
#define ln '\n'
#define getcurrtime ((double)clock()/CLOCKS_PER_SEC)
#define dbgarr(v,s,e) cerr<<#v<<" = "; forsn(i,s,e) cerr<<v[i]<<", "; cerr<<endl
#define inputfile freopen("input.txt", "r", stdin)
#define outputfile freopen("output.txt", "w", stdout)
#define dbg(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) { cerr<<endl; }
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << "\t"; err(++it, args...);
}
template<typename T1,typename T2>
ostream& operator <<(ostream& c,pair<T1,T2> &v){
	c<<"("<<v.fi<<","<<v.se<<")"; return c;
}
template <template <class...> class TT, class ...T>
ostream& operator<<(ostream& out,TT<T...>& c){
    out<<"{ ";
    forstl(x,c) out<<x<<" ";
    out<<"}"; return out;
}
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<int> v32; 
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<p64> vp64;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
const int LIM=1e5+5,MOD=1e9+7;
int t,n,m,k,x,y,w;
v32 dv[LIM];
v64 s1[LIM],s2[LIM];
signed main(){
	fastio;
	forsn(i,1,LIM) for(int j=i;j<LIM;j+=i) dv[j].pb(i);
	cin>>n;
	int s[n];
	forn(i,n) cin>>s[i];
	forsn(i,1,n+1){
		ll pre=0;
		s1[i].pb(pre);
		for(int j=i;j<n;j+=i) pre+=s[j],s1[i].pb(pre);
		int oth=(n-1)%i;
		pre=0;
		s2[i].pb(pre);
		for(int j=oth;j<n;j+=i) pre+=s[j],s2[i].pb(pre);
	}
	ll best=0;
	forsn(i,1,n){
		ll oth=n-1-i;
		forstl(it,dv[oth]){
			if(i<=it) continue;
			if(i%it==0 and i<=oth) continue;
			ll csum=s1[it][oth/it]-s1[it][0];
			// for(int j=it;j<=oth;j+=it) csum+=s[j];
			int pad= (n-1)%it;
			csum+=(s2[it][(i-pad)/it+oth/it]-s2[it][(i-pad)/it]);
			// for(int j=it;j<=oth;j+=it) csum+=s[j+i-it];
			best=max(best,csum);
		}
	}
	cout<<best<<ln;
	return 0;
}

Measured memory_bytes: 43892
# coding: utf-8
# hello worldと表示する
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n,k=MI()
lis=LI()
cou=Counter(lis)
u=cou.most_common()
#print(u)
ans=0
for i in range(len(u)-k):
    j=len(u)-i-1
    #print(j)
    ans+=u[j][1]
    #print(cou.most_common()[j][1])
print(ans)


Measured memory_bytes: 96712
#include<bits/stdc++.h>
using namespace std;
int main(){
    int imem;
    int ibut;
    cin >> imem;
    cin >> ibut;
    int iBibs[imem];
    for(int i = 0;i < imem;i++){
        cin >> iBibs[i];
    }
    for(int k = 2;k <= ibut;k++){
        for(int i = 0;i < imem-1;i++){
            if((iBibs[i]%k) > (iBibs[i+1]%k)){
                swap(iBibs[i],iBibs[i+1]);
            }
        }
    }
    for(int i = 0;i < imem;i++){
        cout << iBibs[i] << endl;
    }
    return 0;
}

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

int n,sum,prod=1,dp1[210],cnt[20],pw[20],ans;
string s;
map<int,int> dp[20][210][2];

inline void dfs(int lvl,int num,int pro,int last)
{
	if(lvl==n+1){
		if(num!=sum) return;
		if(pro>=prod) return;
		int val=pw[n];
		for(int i=0;i<=9;i++) val/=pw[cnt[i]];
		ans+=val;
		return;
	}
	if(num>sum) return;
	if(num+(n-lvl+1)*9<sum) return;
	if(pro>=prod) return;
	for(int i=0;i<=9;i++){
		cnt[i]++;
		if(i>=last) dfs(lvl+1,num+i,pro*(i+1),i);
		cnt[i]--;
	}
}

inline int dfs2(int lvl,int num,int pro,bool flag)
{
	if(dp[lvl][num][flag].count(pro)){
		return dp[lvl][num][flag][pro];
	}
	if(lvl==n+1){
		if(num!=sum) return 0;
		if(pro!=prod) return 0;
		if(!flag) return 0;
		dp[lvl][num][flag][pro]=1;
		return 1;
	}
	if(num>sum) return 0;
	if(num+(n-lvl+1)*9<sum) return 0;
	if(prod%pro!=0) return 0;
	if(!flag){
		for(int i=0;i<=9;i++){
			if(i>(s[lvl-1]-'0')) continue;
			if(i==(s[lvl-1]-'0')) dp[lvl][num][flag][pro]+=dfs2(lvl+1,num+i,pro*(i+1),0);
			if(i<(s[lvl-1]-'0')) dp[lvl][num][flag][pro]+=dfs2(lvl+1,num+i,pro*(i+1),1);
		}
		return dp[lvl][num][flag][pro];
	}
	else{
		for(int i=0;i<=9;i++){
			dp[lvl][num][flag][pro]+=dfs2(lvl+1,num+i,pro*(i+1),1);
		}
		return dp[lvl][num][flag][pro];
	}
}

signed main()
{
	ios::sync_with_stdio(false);
	cin>>s;
	n=s.size();
	pw[0]=1;
	for(int i=1;i<=15;i++) pw[i]=pw[i-1]*i;
	//sum
	for(int i=1;i<=n;i++) sum+=(s[i-1]-'0');
	dp1[0]=1;
	for(int i=1;i<=n;i++){
		for(int j=sum;j>=0;j--){
			for(int k=1;k<=9;k++){
				if(j>=k) dp1[j]+=dp1[j-k];
			}
		}
	}
	for(int i=0;i<sum;i++) ans+=dp1[i];
	//prod
	for(int i=1;i<=n;i++) prod*=(s[i-1]-'0'+1);
	dfs(1,0,1,0);
	//int
	ans+=dfs2(1,0,1,0);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 5416
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    //static int[] dp;
    //static decimal[,,] dp;
    //static decimal N;
    static void Main(string[] args)
    {
        // 入力
        int[] input = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();
        int N = input[0];

        decimal ret = 0;
        if(N%2==0)
        {
            ret = (decimal)0.5;
        }
        else
        {
            ret = (decimal)(N / 2 + 1) / (decimal)N;
        }

        Console.WriteLine(ret + "");
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef short sh;
typedef unsigned short ush;
typedef unsigned int ui;

string s,t;
int out,temp,maks;

int main() {
	cin>>s>>t;
	
	int ls = s.length();
	int lt = t.length();
	int idt = 0;
	
	for(int i = 0; i<=ls-lt; i++){
		
		temp = 0;
		idt = 0;
		for(int j = i; j<lt+i; j++){
			if(s[j] == t[idt]){
				temp++;
				idt++;
			} else {
				idt++;
			}
		}
		
		maks = max(maks,temp);
	}
	
	out = lt - maks;
	cout<<out<<endl;
	return 0;
}

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

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; }

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

int main() {
    int N,Q;
    cin>>N>>Q;
    string s;
    cin>>s;
    vector<vector<char>> q(Q,vector<char>(2));
    for(int i = 0; i < Q; i++) cin>>q[i][0]>>q[i][1];
    auto query=[&](int x){
        for(int i = 0; i < Q; i++){
            if(s[x]==q[i][0]){
                if(q[i][1]=='L') x--;
                else x++;
            }
            if(x<0) return -1;
            if(x>=N) return 1;
        }
        return 0;
    };
    int l = -1,r=N;
    while(r-l>1){
        int mid = (l+r)/2;
        if(query(mid)==-1)l = mid;
        else r=mid;
    }
    int L = r;
    l = -1;
    r = N;
    while(r-l>1){
        int mid = (l+r)/2;
        if(query(mid)==1)r = mid;
        else l=mid;
    }
    int R = l;
    cout<<R-L+1<<endl;
}

Measured memory_bytes: 11396
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
int a,b,c=0,aa[200000],ab[200000],ac[200000]={0};
string s;
signed main()
{
	cin>>a>>b>>c;
	if(a==b&&b==c){
		cout<<"Yes";
	}else{
		cout<<"No";
	}
}

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

int main() {
    int j,p,q,temp1,temp2;
    int k;
    int i=0;
    int n,m;
    int flag=2;
    int num=1;
    cin>>n;
    int a[n];
    for(i=0; i<n; ++i){
        cin>>a[i];
    }
    
    if(n!=1) {
        for (i = 0; i < n-1; ++i) {
            if(flag==2){
                if(a[i]==a[i+1]){continue;}
                else if(a[i]<a[i+1]){flag=0;}
                else{flag=1;}
            }

            if (a[i] == a[i + 1]) { continue; }
            if (flag == 0) {//単調非減少時
                if (a[i] < a[i + 1]) { continue; }
                else {
                    flag=2;
                    ++num;

                }
            } else {//非増加時
                if (a[i] < a[i + 1]) {
                    flag=2;
                    ++num;
                }
                else { continue; }
            }
        }
    }


    cout<<num;
    return 0;
}

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

int main()
{
    int d, n;
    cin >> d >> n;
    if(d == 0){
        if(n == 100){
            cout << 101 << endl;
        }
        else{cout << n << endl;}
    }
    else if(d == 1){
        if(n == 100){
            cout << 10100 << endl;
        }
        else{
            cout << n*100 << endl;
        }
    }
    else{
        if(n == 100){
            cout << 1010000 << endl;
        }
        else{
            cout << n*10000 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 1 << 21;
using pii = std::pair<int, int>;
#define SORT(v) std::sort(v.begin(), v.end())
const int max_N = 110000;
int memo[max_N];
int rec(int N) {
	if (N == 0) return 0;
	if (memo[N] != -1) return memo[N];
	int res = N;
	for (int pow6 = 1; pow6 <= N; pow6 *= 6) res = std::min(res, rec(N - pow6) + 1);
	for (int pow9 = 1; pow9 <= N; pow9 *= 9) res = std::min(res, rec(N - pow9) + 1);
	return memo[N] = res;
}
int main(void) {
	int N,ans=0;
	
	std::cin >> N;
	for (int i = 0; i < max_N; ++i) memo[i] = -1;
	std::cout << rec(N) << std::endl;
	return 0;
	
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long h,ans;
  int count=0;
  cin >> h;
  while(h>1){
    h /= 2;
    count++;
  }
  ans = pow(2,(count+1))-1;
  cout << ans <<endl;
}
  

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

int main(){
    int n,r;

    while(cin>>n>>r,n|r){
        vector<int> v(n);

        for(int i=0; i<n;i++){
            v[i]=n-i;
        }

        for(int i=0; i<r; i++){
            int p,c;
            cin>>p>>c;

            rotate(v.begin(),v.begin()+p-1,v.begin()+p+c-1);
        }

        cout << v[0] << endl;
    }
}

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

public class Main {
	final static int MOD = 1000000007;
	final static int intMax = 1000000000;
	final static int intMin = -1000000000;
	final static int[] dx = { 0, 0, -1, 1 };
	final static int[] dy = { -1, 1, 0, 0 };

	static int add(int a, int b) {
		return (a + b) % MOD;
	}
	
	static int sub(int a, int b) {
		return (a - b + MOD) % MOD;
	}
	
	static int mult(int a, int b) {
		return (int)((((long)(a)) * b) % MOD);
	}
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//		BufferedReader br = new BufferedReader(new FileReader(".in"));
		PrintWriter out = new PrintWriter(new File(".out"));
		StringTokenizer st = new StringTokenizer(br.readLine());
		int H = Integer.parseInt(st.nextToken());
		int W = Integer.parseInt(st.nextToken());
		int[][] grid = new int[H][W];
		for(int i = 0; i < H; ++i) {
			String s = br.readLine();
			for(int j = 0; j < W; ++j) {
				grid[i][j] = s.charAt(j) == '.' ? 0 : 1;
			}
		}
		int[][] dp = new int[H][W];
		dp[0][0] = 1;
		for(int i = 0; i < H; ++i) {
			for(int j = 0; j < W; ++j) {
				if(grid[i][j] == 1) continue;
				if(i > 0) dp[i][j] = add(dp[i][j], dp[i - 1][j]);
				if(j > 0) dp[i][j] = add(dp[i][j], dp[i][j - 1]);
			}
		}
		System.out.println(dp[H - 1][W - 1]);
		br.close();
		out.close();
	}
}

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

int main() {
  string s;
  int k;
  cin>>s>>k;
  set<string> t;
  int n=s.size();
  for(int i=0;i<n;i++){
    string in="";
    for(int j=0;j<k && j+i<n;j++){
      in+=s[i+j];
      t.insert(in);
    }
  }
  int cnt=0;
  for(auto i:t){
    cnt++;
    if(cnt==k)
      cout<<i;
  }
      

}

Measured memory_bytes: 1664
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

amari = sorted([A[i]-B[i] for i in range(N) if A[i]>B[i]])
fusoku = sum([B[i]-A[i] for i in range(N) if A[i] < B[i] ])
fusoku_count = len([B[i]-A[i] for i in range(N) if A[i] < B[i]] )
ans = fusoku_count
while fusoku > 0 :
    if not amari:
        print(-1)
        exit()
    fusoku -= amari.pop()
    ans +=1
print(ans)


Measured memory_bytes: 18524
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)
#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)
#define EREP(i,u) for(int i=start[u];i;i=e[i].next)
#define fi first
#define se second
#define mkr(a,b) make_pair(a,b)
#define SZ(A) ((int)A.size())
template<class T>inline void chkmin(T &a,T b){ if(a>b)a=b;}
template<class T>inline void chkmax(T &a,T b){ if(a<b)a=b;}
inline void myassert(bool a,string s){ if(!a)cerr<<s<<endl,exit(0);}
inline int read()
{
	int s=0,f=1;char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')ch=getchar(),f=-1;
	while(isdigit(ch))s=s*10+ch-'0',ch=getchar();
	return ~f?s:-s;
}

const int maxn=3e3+20;

int n,mod;

inline int power(int a,int b,const int mod)
{
	int ans=1;
	while(b)
	{
		if(b&1)ans=(ll)ans*a%mod;
		b>>=1;
		a=(ll)a*a%mod;
	}
	return ans;
}

int jc[maxn],jcn[maxn],inv[maxn];
int S[maxn][maxn];

inline void prepare()
{
	jc[0]=jc[1]=jcn[0]=jcn[1]=inv[1]=1;
	REP(i,2,n)jc[i]=(ll)jc[i-1]*i%mod,inv[i]=(ll)(mod-mod/i)*inv[mod%i]%mod,jcn[i]=(ll)jcn[i-1]*inv[i]%mod;
	S[0][0]=1;
	REP(i,1,n+1)REP(j,1,i)S[i][j]=(S[i-1][j-1]+(ll)S[i-1][j]*j)%mod;
}

inline void init()
{
	n=read();mod=read();
}

inline int C(int n,int m){ return (ll)jc[n]*jcn[m]%mod*jcn[n-m]%mod;}


inline void doing()
{
	int ans=0;
	REP(i,0,n)
	{
		int xs=(ll)C(n,i)*(i&1?-1:1),res=0;
		int num0=power(2,n-i,mod),num1=power(2,n-i,mod-1);
		int t=power(2,num1,mod),t1=1;
		REP(j,0,i)
		{
			res=(res+(ll)S[i+1][j+1]*t%mod*t1)%mod;
			t1=(ll)t1*num0%mod;
		}
		ans=(ans+(ll)xs*res)%mod;
	}
	ans=(ans+mod)%mod;
	printf("%d\n",ans);
}

int main()
{
	init();
	prepare();
	doing();
	return 0;
}


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

#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;
  int n, i, j, C[VMAX+1];

  scanf("%d",&n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);
  
  for(i=0; i<=VMAX; i++) C[i]=0;
  
  for(i=0; i<n; i++){
    scanf("%hu",&A[i+1]);
    C[A[i+1]]++;
  }

  for(i=1; i<=VMAX; i++) C[i]=C[i]+C[i-1];

  for(j=1; j<=n; j++){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for(i=1; i<=n; i++){
    if(i<=n-1) printf("%d ",B[i]);
    else printf("%d\n",B[i]);
  }
  
  return 0;
}



Measured memory_bytes: 9600
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int s[10];
bool check(int n)
{
	while(n!=0)
	{
		if(s[n%10]==1) return false;
		n/=10;
	}
	return true;
}
int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=k;i++)
	{
		int x;
		scanf("%d",&x);
		s[x]=1;
	}
	while(!check(n))
	{
		n++;
	}
	printf("%d\n",n);
}

Measured memory_bytes: 3228
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String s = "";
		if(n == 25) s = "Christmas";
		else if(n == 24) s = "Christmas Eve";
		else if(n == 23) s = "Christmas Eve Eve";
		else if(n == 22) s = "Christmas Eve Eve Eve";
		System.out.println(s);
	}

}


Measured memory_bytes: 19412
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
using namespace std;


int di(int s, int f, vector< vector<int> > E, const int Size){
	int* cost = new int[Size + 1];
	bool* used = new bool[Size + 1];

	for(int i = 0; i < Size + 1; i++){
		cost[i] = INT_MAX / 4;
		if(i == s){
			cost[i] = 0;
		}
		used[i] = false;
	}

	while(true){
		int v = -1;
		for(int i = 0 ; i < Size + 1; i++){
			if( !used[i] && (v == -1 || cost[v] > cost[i])){
				v = i;
			}
		}
		if(v == -1){
			break;
		}
		used[v] = true;

		for(int i = 0; i < Size + 1; i++){
			cost[i] = min(cost[i], cost[v] + E[v][i]);
		}
	}

	return cost[f];
}


int main(){
	int n, m;
	int x1, x2, y1, y2;
	char dummy;
	int cost = 0;

	cin >> n;
	cin >> m;

	int* a = new int[m + 1];
	int* b = new int[m + 1];
	int* c = new int[m + 1];
	int* d = new int[m + 1];

	vector< vector <int > > E(n + 1, vector<int> (n + 1, INT_MAX / 4));


	for(int i = 1; i <= m; i++){
		cin >> a[i] >> dummy >> b[i] >> dummy >> c[i] >> dummy >> d[i];
		E[a[i]][b[i]] = c[i];
		E[b[i]][a[i]] = d[i];
	}
	cin >> x1 >> dummy >> x2 >> dummy >> y1 >> dummy >> y2;


	cost += di(x1, x2, E, n);
	cost += di(x2, x1, E, n);

	cout << y1 - y2 - cost << endl;
}

Measured memory_bytes: 1220
#include <stdio.h>
#include <string.h>

using namespace std;

int main() {
    char s[100];
    scanf("%s", s);
    bool flag = true;
    for (int i = 0; i < strlen(s); i++) {
        if (i % 2 == 0) {
            if (s[i] != 'R' && s[i] != 'U' && s[i] != 'D') {
                flag = false;
                break;
            }
        } else {
            if (s[i] != 'L' && s[i] != 'U' && s[i] != 'D') {
                flag = false;
                break;
            }
        }
    }
    if (flag) {
        printf("%s", "Yes");
    } else {
        printf("%s", "No");
    }
    return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;


public class Main {
		
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			
			int[] array = new int[N]; 
			int[] values = new int[N + 1];
			
			for(int i = 0; i < N; i++) {
				array[i] = sc.nextInt();
				values[array[i]]++;
			}
			
			long[] all = new long[N + 1];
			long[] selected = new long[N + 1];
			for(int i = 0; i <= N; i++) {
				final long v_0 = Math.max(0, values[i] - 0);
				final long v_1 = Math.max(0, values[i] - 1);
				final long v_2 = Math.max(0, values[i] - 2);
				
				all[i] = (v_0 * v_1) / 2;
				selected[i] = (v_1 * v_2) / 2;
			}
			
			final long sum = Arrays.stream(all).sum();
			
			for(int i = 0; i < N; i++){
				final int v = array[i];
				final long answer = sum - all[v] + selected[v];
				
				//System.out.println(sum + " " + all[v] + " " + selected[v]);
				System.out.println(answer);
			}
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

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

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

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}


Measured memory_bytes: 70428
n,m,x=map(int,input().split())
la=list(map(int,input().split()))
count1=0
count2=0
y=x
while y>=0:
    for i in la:
        if y==i:
            count1+=1
    y-=1

while x<=n:
    for i in la:
        if x==i:
            count2+=1
    x+=1
if count2>count1:
    print(count1)
else:
    print(count2)

Measured memory_bytes: 3064
/*

*/
#include<bits/stdc++.h>

using namespace std;
using ll=long long;
#define rep2(i, a, n) for(int i = (a); i < (n); i++)
#define rep(i, n) rep2(i,0,n)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  int x;cin>>x;
  cout<<not(x)<<endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

int main(){
    long long n,m;
    cin>>n>>m;
    vector<pair<long long,long long>> hoge(n);
    long long ans=0;
    
    for(int i=0;i<n;i++) cin>>hoge.at(i).first>>hoge.at(i).second;
    sort(hoge.begin(),hoge.end());
    
    for(auto a:hoge){
        if(m<a.second){
            ans+=m*a.first;
            m=0;
        }else{
            ans+=a.first*a.second;
            m-=a.second;
        }
        
        if(m<=0) break;
    }
    
    cout<<ans<<endl;
    
    return 0;
}

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

int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }

int main() {
  int K;
  cin >> K;
  int ans = 0;
  for (int i = 1; i <= K; i++) {
    for (int j = 1; j <= K; j++) {
      for (int k = 1; k <= K; k++) {
        int a = gcd(gcd(i, j), k);
        ans += a;
      }
    }
  }
  cout << ans << endl; 
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int n;
    cin >> n;
    ll m=0,a=0,r=0,c=0,h=0;
    vector<int> D(5);
    ll ans=0;
    vector<int> P = {0,0,0,0,0,0,1,1,1,2};
    vector<int> Q = {1,1,1,2,2,3,2,2,3,3};
    vector<int> R = {2,3,4,3,4,4,3,4,4,4};
    rep(i,n){
        string s;
        cin >> s;
        if(s[0] == 'M') m++;
        else if (s[0] == 'A')a++;
        else if (s[0] == 'R')r++;
        else if (s[0] == 'C')c++;
        else if (s[0] == 'H')h++;
    }
    D[0] = m; D[1] = a; D[2] = r; D[3] = c; D[4] = h;
    rep(i,10){
        ans += (ll)D[P[i]] * D[Q[i]] * D[R[i]];
    }
    cout << ans << endl;
    
}

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

// Define
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ul MAX = ULONG_MAX;
#define endl '\n'
#define space ' '
#define elif else if
#define def inline auto
#define func inline constexpr ll
#define run __attribute__((constructor)) def _
#define all(v) begin(v), end(v)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})

// Debug
#define debug(...)                                                             \
    cerr << __LINE__ << ": " << #__VA_ARGS__ << " = ";                         \
    for (auto &&X : {__VA_ARGS__}) cerr << "[" << X << "] ";                   \
    cerr << endl;

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i <= _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i >= _##i; --i)
#define rep(i, n) inc(i, 0, n - 1)

// Stream
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("-O3")
#pragma GCC target("avx")

// Math
func gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
func lcm(ll a, ll b) { return a * b / gcd(a, b); }

signed main() {
    ll N, S = 1;
    cin >> N;
    while (true) {
        if (111 * S >= N) {
            cout << 111 * S << endl;
            return 0;
        }
        S++;
    }
}

// for compilation: g++ -O3 -o _ _.cpp -std=c++17


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

int main(){
	double x1, x2, x3, x4, y1, y2, y3, y4;
	while(cin >>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4){
		if(x4 < x1 || x2 < x3 || y2 < y3 || y4 < y1)cout << "NO" << endl;
		else cout << "YES" << endl;
	}
	return 0;
}

Measured memory_bytes: 3212