akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template<class Monoid> struct SegmentTree {
private:
    using Func = std::function<Monoid(Monoid, Monoid)>;
    Func F;
    Monoid UNITY;
    int n;
    std::vector<Monoid> node;
public:
    SegmentTree() {}

    //m=size, f=[](M a,M b){return ;}
    // size : m
    SegmentTree(int m, const Func f, const Monoid &unity) {
        build(m, f, unity);
    }

    SegmentTree(const std::vector<Monoid>& v, const Func f, const Monoid &unity) {
        build(v, f, unity);
    }

    void build(int m, const Func f, const Monoid &unity) {
        F = f;
        UNITY = unity;
        n = 1; while (n < m) n <<= 1;
        node.resize(n * 2 - 1, UNITY);
    }

    void build(const std::vector<Monoid>& v, const Func f, const Monoid &unity) {
        F = f;
        UNITY = unity;
        int sz = v.size();
        n = 1; while (n < sz) n <<= 1;
        node.resize(n * 2 - 1, UNITY);
        for (int i = 0; i < sz; i++) node[i + n - 1] = v[i];
        for (int i = n - 2; i >= 0; i--) node[i] = F(node[2 * i + 1], node[2 * i + 2]);
    }

    void update(int x, Monoid val) {
        if (x >= n || x < 0) return;
        x += n - 1;
        node[x] = val;
        while (x > 0) {
            x = (x - 1) >> 1;
            node[x] = F(node[2 * x + 1], node[2 * x + 2]);
        }
    }
    // [a,b)
    Monoid get(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        if (r <= a || b <= l) return UNITY;
        if (a <= l && r <= b) return node[k];
        Monoid vl = get(a, b, 2 * k + 1, l, (r - l) / 2 + l);
        Monoid vr = get(a, b, 2 * k + 2, (r - l) / 2 + l, r);
        return F(vl, vr);
    }

    Monoid operator[](int x)const {
        return node[n + x - 1];
    }

    int size() {
        return n;
    }

    void print() {
        for (int i = 0; i < n; i++) {
            std::cout << i << "\t: " << node[n + i - 1] << std::endl;
        }
    }
};

