akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  long long N, M;
  cin >> N >> M;

  long long ans = 0;
  ans += min(N, M / 2);
  M = max(M -(N * 2), 0LL);
  ans += M / 4;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, t, x, y;
	cin>>n;
	vector<pair<int, pair<int,int> > > places;
	places.push_back(make_pair(0, make_pair(0, 0)));
	for(int i = 0; i < n; ++i){
		cin>>t>>x>>y;
		places.push_back(make_pair(t, make_pair(x, y)));
	}
	for(int i = 1; i < n + 1; ++i){
		int d = abs(places[i].second.first - places[i - 1].second.first) + abs(places[i].second.second - places[i - 1].second.second);
		if(d > places[i].first - places[i - 1].first){
			cout<<"No"<<endl;
			return 0;
		}
		else if(d == places[i].first - places[i - 1].first){
			continue;
		}
		else{
			t = places[i].first - places[i - 1].first;
			if(abs(t - d) % 2 != 0){
				cout<<"No"<<endl;
				return 0;
			}
			else{
				continue;
			}
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 1912
#include "bits/stdc++.h"
using namespace std;
double dp[3000][3000];
int main()
{
	int n;
	double p, total = 0;
	scanf("%d%lf", &n, &p);
	dp[1][0] = p;
	dp[0][1] = 1 - p;
	for(int i = 1; i < n; ++i)
	{
		scanf("%lf", &p);
		for(int j = i; j >= 0; --j)
		{
			dp[j + 1][i - j] += dp[j][i - j] * p;
			dp[j][i - j + 1] += dp[j][i - j] * (1 - p);
		}
	}
	for(int i = n / 2 + 1; i <= n; ++i)
	{
		total += dp[i][n - i];
	}
	printf("%.10lf\n", total);
}

Measured memory_bytes: 70016
"use strict";
const Main = (input) =>{
   let xs = input.trim().split('\n');
   let nums = xs[1].split(' ').map(v=>parseInt(v,10));
   let ans = 0;
   for(let i = 0; i < xs[0]; i++){
   ans += nums[i];
   }
   let A = ans/2;
   let answer1 = 0;
   let answer2 = 0;
   for(let l = 0; l < xs[0]; l++){
     if(answer1 < A){
     answer1 = nums[l] + answer1;
     }else{
     answer2 = nums[l] + answer2;
     }
   }
   let X =(Math.abs(answer1 - answer2));
   
   let answer3 = 0;
   let answer4 = 0;
   for(let m = xs[0]-1; m >= 0; m--){
     if(answer3 < A){
     answer3 = nums[m] + answer3;
     }else{
     answer4 = nums[m] + answer4;
     }
   }  
   let Y =(Math.abs(answer4-answer3));
   
   if(X >= Y){
   console.log(Y);
   }else{
   console.log(X);
   }
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 7372
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    double xa1,ya1,xa2,ya2,xb1,yb1,xb2,yb2;
    while(cin>>xa1>>ya1>>xa2>>ya2>>xb1>>yb1>>xb2>>yb2){
        /*
        if(xa1>xa2)swap(xa1,xa2);
        if(ya1>ya2)swap(ya1,ya2);
        if(xb1>xb2)swap(xb1,xb2);
        if(yb1>yb2)swap(yb1,yb2);
        int flg=0;
        if(xb1<=xa1&&xa1<=xb2&&yb1<=ya1&&ya1<=yb2)flg=1;
        if(xb1<=xa1&&xa1<=xb2&&yb1<=ya2&&ya2<=yb2)flg=1;
        if(xb1<=xa2&&xa2<=xb2&&yb1<=ya1&&ya1<=yb2)flg=1;
        if(xb1<=xa2&&xa2<=xb2&&yb1<=ya2&&ya2<=yb2)flg=1;
        if(xa1<=xb1&&xb1<=xa2&&ya1<=yb1&&yb1<=ya2)flg=1;
        if(xa1<=xb1&&xb1<=xa2&&ya1<=yb2&&yb2<=ya2)flg=1;
        if(xa1<=xb2&&xb2<=xa2&&ya1<=yb1&&yb1<=ya2)flg=1;
        if(xa1<=xb2&&xb2<=xa2&&ya1<=yb2&&yb2<=ya2)flg=1;
        if(flg)puts("YES");
        else puts("NO");
        0 2 5 3 2 0 3 5
        */
        if(xa1>xb2||ya1>yb2||xa2<xb1||ya2<yb1)cout<<"NO"<<endl;
        else cout<<"YES"<<endl;
    }
    return 0;
}

Measured memory_bytes: 1220
#include <stdio.h>
int main(void) {
    int n, d, x, a[200];
    int ans = 0;
    int i, j, k;

    scanf("%d", &n);
    scanf("%d %d", &d, &x);
    for (i = 0; i < n; i++) scanf("%d", &a[i]);

    for (i = 0; i < n; i++) {
        for (j = 1; j <= d; j += a[i]) ans++;
    }
    ans += x;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
import math

A,B,H,M = map(int, input().split())

Md = M * 360 / 60
Hd = H * 30 + M * 30 / 60

MHd = abs(Md - Hd)

if MHd > 180 :
    MHd = 360 - MHd

ans = A**2 + B**2 - 2 * A * B *  math.cos(math.radians(MHd))
# print(math.cos(math.radians(60)))

print (math.sqrt(ans))


Measured memory_bytes: 9564
A = list(input())
import math
B = math.ceil(len(A) / 2)
R = 0
C = A[0:B]
D = A[-B:]
D = D[::-1]
count = 0
for i in range(B):
	if C[count] != D[count]:
		R += 1
	count += 1
print(str(R))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007



ll n, m, s[10], u[10] = { 0,2,5,5,4,5,6,3,7,6 }, keta, yoyuu, sai = INF, now;
bool tu[6000][114514];
string ans;
int main() {
	tu[0][0] = true;
	cin >> n >> m;
	REP(i, m) {
		cin >> s[i];
		sai = min(sai, u[s[i]]);
	}
	keta = n / sai;
	now = n;
	yoyuu = n % sai;
	REP(k, keta) {
		REP(i, (k + 1) * 7 + 10) {
			if (tu[k][i]) {
				REP(j, m)tu[k + 1][i + u[s[j]] - sai] = true;
			}
		}
	}
	sort(s, s + m, greater<ll>());

	REP(i, INF) {
		if (tu[keta][yoyuu])break;
		else {
			keta--;
			yoyuu += sai;
		}
	}
	REP(i, keta) {
		if (i == keta - 1) {
			REP(j, m) {
				if (yoyuu == u[s[j]] - sai and tu[keta - i - 1][yoyuu - u[s[j]] + sai]) {
					char a = s[j] + '0';
					yoyuu -= u[s[j]] - sai;
					ans.push_back(a);
					break;
				}
			}
		}
		else {
			REP(j, m) {
				if (yoyuu >= u[s[j]] - sai and tu[keta - i - 1][yoyuu - u[s[j]] + sai]) {
					char a = s[j] + '0';
					//now -= u[s[j]];
					yoyuu -= u[s[j]] - sai;
					ans.push_back(a);
					break;
				}
			}
		}
	}
	cout << ans << endl;
}



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

int main(){
  int64_t A,B,N;
  cin >> A >> B >> N;
  
  int64_t ans= (N >= B-1) ? (A*(B-1))/B
                          : (A*N)/B;
  
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include <stdio.h>

#include <stdlib.h>

#include <time.h>

#include <string.h>

#include <algorithm>

#include <iostream>

#include <map>

#include <queue>

#include <set>

#include <string>

#include <vector>

#include <bits/stdc++.h>

using namespace std;



const double TL = 1.5 * CLOCKS_PER_SEC;

mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());

#define clr(x, y) memset(x, y, sizeof(x))

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

#define LL long long



int n;

LL s[50];



vector<LL> cal(LL x, LL y, int d) {

  LL sx = (x - 1) / s[d] + 1;

  LL tx = (x - 1) % s[d] + 1;

  LL sy = (y - 1) / s[d] + 1;

  LL ty = (y - 1) % s[d] + 1;



  if(tx > s[d - 1] && tx <= s[d - 1] * 2) {

    int p = ty <= s[d - 1] ? 0 : 1;

    return {1, sx, sy + p, tx - s[d - 1], s[d - 1] * 2 - tx + 1};

  }

  if(ty > s[d - 1] && ty <= s[d - 1] * 2) {

    int p = tx <= s[d - 1] ? 0 : 1;

    return {2, sy, sx + p, ty - s[d - 1], s[d - 1] * 2 - ty + 1};

  }

  return {0, 0, 0, 0};

}



int main() {

  //auto start_clock = clock();

 // freopen("in", "r", stdin);

  s[0] = 1;

  for(int i = 1; i <= 30; i++) {

    s[i] = s[i - 1] * 3;

  }

  scanf("%d", &n);

  while(n--) {

    LL x1, y1, x2, y2;

    cin >> x1 >> y1 >> x2 >> y2;

    LL ans = 0;

    for(int i = 30; i >= 0; i--) {

      if(i == 0) {

        ans = abs(x1 - x2) + abs(y1 - y2);

      }

      else {

        auto v1 = cal(x1, y1, i);

        auto v2 = cal(x2, y2, i);

        if(v1[0] == v2[0] && v1[0] != 0 && v1[1] == v2[1] && v1[2] != v2[2]) {

          LL t = min(v1[3] + v2[3], v1[4] + v2[4]);

          if(abs(v1[0]) == 1) {

            t += abs(y1 - y2);

          }

          else {

            t += abs(x1 - x2);

          }

          ans = t;

          break;

        }

      }

    }

    cout << ans << endl;

  }



  return 0;

}



Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
#include <map>
#include <set>
using namespace std;
using Int = int64_t;
using P = pair<Int, Int>;
const Int INF = 1<<30;
const Int MOD = (Int)1e9 + 7;
const Int MAX_N = (Int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
#define debug2(x, y) cout << #x << ": " << x << ", " << #y << ": " << y << endl;
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    int n; cin >> n;
    vector<int> l(n);
    for(int i = 0; i < n; i++) cin >> l[i];

    int ans = 0;
    for(int i = 0; i < l.size(); i++)
    {
        for(int j = i + 1; j < l.size(); j++)
        {
            for(int k = j + 1; k < l.size(); k++)
            {
                int a = l[i];
                int b = l[j];
                int c = l[k];

                if(a == b || b == c || c == a) continue;

                if(a + b > c && b + c > a && c + a > b) ans++;
            }
        }
    }
    cout << ans << endl;
}

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 3648
fun main(args: Array<String>) {
    val mod = 1e9.toLong() + 7

    class Comb {

        val n = 2000

        val fact = LongArray(n + 1)
        val factInv = LongArray(n + 1)

        init {
            fact[0] = 1L
            for (i in 1..n) {
                fact[i] = fact[i - 1] * i % mod
            }
            factInv[n] = inv(fact[n])
            for (i in n downTo 1) {
                factInv[i - 1] = factInv[i] * i % mod
            }
        }

        private fun pow(base: Long, exp: Long): Long {
            if (exp == 0L) return 1L
            var a = pow(base, exp shr 1)
            a *= a
            a %= mod
            if (exp and 1L == 0L) return a
            return base * a % mod
        }

        private fun inv(x: Long): Long {
            return pow(x, mod - 2)
        }

        fun comb(n: Int, k: Int): Long {
            if (k !in 0..n) return 0L
            return fact[n] * factInv[k] % mod * factInv[n - k] % mod
        }

    }

    val cb = Comb()

    val (n, k) = readLine()!!.split(' ').map { it.toInt() }

    for (i in 1..k) {
        println(cb.comb(n - k + 1, i) * cb.comb(k - 1, i - 1) % mod)
    }

}


Measured memory_bytes: 36336
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a>b)swap(a,b);
    if(b>c)swap(b,c);
    if(a>b)swap(a,b);
    cout << a <<" "<< b <<" "<< c << endl;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
 
 
int main() {
    int X,Y;
    cin >> X >> Y;
    int ans=1;
    if(X%Y==0) cout << -1 << endl;
    else{
    while(true){
        ans*=X;
        if(ans%Y!=0){
            cout << ans << endl;
            break;
        }
        
    }
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

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

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
    
    int n, ans=3;
    char s[max][2];
    
    scanf("%d", &n);
    rep(i, n){
        scanf("%s", s[i]);
    }
    
    rep(i, n){
        if (s[i][0]=='Y') {
            ans++;
            break;
        }
    }
    
    if (ans==4) {
        printf("Four");
    } else {
        printf("Three");
    }
    
    return 0;
}


Measured memory_bytes: 1724
#include <bits/stdc++.h>
using namespace std;
 
int main() {  
  string n,m,x;
  char a,b,c;

  cin>>n;m=n;
  a=n[0];b=n[1];c=n[2];
  m[0]=a; m[1]=a; m[2]=a;
  
  if(a==b&&a==c){cout<<n;}
  else if(n<m){
      cout<<m;
  }
  else{
      x=n[0]+1;
      cout<<x+x+x;
      }
}

Measured memory_bytes: 256
#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;

#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vll;

typedef tree <pii, null_type, less <pii>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int N = 2e5 + 123, K = 999;
int n, a[N], q, ind[N], dp[N], f[N];
pii query[N], p[N];
vi vec[N];

struct block {
	vector <pii> v, tmp_v;
	vi s, ord, tmp;
	int suf = N, val = -1;
	void add(int x) {
		for (int i = suf; i < (int)v.size(); i++) {
			v[i].F = val;
		}
		suf = N, val = -1;
		int l = p[x].F, r = p[x].S;
		v.pb({r, l});
		s.pb(dp[l - 1] - f[l - 1]);
		for (int i = (int)s.size() - 2; i >= 0; i--) {
			s[i] = min(s[i], s[i + 1]);
		}
	}
	int get(int x) {
		if (v.empty()) {
			return N;
		}
		int L = p[x].F, R = p[x].S;
		int pos = lower_bound(all(v), mp(L - 1, 0)) - v.begin();
		if (pos < suf) {
			if (pos == (int)v.size()) {
				return N;
			}
			suf = pos, val = R;
			return s[pos];
		}	else {
			if (val >= L - 1) {
				val = R;
				return s[suf];
			}	else {
				return N;
			}
		}
	}
	int naive_get(int x) {
		if (v.empty()) {
			return N;
		}
		int L = p[x].F, R = p[x].S, res = N;
		for (int i = 0; i < (int)v.size(); i++) {
			if (i >= suf) {
				v[i].F = val;
			}
			if (v[i].S <= L && v[i].F >= L - 1) {
				res = min(res, dp[v[i].S - 1] - f[v[i].S - 1]);
				v[i].F = R;
				tmp.pb(i);
			}	else {
				ord.pb(i);
			}
		}
		suf = N, val = -1;
		for (int i = 0; i < (int)ord.size(); i++) {
			tmp_v.pb(v[ord[i]]);
		}
		for (int i = 0; i < (int)tmp.size(); i++) {
			tmp_v.pb(v[tmp[i]]);
		}
		v = tmp_v;
		ord.clear();
		tmp.clear();
		tmp_v.clear();
		for (int i = (int)s.size() - 1; i >= 0; i--) {
			if (i == (int)s.size() - 1) {
				s[i] = dp[v[i].S - 1] - f[v[i].S - 1];
			}	else {
				s[i] = min(s[i + 1], dp[v[i].S - 1] - f[v[i].S - 1]);
			}
		}
		return res;
	}
};

block b[250];

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	cin >> n;
	int s = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		f[i] = f[i - 1] + (a[i] == 0) - (a[i] == 1);
		s += a[i];
	}
	cin >> q;
	for (int i = 1; i <= q; i++) {
		int l, r;
		cin >> l >> r;
		p[i] = {l, r};
		vec[r].pb(i);
		query[i - 1] = {l, i};
	}
	sort(query, query + q);
	for (int i = 0; i < q; i++) {
		ind[query[i].S] = i;
	}
	for (int i = 1; i <= n; i++) {
		int res = N;
		for (int j : vec[i]) {
			b[ind[j] / K].add(j);
			for (int k = 0; k <= (q - 1) / K; k++) {
				int last = min(q - 1, K * (k + 1) - 1);
				if (query[last].F <= p[j].F && last < q - 1) {
					res = min(res, b[k].get(j));
				}	else {
					res = min(res, b[k].naive_get(j));
					break;
				}
			}
		}
		dp[i] = min(dp[i - 1], res + f[i]);
	}
	cout << dp[n] + s;
}


Measured memory_bytes: 21504
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int a = in.nextInt();
		int b = in.nextInt();

		int ans = (n*a < b) ? n * a : b;

		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#define REP(i,a) for(int i = 0; i < (a); i++)
using namespace std;

int main(){
	int h,w;
	cin >> h >> w;
	char a[h][w];
	bool del_h[h] = {};
	REP(i,h){
		bool black = false;
		REP(j,w){
			cin >> a[i][j];
			if(a[i][j] == '#')black = true;
		}
		if(black == false)del_h[i] = true;
	}
	bool del_w[w] = {};
	REP(i,w){
		bool black = false;
		REP(j,h){
			if(a[j][i] == '#')black = true;
		}
		if(black == false)del_w[i] = true;
	}
	REP(i,h){
		if(del_h[i] == false){
			REP(j,w){
				if(del_w[j] == false)cout << a[i][j];
			}
			cout << endl;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define MAX 2000000
#define SENTINEL 2000000000

int L[MAX/2+2], R[MAX/2+2];
int cnt;

void merge(int A[], int n, int left, int mid, int right){
    int n1 = mid - left;
    int n2 = right - mid;
    for(int i=0; i<n1;++i) L[i] = A[left+i];
    for(int i=0; i<n2;++i) R[i] = A[mid+i];
    L[n1] = R[n2] = SENTINEL;

    int i = 0, j = 0;
    for(int k=left;k<right;++k){
        cnt++;
        if(L[i] <= R[j]) A[k] = L[i++];
        else
        {
            A[k] = R[j++];
        }
        
    }

}

void mergeSort(int A[], int n, int left, int right){
    if(left+1<right){
        int mid = (left+right)/2;
        mergeSort(A, n, left, mid);
        mergeSort(A, n, mid, right);
        merge(A, n, left, mid, right);
    }
}

int main()
{
    int A[MAX], n, i;
    cnt = 0;

    cin >> n;
    for(int i = 0; i< n; ++i) cin >> A[i];

    mergeSort(A, n, 0, n);

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

    cout << cnt << endl;


    return 0;

}



Measured memory_bytes: 6984
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int cnt = 0;
vector<int>L(252525), R(252525);


void Merge(vector<int> &A, int left, int mid, int right) {
	int n1 = mid - left;
	int n2 = right - mid;
	for (int i = 0; i < n1; i++)L[i] = A[left + i];
	for (int i = 0; i < n2; i++)R[i] = A[mid + i];
	L[n1] = R[n2] = INF<int>();
	int i = 0, j = 0;
	for (int k = left; k < right; k++) {
		cnt++;
		if (L[i] <= R[j]) {
			A[k] = L[i++];
		}
		else {
			A[k] = R[j++];
		}
	}
}

void MergeSort(vector<int> &A, int left, int right) {
	if (left + 1 < right) {
		int mid = (left + right) / 2;
		MergeSort(A, left, mid);
		MergeSort(A, mid, right);
		Merge(A, left, mid, right);
	}
}

int n;

int main() {
	vector<int> A;
	cin >> n;
	REP(i, n) {
		int num;
		cin >> num;
		A.emplace_back(num);
	}
	MergeSort(A, 0, n);

	REP(i, n) {
		if (i)cout << " ";
		cout << A[i];
	}
	cout << endl;
	cout << cnt << endl;
}


Measured memory_bytes: 6932
#include <stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
long long int max(long long x,long long y)
{
    long long q,yu=1,j,k;
    j=x,k=y;
    if(x<y)
    {
        q=x;x=y;y=q;
    }
    while(yu)
    {
        yu=x%y;
        x=y;
        y=yu;
    }
    return j/x*k;
}
int main()
{
    long long t[105];
    int n,i;
    t[0]=1;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%lld",&t[i]);
        t[i]=max(t[i-1],t[i]);
    }
    printf("%lld\n",t[i-1]);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

string dp[101][101];

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

int w,h;
char field[101][101];

string maxString(string str1,string str2){
	string res1=str1;
	string res2=str2;

	if(str1==""){
		return str2;
	}
	else if(str2==""){
		return str1;
	}

	// ツ静ヲツ督ェツづ頚eroツづーツ湘つキ
	int idx1=str1.size()-1;
	for(int i = 0; i < (int)(str1.size())-1; i++){
		if(str1[i]!='0'){
			idx1=i;
			break;
		}
	}
	str1=str1.substr(idx1);

	idx1=str2.size()-1;
	for(int i = 0; i < (int)(str2.size())-1; i++){
		if(str2[i]!='0'){
			idx1=i;
			break;
		}
	}
	str2=str2.substr(idx1);

	if(str1.size()>str2.size())
		return res1;
	else if(str1.size()<str2.size())
		return res2;
	else{
		for(int i = 0; i < str1.size(); i++){
			if(str1[i]>str2[i]){
				return res1;
			}
			else if(str1[i]<str2[i]){
				return res2;
			}
		}
		return res1;
	}
}

string dfs(int x,int y){
	if(dp[y][x]!="")
		return dp[y][x];
	if(!(field[y][x]>='0'&&field[y][x]<='9')){
		return "";
	}
	string res="";
	for(int i = 0; i < 2; i++){
		int ny=y+dy[i];
		int nx=x+dx[i];
		if(ny>=0&&nx>=0&&ny<h&&nx<w&&(field[ny][nx]>='0'&&field[ny][nx]<='9')){
			string s=(dfs(nx,ny));
			if(s!="")
				res=maxString(res,s);
		}
	}
	res=res+field[y][x];
	dp[y][x]=res;
	return res;
}

int main(){

	while(cin>>w>>h&&!(w==0&&h==0)){
		for(int i = 0; i < 101; i++){
			for(int j =0; j < 101; j++){
				dp[i][j]="";
				field[i][j]=0;
			}
		}

		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				cin>>field[i][j];
			}
		}
		string maxNum="";
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				string res=dfs(j,i);
				if(res=="")
					continue;
				maxNum=maxString(maxNum,res);
			}
		}

		// ツ静ヲツ督ェツづ頚eroツづーツ湘つキ
		if(maxNum!=""&&maxNum[0]=='0'){
			int idx1=maxNum.size()-1;
			for(int i = 0; i < (int)(maxNum.size())-1; i++){
				if(maxNum[i]!='0'){
					idx1=i;
					break;
				}
			}
			maxNum=maxNum.substr(idx1);
		}
		cout<<maxNum<<endl;
	}

	return 0;
}

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

