akhauriyash/Code-Regression huggingface dataset:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from math import sqrt, ceil, log10
def main():
    n = int(input())
    sqrtn = ceil(sqrt(n))
    r = n
    for i1 in range(1, sqrtn + 1):
        if n % i1 == 0:
            t1 = log10(i1)
            t2 = log10(n//i1)
            t = max(t1, t2) + 1
            r = min(r, t)
    print(int(r))

if __name__ == '__main__':
    main()


Measured memory_bytes: 9260
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
const int inf=1000000007;
const int MOD=1000000007;
const int rest=MOD;
long myPow(long x, long n, long m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}
long kaijo(int a){
  long ans;
  ans=a;
  if(a==0) return 1;
  else{
  for(int i=1;i<a;i++){
    ans=ans*i;
    ans=ans%rest;
  }
  }
  return ans;
}
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int k2(int n,int k){
  int res=1;
  for(int i=n;i>n-k;i--){
    res*=i;
    res%=MOD;
  }
  return res;
}
signed main(){
  int n,a,b;cin>>n>>a>>b;
  int res=myPow(2,n,MOD)-1;
  int ka=k2(n,a)*modinv(kaijo(a),MOD)%MOD;
  //ka*=myPow(2,a,MOD);
  ka%=MOD;
  int kb=k2(n,b)*modinv(kaijo(b),MOD)%MOD;
  //kb*=myPow(2,b,MOD);
  kb%=MOD;
  res+=2*MOD-ka-kb;
  res%=MOD;
  cout<<res<<endl;
  //cout<<k2(5,2)<<endl;
  return 0;
}


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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 5e5 + 10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}


vector<int> g[N];
bool viss[N];
int vis[N];

// Normal DFS
void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

// DFS with visiting status
void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

// DFS with strongly connected component
void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0 || vis[x] > (num+1))
      dfs2(x, curr, num+1);
}

// XOR from 0 to n
ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

// Power in logn with mod 1000000007
llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}

// Factorial with dp
llt factdp[N];
llt fact(llt x)
{
  if(x == 0) return 1;
  if(x == 1) return 1;
  if(factdp[x] != 0) return factdp[x];
  return factdp[x] = (x*fact(x-1))%M;
}
// Combination
ll modcomb(ll n, ll r)
{
  if(n < r) return 0;
  ll res = fact(n);
  (res *= ppow(fact(r), M-2)) %= M;
  (res *= ppow(fact(n-r), M-2)) %= M;
  return res;
}

// String return to base b
string ansConv ="";
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ansConv += to_string(x);
     return;
}

// Convert string to num wiht base b
llt convertstrtob(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}

// Union Find
// Find()
int parent[N], ran[N];
int find(int x)
{
    if(parent[x]==x)return x;
    else return parent[x]=find(parent[x]);
}
// Union()
void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y)return;

    if(ran[x]<ran[y])
        parent[x]=y;
    else{
        parent[y]=x;
        if(ran[x]==ran[y])ran[x]++;
    }
}

// Main Code

int main()
{
  int a, b, c, d;
  cin>>a>>b>>c>>d;
  if(a > c)
  {
    swap(a, c);
    swap(b, d);
  }
  if(a <= c)
  {
    if(b < c)
    cout<<"0"<<endl;
    else
    {
      b = min(b, d);
      cout<<(b-c)<<endl;
    }
  }
  return 0;
}


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