int main() {
    int n, k; cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i] -= k;
    }
    vector<ll> sum(n + 1); // [0:i)
    sum[0] = 0;
    map<ll, int> mp;
    mp[0] = -1;
    for (int i = 0; i < n; i++) {
        sum[i + 1] = sum[i] + a[i];
        mp[sum[i + 1]] = -1;
    }
    int t = 0;
    for (auto p : mp) {
        mp[p.first] = t++;
    }
    SegmentTree<ll> seg(t, [](int a, int b) {return a + b; }, 0);
    ll ans = 0;
    for (int i = n; i >= 0; i--) {
        ans += seg.get(mp[sum[i]], t);
        seg.update(mp[sum[i]], seg[mp[sum[i]]] + 1);
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> d(N);
  
  for(int i = 0; i < N; i++){
    cin >> d.at(i);
  }
  sort(d.begin(), d.end());
  
  int index1 = d.size()/2;
  int index2 = d.size()/2 - 1;
  int ans; 
  cerr << d.at(index1) << " " << d.at(index2) << endl;
  if(d.at(index1) == d.at(index2)){
    ans = 0;
  } else {
    ans = d.at(index1) - d.at(index2);
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define mid ((l+r)>>1)
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
using namespace std;
template<class T>il read(T &x){
	int f=1;char k=getchar();x=0;
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=x*10+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x>=10) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
ll mul(ll a,ll b,ll mod){long double c=1.;return (a*b-(ll)(c*a*b/mod)*mod)%mod;}
it qpow(int x,int k,int mod){
	int res=1,bas=x;
	while(k){
		if(k&1) res=1ll*res*bas%mod;
		bas=1ll*bas*bas%mod,k>>=1;
	}
	return res;
}
const int N = 1e5+5;
int n,m,x,y,z,fa[N];
it find(int x){return x==fa[x]?x:fa[x]=find(fa[x]);}
il Merge(int x,int y){
	x=find(x),y=find(y);
	if(x==y) return ;
	fa[x]=y;
}
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(n),read(m);
	for(ri i=1;i<=n;++i) fa[i]=i;
	for(ri i=1;i<=m;++i){
		read(x),read(y),read(z);
		Merge(x,y);
	}
	int ans=0;
	for(ri i=1;i<=n;++i) if(find(i)==i) ++ans;
	print(ans);
	return 0;
}

Measured memory_bytes: 896
n = int(input())
pos = [list(list(map(int, input().split()))) for _ in range(n)]

dst = 0
for i in range(n-1):
    for j in range(i+1, n):
        dst += ((pos[i][0]-pos[j][0])**2 + (pos[i][1]-pos[j][1])**2)**(1/2)
print(dst*2/n)


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

typedef long long ll;

int N, M;
vector<int> imos1;
vector<ll> imos2;
ll sum = 0;

int main(void) {
	cin >> N >> M;
	imos1.resize(2 * M + 1);
	imos2.resize(2 * M + 1);
	int a0;
	cin >> a0;
	for (int i = 1; i < N; ++i) {
		int a1;
		cin >> a1;
		if (a0 > a1)
			a1 += M;

		++imos1[a0];
		--imos1[a1];
		imos2[a0] += a0 - 1;
		imos2[a1] -= a0 - 1;

		sum += a1 - a0;
		a0 = a1;
		a0 %= M;
	}

	for (int i = 1; i < 2 * M; ++i) {
		imos1[i] += imos1[i - 1];
		imos2[i] += imos2[i - 1];
	}

	ll ans = sum;
	for (int i = 0; i < M; ++i) {
		int a = imos1[i];
		ll b = imos2[i];
		ll val = sum;
		val -= (ll)a * (ll)i - b - a;
		a = imos1[i + M];
		b = imos2[i + M];
		val -= (ll)a * (ll)(i + M) - b - a;
		ans = min(ans, val);
	}

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 2560
N = int(input())
w = []
flg = True
for i in range(N):
    w.append(str(input()))

if len(w) != len(set(w)):
    flg = False
else:
    for i in range(1,N):
        if w[i][0] != w[i-1][-1]:
            flg = False
            break
if flg:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
using namespace std;
int main(){
   int N,M;
  cin>>N>>M;
  vector<vector<int>>s(M);
  for(int i=0;i<M;++i){
    int k;
    cin>>k;
    for(int j=0;j<k;++j){
      int a;
      cin>>a;
      --a;
      s[i].push_back(a);
    }
  }
  vector<int>p(M);
  for(int i=0;i<M;++i){
    cin>>p[i];
  }
  long long res=0;
  for(int bit=0;bit<(1<<N);bit++){
    bool ok=true;
    for(int i=0;i<M;i++){
      int con=0;
      for(auto v:s[i]){
         if(bit&(1<<v)) con++;
      }
      if(con%2!=p[i]) ok=false;
    }
    if(ok) res++;
  }
  cout<<res<<endl;
}
    


Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int MAX = 1000000;

int main(){
	bool b[MAX] = {true};
	static int a[MAX] = {0,0};
	int n;
	for(int i = 2;i < MAX;i++){
		if(!b[i]){
			for(int j = 2;i*j < MAX;j++){
				b[i*j] = true;
			}
		}
		a[i] = a[i-1] + !b[i];
	}
	while(cin >> n){
		cout << a[n] << endl;
	}
	return 0;
}

Measured memory_bytes: 7932
#include<bits/stdc++.h>
using namespace std;
#define cool ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int main()
{ 
    cool;
    long long int a,b;
    cin>>a>>b;
    if((a+b)%2==0)
    cout<<((a+b)/2);
    else
    cout<<"IMPOSSIBLE";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INT(a) scanf("%d",&a)
#define STR(a) scanf("%s",a)
#define DBL(a) scanf("%lf",&a)
#define LNG(a) scanf("%lld",&a)
#define PI acos(-1)
#define ll long long
#define ff first
#define ss second

typedef pair< ll, pair< int, pair< int, int > > > pii;

ll a[1005], b[1005], c[1005];
map< pair< int, pair< int, int > >, bool > vis;

int main(){
	int x,y,z,k;
	cin>>x>>y>>z>>k;
	for(int i=0;i<x;i++) cin>>a[i];
	for(int i=0;i<y;i++) cin>>b[i];
	for(int i=0;i<z;i++) cin>>c[i];

	sort(a, a+x, greater< ll >());
	sort(b, b+y, greater< ll >());
	sort(c, c+z, greater< ll >());
	
	priority_queue< pii > Q;

	Q.push({a[0]+b[0]+c[0], {0, {0, 0}}});

	int cnt=0;
	while(cnt<k){
		pii tmp = Q.top(); Q.pop();
		cout<<tmp.ff<<endl;
		if(tmp.ss.ff+1<x && !vis[{tmp.ss.ff+1, {tmp.ss.ss.ff, tmp.ss.ss.ss}}]){
			Q.push({a[tmp.ss.ff+1]+b[tmp.ss.ss.ff]+c[tmp.ss.ss.ss], {tmp.ss.ff+1, {tmp.ss.ss.ff, tmp.ss.ss.ss}}});
			vis[{tmp.ss.ff+1, {tmp.ss.ss.ff, tmp.ss.ss.ss}}]=1;
		}
		if(tmp.ss.ss.ff+1<y && !vis[{tmp.ss.ff, {tmp.ss.ss.ff+1, tmp.ss.ss.ss}}]){
			Q.push({a[tmp.ss.ff]+b[tmp.ss.ss.ff+1]+c[tmp.ss.ss.ss], {tmp.ss.ff, {tmp.ss.ss.ff+1, tmp.ss.ss.ss}}});
			vis[{tmp.ss.ff, {tmp.ss.ss.ff+1, tmp.ss.ss.ss}}]=1;
		}
		if(tmp.ss.ss.ss+1<z && !vis[{tmp.ss.ff, {tmp.ss.ss.ff, tmp.ss.ss.ss+1}}]){
			Q.push({a[tmp.ss.ff]+b[tmp.ss.ss.ff]+c[tmp.ss.ss.ss+1], {tmp.ss.ff, {tmp.ss.ss.ff, tmp.ss.ss.ss+1}}});
			vis[{tmp.ss.ff, {tmp.ss.ss.ff, tmp.ss.ss.ss+1}}]=1;
		}
		cnt++;
	}

	return 0;
}

Measured memory_bytes: 896
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;


void solve() {
    int N, X, Y; cin >> N >> X >> Y;
    X--; Y--;
    
    vector<int> res(N);

    for (int i = 0; i < N-1; i++) {
        for (int j = i+1; j < N; j++) {
            int d1 = j-i;
            int d2 = abs(X - i) + abs(Y - j) + 1;
            int d3 = abs(Y - i) + abs(X - j) + 1;
            int d = min(d1, min(d2, d3));
            //cout << i << " " << j << " " << d1 << " " << d2 << " " << d3 << endl;
            res[d]++;
        }
    }

    for (int i = 1; i < N; i++) {
        cout << res[i] << endl;
    }
}


int main() {
    solve();
    return 0;
}

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    int M, NA, NB;
    while (cin >> M >> NA >> NB, M || NA || NB) {
        vector<int> P(M);
        rep(i, M) {
            cin >> P[i];
        } 

        int ans = 0, mgap = 0;
        for (int i=NA; i<=NB; i++) {
            int gap = P[i-1] - P[i];
            if (gap >= mgap) {
                ans = i;
                mgap = gap;
            }
        }

        cout << ans << endl;
    }
}

Measured memory_bytes: 3104
#include<stdio.h>
int main()
{
    int n, m, x;
    scanf("%d %d %d", &n, &m, &x);
    int a[100];
    int i;
    for (i = 0; i < m; i++)
        scanf("%d", &a[i]);
    int k;
    for(i=0;i<m-1;i++)
        if (a[i] > a[i + 1])
        {
            k = a[i];
            a[i] = a[i + 1];
            a[i + 1] = k;
            if (i != 0)
                i -= 2;
        }
    int ans1, ans2;
    ans1 = ans2 = 0;
    i = 0;
    while (a[i] < x)
    {
        ans1++;
        i++;
    }
    while (i < m)
    {
        ans2++;
        i++;
    }
    if (ans1 > ans2)
        ans1 = ans2;
    printf("%d\n", ans1);
    return 0;
}

Measured memory_bytes: 128
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from itertools import chain
from copy import deepcopy
def main():
    h, w = map(int, input().split())
    # '#'を1に、'.'を-1に置き換える。
    # 上下左右にダミーのマスとして0を置く。
    hw = []
    hw.append([0] * (w + 2))
    for _ in range(h):
        row = list(input())
        row2 = [-1 if i == '#' else 0 for i in row]
        row3 = list(chain([0], row2, [0]))
        hw.append(row3)
    hw.append([0] * (w + 2))
    hw2 = deepcopy(hw)
    for i1 in range(1, h + 1):
        for i2 in range(1, w + 1):
            if hw[i1][i2] == 0:
                bombs = sum(hw[i1 - 1][i2-1:i2+2])
                bombs += sum(hw[i1][i2 - 1:i2 + 2])
                bombs += sum(hw[i1 + 1][i2 - 1:i2 + 2])
                hw2[i1][i2] = - bombs
    for j1 in range(1, h + 1):
        row4 = hw2[j1][1:w+1]
        row5 = ['#' if i == -1 else str(i) for i in row4]
        print("".join(row5))


if __name__ == '__main__':
    main()

Measured memory_bytes: 9192
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
    while(1){
        ll w,d; cin >> w >> d;
        if(w+d==0) break;
        vl h(w), H(d);
        rep(i,w) cin >> h[i];
        rep(i,d) cin >> H[i];
        sort(rall(h)); sort(rall(H));
        ll ans = 0;
        rep(i,w){
            ans += h[i];
            rep(j,d){
                if(h[i] == H[j]){
                    H[j] = 0;
                    break;
                }
            }
        }
        //cout << ans << endl;
        rep(j,d) ans += H[j];
        cout << ans << "\n";
    }
}


Measured memory_bytes: 3080
#if loc||local
#define _GLIBCXX_DEBUG
#endif

#include<bits/stdc++.h>
using namespace std;

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
#if loc||local
template<class T>void dump(T&& t){cerr<<t<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}
constexpr ll dx[]={1,0,-1,0,1,1,-1,-1};
constexpr ll dy[]={0,1,0,-1,1,-1,1,-1};
constexpr ll ddx[] = {2,2,2,2,2,-2,-2,-2,-2,-2,1,0,-1,1,0,-1};
constexpr ll ddy[] = {0,1,2,-1,-2,2,1,0,-1,-2,2,2,2,-2,-2,-2};
using T3 = tuple<ll,ll,ll>;
using T4 = tuple<ll,ll,ll,ll>;
signed main(){

  int h,w;
  cin>>h>>w;
  int ch,cw;
  cin>>ch>>cw;
  int dh,dw;
  cin>>dh>>dw;
  auto s = vec<char>(h,w);
  cin>>s;
  ch--;cw--;dh--;dw--;

  auto dist = vec<ll>(h,w);
  for(auto& di:dist)for(auto& dij:di)dij=INF;
  priority_queue<T3,vector<T3>,greater<>> que;
  que.emplace(0,ch,cw);
  while(!que.empty()){
    auto [cost,y,x] = que.top();
    que.pop();
    if(!chmin(dist[y][x],cost))continue;
    rep(i,4){
      int ny = y+dy[i];
      int nx = x+dx[i];
      if(ny==-1||nx==-1||ny==h||nx==w)continue;
      if(s[ny][nx]=='#')continue;
      if(dist[ny][nx]<cost)continue;
      que.emplace(cost,ny,nx);
    }
    rep(j,4){
      int ny = y+dy[j+4];
      int nx = x+dx[j+4];
      if(ny==-1||nx==-1||ny==h||nx==w)continue;
      if(s[ny][nx]=='#')continue;
      if(dist[ny][nx]<cost+1)continue;
      que.emplace(cost+1,ny,nx);
    }
    rep(k,16){
      int ny = y+ddy[k];
      int nx = x+ddx[k];
      if(ny<0||nx<0||ny>=h||nx>=w)continue;
      if(s[ny][nx]=='#')continue;
      if(dist[ny][nx]<cost+1)continue;
      que.emplace(cost+1,ny,nx);
    }
  }
  cout<<(dist[dh][dw]==INF?-1:dist[dh][dw])<<endl;

}


Measured memory_bytes: 13728
#include <cstdio>
#include <algorithm>
#define repu(i,x,y) for (int i=x; i<=y; ++i)
#define repd(i,x,y) for (int i=x; i>=y; --i)
using namespace std;

int n,m,len[2010],l[2010],r[2010],stk[2010],top,ans;
char a[2010][2010];

int main()
{
    scanf("%d%d",&n,&m);
    repu(i,1,n)
        scanf("%s",a[i]+1);
    ans=m;
    repu(i,1,m)
    {
        stk[top=0]=0;
        repu(j,1,n-1)
        {
            len[j]=i>1 && (a[j][i]==a[j+1][i])==(a[j][i-1]==a[j+1][i-1])?len[j]+1:1;
            for (; top && len[j]<=len[stk[top]]; --top);
            l[j]=stk[top],stk[++top]=j;
        }
        stk[top=0]=n;
        repd(j,n-1,1)
        {
            for (; top && len[j]<=len[stk[top]]; --top);
            r[j]=stk[top],stk[++top]=j;
            ans=max(ans,len[j]*(r[j]-l[j]));
        }
    }
    printf("%d\n",ans);
    return 0;
}

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

int main(){
  string s;
  std::cin >> s;
  if(s[2]==s[3] && s[4]==s[5])std::cout << "Yes" << '\n';
  else std::cout << "No" << '\n';


  return 0;
}


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

int main() {
  char a,b;
  cin >> a >>b;
  if((a == 'H' && b == 'H') || (a=='D' && b =='D')) cout << "H" << endl;
  else cout << "D" << endl;
}

Measured memory_bytes: 3604
#define ffor(i,a,b) for (int i=(a);i<(b);i++)
#define rfor(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define rep(i,n) for (int i=0;i<(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<queue>
#define SIZE 100001
#define MOD 1000000007
#define INF 100000000
using namespace std;

int main(){
	cin.tie(0);

	int n;
	cin >> n;
	string S[50];
	int key[50][26] = {};


	rep(i,n){
		cin >> S[i];
		for(int j = 0; S[i][j] != '\0'; j++){
			key[i][S[i][j] - 'a']++;
		}
	}

	rep(i,26){
		int cn = 50;
		rep(j,n){
			cn = min(cn,key[j][i]);
		}
		cout<< string(cn,'a'+i);
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))

dp = [0]*(int(1e5) + 1)
for e in a:
    dp[e] += 1

ans = 0
for i in range(1, int(1e5)):
    ans = max(ans, dp[i-1] + dp[i] + dp[i+1])
print(ans)


Measured memory_bytes: 52908
#pragma GCC optimize("Ofast")
//没错，我就是抄zyy代码了
//啊，代码都不能抄，那还有什么可以抄啊 
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const int inf = 0x3f3f3f3f;
#define Rep(i,a,b) for(register int i=(a);i<=int(b);++i)
#define Dep(i,a,b) for(register int i=(a);i>=int(b);--i)
#define rep(i,a,b) for(register int i=(a);i<int(b);++i)
#define mem(x,v) memset(x,v,sizeof(x))
#define fi first
#define se second
#define lowbit(x) ((x)&-(x))
#define debug(x) cout << #x " = " << x << endl;
namespace IO{
	const int L = 1 << 15;
	char ibuf[L|1],*iS=ibuf,*iT=ibuf;
	char obuf[L|1],*oS=obuf,*oT=obuf+L;
	char c,st[66];int tp=0,f;
	inline char gc(){
		if(iS==iT) iT=(iS=ibuf)+fread(ibuf,sizeof(char),L,stdin);
		return (*iS++);
	}
	inline void flush() {
		fwrite(obuf,sizeof(char),oS-obuf,stdout);
		oS = obuf;
	}
	inline void pc(char c){*oS++=c;if(oS==oT) flush();}
	#define gc getchar
	#define pc putchar
	inline ll read(){
		ll x=0;f=1,c=gc();
		for(;!isdigit(c);c=gc())if(c=='-')f=-1;
		for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c&15);
		return x*f;
	}
	void write(ll x){
		if(!x) pc('0');if(x<0) pc('-'),x=-x;
		while(x) st[++tp]=x%10+'0',x/=10;
		while(tp) pc(st[tp--]);
	}
	void wri(ll x){write(x);pc(' ');}
	void writeln(ll x){write(x);pc('\n');}
	struct IOflusher{~IOflusher(){flush();}}_ioflusher_;
}
using IO::read;
using IO::writeln;
using IO::wri;
inline void gg(string s){cout << s << endl;exit(0);}
inline void gg(ll x){writeln(x);exit(0);}
const int N=505;
int n,mod,f[N][N],ans;
pair<int,int>a[N];
#define sqr(x) ((x)*(x))
int main(){
	n = read();mod = read();
	rep(i,0,n){
		while(sqr(i)+sqr(a[i].fi)<sqr(n)) ++a[i].fi;
		--a[i].fi,a[i].se=n+n-1;
		while(sqr(i)+sqr(a[i].se)>sqr(n+n)) --a[i].se;
	}
	rep(i,n,2*n){
		a[i].fi=n+n-1;
		while(sqr(i)+sqr(a[i].fi)>sqr(n+n))--a[i].fi;
	}
	sort(a,a+n+n);
	Rep(t,0,n){
		f[0][0]=1;
		for(int i=0,s1=0,s2=0;i<n+n;++i)
			if(!a[i].se){
				Rep(j,0,t)
					f[i+1][j]=1ll*f[i][j]*(a[i].first+1-(s1+j))%mod;
				++s1;
			}else{
				Rep(j,0,t)
					f[i+1][j]=1ll*f[i][j]*(a[i].second+1-(n+s2+t-j))%mod;
				rep(j,0,t)
					f[i+1][j+1]=(f[i+1][j+1]+1ll*f[i][j]*(a[i].first+1-(s1+j)))%mod;
				++s2;
			}
		ans=(ans+(t&1?mod-f[n+n][t]:f[n+n][t]))%mod;
	}
	writeln(ans);
	return 0;
}