const int MOD = 1000000007;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a%b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

string IN[] = { "dream", "dreamer", "erase", "eraser" };
int l[] = {5, 7, 5, 6};

int main() {
    string S;
    cin >> S;

    reverse(S.begin(), S.end());

    rep(i, 4) reverse(IN[i].begin(), IN[i].end());

    bool can = true;
    while (can) {
        can = false;
        rep(i, 4) {
            string t = S.substr(0, l[i]);
            if (t == IN[i]) {
                S = S.erase(0, l[i]);
                can = true;
            }
        }
    }

    if (S.size() > 0) cout << "NO" << endl;
    else cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(_i,_a,_n) for(int _i=_a;_i<=_n;++_i)
#define PER(_i,_a,_n) for(int _i=_n;_i>=_a;--_i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(_a) ({REP(_i,1,n) cout<<_a[_i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



#ifdef __APPLE__
const int N = 1e2+50;
#else
const int N = 1e6+50;
#endif


ll n,a,b;

int main() {
	scanf("%lld%lld%lld",&n,&a,&b);
	if ((b-a)%2==0) return printf("%lld\n",(b-a)/2),0;
	ll t = n-b, x = a, y = b;
	x += t, y += t;
	ll ans = t+(y-x+1)/2;
	t = a-1, x = a, y = b;
	x -= t, y -= t;
	ans = min(ans, t+(y-x+1)/2);
	printf("%lld\n", ans);
}









Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())
cnt = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500 * i + 100 * j + 50 * k == x:
                cnt += 1