int main(){
    int N;  cin >> N;
    vector<ll> a(N);
    for(int i=0; i<N; i++)  cin >> a[i];

    ll ans = 0;
    for(int i=0; i<N; i++){
        ans += a[i]/2;
        a[i] = a[i]%2;
        if(i<N-1 && a[i]==1 && a[i+1]>0){
            ans++;
            a[i]--;
            a[i+1]--;
        }
    }
    cout << ans << endl;
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 110;


int n, k;
int g[maxn][maxn];

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

    cin>>n>>k;

    int x = n-1;
    if (k > x*(x-1)/2) out(-1);

    for (int i=1; i<n; i++) {
	g[0][i]=1;
    }

    x = (x)*(x-1)/2;

    for (int i=1; i<n && x>k; i++) {
	for (int j=i+1; j<n && x>k; j++) {
	    assert(g[i][j]==0);
	    g[i][j]=1;
	    x--;
	}
    }

    int m = 0;
    for (int i=0; i<n; i++) {
	for (int j=i+1; j<n; j++) {
	    m += g[i][j];
	}
    }


    cout<<m<<endl;
    for (int i=0; i<n; i++) {
	for (int j=i+1; j<n; j++) {
	    if (g[i][j]) {
		cout<<i+1<<" "<<j+1<<"\n";
	    }
	}
    }

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
const ll mol = 1e9 + 7;
const int maxn = 2e5;
 
int a[maxn + 11],b[maxn + 11];
 
int main() {
	int k,n;
	scanf("%d %d",&n,&k);
	int ca = 0 , cb = 0;
	for (int i = 1; i <= n; i++) {
		int x;
		scanf("%d",&x);
		if (x >= 0) a[++ca] = x;
		else b[++cb] = -x;
	}
	sort(a + 1 , a + 1 + ca , [&](int x,int y) { return x > y; });
	sort(b + 1 , b + 1 + cb , [&](int x,int y) { return x > y; });
	if (ca == 0) {
		ll ans = 1;
		if (k % 2 == 1) {
			for (int i = cb; i >= cb - k + 1; i--)
				ans = ans * b[i] % mol;
			ans = mol - ans;
		}
		else {
			for (int i = 1; i <= k; i++)
				ans = ans * b[i] % mol;
		}
		printf("%lld\n" , ans);
		return 0;
	}
	if (n == k) {
		ll ans = 1;
		for (int i = 1; i <= ca; i++)
			ans = ans * a[i] % mol;
		for (int i = 1; i <= cb; i++)
			ans = ans * b[i] % mol;
		if (cb & 1) ans = mol - ans;
		printf("%lld\n" , ans);
		return 0;
	}
	int u,d;
	if (ca >= k) { u = k; d = 0; }
	else if ((k - ca) % 2 == 0) {
		u = ca; d = k - ca;
	}
	else {
		u = ca - 1; d = k - ca + 1;
	}
	while (1) {
		if (u < 2 || d + 2 > cb) break;
		if (1ll * a[u] * a[u - 1] > 1ll * b[d + 1] * b[d + 2]) break;
		u -= 2; d += 2;
	} 
	ll ans = 1;
	for (int i = 1; i <= u; i++) ans = ans * a[i] % mol;
	for (int i = 1; i <= d; i++) ans = ans * b[i] % mol;
	printf("%lld\n" , ans);
} 

Measured memory_bytes: 4604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
int main()
{
    int n, u, v;
    cin >> n >> u >> v;
    u--;v--;
    vector<vector<int>> d(n);
    for(int i = 0; i < n-1; i++)
    {
        int a, b;
        cin >> a >> b;
        a--;b--;
        d[a].push_back(b);
        d[b].push_back(a);
    }
    if(d[u].size() == 1 && d[u][0] == v)
    {
       cout << 0 << endl;
       return 0;
    }
    queue<P> que;
    que.push(P(u, 1));
    que.push(P(v, -1));
    vector<int> seen(n);
    seen[u] = 1;
    seen[v] = -1;
    bool flag = false;
    int pos = 0;
    bool flag2 = false;
    while(!flag)
    {
        P p = que.front();
        que.pop();
        int v = p.first;
        for(int nx : d[v])
        {
            if(seen[nx] == 0)
            {
                seen[nx] = p.second;
                que.push(P(nx, seen[nx]));
            }
            else if(seen[nx] == p.second)
            {
            }
            else if(p.second == 1)
            {
                // can access v
                pos = v;
                flag = true;
                break;
            }
            else if(p.second == -1)
            {
                // cannot access nx
                // only one nx
                seen[nx] = -1;
                for(int j : d[nx])
                {
                    if(seen[j] == 1)
                    {
                        pos = j;
                        flag = true;
                        flag2 = true;
                    }
                    if(flag) break;
                }
            }
            if(flag) break;
        }
    }
    if(pos == u)
    {
        cout << 1 << endl;
        return 0;
    }
    vector<ll> dis(n);
    function<void(int, int)> dfs = [&](int before, int now)
    {
        for(int nx : d[now])
        {
            if(nx == before) continue;
            dis[nx] = dis[now] + 1;
            dfs(now, nx);
        }
    };
    for(int nx : d[pos])
    {
        if(seen[nx] == -1) continue;
        dis[nx] = 1;
        dfs(pos, nx);
    }
    ll ma = 0;
    for(int i = 0; i < n; i++)
    {
        ma = max(ma, dis[i]);
    }
    cout << dis[u] + ma  + flag2<< endl;
}


Measured memory_bytes: 12672
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const double EPS = 1e-10;
const int INF = 2147483647;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

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

	int n = s.size();

	cout << s.substr(0, n - 8);


	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
 
typedef unsigned long long ull;
const ull p=1000000007;
string S,T;
 
signed main(){
    ull power[26];
    power[0]=1;
    for(int i=1;i<26;i++)power[i]=power[i-1]*p;
 
    cin>>S>>T;
    vector<ull>hs;
    for(int i=min(S.size(),T.size());i>0;i--){
        ull h=0;
        hs.clear();
        for(int j=0;j+1<i;j++){
            h+=power[T[j]-'a'];
        }
        for(int j=i-1;j<T.size();j++){
            h+=power[T[j]-'a'];
            hs.pb(h);
            h-=power[T[j-i+1]-'a'];
        }
 
        sort(all(hs));
 
        h=0;
        for(int j=0;j+1<i;j++){
            h+=power[S[j]-'a'];
        }
        for(int j=i-1;j<S.size();j++){
            h+=power[S[j]-'a'];
            if(binary_search(all(hs),h)){
                cout<<i<<endl;
                return 0;
            }
            h-=power[S[j-i+1]-'a'];
        }
    }
    cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 3196
// AOJ 1528: Warping Girl
// 2019.2.21 bal4u

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

// Hash Functions
#define HASHSIZ 4999
typedef struct { int key; int id; } HASH;
HASH hash[HASHSIZ + 5], *hashend = hash + HASHSIZ;

int lookup(int key)
{
	HASH *p = hash + ++key % HASHSIZ;
	while (p->key) {
		if (p->key == key) return p->id;
		if (++p == hashend) p = hash;
	}
	return -1;
}

void insert(int key, int id)
{
	HASH *p = hash + ++key % HASHSIZ;
	while (p->key) {
		if (p->key == key) return;
		if (++p == hashend) p = hash;
	}
	p->key = key, p->id = id;
}

#define gc() getchar()
int in()
{
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

typedef struct { int P, D, T; int tm;  char f; } T;
T tbl[2005];

int cmp(const void *a, const void *b)
{
	return ((T *)a)->P - ((T *)b)->P;
}

int main()
{
	int i, j, ii, L, n;
	int id, now, tim, min;

	L = in(), n = in();
	for (i = 0; n--; ) {
		tbl[i].P = in(), tbl[i].D = in(), tbl[i].T = in();
		if (tbl[i].D == 0) continue;
		tbl[i].f = 1, tbl[i].tm = L;
		tbl[i + 1].P = tbl[i].P + tbl[i].D, tbl[i + 1].tm = L;
		i += 2;
	}
	n = i;
	qsort(tbl, n, sizeof(T), cmp);
	for (i = 0; i < n; i++) {
		if (tbl[i].f == 0) insert(tbl[i].P, i);
	}

	now = tim = 0;
	for (i = 0; i < n; ) {
		min = tbl[i].tm;
		for (j = i+1; tbl[j].P == tbl[i].P; j++) {
			if (tbl[j].tm < min) min = tbl[j].tm;
		}
		if (min > tbl[i].P - now + tim) min = tbl[i].P - now + tim;
		now = tbl[i].P, tim = min;
		ii = j;

		for (j = i; j < ii; j++) {
			if (tbl[j].f) {
				id = lookup(tbl[j].P + tbl[j].D);
				if (tbl[id].tm > tim + tbl[j].T) tbl[id].tm = tim + tbl[j].T;
			}
		}
		i = ii;
	}
	printf("%d\n", L - now + tim);
	return 0;
}


Measured memory_bytes: 2064
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

#define YES(n) cout << (n?"YES":"NO")<<endl;
#define Yes(n) cout << (n?"Yes":"No")<<endl;

int main() {
    int N, A;
    cin >> N >> A;
    Yes(N % 500 <= A);
}

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

using namespace std;

int main(){

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

	sort(a,a+n);
	cout<<a[n/2]-a[n/2-1]<<'\n';
	return 0;

}


Measured memory_bytes: 3988
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

const ll MOD = 1000000007LL;
const double PI = 3.14159265358979323846;

//conversion
//------------------------------------------
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

//main function
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	ll M;
	cin >> M;

	ll res = -1;
	ll sum = 0;
	ll d, c;
	for (ll i = 0; i < M; ++i) {
		cin >> d >> c;
		sum += d * c;
		res += c;
	}

	res += (sum - 1) / 9;

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
/*
 _  __    _   _   _ ____ _____ 
| |/ /   / \ | | | / ___|_   _|
| ' /   / _ \| | | \___ \ | |  
| . \  / ___ \ |_| |___) || |  
|_|\_\/_/   \_\___/|____/ |_|  
*/
#include <bits/stdc++.h>
#define rep(i, a, b) for (long long i = (a); i < (b); i++)
#define per(i, a, b) for (long long i = (a); i > (b); i--)
#define a(x) (x.begin(), x.end())
#define ar(x) (x.rbegin(), x.rend())
#define pb push_back
#define Pb() pop_back()
#define ll long long int
#define ull unsigned long long int
#define pii pair<int, int>
#define pll pair<ll, ll>
#define sc scanf
#define scin(x) sc("%d", &(x))
#define scln(x) sc("%lld", &(x))
#define pf prllf
#define ms(a, b) memset(a, b, sizeof(a))
#define mp make_pair
#define db double
#define EPS 10E-10
#define ff first
#define ss second
#define sqr(x) (x) * (x)
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int>>
#define vll vector<vector<ll>>
#define DBG pf("HI\n")
#define MOD 1000000007
#define CIN                       \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define RUN_CASE(t, T) for (__typeof(t) t = 1; t <= T; t++)
#define CASE(t) prllf("Case %d: ", t)
#define CASEL(t) prllf("Case %d:\n", t)
#define intlimit 2147483647
#define longlimit 9223372036854775807
#define infinity (1 << 28)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a) * (b) / gcd(a, b))
#define PI 2 * acos(0.0)
using namespace std;
int main()
{
    CIN;
    int n,m;
    cin >> n >> m;
    cout << ceil((double)n/(2*m+1));
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MON 1000000007
#define INF (1<<29)
typedef long long Int;
typedef pair<Int, Int> P;

#define max(x, y) ((x)>(y)?(x):(y))
#define min(x, y) ((x)<(y)?(x):(y))


class Edge{
public:
  int from, to, rev;
  Int cost, lim;
  Edge(int from, int to, Int cost, int lim = -1, Int rev = -1):
    from(from),to(to),cost(cost),lim(lim),rev(rev){}
};


class Graph{
public:
  int n;
  int m;
  vector<vector<Edge>> edge;
  Graph(int n = 0):n(n),m(0){
    edge = vector<vector<Edge>>(n);
  }
  void add_edge(int from, int to, int cost = 1, int lim = -1)
  {
    if(lim == -1){
      edge[from].push_back(Edge(from, to, cost));
      return;
    }
    edge[from].push_back(Edge(from, to, cost, lim, edge[to].size()));
    edge[to].push_back(Edge(to, from, -cost, 0, edge[from].size() - 1));
  }
};


class Dinic{
public:
  Graph *g;
  vector<int> iter, level, come;

  Dinic(){};
  void bfs(int s){
    queue<int> q;
    fill(level.begin(), level.end(), INF);
    level[s] = 0;
    q.push(s);
    while(!q.empty()){
      int x = q.front();q.pop();
      for(auto e:g->edge[x]){
	if(level[e.to] != INF)continue;
	if(e.lim <= 0)continue;
	level[e.to] = level[x] + 1;
	q.push(e.to);
      }
    }
  }

  Int dfs(int s, int t, Int f){
    if(s == t)return f;
    if(come[s])return 0;
    come[s] = true;
    for(int &i = iter[s];i < g->edge[s].size();i++){
      Edge &e = g->edge[s][i];
      if(e.lim <= 0)continue;
      Int tmp = dfs(e.to, t, min(f, e.lim));
      if(tmp == 0)continue;
      e.lim -= tmp;
      g->edge[e.to][e.rev].lim += tmp;
      return tmp;
    }
    return 0;
  }
  Int max_flow(Graph &_g, int s, int t){
    g = &_g;
    iter = vector<int>(g->n);
    level = vector<int>(g->n);
    come = vector<int>(g->n, 0);
    Int res = 0;
    while(true){
      bfs(s);
      if(level[t] == INF)break;
      fill(iter.begin(), iter.end(), 0);
      while(true){
	fill(come.begin(), come.end(), false);
	Int tmp = dfs(s, t, INF);
	if(tmp == 0)break;
	else res += tmp;
      }
    }
    return res;   
  }  
};

int main(){
  int n1, n2, e, x, y;
  cin >> n1 >> n2 >> e;
  Graph g(n1+n2+2);
  int s = n1+n2, t = n1+n2+1;
  for(int i = 0;i < n1;i++)g.add_edge(s, i, 1, 1);
  for(int i = 0;i < n2;i++)g.add_edge(n1+i, t, 1, 1);
  for(int i = 0;i < e;i++){
    cin >> x >> y;
    g.add_edge(x, n1+y, 1, 1);
  }
  Dinic d;
  cout << d.max_flow(g, s, t) << endl;
  return 0;
}


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

#define all(x) (x).begin(),(x).end()

using namespace std;

int main(){
	int n;
	
	cin >> n;
	
	int a[n],b[n],c[n];
	int tmp[3];
	int ans[3];
	
	for(int i=0; i<n; i++)	cin >> a[i] >> b[i] >> c[i];
	
	ans[0]=a[0];
	ans[1]=b[0];
	ans[2]=c[0];
	for(int i=1; i<n; i++){
		tmp[0]=max(ans[1]+a[i],ans[2]+a[i]);
		tmp[1]=max(ans[0]+b[i],ans[2]+b[i]);
		tmp[2]=max(ans[0]+c[i],ans[1]+c[i]);
		
		ans[0]=tmp[0];
		ans[1]=tmp[1];
		ans[2]=tmp[2];
	}
	
	cout << max(max(ans[0],ans[1]),ans[2]) << endl;
	
	return 0;
}

Measured memory_bytes: 1408
import java.util.*;
import java.io.*;
public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));
		int n = Integer.parseInt(reader.readLine());
		long[] list = Arrays.stream(reader.readLine().split(" ")).mapToLong(Long::parseLong).toArray();
		long money = 1000;
		long stocks = 0;
		int i = 0;
		while(i<n){
			while(i+1<n && list[i]>=list[i+1]) i++;
			if(i==n-1 && stocks==0){
				System.out.println(money);
				return;
			}
			stocks += (money/list[i]);
			money -= (list[i]*(money/list[i]));
			while(i+1<n && list[i+1]>=list[i]) i++;
			if(i==n-1){
				money += stocks*list[i];
				stocks = 0;
				System.out.println(money);
				return;
			}
			money += (stocks*list[i]);
			stocks = 0;
			i++;
		}
		if(i==n-1) System.out.println(money);
	}
}