Measured memory_bytes: 4580
import math
N,K= map(int,input().split())
choose_count = 1
for i in range(K):
	left = K - choose_count
	if left < 0:
		print(0)
		continue
	if N-K+1-choose_count<0:
		print(0)
		continue
	choose = math.factorial(N-K+1)//(math.factorial(choose_count)*math.factorial(N-K+1-choose_count))
	ans = choose*math.factorial(left+choose_count-1)//(math.factorial(left)*math.factorial(choose_count-1))
	print(int(ans)%1000000007)
	choose_count += 1


Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=2e5+5;
int main()
{
    int r,d,x,arr[11];
    cin>>r>>d>>x;
    arr[0]=r*x-d;
    cout<<arr[0]<<endl;
    for(int i=1;i<10;i++){
        arr[i]=r*arr[i-1]-d;
        cout<<arr[i]<<endl;
    }
   //while solving this problem.....I'm in my way to fail the next exam.
    return 0;
}


Measured memory_bytes: 256
n = int(input())

t = x = y = 0
for _ in range(n):
    t_, x_, y_ = map(int, input().split())
    dt, dx, dy = (t_ - t), abs(x_ - x), abs(y_ - y)

    if dx + dy > dt:
        print("No")
        exit()

    if dt % 2 != (dx + dy) % 2:
        print("No")
        exit()

    t, x, y = t_, x_, y_