print(cnt)

Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
    int n,a,b,ar[1000],i,sml=0,big=0,m,mid,x;
    scanf ("%d %d %d",&n,&a,&b);
    for (i=0;i<n;++i){

       scanf ("%d",&m) ;
       if (m<=a)++sml;
       else if (m>b)++big;

    }
    mid = n-(sml+big);
    if (sml<=mid && sml<=big)printf ("%d\n",sml);
    else if (mid<=sml && mid<=big)printf ("%d\n",mid);
    else if (big<=mid && big<=sml)printf ("%d\n",big);

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define N 100005
#define ll long long
using namespace std;
int read(){
    int x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
    return f*x;
}
int num[N];
bool vis[N];
vector<pair<int,int> >v_[N];
ll dis[N];
int main(){
	ios::sync_with_stdio(false);
	int n,m;cin>>n>>m;
	int t1,t2,t3;
	for(int i=1;i<=m;i++){
		cin>>t1>>t2>>t3;
		num[t2]++;vis[t1]=1;
		v_[t1].push_back(make_pair(t2,t3));
	}
	if(m==0){
		cout<<"Yes"<<endl;
		return 0;
	}
	queue<int>que;
	for(int i=1;i<=n;i++){
		if(!vis[i]) continue;
		if(!num[i]) que.push(i);
	}
	if(que.empty()){
		cout<<"No"<<endl;
		return 0;
	}
	while(!que.empty()){
		int t=que.front();que.pop();
		for(int i=0;i<v_[t].size();i++){
			if(dis[v_[t][i].first]==0||dis[t]+v_[t][i].second==dis[v_[t][i].first]){
				dis[v_[t][i].first]=dis[t]+v_[t][i].second;
				num[v_[t][i].first]--;
				if(!num[v_[t][i].first]) que.push(v_[t][i].first);
			}
			else{
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}


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

int main(){
    int w, q;
    while(cin >> w >> q, w+q){
        int a[w];   for(int i = 0; i < w; i++)  a[i] = -1;
        while(q-- > 0){
            char op;
            int x, y;
            cin >> op;
            if(op == 's'){
                cin >> x >> y;
                bool sleep = false;
                for(int j = 0; j <= w-y; j++){
                    int k;
                    for(k = 0; k < y; k++)  if(a[j+k] != -1)    break;
                    if(k == y){
                        for(k = 0; k < y; k++)  a[j+k] = x;
                        sleep = true;
                        cout << j << endl;
                        break;
                    }
                }
                if(!sleep)  cout << "impossible" << endl;
            }else{
                cin >> x;
                for(int i = 0; i < w; i++)  if(a[i] == x)   a[i] = -1;
            }
        }
        cout << "END" << endl;
    }
    return 0;
}


Measured memory_bytes: 3016
A,B,C = map(int,input().split())
memo = set()
def f(a,b,c):
  if (a,b,c) in memo : return -1
  if a%2 or b%2 or c%2 : return 0
  memo.add((a,b,c))
  r = f((b+c)//2,(a+c)//2,(a+b)//2)
  return r+1 if r>=0 else -1

print(f(A,B,C))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
#define pi acos(-1)
#define inf 2e9 
using namespace std;
const int mod=924844033;
const int N=4005;
inline ll rd(){
	ll x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=0;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
	return f?x:-x;
}int n,m,tot;bool vis[N];
ll f[N][N][2],fac[N],ans;
int main(){
	n=rd(),m=rd();fac[0]=1; 
	for(int i=1;i<=n;i++) fac[i]=fac[i-1]*i%mod;
	for(int i=1;i<=m;i++){
		for(int t=2;t--;){
			for(int j=i;j<=n;j+=m){
				tot++;if(j!=i) vis[tot]=1;
			}
		}
	}f[0][0][0]=1;
	for(int i=0;i<n*2;i++){
		for(int j=0;j<=n;j++){
			f[i+1][j][0]=(f[i][j][0]+f[i][j][1])%mod;
			if(vis[i+1]) f[i+1][j+1][1]=f[i][j][0];
		}
	} 
	for(int i=0,t=1;i<=n;i++,t=-t){
		f[2*n][i][0]=1ll*(f[2*n][i][0]+f[2*n][i][1])*fac[n-i]%mod;
		ans=(ans+f[2*n][i][0]*t+mod)%mod; 
	}cout<<ans;
	return 0;
}

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

int main(){
    string S;
    cin >> S;
    int ans = 700;
    if (S[0] == 'o') ans += 100;
    if (S[1] == 'o') ans += 100;
    if (S[2] == 'o') ans += 100;
    cout << ans << endl;
}


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

int main()
{
	string S;
	cin >> S;

	bool flg = true;

	for (int i = 0; i < S.length() - 1; i++)
	{
		if (S[i + 1] == S[i])
		{
			flg = false;
			break;
		}
	}
	if (flg == true)
	{
		cout << "Good" << endl;
	}
	else
	{

		cout << "Bad" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE BangPatterns          #-}
{-# LANGUAGE CPP                   #-}
{-# LANGUAGE LambdaCase            #-}
{-# LANGUAGE MagicHash             #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE MultiWayIf            #-}
{-# LANGUAGE OverloadedStrings     #-}
{-# LANGUAGE TupleSections         #-}
{-# LANGUAGE TypeFamilies          #-}
{-# LANGUAGE ViewPatterns          #-}

import           Control.Applicative
import           Control.Exception
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString             as B
import qualified Data.ByteString.Builder     as B
import qualified Data.ByteString.Char8       as C
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import qualified Data.Foldable               as F
import           Data.Function
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import qualified Data.List                   as L
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           GHC.Exts
import qualified System.IO                   as IO
import           Unsafe.Coerce

main :: IO ()
main = do
    [w,h,x,y] <- map read.words <$> getLine :: IO [Int]
    let area :: Double
        area = fromIntegral w * fromIntegral h * 0.5
    if even h && even w && x == div w 2 && y == div h 2
    then putStrLn $ shows area " 1"
    else putStrLn $ shows area " 0"

-------------------------------------------------------------------------------
type Parser a = C.ByteString -> Maybe (a, C.ByteString)

parseInt :: Parser Int
parseInt = C.readInt . C.dropWhile isSpace

parseInt2 :: Parser (Int, Int)
parseInt2 = runStateT $
    (,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)

parseInt3 :: Parser (Int, Int, Int)
parseInt3 = runStateT $
    (,,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)

parseInt4 :: Parser (Int, Int, Int, Int)
parseInt4 = runStateT $
    (,,,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)

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

using namespace std;

int main(){
  string s;
  cin >> s;
  string ope[3];
  
  for(int op=0;op < (1<<3);op++){
    int sum = 0;
    sum = s[0] - '0';
    for(int i=0;i < 3;i++){
      if((op >> i) & 1){
        sum += s[i+1] - '0';
        ope[i] = '+';
      }else{
        sum -= s[i+1] - '0';
        ope[i] = '-';
      }
    }
    if(sum == 7) break;
  }
  cout << s[0] << ope[0] << s[1] << ope[1] << s[2];
  cout << ope[2] << s[3] << "=7" << endl;
  return 0;
}

Measured memory_bytes: 3632
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
constexpr long long LINF = 1000100010001000100LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i, j, n) for(int i=(j); i<(n); i++)
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; }


int main() { 
    ll a, b, c, x, y; cin >> a >> b >> c >> x >> y;
    ll res = 0;
    int num = min(x,y);
    res += min(a+b, 2*c) * num;
    num = abs(x-y);
    res += min(x>y?a:b, 2*c)*num;
    cout << res << ln;
}

Measured memory_bytes: 256
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <float.h>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <locale>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <wchar.h>
#include <wctype.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cerrno>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <limits>
#include <map>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <istream>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <utility>
#include <vector>
#include <cwchar>
#include <cwctype>
#include <complex.h>
#include <fenv.h>
using namespace std;
int n,m;
vector<int> a[9];
long long num;
bool use[9];
bool ok()
{
	int i;
	for(i=0;i<n;i++) if(!use[i]) return 0;
	return 1;
}
void dfs(int lst,int dp)
{
//	cout<<lst<<endl;
	if(dp==n-1){
		if(ok()) num++;
		return;
	}else{
		int i;
		for(i=0;i<a[lst].size();i++){
			if(!use[a[lst][i]]){
				use[a[lst][i]]=1;
				dfs(a[lst][i],dp+1);
				use[a[lst][i]]=0;
			}
		}
	}
	return;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin>>n>>m;
	int x,y,i,j;
	for(i=0;i<m;i++)
	{
		cin>>x>>y;
		a[x-1].push_back(y-1);
		a[y-1].push_back(x-1);
	}
	use[0]=1;
	dfs(0,0);
	cout<<num<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int price, min;
  int residual;

  cin >> price >> min;
  residual = price % 500;
  if (residual == 0) {
    cout << "Yes" << endl;
  }
  else if (residual <= min) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
 
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>

int main() {
	int n;
	cin >> n;
	vector<int>p(n);
	rep(i, n) {
		cin >> p[i];
	}
	int sum(0);
	int buffer(p[0]);
	rep(i, n) {
		buffer = min(buffer, p[i]);
		if (buffer == p[i]) {
			++sum;
		}
		
	}
	cout << sum;
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#define MAX 100
#define INFTY 1000000000
#define WHITE 0
#define BLACK 1
#define min(a,b) ( (a<b)? (a):(b) )
int M[MAX][MAX];
int d[MAX];
int color[MAX];
int n;

void trace(){
    int v;
    for(v=0;v<n;v++){
	printf("%d(%d): %d\n",v,color[v],d[v]);
    }
    printf("\n");
}

void dijkstra(){
    int u,v;
    int cnt=0,minv;

    u=0;
    d[u]=0;
    color[u]=BLACK;
    cnt++;

    while(cnt<n){
	for(v=0;v<n;v++){
	    if(color[v]==WHITE){
		d[v]=min(d[v],d[u]+M[u][v]);
	    }
	}
	
//	trace();

	minv=INFTY;

	for(v=0;v<n;v++){
	    if(color[v]==WHITE && d[v]<minv){
		u=v;
		minv=d[v];
	    }
	}

	color[u]=BLACK;
	cnt++;
    }
}


int main(void){
    int i,j;
    int u,k,v,c;

    scanf("%d",&n);

    for(i=0;i<n;i++) for(j=0;j<n;j++){
	M[i][j]=INFTY;
    }

    for(i=0;i<n;i++){
        scanf("%d%d",&u,&k);
	    while(k--){
		scanf("%d%d",&v,&c);
		M[u][v]=c;
	    }
    }

/*
    for(i=0;i<n;i++){
	for(j=0;j<n;j++){
	    printf("%d ",( (M[i][j]==INFTY) ? (-1):(M[i][j]) ));
	}
	printf("\n");
    }
*/	
		
    for(i=0;i<n;i++){
	d[i]=INFTY;
	color[i]=WHITE;
    }

    dijkstra();

    for(i=0;i<n;i++){
	printf("%d %d\n",i,d[i]);
    }

    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
    #include <ext/pb_ds/tree_policy.hpp> 
    #include <functional> // for less 
    using namespace __gnu_pbds; 
    using namespace std;
    //typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;    
    #define ll            long long
    #define pb            push_back
    #define ppb           pop_back
    #define si            set <ll>
    #define endl          '\n'
    #define fr            first
    #define sc            second
    #define mii           map<ll ,ll >
    #define msi           map<string,ll >
    #define mis           map<ll , string>
    #define rep(i,a,b)    for(ll  i=a;i<b;i++)
    #define all(v)        v.begin(),v.end()
    #define sort(v)       sort(all(v))
    #define pii           pair<ll ,ll >
    #define vi            vector<ll >
    #define vii           vector<pair<ll , ll >>
    #define vs            vector<string>
    #define sz(x)         (ll)x.size()
    #define M             1000000007
    #define bs            binary_search
    #define rev(a)        reverse(all(a));
    #define sp(n)         setprecision(n)
    #define spl           " "
    #define arr(a,n)      rep(i,0,n) cin>>a[i]
    #define mod           998244353
    #define print_vector(a)  for(auto t:a) cout<<t<<" ";cout<<endl;
    #define print_arr(a,n)   rep(i,0,n) cout<<a[i]<<" "; cout<<endl;        
    #define show(a,n)     for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;
    #define N             100000000
    #define debug(x)      cout << #x << " is " << x << endl;
    #define time          cout << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    #define INF           1ll<<31
    using namespace std;
    ll min(ll a,ll b)
    {
        return a>b?b:a;
    }
    ll max(ll a,ll b)
    {
        return a>b?a:b;
    }
    const ll maxn=2e5+500;
    void solve()
    {
      ll n;
      cin>>n;
      std::map<string ,ll> mp;
      string x;
      rep(i,0,n) {cin>>x;mp[x]++;}
      ll mx=-1;
      vs v;
      for(auto it:mp) mx=max(mx,it.sc);
      for(auto it:mp) if(it.sc==mx) v.pb(it.fr);
      sort(v);
      for(auto it:v) cout<<it<<" ";
    }
    signed main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        #ifndef ONLINE_JUDGE
        //freopen("input.txt","r",stdin);
        //freopen("output.txt","w",stdout);
        #endif
        ll t=1;
        //cin>>t;
        while(t--) solve();
    }
    

/*
9 1
1 1 1 3 5 3 5 7
1 5
*/


Measured memory_bytes: 25584
#ライブラリインポート
from collections import defaultdict
import copy

#入力受け取り
def getlist():
	return list(map(int, input().split()))

INF = 10 ** 9 + 7

#処理内容
def main():
	H, W, K = getlist()
	A = [0] * W
	A[0] = 1
	if W == 1:
		print(1)
	else:		
		for i in range(H):
			B = [0] * W
			for j in range(1 << (W - 1)):
				output = [0] * (W - 1)
				for k in range(W - 1):
					if ((j >> k) & 1) == 1:
						output[k] = 1
				judge = "Yes"
				for k in range(W - 2):
					if output[k] == 1 and output[k + 1] == 1:
						judge = "No"
				if judge == "Yes":
					if output[0] == 1:
						B[0] += A[1]
					else:
						B[0] += A[0]
					for k in range(1, W - 1):
						if output[k - 1] == 1:
							B[k] += A[k - 1]
						elif output[k] == 1:
							B[k] += A[k + 1]
						else:
							B[k] += A[k]
					if output[W - 2] == 1:
						B[W - 1] += A[W - 2]
					else:
						B[W - 1] += A[W - 1]

			for i in range(W):
				B[i] %= INF
			A = copy.deepcopy(B)
		print(A[K - 1] % INF)
	
if __name__ == '__main__':
	main()

Measured memory_bytes: 43888
#include<bits/stdc++.h>
using namespace std;
long long n,a[100002],z,zs;//z是出现奇数次，还是偶数次，zs是留下了多少个数
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
      cin>>a[i];
    sort(a+1,a+n+1);//输入排序不解释
    z=1;//初值定1，方便以后运算
    for(int i=2;i<=n;i++)//因为和前一个比较，所以从2开始。
    {
        if(a[i]==a[i-1])z=(z+1)%2;//相等则加一个，看看是奇数次，还是偶数次，奇数次就还有，偶数次就没有。
        else zs+=z,z=1;//否则加上它，赋值为1。
    }
    if(z%2)zs++;//最后一次特判
    cout<<zs<<endl;//输出答案
    return 0;
}

Measured memory_bytes: 1024
import re

s = str(input())
flag = True

s_array = s.split('hi')
    
for list in s_array:
    res = re.match('[a-z0-9]', list)
    
    if res and len(res.group()) > 0 :
        flag = False
        break
            
if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3188
fun main(args: Array<String>) {
  val N = readInt()
  val abList = (2..N).map { readInts() }
  val graph = Graph(N)
  abList.forEach { graph.addEdge(it[0], it[1]) }
  val resultMap = mutableMapOf<Pair<Int, Int>, Int>()

  var maxNum = 0

  fun search(i: Int, from: Int, fromNum: Int) {
    val edgeSet = graph.getNode(i).edgeList
    var num = 1
    edgeSet.forEach { j ->
      if (j == from) return@forEach
      val a = Math.min(i, j)
      val b = Math.max(i, j)
      if (num == fromNum) num++
      resultMap[a to b] = num
      search(j, i, num)
      if (maxNum < num) maxNum = num
      num++
    }
  }
  search(1, 0, 0)
  println(maxNum)
  abList.forEach {
    println(resultMap[it[0] to it[1]])
  }
}

fun readString() = readLine()!!
fun readStrings() = readString().split(' ')
fun readInt() = readString().toInt()
fun readInts() = readStrings().map { it.toInt() }


class Node {
  //  val edgeSet = mutableSetOf<Int>()
  val edgeList = mutableListOf<Int>()
}

class Graph(nodeSize: Int) {
  private val nodeArray = Array(nodeSize) { Node() }
  fun getNode(id: Int) = nodeArray[id - 1]
  fun addEdge(a: Int, b: Int) {
    getNode(a).edgeList.add(b)
    getNode(b).edgeList.add(a)
  }
}


Measured memory_bytes: 111952
import java.util.Arrays;
import java.util.Scanner;

//0631
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), m = sc.nextInt(), l[] = new int[m], a = 0;
        for (int i = 0; i < m; i++) {
            l[i] = n - sc.nextInt();
            sc.nextInt();
            a += l[i] > 0 ? l[i] : 0;
        }
        Arrays.sort(l);
        System.out.println(a - l[m - 1]);
    }
}



Measured memory_bytes: 32696
open System
               
let N,M = 
    let t = Console.ReadLine().Split()
            |> Array.map(int64)
    t.[0],t.[1]

match N,M with
| 1L,1L -> 1L
| 1L,_  -> M - 2L
| _ ,1L -> N - 2L
| _     -> (N - 2L) * (M - 2L) 
|> printfn "%i"

Measured memory_bytes: 13916
N = int(input())
A = list(map(int, input().split()))
mighty = 0
s = set()
for x in A:
    if x < 400:
        s.add('gray')
    elif x < 800:
        s.add('brown')
    elif x < 1200:
        s.add('green')
    elif x < 1600:
        s.add('water')
    elif x < 2000:
        s.add('blue')
    elif x < 2400:
        s.add('yellow')
    elif x < 2800:
        s.add('orange')
    elif x < 3200:
        s.add('red')
    else:
        mighty += 1
answer = max(1, len(s))
answer_max = answer + mighty
answer_max = min(answer_max, N)
print(answer, answer_max)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
	int i,n,s=0,need,one;
	need=1;
	one=0;
	cin>>n;
	int a[n];
	for(i=0;i<n;i++)cin>>a[i];
	for(i=0;i<n;i++){
		if(a[i]==1)one++;
	}
	if(one==0){
		cout<<"-1";
		return 0;
	}
	for(i=0;i<n;i++){
		if(a[i]!=need)s++;
		else need++;
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

main(){
	int n,R,min,max,i;
	scanf("%d",&n);
	scanf("%d",&R);
	min=R;
	scanf("%d",&R);
	max=R-min;
	if(R<min)min=R;
	for(i=2;i<n;i++){
		scanf("%d",&R);
		if(R-min>max)max=R-min;
		if(R<min)min=R;
		
	}
	printf("%d\n",max);
	return 0;		
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
int n,m,inf,ii,ic,ip,i,j,e,mx,nxt,res,a[200200],b[200200],k[200200],f[2][200200];
long long cur;
bool cmp(int i, int j) {
  if (a[i]==0) {
    if (a[j]==0) return b[i]<b[j];
    return false;
  }
  if (a[j]==0) return true;
  return a[i]*(b[j]+1LL)>a[j]*(b[i]+1LL);
}
int main() {
  scanf("%d%d",&n,&m);
  for (i=0; i<n; i++) {
    scanf("%d%d",&a[i],&b[i]);
    k[i]=i;
  }
  sort(k,k+n,cmp);
  memset(f,120,sizeof(f));
  inf=f[0][0]; f[0][0]=0;
  for (ii=0; ii<n; ii++, mx=nxt) {
    ip=ii&1; ic=1-ip; i=k[ii]; nxt=mx;
    if (a[i]==0) break;
    for (j=0; j<=mx; j++) if (f[ip][j]<inf) {
      if (f[ip][j]<f[ic][j]) f[ic][j]=f[ip][j];
      cur=(f[ip][j]+1LL)*(a[i]+1LL)+b[i];
      if (cur<=m && cur<f[ic][j+1]) {
        f[ic][j+1]=cur;
        nxt=max(nxt,j+1);
      }
      f[ip][j]=inf;
    }
  }
  res=mx;
  for (j=0; j<=mx; j++) if (f[ip][j]<inf) {
    cur=f[ip][j];
    for (e=ii; e<n; e++) {
      i=k[e];
      cur=(cur+1LL)*(a[i]+1LL)+b[i];
      if (cur>m) break;
    }
    res=max(res,e-ii+j);
  }
  printf("%d\n",res);
  return 0;
}


Measured memory_bytes: 4096
// Template {{{
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
using namespace std;
typedef long long LL;

#ifdef LOCAL
#include "contest.h"
#else
#define dump(x) 
#endif

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
inline bool valid(int x, int w) { return 0 <= x && x < w; }

void iostream_init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.setf(ios::fixed);
    cout.precision(12);
}
//}}}

int main(){
    iostream_init();
    int N, T;
    cin >> N >> T;
    vector<int> A(N);
    REP(i, N) cin >> A[i];

    vector<int> min_As(N);
    vector<int> min_indexs(N);
    int min_A = INT_MAX;
    int min_index = -1;
    int max_diff = INT_MIN;
    REP(i, N) {
        if(min_A > A[i]) {
            min_A = A[i];
            min_index = i;
        }
        min_As[i] = min_A;
        min_indexs[i] = min_index;
        max_diff = max(max_diff, A[i] - min_A);
    }

    vector<bool> used(N);
    REP(i, N) {
        if(A[i] - min_As[i] == max_diff) {
            used[min_indexs[i]] = true;
        }
    }

    int ans = 0;
    REP(i, N) ans += used[i];
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>
#include <math.h>

int main(void)
{
	double a;
	double sum;
	int i;
	
	while (scanf("%lf", &a) != EOF){
		sum = 0;
		sum += a;
		
		for (i = 2; i <= 10; i++){
			if (i % 2 == 0){
				a *= 2;
				sum += a;
			}
			else {
				a /= 3;
				sum += a;
			}
		}
		printf("%.8f\n", sum);
	}
	
	return (0);
}

Measured memory_bytes: 0