Measured memory_bytes: 34412
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

#define INF LLONG_MAX / 5
#define MOD 1000000007
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define enld endl


signed main() {
	int N;
	cin >> N;
	vector<string>S(N);
	rep(i, N) {
		cin >> S[i];
	}
	vector < vector<int>>AL(N, vector<int>(26));
	rep(i, N) {
		rep(j, S[i].size()) {
			AL[i][S[i][j] - 'a']++;
		}
	}
	
	vector<int>NUM(26);
	rep(j, 26) {
		int m = INF;
		rep(i, N) {
			m = min(m, AL[i][j]);
		}
		rep(_, m) {
			cout << char('a' + j);
		}
	}
	cout << endl;
}

Measured memory_bytes: 3080
//
// Created by yuu on 2019-08-04.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>

using namespace std;

int ANS[100010] ={};
int main(void){
    string S;
    cin>>S;

    int rihgt_count = 0;
    for (int i = 0; i < S.length(); ++i) {
        if(S[i]=='R'){
            rihgt_count++;
        }else{
            if(rihgt_count>0){
                if(rihgt_count%2==0){
                    ANS[i-1] += rihgt_count/2;
                    ANS[i] += rihgt_count/2;
                }else{
                    ANS[i-1] += rihgt_count/2 +1;
                    ANS[i] += rihgt_count/2;
                }
                rihgt_count = 0;
            }
        }
    }

    int left_count;
    for (int i = S.length()-1; i >=0; --i) {
        if(S[i]=='L'){
            left_count++;
        }else{
            if(left_count>0){
                if(left_count%2==0){
                    ANS[i+1] += left_count/2;
                    ANS[i] += left_count/2;
                }else{
                    ANS[i+1] += left_count/2 +1;
                    ANS[i] += left_count/2;
                }
                left_count = 0;
            }
        }
    }

    for (int i = 0; i < S.length(); ++i) {
        if(i==0){
            cout<<ANS[i];
        }else{
            cout<<" "<<ANS[i];
        }
    }

    cout<<endl;



    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void){
    char str[101];

    int i;

    scanf("%s",&str);
    
    for(i=0; i<=100; i++){
      if(i%2==1 && str[i]=='R' ){
          printf("No");
          break;
      }else if(i%2==0 && str[i]=='L'){
          printf("No");
          break;
      }else if(str[i]=='\0'){
          printf("Yes");
          break;
      }
    }

    return 0;
}

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