print("Yes")


Measured memory_bytes: 3060
#include<iostream>
#include<math.h>
#include<iomanip>
#include<string.h>
#include<cstdio>
#include<cstdlib>
#include<stack>

using namespace std;

int main(){

  int n, q;

  cin >> n;

  int s[n + 1];

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

  cin >> q;

  int sum = 0;

  for(int i = 0; i < q; i++){
    int t;
    cin >> t;

    s[n] = t;
    int j = 0;
    while(s[j] != t){
      j++;
    }
    if(j != n) sum++;
  }

  cout << sum << endl;



  return 0;

}


Measured memory_bytes: 3112
n, k = map(int, input().split())
A = list(map(int, input().split()))
d = 10**9 + 7

down1 = 0
for i in range(n-1):
  for j in range(i+1, n):
    if A[i] > A[j]: down1 += 1

down2 = 0
for i in range(n):
  for j in range(n):
    if A[i] > A[j]: down2 += 1

ans = (down2 * ((k-1) * k // 2)) % d
ans = (ans + down1 * k) % d
print(ans)

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner in= new Scanner(System.in);
		int a=0,b=0,temp1,temp2,j;
		j=in.nextInt();
		while(j!=0){
			
			for(int i=0;i<j;i++){
				temp1=in.nextInt();
				temp2=in.nextInt();
				if(temp1>temp2){
					a+=temp1+temp2;
				}
				else if(temp1==temp2){
					a+=temp1;b+=temp2;
				}
				else{
					b+=temp1+temp2;
				}
				
			}
			System.out.printf("%d %d\n",a,b);
			a=0;b=0;
			j=in.nextInt();
			
		}
	}
}