int main(void){

    int H, W;

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

    char s[H][W+1];

    for(int i = 0; i < H; i++){
        scanf("%s", s[i]);
    }

    int c[H][W];

    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            c[i][j] = 1000000;
        }
    }

    c[0][0] = 1;

    int r = 1;

    while(1){
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                if(c[i][j] == r){
                    if(i > 0 && s[i-1][j] == '.' && c[i-1][j] == 1000000){
                        c[i-1][j] = r+1;
                    }
                    if(j > 0 && s[i][j-1] == '.' && c[i][j-1] == 1000000){
                        c[i][j-1] = r+1;
                    }
                    if(i < H-1 && s[i+1][j] == '.' && c[i+1][j] == 1000000){
                        c[i+1][j] = r+1;
                    }
                    if(j < W-1 && s[i][j+1] == '.' && c[i][j+1] == 1000000){
                        c[i][j+1] = r+1;
                    }
                }
            }
        }
        r++;
        if(c[H-1][W-1] != 1000000 || r > H * W){
            break;
        }
    }

    int b = 0;

    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(s[i][j] == '#'){
                b++;
            }
        }
    }

    if(c[H-1][W-1] == 1000000){
        printf("-1\n");
    }else{
        printf("%d\n", H * W - b - c[H-1][W-1]);
    }

    return 0;
}

Measured memory_bytes: 1700
/*
**   Contest : Educational DP Contest
**   Problem : D - Knapsack 1
**
**    Author : Dhiraj Govindvira
**      Date : 05-Jun-2020 ~ Friday
**      Time : 02:59:49 PM
*/

#if __has_include("D:/dhiraj/Programming/debug.h")
    #include "D:/dhiraj/Programming/debug.h"
#else
    #include <bits/stdc++.h>
    using namespace std;
    #define d(...) 11
    #define cerr if(0) cerr
#endif

// Macro --------------------------------------------------------------------

#define ll                  long long int
#define loop(i,s,e)         for(ll i=(s); i<(e); i++)
#define rloop(i,s,e)        for(ll i=(s); i>=(e); i--)
#define iter(it,var)        for(auto it=var.begin(); it!=var.end(); it++)
#define riter(it,var)       for(auto it=var.rbegin(); it!=var.rend(); it++)
#define all(x)              x.begin(),x.end()
#define rall(x)             x.rbegin(),x.rend()
#define endl                '\n'

// Template -----------------------------------------------------------------

// multiple input
template <typename T> 
inline void inp(T &any) {
    cin >> any;
}
template <typename T, typename... U> 
inline void inp(T &a, U &...b) {
    cin >> a; inp(b...);
}
// scan vector
template <typename T> 
inline istream &operator>>(istream &in, vector<T> &a) {
    for(auto &x : a) in >> x;
    return in;
}
// scan pair
template <typename T, typename U> 
inline istream &operator>>(istream &in, pair<T,U> &a) {
    in >> a.first >> a.second; 
    return in;
}

// Solve --------------------------------------------------------------------

void solve(ll &T)
{
    ll n, w;
    cin>>n>>w;

    vector<pair<ll,ll>> ks(n);
    cin>>ks;

    vector<ll> dp(w+1);
    for(ll i=1; i<=n; i++)
    {
        ll W = ks[i-1].first;
        ll V = ks[i-1].second;

        for(ll j=w; j>=0; j--)
        {
            if(j >= W) {
                dp[j] = max(dp[j], dp[j-W] + V);
            }
        }
    }
    cout<<*max_element(all(dp))<<endl;
}

// Main ---------------------------------------------------------------------

int main()
{
    #ifdef Dhiraj
        freopen("D:/dhiraj/Programming/i1.txt","r",stdin);
        freopen("D:/dhiraj/Programming/o1.txt","w",stdout);
    #endif

    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    loop(Case,1,t+1)
    {
        cerr<<"Case #"<<Case<<'\n';
        solve(Case);
    }
    return 0;
}

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

int main(){
	int m[10];
	
	for(int i = 0;i < 10;i++){
		cin >> m[i];
		
		while(!((m[i] >= 0)&&(m[i] <= 10000))){
			cout << "wrong value\n";
			cin >> m[i];
		}
	}
	sort(m, m+10,greater<int>());
	
	for(int i = 0;i < 3;i++){
		cout << m[i] << "\n";
	}
	
    return 0;
}

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

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

int main(){
    ll A, B;
    string b;
    cin >> A >> b;
    B = 100*(b[0] - '0') + 10*(b[2] - '0') + (b[3] - '0');
    ll ans = A * B;
    ans /= 100;
    cout << ans << endl;
    return 0;
}

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