Measured memory_bytes: 12000
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N = I()
    H = LI()
    before = -inf
    ans = 0
    cnt = 0
    for h in H:
        if before >= h:
            cnt += 1
            before = h
        else:
            ans = max(cnt,ans)
            cnt = 0
            before = h
    ans = max(cnt,ans)
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 59536
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
int main(){
  int N, M, C; cin >> N >> M >> C;
  vector<int> B(M); rep(i, M) cin >> B.at(i);
  vector<vector<int>> A(N, vector<int>(M)); rep(i, N) rep(j, M) cin >> A.at(i).at(j);
  int ans = 0;
  rep(i, N){
    int source = 0;
    rep(j, M) source += A.at(i).at(j) * B.at(j);
    if(source + C > 0) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define N 1000000007
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,k ,i, x = 1,s = 0,ans = 0;
    cin>>n>>k;
    ll a[n], b[n+1];
    for(i=0;i<n;i++)
        cin>>a[i];
    map <int,int> mapp;
    mapp[0] = 1;
    b[0] = 0;
    for(i=0;i<n;i++)
    {
        if(i >= k-1)
        {
            mapp[b[i-k+1]]--;
        }
        s = (s+a[i])%k;
        //cout<<((s-x)%k+k)%k<<" ";
        //cout<<mapp[((s-x)%k+k)%k]<<endl;
        ans += mapp[((s-x)%k+k)%k];
        b[i+1] = ((s-x)%k+k)%k;
        mapp[((s-x)%k+k)%k]++;
        x++;
    }
    cout<<ans;
    return 0;
}

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

// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

typedef long long ll; 
typedef long double ld; 
typedef pair<int,int> p32;   
typedef pair<ll,ll> p64;  
typedef pair<double,double> pd; 
typedef pair<ld,ld> pld; 
typedef vector<int> v32;  
typedef vector<ll> v64;  
typedef vector<pd> vpd;   
typedef vector<p32> vp32;  
typedef vector<p64> vp64;  
typedef vector<v32> vv32;  
typedef vector<v64> vv64;  

#define pb push_back
#define mp make_pair
#define prarr(a,n) cerr<<#a<<" : ";for(ll i=0;i<n;i++) cerr<<a[i]<<" "; cerr<<endl;
#define prmat(mat,row,col) cerr<<#mat<<" :\n";for(ll i=0;i<row;i++) {for(ll j=0;j<col;j++) cerr<<mat[i][j]<<"\t";cerr<<endl;}
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
#define all(a) a.begin(),a.end()
#define sz(x) ((int)x.size())
#define endl '\n'
#define fast_io ios_base::sync_with_stdio(NULL); cin.tie(NULL)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {ll idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
template <class T> void prall(T a) { prc(all(a)); }

#include <bits/extc++.h> /** keep-include */
using namespace __gnu_pbds;
template <class T>
using Tree = tree<T, null_type, less<T>, rb_tree_tag,
        tree_order_statistics_node_update>;

const int inf=1000*1000*1000+9; 
const ll infl=1ll*inf*inf; 
int mod=1000*1000*1000+7;  
// ----------------------------------------------------------------------------	-------------- 

void pre(){
}

string s; 
const int nax=1e6+5; 
int dp[nax][2]; 
int go(int i, int carry ){
  if(i==sz(s)){
    return carry; 
  }
  if(dp[i][carry]!=-1) return dp[i][carry]; 
  int ret=inf; 
  if(carry){
    int res=go(i+1,0)+10-(s[i]-'0'); 
    res=min(res,go(i+1,1)+10-(s[i]-'0')-1); 
    ret=min(ret,res); 
  }
  else {
    ret=min(ret,go(i+1,0)+s[i]-'0'); 
    if(s[i]-'0' < 9){
      ret=min(ret,go(i+1,1)+s[i]-'0'+1); 
    }
  }
  return dp[i][carry]=ret; 
}

void solve(){
  cin>>s; 
  int n=sz(s); 
  memset(dp,-1,sizeof(dp)); 
  cout<<min(go(0,1)+1,go(0,0))<<endl; 
}



int main(){
	// clock_t beg=clock(); 
  fast_io; 
  int testcases=1; 
  pre(); 
  // cin>>testcases; 
  cout << fixed << setprecision(13); 
  int cs=0; 
  while(testcases--){
    cs++; 
    // cout<<"Case #"<<cs<<": "; 
    solve(); 	
  }
	// clock_t end=clock(); 
	// fprintf(stderr, "%lf\n", (double)(end-beg)/(CLOCKS_PER_SEC));
}





Measured memory_bytes: 56092
#include <iostream> 
#include <algorithm> 
typedef long long ll;
ll n;
ll a[55];
int main()
{
    scanf("%lld",&n);
    for(int i=1;i<=50;i++)
    {
        a[i]=n/50+i-1;
    }
    n%=50;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=50;j++)
        {
            a[j]--;
        }
        a[i]+=51;
    }
    printf("50\n");
    for(int i=1;i<=50;i++)
    {
        if(i!=1) printf(" ");
        printf("%lld",a[i]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 256
import math,fractions
from collections import Counter
n = int(input())
v = [int(i) for i in input().split()]
a = Counter(v[1::2]).most_common()
b = Counter(v[0::2]).most_common()
a.append((0,0))
b.append((0,0))

if a[0][0] != b[0][0]:
    print(n//2 - a[0][1] + n//2 - b[0][1])
else:
    tmp_x = n//2 - a[1][1] + n//2 - b[0][1]
    tmp_y = n//2 - a[0][1] + n//2 - b[1][1]
    print(min(tmp_x, tmp_y))


Measured memory_bytes: 22348
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
        int a,b;
        cin >> a >> b;
        int n=0,c=b;
        while(c){
                c/=10; n++;
        }
        if(sqrt(a*pow(10,n)+b)-(int)sqrt(a*pow(10,n)+b)) cout << "No" << endl;
        else cout << "Yes" << endl;
        return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  vector<int> high(10);
  for(int i=0; i<10; i++) cin >>high[i];
  sort(high.begin(),high.end());
  for(int i=9; i>6; i--) cout<<high[i]<<endl;
  return 0;
}

Measured memory_bytes: 1212
#include <stdio.h>
#include <stdlib.h>
  
int n, m;
  
void merge(int *u, int *net, int oldnet, int newnet);
  
int main(int argc, char *argv[])
{
  int i, s, t, p, q;
  int *u;
  int *net;
  
  scanf("%d", &n);
  scanf("%d", &m);
  u = (int *)malloc(sizeof(int) * n);
  net = (int *)malloc(sizeof(int) * (m + 1));
  for (i = 0; i < n; i++) u[i] = -1;
  for (i = 0; i <= m; i++) net[i] = 0;
  
  p = 1;
  
  for (i = 0; i < m; i++) {
    scanf("%d", &s);
    scanf("%d", &t);
    if (s != t) {
      if (u[s] == -1 && u[t] == -1) {
    u[s] = p;
    u[t] = p;
    net[p] += 2;
    p++;
      } else {
    if (u[s] != -1 && u[t] == -1) {
      u[t] = u[s];
      net[u[s]]++;
    } else if (u[s] == -1 && u[t] != -1) {
      u[s] = u[t];
      net[u[t]]++;
    } else {
      if (u[s] != u[t]) {
        if (net[u[s]] > net[u[t]]) merge(u, net, u[t], u[s]);
        else merge(u, net, u[s], u[t]);
      }
    }
      }
    }
  }
  
  scanf("%d", &q);
  
  for (i = 0; i < q; i++) {
    scanf("%d", &s);
    scanf("%d", &t);
  
    if (s == t) printf("yes\n");
    else {
      if (u[s] == u[t] && u[s] != -1 && u[t] != -1) printf("yes\n");
      else printf("no\n");
    }
  }
  
  return 0;
}
  
void merge(int *u, int *net, int oldnet, int newnet)
{
  int i;
    
  for (i = 0; i < n; i++) {
    if (u[i] == oldnet) u[i] = newnet;
  }
  
  net[newnet] += net[oldnet];
  net[oldnet] = 0;
}

Measured memory_bytes: 1368
//Abhinav ---IIIT_A
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
// it is a knapsack dummy
int knp(int wei[],int val[],int n,int mxl){
	int dp[n+1][mxl+1]; // consider items for all possible weight
	//for(int i=0;i<n;++i) cout<<wei[i]<<" "<<val[i]<<"\n";
	for(int i=0;i<=n;++i) for(int j=0;j<=mxl;++j){
		if(i==0 || j==0) dp[i][j]=0;
		else if(wei[i-1]<=j) {
			// consider the weight
			dp[i][j] = max(val[i-1]+dp[i-1][j-wei[i-1]],dp[i-1][j]);
			// either include or not
		}
		else {
			// now i cannot include it 
			dp[i][j]=dp[i-1][j];
		}
	}
	//for(int i=0;i<=n;++i){
	//	for(int j=0;j<=mxl;++j) cout<<dp[i][j]<<" ";
	//	cout<<"\n";
	//}
	return dp[n][mxl]; // all items considered
}
int knp2(int wei[],int val[],int n,int mxl,bool inc[]){
	int dp[n+1][mxl+1]; 
	for(int i=0;i<=n;++i) for(int j=0;j<=mxl;++j){
		if(i==0 || j==0) dp[i][j]=0;
		else if(wei[i-1]<=j) {
			dp[i][j] = max(val[i-1]+dp[i-1][j-wei[i-1]],dp[i-1][j]);
		}
		else {
			dp[i][j]=dp[i-1][j];
		}
	}
	// if it comes form top -> not include else include
	// for minimum we if include == not include then not include;
	int ans=dp[n][mxl];
	int curr_w=mxl;
	for(int i=n;i>0;--i){
		if(ans<=0) break; // no solution
		if(ans==dp[i-1][curr_w]) continue; // not include
		else{
			// include
			inc[i-1]=1;
			ans-=val[i-1]; curr_w-=wei[i-1];
		}
	}
	return dp[n][mxl]; 
}
vector<int> prime;
void seive(){
	int arr[200005]={0};
	for(int i=2;i<200005;++i){
		if(arr[i]==0){
			prime.push_back(i);
			for(int j=2*i;j<200005;j+=i)
				arr[j]=1;
		}
	}
}
int fx(int n){
	for(auto it : prime){
		if(n%it==0) return it;
	}
	return n;
}
int lcm(int a,int b){
	a/=__gcd(a,b);
	return a*b;
}
void solve(){
	int n,k; cin>>n>>k;
	int a[n],b[n];
	for(int i=0;i<n;++i) cin>>a[i];
	for(int i=0;i<n;++i) cin>>b[i];
	sort(a,a+n);
	sort(b,b+n);
	int i=0,j=n-1;
	while(i<n && a[i]<b[j]){
		a[i]=b[j];
		++i; --j;
	}
	int s=0;
	for(int i=0;i<n;++i) s+=a[i];
	cout<<s<<"\n";
}
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ld a,b,h,m; cin>>a>>b>>h>>m;
	ld t=(h*30.000000000)+(m*0.500000000);
	ld t1=(m*6.000000000);
	t-=t1;
	ld pi=3.1415926535;
	t*=pi;
	t/=180.000000000;
	ld c= sqrt(a*a+b*b-2*a*b*cos(t));
	cout<<fixed<<setprecision(18)<<c<<"\n";
	return 0;
}



Measured memory_bytes: 4196
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
  int N;
  cin >> N;
  vector<int> counts(N + 1);
  for (int i = 2; i <= N; ++i) {
    int A;
    cin >> A;
    counts[A]++;
  }
  for (int i = 1; i <= N; ++i) {
    cout << counts[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
inline int gcd(int a, int b) {
	return b ? gcd(b, a % b) : a;
}
int n, a[100005];
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	sort(a + 1, a + 1 + n);
	int ans = 1;
	for (int i = 1; i <= n; i++)
		ans = 1ll * ans * gcd(a[i], i - 1) % mod;
	printf("%d\n", ans);
	return 0;
}

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

int main() {
    long n, a, b;
    cin >> n >> a >> b;
    
    if (n == 1 and a != b) {
        cout << 0 << endl;
        return 0;
    }
    
    long nax = a + (n - 1) * b, nin = (n - 1) * a + b;
    cout << max(0L, nax - nin + 1) << endl;
    return 0;
}

Measured memory_bytes: 256
import numpy as np
 
N,H = map(int,input().split())
ab = np.asarray([list(map(int,input().split())) for _ in range(N)])
 
 
#bのうち大きなものから引いていく
#b[i]のうち、max(a)が大きければ、以降max(a)で攻撃し続ける
 
max_a = np.max(ab[:,0])
b_sort = np.sort(ab[:,1])[::-1] #降順
 
ans = 0
 
b_sort = b_sort[np.where(b_sort > max_a)]
 
#b_sortの中で大きいのから順に引いていく
for i in range(len(b_sort)):
  H -= b_sort[i]
  ans += 1
  if H <= 0:
    print(ans)
    exit()
 
#bをすべて引いてもH>0ならaで攻撃
if H % max_a == 0:
  ans += H // max_a
else:
  ans += H // max_a + 1
 
print(ans)

Measured memory_bytes: 39908
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define sz(x) int(x.size())
using ll = long long;
const ll LLINF = numeric_limits<long long>::max();
const int mod = 1000000007;
const int INF = 1001001001;
int main()
{
    string S,T;
    cin >> S;
    int N = S.length();
    T = S;
    reverse(T.begin(), T.end());

    string s,t,a,b;


    if (S==T){
        s = S.substr(0,(N-1)/2);
        t = s;
        reverse(t.begin(), t.end());
        
        if (s==t){
            s = S.substr((N+3)/2-1,N);
            t=s;
            
            reverse(t.begin(), t.end());
            if(s==t){
                cout << "Yes";
                return 0;
            }
        }

    }
    cout << "No";

    return 0;
}

Measured memory_bytes: 384
//header{{{
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/math/common_factor_rt.hpp>
  
using namespace std;
//using namespace boost::multiprecision;  
//using namespace boost::math;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

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


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

    int n, k;
    cin >> n >> k;

    vector<int> a(n);

    rep(i,n){
        cin >> a[i];
    }

    auto f = [&](long double key){
        int cnt = 0;
        rep(i,n){
            cnt += ceil(a[i] / key) - 1;
        }
        return (cnt);
    };

    int ok = 1e9 + 1, ng = 0;
    
    while(ok - ng > 1){
        auto mid = (ok + ng) / 2;
        if(f(mid) <= k){
            ok = mid;
        }else{
            ng = mid;
        }
    }

    cout << int(ceil(ok)) << '\n';

    return 0;
}



Measured memory_bytes: 4712
#include <bits/stdc++.h>
#include<iostream>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

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

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 1152921504606846976
const double PI = 3.1415926535897932;

int main()
{
    int n; cin >> n;
    bool ok = false;
    int k;
    for(int i = 1; (i-1) * (i-1) <= 2*n+1; i++){
        if(2 * n == i * (i-1)){
            ok = true;
            k = i;
        }
    }
    if(ok){
        vector<int> v[k];
        int add = 1;
        int cnt = 1;
        for(int i = 0; i < k-1 ; i++){
            int x = k-i;
            for(int j = 0; j < x; j++){
                v[i].push_back(add+j);
            }
            for(int j = 0; j < k-i-1; j++){
                v[j+cnt].push_back(add+j);
            }
            cnt++;
            add += (k-i-1);
            
        }
        cout << "Yes" << endl;
        cout << k << endl;
        rep(i,k){
            cout << k-1 << ' ';
            rep(j,k-1) cout << v[i][j] << ' ' ;
            cout << endl;
        }
    }else{
        cout << "No";
    }
}

Measured memory_bytes: 2304
// Problem Code: abc174_b

#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

int distance(long long D, vector<pair<long long, long long>>& P) {
	return count_if(P.begin(), P.end(), [&D](auto& p) {
		return p.first * p.first + p.second * p.second <= D * D;
	});
}

int main() {
	int N, D;
	cin >> N >> D;
	vector<pair<long long, long long>> P(N);
	for (int i = 0; i < N; i++)
		cin >> P[i].first >> P[i].second;
	cout << distance(D, P);
	return 0;
}

Measured memory_bytes: 6412
#include<bits/stdc++.h>
using namespace std;
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 
 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define in insert
#define ld long double
 
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
 
typedef long long int ll;
 
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =1e9+7;
const ll maxn =200001;
ll power(ll x, ll n) {
    ll res = 1;
    for (; n > 0; n >>= 1) {
    if (n & 1) res = (res * x) % mod;
    x = (x * x) % mod;
    }
    return res;
}

int main()
{
  IOS
  ll n,k;
  cin>>n>>k;
  ll a[n];
  for(ll i=0;i<n;i++)
  {
    cin>>a[i];
  }
  ll ans=0;
  sort(a,a+n,greater<ll>());
  for(ll i=k;i<n;i++)
  {
    ans+=a[i];
  }
  cout<<ans<<endl;
  
}

Measured memory_bytes: 1792
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    if (N == 1) {
        writeln("Hello World");
    } else {
        auto A = readln.chomp.to!int;
        auto B = readln.chomp.to!int;
        writeln(A + B);
    }
}

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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

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

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

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

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