int main() {
    int N;
    cin >> N;
    vector<string> s(N);
    for(int i=0; i<N; ++i) {
        cin >> s[i];
    }
    int M;
    cin >>M;
    vector<string> t(M);
    for(int i=0; i<M; ++i) {
        cin >> t[i];
    }
    vector<int> c(N, 1);
    for(int i = 0; i<N; ++i) {
        for(int j = i+1; j<N; ++j) {
            if (s[i] == s[j]) {
                ++c[i];
            }
        }
    }
    for(int i = 0; i<N; ++i) {
        for(int j = 0; j<M; ++j) {
            if (s[i] == t[j]) {
                --c[i];
            }
        }
    }
    int ccc=0;
    for(int i = 0; i < N; ++i) {
        if(ccc<c[i]) {
            ccc = c[i];
        }
    }
    cout << ccc << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int N,M,X;
    scanf("%d %d %d",&N,&M,&X);
    int A[M+1];
    for(int i=1;i<=M;i++){
        scanf("%d",&A[i]);
    }
    int j = 1;
    while(A[j]<X){
        j++;
    }
    j--;
    if(j<M-j){
        printf("%d",j);
    }else{
        printf("%d",M-j);
    }
    return 0;
}

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

int main() {
    ll a , b , c;
    cin >> a >> b >> c;
    ll d = c - a - b;
    if(d > 0 && d * d > 4 * a * b){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
//################################################################
//################################################################
//####In the Name Of Allah,the Most Gracious,the Most Merciful.###
//######Created by Sazid Rahman  Simanto on 2/21/16.##############
//# Copyright © 2016 Sazid Rahman  Simanto. All rights reserved.##
//################################################################
//################################################################

#include<bits/stdc++.h>
using namespace std;
#define MSET(a,x) memset(a,x,sizeof a)
#define FOR(i,x,y) for(int i=(x);i<=(y);i++)
#define ROF(i,x,y) for(int i=(y);i>=(x);i—-)
#define SQ(x) ((x)*(x))
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define ff first
#define ss second
#define pb push_back
#define inf 1061109567
#define maxn 100001
#define esp 1e-8

typedef pair<int,int>ii;
typedef long long ll;
typedef vector<ii>vii;
typedef vector<int>vi;

int gcd(int a,int b){
    if(b==0) return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a*(b/gcd(a,b));

}

int posMod(int a,int m)
{
	return ((a%m)+m)%m;
}

int Set(int N,int pos){return N=N | (1<<pos);}
int reset(int N,int pos){return N= N & ~(1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}

//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

//################################################################
//##    Template Ends Here……                        			##
//################################################################


int main()
{
	//std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //freopen("output.txt", "w", stdout);
	int n,a,b;
    cin>>n>>a>>b;
    int count=n;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        if(x>=a && x<b) count--;
    }
    cout<<count<<endl;

    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
n, q = map(int, input().split())

trees = [ [] for i in range(n+1) ]
for i in range(n-1):
    a, b = map(int, input().split())
    trees[a].append(b)
    trees[b].append(a)

values = [0] * (n+1)
for i in range(q):
    p, x = map(int, input().split())
    values[p] += x
#print(values)

def dfs2(i, parent):
    for j in trees[i]:
        if j == parent: continue
        values[j] += values[i]
        dfs2(j, i)

dfs2(1, -1)
print(*values[1:])

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

//C++14 (GCC 5.4.1)

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

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

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

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}

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

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

    vector<int> im(N+1,0),cans(N);
    rep(i,M){
        cin >> l>>r;
        im[l-1]++;
        im[r]--;
    }
    cans[0]=im[0];
    repd(i,1,N){
        cans[i]=cans[i-1]+im[i];
        //cout<<cans[i]<<endl;
    }
    ll ans=0;
    rep(i,N){
        if(cans[i]==M)ans++;
    }
    cout << ans <<endl;
    return (0);
}

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

#define endl '\n'

int N, M, K;
int sx, sy;
char A[200005], B[200005];

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

bool safe(int x, int y) {
    if(x && x <= N && y && y <= M) return 1;
    return 0;
}

bool solve(int dir, int opdir, char c1, char c2) {
    int x = sx, y = sy;
    for(int i=1; i<=K; i++) {
        if(A[i] == c1) {
            int nx = x + dx[dir], ny = y + dy[dir];
            if(!safe(nx, ny)) return 0;
            x = nx, y = ny;
        }
        if(B[i] == c2) {
            int nx = x + dx[opdir], ny = y + dy[opdir];
            if(safe(nx, ny)) x = nx, y = ny;
        }
    }
    return 1;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> N >> M >> K;
    cin >> sx >> sy;
    cin >> A+1 >> B+1;
    if(solve(1, 2, 'L', 'R') && solve(2, 1, 'R', 'L') && solve(3, 4, 'U', 'D') && solve(4, 3, 'D', 'U')) cout << "YES";
    else cout << "NO";
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>

using namespace std;

int n, varf;

int rez[300000];

int main()
{
    #ifdef ONLINE_JUDGE
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(0);
    #endif // ONLINDE_JUDGE

    cin >> n >> varf;
    n = (n << 1) - 1;

    if(varf == 1 || varf == n)
    {
        cout << "No\n";

        return 0;
    }

    cout << "Yes\n";

    if(varf == ((n + 1) >> 1))
    {
        for(int i = 1; i <= n; i ++)
            cout << i << "\n";

        return 0;
    }

    int near = varf + (varf > ((n + 1) >> 1) ? 1 : -1);

    int last = 0;
    int cnt = 0;
    for(int i = 1; cnt < (n >> 1) && i <= n; i ++)
    {
        if(i != varf && i != near)
        {
            cnt ++;
            cout << i << "\n";
        }

        last = i;
    }

    cout << near << "\n" << varf << "\n";

    int i;
    for(i = last + 1; i <= n; i ++)
    {
        if(i != varf && i != near)
            cout << i << "\n";
    }

    return 0;
}


Measured memory_bytes: 1536
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue> 
#include<stack>
#include<vector>
#include<cmath>
using namespace std;
struct node {
	int time;
	int x, y;
}a[100005];
int main()
{
	int n;
	bool bj = true;
	cin >> n;
	for(int i = 1; i <= n; i++)
		scanf("%d %d %d", &a[i].time, &a[i].x, &a[i].y);
	for(int i = 1; i <= n; i++)
		if((a[i].time - a[i - 1].time) - (abs(a[i].x - a[i - 1].x) + abs(a[i].y - a[i - 1].y)) < 0 || (abs((a[i].time - a[i - 1].time) - (abs(a[i].x - a[i - 1].x) + abs(a[i].y - a[i - 1].y)))) % 2 != 0) {
			bj = false;
			break;
		}
	if(bj == true)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 1408
// Best practice

#include<bits/stdc++.h>

#define int         long long
#define pb          push_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define pii 		pair<int,int>
#define psi 		pair<string,int>
#define vi 			vector<int>
#define vpii  		vector<pii>
#define vvi 		vector<vi>
#define sz(x)	    (int)(x).size()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007
#define hell        998244353
#define output(x)   cout << (x ? "YES" : "NO")<<endl;
using namespace std;


// Code from Here -------------------------------------------------------------------------------


signed main() {
	tezz

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int t;
	cin >> t;
	map<string,int> mp;
	while(t--){
		string s;
		cin >> s;
		mp[s]++;
	}
	cout << sz(mp);

	return 0;
}  


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

int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        string str1;
        string str2;
        cin >> str1 >> str2;
        int d = 1;
        int n1 = 0;
        for (const char c : str1) {
            if (c == 'm') {
                n1 += d * 1000;
                d = 1;
            } else if (c == 'c') {
                n1 += d * 100;
                d = 1;
            } else if (c == 'x') {
                n1 += d * 10;
                d = 1;
            } else if (c == 'i') {
                n1 += d * 1;
                d = 1;
            } else {
                d = c - '0';
            }
        }
        d = 1;
        int n2 = 0;
        for (const char c : str2) {
            if (c == 'm') {
                n2 += d * 1000;
                d = 1;
            } else if (c == 'c') {
                n2 += d * 100;
                d = 1;
            } else if (c == 'x') {
                n2 += d * 10;
                d = 1;
            } else if (c == 'i') {
                n2 += d * 1;
                d = 1;
            } else {
                d = c - '0';
            }
        }
        int n3 = n1 + n2;
        int num[4] = {1000, 100, 10, 1};
        char ch[4] = {'m', 'c', 'x', 'i'};
        for (int i = 0; i < 4; i++) {
            if (n3 >= num[i]) {
                int m = n3 / num[i];
                n3 = n3 % num[i];
                if (m == 1) {
                    cout << ch[i];
                } else {
                    cout << m << ch[i];
                }
            }
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 2968
package main

import (
	"fmt"
)

func main() {
	var N, M int
	fmt.Scanf("%d %d", &N, &M)
	H := make([]int, N)
	peaksCounter := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &H[i])
		peaksCounter[i] = 0
	}

	for i := 0; i < M; i++ {
		var a, b int
		fmt.Scanf("%d %d", &a, &b)
		if H[a-1] > H[b-1] {
			peaksCounter[b-1]++
		} else if H[a-1] < H[b-1] {
			peaksCounter[a-1]++
		} else {
			peaksCounter[b-1]++
			peaksCounter[a-1]++
		}
	}

	r := 0
	for _, count := range peaksCounter {
		if count == 0 {
			r++
		}
	}
	fmt.Println(r)
}


Measured memory_bytes: 6504
local msq = math.sqrt
local mma = math.max
local t = {}
for i = 1, 6 do t[i] = io.read("*n") end
local a = msq((t[1] -t[3]) * (t[1] - t[3]) + (t[2] -t[4]) * (t[2] - t[4]))
local b = msq((t[1] -t[5]) * (t[1] - t[5]) + (t[2] -t[6]) * (t[2] - t[6]))
local c = msq((t[5] -t[3]) * (t[5] - t[3]) + (t[6] -t[4]) * (t[6] - t[4]))
local S = 0
do
  local z = (a + b + c) / 2.0
  S = msq(z * (z - a) * (z - b) * (z - c))
end

local function check(r)
  local h1 = 2 * S / a
  if h1 <= r then return false end
  local rate1 = (h1 - r) / h1
  local a1, b1, c1 = a * rate1, b * rate1, c * rate1
  local S1 = S * rate1 * rate1
  local h2 = 2 * S1 / b1
  if h2 <= r then return false end
  local rate2 = (h2 - r) / h2
  local a2, b2, c2 = a1 * rate2, b1 * rate2, c1 * rate2
  local S2 = S1 * rate2 * rate2
  local h3 = 2 * S2 / c2
  if h3 <= r then return false end
  local rate3 = (h3 - r) / h3
  local a3, b3, c3 = a2 * rate3, b2 * rate3, c2 * rate3
  local v = mma(a3, mma(b3, c3))
  return 2 * r <= v
end

local min, max = 0, 2000.0
while(os.clock() < 1.5) do
  local mid = (min + max) / 2.0
  if check(mid) then
    min = mid
  else
    max = mid
  end
end
print(string.format("%.12f", min))


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

int main(){
    int n;
    cin >> n;
    map <string, ll> mp;
    rep(i,n){
        string s;
        cin >> s;
        mp[s] ++;
    }
    ll mx = 0;
    for (auto p : mp) mx = max(mx, p.second);
    for (auto p : mp){
        if (p.second != mx) continue;
        cout << p.first << endl;
    }
    return 0;
}

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

#define int ll

#define pb push_back
#define all(v) (v).begin(), (v).end() 
#define sz(v) (int)((v).size())
#define fs first
#define sd second

typedef long long ll;

typedef pair < int, int > pi;
typedef pair < pi, int > ppi;

typedef vector < int > vi;
typedef vector < vector < int > > vvi;
typedef vector < pi > vpi;
typedef vector < vpi > vvpi;
typedef vector < ppi > vppi;

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

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}

void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifdef LOCAL
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

double get_time() {
	return 1.0 * clock() / CLOCKS_PER_SEC;
}

const int MAX = 3E5 + 100, MOD = 1E9 + 7;
int fac[MAX], ifac[MAX];


ll binpow(ll base, ll e, ll mod) {
	ll ret = 1;
	while(e) {
		if(e & 1)
			ret  = ret * base % mod;
		base = base * base % mod;
		e >>= 1;
	}		
	return ret;
}

int32_t main() {
	fac[0] = ifac[0] = 1;
	for(int i = 1; i < MAX; i++) {
		fac[i] = (i * fac[i - 1]) % MOD;
		ifac[i] = (binpow(i, MOD - 2, MOD) * ifac[i - 1]) % MOD;
	}
	int t = 1;
	// /cin >> t;
	while(t--) {
		int h, w, n;
		cin >> h >> w >> n;
		vpi v;
		for(int i = 0; i < n; i++) {
			int x, y;
			cin >> x >> y;
			v.emplace_back(x, y);
		}
		auto get_ways = [&] (int x1, int y1, int x2, int y2) {
			int dx = abs(x2 - x1), dy = abs(y2 - y1);
			return (fac[dx + dy] * (ifac[dx] * ifac[dy] % MOD)) % MOD;
		};
		v.emplace_back(h, w);
		sort(all(v));
		vi ways(n + 1);
		for(int i = 0; i <= n; i++) {
			int x = v[i].fs, y = v[i].sd;
			ways[i] = get_ways(1, 1, x, y);
		}
		for(int i = 0; i < n; i++) {
			int x = v[i].fs, y = v[i].sd;
			for(int j = i + 1; j <= n; j++) {
				int xx = v[j].fs, yy = v[j].sd;
				if(xx < x || yy < y)
					continue;
				ways[j] = ((ways[j] - ways[i] * get_ways(x, y, xx, yy) % MOD) % MOD + MOD) % MOD;
			}
		}
		cout << ways[n] << '\n';
	}
}

Measured memory_bytes: 4992
from collections import Counter
N = int(input())
S = input()
BN = [0 for i in range(N)]
if S[0] == '.':
    BN[0] = 0
else:
    BN[0] = 1
for i in range(1, N):
    if S[i] == '.':
        BN[i] = BN[i-1]
        continue
    BN[i] = BN[i-1] + 1
ans = min(N-BN[-1], BN[-1])
for i in range(1,N):
    white = BN[i-1]
    black = N-i-(BN[-1]-BN[i-1])
    # print(N, i, BN[-1], BN[i-1])
    # print(white, black)
    ans = min(ans, white+black)
print(ans)


Measured memory_bytes: 11748
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <stdio.h>
#include <string.h>

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

using namespace std;

int main(){
    int data[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << data[k-1] << endl;
}

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

public class Main {
    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int n = fs.nextInt();
        Integer[] l = new Integer[n];
        for(int i=0; i<n; i++) {
            l[i] = fs.nextInt();
        }

        Arrays.sort(l,Comparator.reverseOrder());

        int cnt = 0;
        for(int i=0; i<n-2; i++) {
            for(int j=i+1; j<n-1; j++) {
                for(int k=j+1; k<n; k++) {
                    if(l[k]>l[i]-l[j]) cnt++;
                    else break;
                }
            }
        }
        System.out.println(cnt);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
 
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
 
    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }
 
    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }
 
    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }
 
    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
 
    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
 
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }
 
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

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

using namespace std;
typedef long long llong;

#define MAX 11
const llong mod = 1000000000 + 7;

int main()
{
  int len = 0;
  char S[MAX], T[MAX + 1];
  scanf("%s", S);
  scanf("%s", T);

  len = strlen(S);
  for (int i = 0; i < len; i++)
  {
    if (S[i] != T[i])
    {
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");

  return 0;
}

Measured memory_bytes: 1640