void solve() {
    //const i64 mod = 1'000'000'007;

    i64 N,M;
    cin >> N >> M;

    vector<vector<i64>> to(N);
    rep(i,0,M){
        i64 x,y;
        cin >> x >> y;
        --x;
        --y;
        to[x].emplace_back(y);
    }

    vector<i64> memo(N);
    vector<bool> done(N);
    function<i64(i64)> rec=[&](i64 u){
        if(done[u]) return memo[u];
        done[u]=true;
        for(auto v:to[u]){
            chmax(memo[u],rec(v)+1);
        }
        return memo[u];
    };

    rep(i,0,N) rec(i);
    cout << *max_element(begin(memo),end(memo)) << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 9216
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;

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

int main(void){
    int h,w,H,W;
    cin>>H>>W>>h>>w;


    cout<<H*W-(H*w+h*W)+w*h<<endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;
using ll=long long int;

int main()
{
  ll n,k,cnt=0;
  cin>>n>>k;
  for (int b = 1; b <= n; ++b)
  {
    ll p=n/b,r=n%b;
    cnt+=max(b-k,0LL)*p;
    cnt+=max(r-k+1,0LL);
  }
  if(k==0) cout<<cnt-n;
  else cout<<cnt;
}

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

int w, h;
int field[20][20];

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

bool in_board(int x, int y){
    return 0 <= x && x < h && 0 <= y && y < w; 
}

int dfs(int x, int y, int cnt){
    int ret = -1;
    if(cnt >= 10) return ret;
    for(int i = 0; i < 4; i++){
        int nx = x + dx[i], ny = y + dy[i];
        if(!in_board(nx, ny) || field[nx][ny] == 1) continue;
        while(in_board(nx, ny) && field[nx][ny] % 2 == 0){
            nx += dx[i];
            ny += dy[i];
        }
        if(!in_board(nx, ny)) continue;
        if(field[nx][ny] == 3) return cnt + 1;
        field[nx][ny] = 0;
        int t = dfs(nx-dx[i], ny-dy[i], cnt + 1);
        if(t >= 0 && (ret < 0 || t < ret)){
            ret = t;
        }
        field[nx][ny] = 1;
    }
    return ret;
}

int main(){
    while(scanf("%d%d", &w, &h) && (w||h)){
        int sx, sy;
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                scanf("%d", &field[i][j]);
                if(field[i][j] == 2){
                    sx = i; sy = j;
                }
            }
        }
        printf("%d\n", dfs(sx, sy, 0));
    }
    return 0;
}

Measured memory_bytes: 1188
N = int(input())
enemy = list(map(int, input().split()))
heroes = list(map(int, input().split()))
ans = 0
for i in range(N):
  diff = min(enemy[i], heroes[i])
  enemy[i] -= diff
  heroes[i] -= diff
  ans += diff

  diff = min(enemy[i + 1], heroes[i])
  enemy[i + 1] -= diff
  heroes[i] -= diff
  ans += diff

print(ans)

Measured memory_bytes: 19116