akhauriyash/Code-Regression huggingface dataset:
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
 
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1000000007
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)

typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD = 1000000007;
//ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
int N;
ll A,B;
ll nums[26]={0};
int main(){
	cin>>N;
	string str;
	cin>>str;
	
	rep(i,N){
		int x=str[i]-'a';
		nums[x]++;
	}
	ll ans=0;
	rep(i,26){
		ans=ans+(nums[i]+(ans*nums[i])%MOD)%MOD;
		ans=ans%MOD;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(){
	int n, a, b, c;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a >> b >> c;
			if((a * a) + (b * b) == (c * c) || (b * b) + (c * c) == (a * a) || (c * c) + (a * a) == (b * b)){
				cout << "YES" << endl;
			}
			else{
				cout << "NO" << endl;
			}
	}
	return(0);
}

Measured memory_bytes: 1152
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var answerList = new Dictionary<double, Tuple<long, long>>();
            const int num = 2000;
            foreach (var A in Enumerable.Range(0, num).Select(elem => elem - (num / 2)))
            {
                foreach (var B in Enumerable.Range(0, num).Select(elem => elem - (num / 2)))
                {
                    var answer = Math.Pow(A, 5) - Math.Pow(B, 5);
                    if (answer >= 1)
                    {
                        answerList[answer] = new Tuple<long, long>(A, B);
                    }
                }
            }

            var X = long.Parse(Console.ReadLine());
            var tuple = answerList[X];
            Console.WriteLine($"{tuple.Item1} {tuple.Item2}");
        }
    }
}


Measured memory_bytes: 150588
import sys 
try:
	sys.stdin = open('input.txt', 'r') 
	sys.stdout = open('output.txt', 'w')
except:
	pass
input = sys.stdin.readline
for tt in range(1):
	a,b,c,k = map(int,input().split())
	ans = 0
	if k>=a:
	  k-=a
	  ans +=a
	else:
	  ans += k
	  k = 0
	if k>=b:
	  k-=b
	else:
	  k = 0
	if k>=c:
	  k-=c
	  ans -= c
	else:
	  ans -= k
	  k = 0
	print(ans)
		

Measured memory_bytes: 9204
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace AtCoder {
    class Practice {
        static void Main() => CustomMain();

        static void Solve() {
            var s = ReadString();

            var ans = 100;
            for (var c = 'a'; c <= 'z'; c++) {
                var len = s.Split(c).Select(x => x.Length).Max();
                ans = Math.Min(ans, len);
            }

            WriteAnswer(ans);
        }


        static void CustomMain() {
#if DEBUG
            // ファイルからテストケースを読み込む
            global::Common.ChangeStdIn();
            // 時間計測
            var stopwatch = new Stopwatch();
            stopwatch.Start();
#endif
            // 出力高速化
            var streamWriter = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            Console.SetOut(streamWriter);
            // 回答
            Solve();
#if DEBUG
            stopwatch.Stop();
            Console.WriteLine(stopwatch.Elapsed);
#endif
            Console.Out.Flush();
        }

        static string ReadString() => Console.ReadLine().Trim();
        static int ReadInt() => int.Parse(ReadString());
        static long ReadLong() => long.Parse(ReadString());
        static float ReadFloat() => float.Parse(ReadString());
        static double ReadDouble => double.Parse(ReadString());

        static string[] ReadStringArray() => ReadString().Split(' ');
        static int[] ReadIntArray() => Array.ConvertAll(ReadString().Split(' '), int.Parse);
        static long[] ReadLongArray() => Array.ConvertAll(ReadString().Split(' '), long.Parse);
        static float[] ReadFloatArray() => Array.ConvertAll(ReadString().Split(' '), float.Parse);
        static double[] ReadDoubleArray() => Array.ConvertAll(ReadString().Split(' '), double.Parse);

        static T TypeConversion<T>(string s) {
            if (typeof(T) == typeof(int)) {
                return (T) Convert.ChangeType(int.Parse(s), typeof(T));
            } else if (typeof(T) == typeof(long)) {
                return (T) Convert.ChangeType(long.Parse(s), typeof(T));
            } else if (typeof(T) == typeof(double)) {
                return (T) Convert.ChangeType(double.Parse(s), typeof(T));
            } else {
                return (T) Convert.ChangeType(s, typeof(T));
            }
        }

        static void ReadMulti<T, U>(out T a, out U b) {
            var str = ReadStringArray();
            a = TypeConversion<T>(str[0]);
            b = TypeConversion<U>(str[1]);
        }

        static void ReadMulti<T, U, V>(out T a, out U b, out V c) {
            var str = ReadStringArray();
            a = TypeConversion<T>(str[0]);
            b = TypeConversion<U>(str[1]);
            c = TypeConversion<V>(str[2]);
        }

        static void WriteAnswer(object ans) => Console.WriteLine(ans);

        static bool IsOdd(long num) {
            return (num & 1) == 1;
        }

        static bool IsEven(long num) {
            return (num & 1) == 0;
        }

        static long GCD(long a, long b) {
            return b != 0 ? GCD(b, a % b) : a;
        }
    }
}

Measured memory_bytes: 13268
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextInt()) {
            int N = sc.nextInt();
            int[] a = new int[100002];
            for (int i = 0; i < N; i++) {
                a[i] = sc.nextInt();
            }
            int ans = 0;

            for (int i = 0; i < N; i++) {
                if ( a[i] != i + 1 ) {
                    continue;
                }
                int start = i;
                while (i < N && a[i] == i + 1) {
                    i++;
                }
                ans += (i - start + 1) / 2;
                i--;
            }
            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 50460
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
A = list(map(int,input().split()))
dp0 = [0] * (n+11)
dp1 = [0] * (n+11)
dp2 = [0] * (n+11)
for i,ai in enumerate(A):
  dp2[i+11] = (max(dp0[i+7] + ai, dp1[i+8] + ai, dp2[i+9] + ai) if i >= 2 else 0)
  dp1[i+11] = (max(dp0[i+8] + ai, dp1[i+9] + ai) if i >= 1 else 0)
  dp0[i+11] = dp0[i+9] + ai 
if n % 2 == 0:
  print(max(dp0[n + 9], dp1[n + 10]))
else:
  print(max(dp0[n + 8], dp1[n + 9], dp2[n + 10]))

# debug
# print(dp0,dp1,dp2,sep="\n")




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

int main(){
    string s;
    cin >> s;
    string t;
    cin >> t;
    int ans = 0;
    int n = s.size();
    for(int i = 0; i < n; i++){
        if(s[i] != t[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main(){
    int n;
    vector<int> a;
    cin >> n;
    for(int i=0;i<n;i++){
        int tmp;
        cin >> tmp;
        a.push_back(tmp);
    }

    sort(a.begin(),a.end());

    bool check=true;

    for(int i=0;i<n-1;i++){
        if(a[i]==a[i+1]){
            check=false;
            break;
        }
    }

    if(check==true){
        cout << "YES";
    }else{
        cout << "NO";
    }

    return 0;
}


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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair


int dfs(int now, int par, vii &G) {
  int g = 0;
  rep (i, G[now].size()) {
    if (G[now][i] == par) continue;
    g ^= (dfs(G[now][i], now, G) + 1);
  }
  return g;
}

int main() {
  int n;
  cin >> n;
  vii G(n);
  rep (i, n - 1) {
    int u, v;
    cin >> u >> v;
    u--; v--;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  if (dfs(0, -1, G) == 0) {
    cout << "Bob" << endl;
  }
  else {
    cout << "Alice" << endl;
  }
}
  


Measured memory_bytes: 13568
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

long long gcd(long long a, long long b) {
    if (a < b) return gcd(b, a);

    long long r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}


int main() {
    long long a, b; cin >> a >> b;

    cout << lcm(a, b) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int N, M, X, Y; cin >> N >> M >> X >> Y;
    int x_num = 0, y_num = 10e5;
    for (int i = 0; i < N; i++) {
        int tmp; cin >> tmp;
        if (i == 0) x_num = tmp;
        else x_num = max(x_num, tmp);
    }
    for (int i = 0; i < M; i++) {
        int tmp; cin >> tmp;
        if (i == 0) y_num = tmp;
        else y_num = min(y_num, tmp);
    }
    for (int i = X + 1; i <= Y; i++) {
        if (i <= y_num && i > x_num) {
            printf("%s\n", "No War");
            return 0;
        }
    }
    printf("%s\n", "War");
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  
  int buka[N+1] = {};
  
  for(int i=1;i<N;i++){
    int A;
    cin >> A;
    buka[A]++;
  }
  
  for(int i=1;i<N+1;i++){
    cout << buka[i] << endl;
  }
}

Measured memory_bytes: 4368
#include<iostream>
using namespace std;
int main(){

	int a,N,sum=0,b=0;

	cin>>N;

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

		if(a==1){
			sum=sum+1;
			if(sum>b){
				b=sum;
			}
		}
		else{
			sum=0;
		}
	}
	cout<<b+1<<endl;

	return 0;
}



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

int solve(vector<int> h, int l, int r, int min_h){
	if(l + 1 == r) return h[l] - min_h;
	else{
		vector<int>::iterator minIt = min_element(h.begin() + l, h.begin() + r);
		size_t min_i(distance(h.begin(), minIt));
		if(min_i == l){
			return solve(h, l+1, r, h[l]) + h[l] - min_h;
		}else if(min_i == r-1){
			return solve(h, l, r-1, h[min_i]) + h[min_i] - min_h;
		}else{
			return solve(h, l, min_i , h[min_i]) + solve(h, min_i + 1, r, h[min_i]) + h[min_i] - min_h;
		}
	}
}

int main(){
	cin >> N;
	vector<int> h(N);
	for(int i(0);i<N;++i) cin >> h[i];
	cout << solve(h, 0, N, 0) << endl;
	return 0;
}

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

int main() {
  int N,M;
  cin >> N >> M;
  vector<pair<int,int>> V(M);
  for(int i=0;i<M;i++){
    int a,b;
    cin >> a >> b;
    V[i] = make_pair(b,a);
  }
  sort(V.begin(),V.end());
  
  int p=1,ans=0;
  for(int i=0;i<M;i++){
    if(V[i].second<p) continue;
    ans++;
    p = V[i].first;
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define rgi register int
#define rgl register ll
#define maxn 1000005
#define mod 1000000003
#define inf 1000000007
namespace lib
{
	using namespace std;
	
	
	class fastio
	{
		private:
			#define _NUMLEN 111
			char _num[_NUMLEN],_ch;
			int _f,_head;
			bool _useSTD;
		public:
			inline void ioSTD()
			{
				_useSTD=1;
				ios::sync_with_stdio(false);
				cin.tie(0),cout.tie(0);
			}
			inline void gc(char & _c)
			{
				if(_useSTD)cin>>_c;
				else _c=getchar();
			}
			inline void pc(char _c)
			{
				if(_useSTD)cout<<_c;
				else putchar(_c);
			}
			template<typename _T> inline fastio & operator - (_T & _x)
			{
				if(_useSTD)cin>>_x;
				else
				{
					_x=0;
					while(!isdigit(_ch)) _f|=_ch=='-',gc(_ch);
					while(isdigit(_ch)) _x=(_x<<1)+(_x<<3)+(_ch^48),gc(_ch);
					_f&&(_x=-_x,_f=0);
				}
				return *this; 
			}
			template<typename _T> inline fastio & operator + (_T _x)
			{
				if(_useSTD)cin>>_x;
				else
				{
					_T _k;
					if(_x==0) {pc('0'),pc(' ');return *this;}
					if(_x<0) pc('-'),_x=-_x;
					while(_x>0) _k=_x/10,++_head,_num[_head]=(_x-(_k<<1)-(_k<<3))^48,_x=_k;
					while(_head>0) pc(_num[_head]),--_head;
					pc(' ');
				}
				return *this; 
			}
			template<typename _T> inline fastio & operator >> (_T & _x) {cin>>_x;return *this;}
			template<typename _T> inline fastio & operator << (_T _x) {cout<<_x;return *this;}
			#define endln pc('\n')
		fastio() {_f=0,_head=0,_useSTD=0,_ch=' ';}
	}io;
	
	
	inline void fileio(string _r,string _w)
	{
		if(_r[0]!='-')freopen(_r.c_str(),"r",stdin);
		if(_w[0]!='-')freopen(_w.c_str(),"w",stdout);
	}
}using namespace lib;

int a[4];
signed main()
{
//	fileio("tt.in","tt.out");
//	io.ioSTD();
	int b,c;
	io-b-c;
	a[b]=1,a[c]=1;
	for(rgi i=1;i<=3;++i)
		if(!a[i])io+i;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

void testsort(int a[], int l, int r);

int main(void)
{
  int n,k,ans=0;
  int a[60] = {0};

  scanf("%d %d", &n, &k);

  for (int i=0; i < n; i++) {scanf("%d", &a[i]);}
  testsort(a, 0, n);
  for (int i=0; i < k; i++) {ans += a[i];}
     
     printf("%d\n", ans);


    return 0;
  }

//ソート大きい順に並べる
void testsort(int a[], int l, int r)
{
  for (int i = l+1; i < r; i++) {
    for (int j = i; j > l; j--) {
      if (a[j] > a[j-1]) { int t = a[j]; a[j] = a[j-1]; a[j-1] = t;}
    }
  }
}




Measured memory_bytes: 128
local ior = io.read
local n = ior("*n")

local function get2(x)
  local z = 0
  while(x % 2 == 0) do
    x = x // 2
    z = z + 1
  end
  return z
end

local ret = get2(ior("*n"))

for i = 2, n do
  ret = math.min(ret, get2(ior("*n")))
end
print(ret)


Measured memory_bytes: 508
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,sum;
int a[1000001];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);sum+=a[i];
	}
	sort(a+1,a+1+n);
	sum=sum-a[n]/2;
	cout<<sum; 
	return 0;
 } 

Measured memory_bytes: 384
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> //required
//#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define lb long double
#define pb push_back
#define loop(i,start,n) for(ll i=start;i<n;i++)
#define rloop(i,n,start)for(ll i=n;i>=start;i--)
#define mod 1000000007
#define endl "\n"
#define INF     1e15
#define NEG_INF -1e15
#define pll pair<ll,ll>
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
//template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
//using namespace __gnu_pbds;

int main(){
	IOS;
	ll n;
	cin >> n;
	ll a[n + 1];
	loop(i, 1, n + 1)
		cin >> a[i];
	ll total = 0;
	for(int i = 1; i <= n; i += 2){
		total = total xor (a[i] xor a[i + 1]);
	}

	loop(i, 1, n + 1)
		cout << (total xor a[i]) << " " ;
}

Measured memory_bytes: 5184
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int a[100],b[100],n,c=100;
    string s;
    cin>>s;
    n=s.length();
    for(int i=0;i<n;i++){
        a[i]=s[i]-'a';
        //cout<<a[i]<<endl;
    }
    
    for(int i=0;i<26;i++){
        bool hoge=false;
        for(int j=0;j<n;j++){
            //cout<<i<<","<<j<<","<<a[j]<<","<<hoge<<endl;
            if(a[j]==i){
                hoge=true;
                j=n;
            }
            
        }
        if(hoge){
            for(int j=0;j<n;j++){
                b[j]=a[j];
            }
            for(int j=0;j<n;j++){
                bool fuga=false;
                for(int k=0;k<n-j;k++){
                    if(b[k]!=i){
                        k=n;
                        fuga=true;
                    }
                }
                
                if(fuga){
                    for(int k=0;k<n-1;k++){
                        if(b[k+1]==i){
                            b[k]=i;
                        }
                    }
                }else{
                    c=min(c,j);
                    j=100;
                }
            }
        }
    }
    cout<<c<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a,b;
	
	scanf("%d %d",&a,&b);
	if(a==b)
	printf("a == b\n");
	else if(a<b)
	printf("a < b\n");
	else printf("a > b\n");
	
	return 0;
}

Measured memory_bytes: 2576
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    int h, w, a, b;
    int MOD = 1000000007;

    public static void main(String args[]) {
        new Main().run();
    }

    void run() {
        FastReader sc = new FastReader();
        h = sc.nextInt();
        w = sc.nextInt();
        a = sc.nextInt();
        b = sc.nextInt();
        solve();
    }

    void solve() {
        Combination c = new Combination(h + w, MOD);
        long ans = 0;
        for (int i = 0; i < h - a; i++) {
            ans += c.comb(i + b - 1, b - 1) * c.comb(h - i + w - b - 2, w - b - 1) % MOD;
            ans %= MOD;
        }
        System.out.println(ans);
    }

    class Combination {
        long mod;
        int[] facts;
        int[] invs;
        int[] invFacts;

        public Combination(int max, int mod) {
            this.mod = mod;
            facts = new int[max + 2];
            invs = new int[max + 2];
            invFacts = new int[max + 2];
            invs[1] = 1;
            for (int i = 2; i <= max + 1; i++) {
                invs[i] = (int)((long)invs[mod % i] * (mod - mod / i) % mod);
            }
            facts[0] = 1;
            invFacts[0] = 1;
            for (int i = 1; i <= max + 1; i++) {
                facts[i] = (int)(facts[i - 1] * (long)i % mod);
                invFacts[i] = (int)(invFacts[i - 1] * (long)invs[i] % mod);
            }
        }

        long comb (int n, int k) {
            if (k < 0 || k > n) return 0;
            return facts[n] * (long)invFacts[k] % mod * (long)invFacts[n - k] % mod;
        }

        long combRep(int n, int k) {
            return comb(n + k - 1, k);

        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 23508
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n) ; i++)
#define rrep(i,n) for(int i = n-1; i >= 0 ; i--)
typedef long long ll;
constexpr auto INFI = 2147483647;
const ll INFL = 9223372036854775807;

int main(){

  int n ;
  cin >> n;
  n = n % 10;
  string ans;
  if (n == 3) {
    ans = "bon";
  } else if (n == 0 || n == 1 || n == 6 || n == 8) {
    ans = "pon";
  } else {
    ans = "hon";
  }

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

Measured memory_bytes: 3596
/* Arpit Pandey*/ 

#include <bits/stdc++.h>
#include <stdlib.h>
#include <stdint.h>
using namespace std;
 
#define int long long
#define pb push_back
#define in insert
#define F first
#define S second
#define mod 1000000007
#define endl '\n'
#define test(x) int x;cin>>x; while(x-->0)
#define memset(a,b) memset(a,b,sizeof(a))
#define debug(x) cout << "[ " << #x  << " : " << x << " ]" << endl;
 
void fast_io()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("error.txt", "w", stderr);
    freopen("output.txt", "w", stdout);
#endif
}
void sol()
{
  int n,d,x,y,ans=0,r;cin>>n>>d;
  for (int i = 0; i < n; ++i)
  {
    cin>>x>>y;
    double r=sqrt(x*x+y*y);
    if(r<=d*1.0)
      {
        ans++; 
        //cout<<x<<" "<<y<<" "<<r<<endl;
      }
  }
  cout<<ans;
}

int32_t main()
{
    fast_io();
    //test(t)
    sol();
    
    //cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
    //cerr << sizeof(dp)*(1e-6) << " megabytes\n";
    return 0;
}


Measured memory_bytes: 3640
from collections import defaultdict
n = int(input())
d = defaultdict(int)
for i in range(1, n+1):
  s = str(i)
  d[(s[0], s[-1])]+=1
ans = 0
x = list(d.keys())
for i in x:
    ans+=d[i[::-1]]*d[i]
print(ans)


Measured memory_bytes: 3436
#include <iostream>

using namespace std;

int f(int H, int W, int h, int w) {
    return (H - h) * (W - w);
}

int main() {

    int H, W, h, w;
    cin >> H >> W >> h >> w;

    int result = f(H, W, h, w);
    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int 
#define pi pair<int,int> 
#define pb push_back
#define INF INT_MAX 
#define mod 1000000007ll
#define fi first
#define se second
#define f(i,p,q) for(int i=p;i<q;i++)
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pii(a) printf("%d\n",a)
#define psi(a) printf(" %d",a)
#define poi(a) printf("%d",a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld\n",a)
#define Nline() printf("\n")
#define sstr(str) scanf("%s",str)
#define pstr(str) printf("%s\n",str)
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vvi vector<vi>
#define all(v) (v).begin(),(v).end()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define VI(a,n) vi a(n); rep(i,n)cin>>a[i];
#define sq(n) (n)*(n)
#define iso ios::sync_with_stdio(false); cin.tie(0);cout.tie(NULL);
signed main()
{    iso;
     int n;cin>>n;
	 int ar[n];
	 f(i,0,n)cin>>ar[i];
	 int dp[n+5][2];
	 dp[0][0]=0;
	 dp[0][1]=0;
	 dp[1][0]=ar[0];
	 dp[1][1]=ar[1];
	 for(int i=2;i<n;i++){
	 	if((i&1)==0){
	 		dp[i][1]=ar[i]+max(dp[i-2][1],dp[i-2][0]);
	 		dp[i][0]=max({dp[i-1][0],dp[i-1][1]});
		 }
		 else{
		 	dp[i][1]=max({dp[i-1][0]+ar[i],dp[i-2][1]+ar[i],dp[i-2][0]+ar[i]});
		 	dp[i][0]=(dp[i-2][0]+ar[i-1]);
		 }
	 }
	/* cout<<" ";
	 for(int i=1;i<n;i++){
	 	cout<<dp[i][1]<<" ";
	 }
	 cout<<"\n";cout<<" ";
	 for(int i=1;i<n;i++){
	 	cout<<dp[i][0]<<" ";
	 }
	 cout<<endl;*/
	 //cout<<dp[n-1][1]<<" "<<dp[n-1][0];
	 cout<<max(dp[n-1][1],dp[n-1][0]); 
}

Measured memory_bytes: 8204
/*
 * a.cc:
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
#include<iomanip>

using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main(){
  int A,B;
  cin>>A>>B;

  int sum=1;
  int num=0;

  while (sum<B){
    
    sum+=A-1;
    num++;



  }
  cout<<num<<endl;
  return 0;




}


Measured memory_bytes: 3628
#include <iostream>  // cin,cout
#include <stdio.h>   // printf,scanf (standard input/output)
#include <cmath>     // abs(x),pow(x,2)
#include <string>
#include <string.h>  // strlen, strcmp
#include <algorithm> // min,max, sort(v.begin(),v.end())
#include <vector>
#include <time.h>
using namespace std;


void Print_vec (vector<char> v) {
    for (int i=0;i<v.size();i++) cout << v[i] << " " ; cout << endl;
}


int main() {
    
//    char E[] = "EDCBA";
//    sort(E,E+5);
//    cout << E[0] << E[1] << endl;
    
    char s[100];
    char t[100];
    cin >> s;
    cin >> t;
    
    string temp = s;
    string temp2 = t;
    
    sort(s,s+temp.length());
    sort(t,t+temp2.length(),greater<int>());
    
    temp = s;
    temp2 = t;
    //cout << temp2 << endl;
    
    if (temp<temp2) cout << "Yes" << endl;
    else cout << "No" << endl;

    
    return 0;
}


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

int main() {
    int a, b;
    cin >> a >> b;
    int count = 0;
    int ans = 1;
    for (int i = 0; b > ans; i++)
    {
        ans += (a - 1);
        count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3572
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct node{
  int key;
  struct node *p;
  struct node *l;
  struct node *r;
} ;

int flag = 0;

typedef struct node Node;

Node *root, *NIL;

void Insert(int);
void Inorder(Node *);
void Preorder(Node *);
void Find(Node *, int);

int main(){
  int n,i,a;
  char in[7],insert[7] = "insert",find[5] = "find",print[6] = "print";
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%s",in);
    (void)getchar();
    if(strcmp(in, insert) == 0) {
      scanf(" %d",&a);
      Insert(a);
    }
    else if(strcmp(find, in) == 0) {
      scanf("%d",&a);
      Find(root,a);
      if(flag == 1){
        printf("yes\n");
      }
      else{
        printf("no\n");
      }
      flag = 0;
    }
    else  {
      Inorder(root);
      printf("\n");
      Preorder(root);
      printf("\n");
    }
  }
  return 0;
}
void Insert(int a) {
  Node *x = NIL;
  Node *y = root;
  Node *z;

  z = malloc(sizeof(Node));
  z -> key = a;
  z -> l = NIL;
  z -> r = NIL;
  while(y != NIL) {
    x = y;
    if(z -> key < y -> key){
      y = y -> l;
    }
    else{
      y = y -> r;
    }
  }

  z -> p = x;
  if(x == NIL){
    root = z;
  }
  else {
    if(z -> key < x -> key){
      x -> l = z;
    }
    else{
      x -> r = z;
    }
  }
}

void Inorder(Node *u) {
  if(u == NIL){
    return;
  }
  else {
    Inorder(u -> l);
    printf(" %d", u->key);
    Inorder(u -> r);
  }
}

void Preorder(Node *b) {
  if(b == NIL){
    return;
  }
  else {
    printf(" %d", b->key);
    Preorder(b -> l);
    Preorder(b -> r);
  }
}
void Find(Node *b, int c) {
    if(b == NIL){
      return;
    }
  else {
    if(b -> key == c) {
      flag = 1;
      return;
    }
  }
    if(b -> key > c) {
      Find(b -> l, c);
      return;
    }
    else {
      Find(b -> r, c);
      return;
    }
}



Measured memory_bytes: 20436
#include <iostream>
#include <string>
using namespace std;
int main() {
  string S,T,x;
  cin>>S>>T;
  bool flag=false;
  for(int i=0;i<S.size();i++){
  x=S[S.size()-1];
  S.pop_back();
  S.insert(0,x);
  if(S==T){
    cout<<"Yes";
    flag=true;
    break;
  }
  }
  if(flag==false){
    cout<<"No";
  }

return 0;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define sz(x) (int)((x).size())
# define F first
# define S second
# define pb push_back
# define ub upper_bound
# define lb lower_bound
# define end(x) prev(x.end());
# define all(x) x.begin(), x.end()
# define pqueue priority_queue
# define mset multiset
# define umap unordered_map
# define Speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
# define rep(i,n) for(int i=0;i<n;++i)
# define forn(i,n) for(int i=1;i<=n;++i)
# define lr(i,l,r) for(int i=l;(l>r?i>=r:i<=r);(l>r?--i:++i))

using namespace std;

template<class T> void umin(T &a, T b) { a = min(a, b); }
template<class T> void umax(T &a, T b) { a = max(a, b); }

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

const int mod = 1e9+7;
const int N = 2e5+5;

void solve(){
	string s,t;
	cin>>s>>t;
	int x=sz(s);
	while(x--){
		if(s==t){
			cout<<"Yes\n";
			return;
		}
		else{
			s=s[sz(s)-1]+s;
			s.pop_back();
		}
	}
	cout<<"No";
}

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

Measured memory_bytes: 3596
k, n = map(int, input().split())
a = list(map(int, input().split()))

sa = [0]*len(a)
for i in range(n-1):
  sa[i] = a[i+1] - a[i]
sa[n-1] = a[0] + k - a[n-1]

print(k-max(sa))


Measured memory_bytes: 78668
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<int, int> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
int n, b;
map<int, int> m;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    int count = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> b;
        if (b / 400 > 7)
        {
            m[8]++;
        }
        else if (m[b / 400] == 0)
        {
            count++;
            m[b / 400] = 1;
        }
        else
        {
            m[b / 400] = 1;
        }
    }
    if (count == 0)
    {
        cout << 1 << "\n";
    }
    else
        cout << count << "\n";
    while (m[8] > 0)
    {
        m[8]--;
        count++;
    }
    cout << count << "\n";
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

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

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

const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const bool debug = 0;

int main() {
	int d, l;
	cin >> d >> l;
	
	cout << d / l + (d % l) << endl;
	return 0;
}

Measured memory_bytes: 3092
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>    
typedef long long ll;
#define rep(i, a, b) for (int i = a; i <= b; ++ i)
using namespace std;
int n, h[100], f[100];
int main() {
    scanf("%d", &n); char ch[100];
    rep(i, 0, 25) h[i] = 100;
    rep(i, 1, n) {
        scanf("%s", ch);
        rep(j, 0, 25) f[j] = 0;
        rep(j, 0, strlen(ch) - 1) ++ f[ch[j] - 'a'];
        rep(j, 0, 25) h[j] = min(h[j], f[j]);
    }
    rep(i, 0, 25) rep(j, 1, h[i]) printf("%c", 'a' + i);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define sar(a,n) {cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl;}

using namespace std;

template<typename S,typename T>auto&operator<<(ostream&o,pair<S,T>p){return o<<"{"<<p.fi<<","<<p.se<<"}";}
template<typename T>auto&operator<<(ostream&o,set<T>s){for(auto&e:s)o<<e<<" ";return o;}
template<typename S,typename T,typename U>
auto&operator<<(ostream&o,priority_queue<S,T,U>q){while(!q.empty())o<<q.top()<<" ",q.pop();return o;}
template<typename K,typename T>auto&operator<<(ostream&o,map<K,T>&m){for(auto&e:m)o<<e<<" ";return o;}
template<typename T>auto&operator<<(ostream&o,vector<T>v){for(auto&e:v)o<<e<<" ";return o;}
void ashow(){cout<<endl;}template<typename T,typename...A>void ashow(T t,A...a){cout<<t<<" ";ashow(a...);}
template<typename S,typename T,typename U>
struct TRI{S fi;T se;U th;TRI(){}TRI(S f,T s,U t):fi(f),se(s),th(t){}
bool operator<(const TRI&_)const{return(fi==_.fi)?((se==_.se)?(th<_.th):(se<_.se)):(fi<_.fi);}};
template<typename S,typename T,typename U>
auto&operator<<(ostream&o,TRI<S,T,U>&t){return o<<"{"<<t.fi<<","<<t.se<<","<<t.th<<"}";}

typedef pair<int, int> P;
typedef pair<ll, ll> pll;
typedef TRI<int, int, int> tri;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef vector<string> vs;

const int MAX_N = 100005;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<pair<int, int> > d;
    for(int i = 0; i < a; ++i){
        int p;
        cin >> p;
        d.emplace_back(p, 0);
    }
    for(int j = 0; j < b; ++j){
        int q;
        cin >> q;
        d.emplace_back(q, 1);
    }
    for(int k = 0; k < c; ++k){
        int r;
        cin >> r;
        d.emplace_back(r, 2);
    }
    sort(d.begin(), d.end(), greater<pair<int, int> >());
    long long ans = 0;
    int red = 0, green = 0, total = 0;
    for(const auto& e : d){
        if(e.second == 0){
            // red
            if(red >= x) continue;
            ++red, ++total;
            ans += e.first;
        }else if(e.second == 1){
            if(green >= y) continue;
            ++green, ++total;
            ans += e.first;
        }else{
            ++total;
            ans += e.first;
        }
        if(total >= x + y) break;
    }
    cout << ans << "\n";
    return 0;
}


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

int main(){
    
    int n;

    cin>>n;
    
    int p[n],sorting[n];
    
    for(int i=0;i<n;i++){
        cin>>p[i];
        sorting[i] = p[i];
    }
    
    sort(sorting, sorting+n);
    
    int pos = -1;
    
    for(int i=0;i<n;i++){
        if(pos != -1 && sorting[i] != p[i]){
            swap(p[pos], p[i]);
            break;
        }
        if(sorting[i] != p[i]) pos = i;
    }

    bool flag = true;

    for(int i=0;i<n;i++){
        if(sorting[i] != p[i]){
            flag = false;
            break;
        }
    }
    
    if(flag) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 1000000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    int n, k; cin >> n >> k;
    int r, s, p; cin >> r >> s >> p;
    string t; cin >> t;
    t += string(k, ' ');
    int ans = 0;
    for (int i = 0; i < k; ++i) {
        int l = 1;
        for (int j = i + k; j < t.size(); j += k) {
            if (t[j] == t[j - k]) {
                ++l;
            }
            else {
                int m = t[j - k] == 'r' ? p
                    : t[j - k] == 's' ? r
                    : s;
                ans += (l + 1) / 2 * m;
                l = 1;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 632
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect
from heapq import heappush, heappop

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n = INT()
S = [input() for _ in range(n)]

dic = defaultdict(lambda: INF)
set_char = set()
for s in S:
	set_char |= set(s)
for s in S:
	cnt_s = Counter(s)
	for char in set_char:
		dic[char] = min(dic[char], cnt_s[char])

ans = ""
for x in sorted(dic.keys()):
	if dic[x] != 0:
		ans += x*dic[x]
print(ans)


Measured memory_bytes: 5148
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;


int main(){

    int N,M;
    cin>>N>>M;
    if(N==M)cout<<"Yes";
    else cout<<"No";

    return 0;
}

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

constexpr long long MOD = 1000000007;
constexpr int MAX_N = 200000 + 1;
long long fact[MAX_N];
void init_fact() {
    fact[0] = 1;
    for(auto i = 1; i < MAX_N; ++i)
        fact[i] = fact[i-1] * i % MOD;
}

long long pow_mod(long long x, long long y, long long mod) {
    auto ret=1ll;
    while (y) {
            if (y % 2)
                ret = ret * x % mod;
            x =  x * x % mod;
            y /= 2;
        }
    return ret;
}

long long n;
long long ret[200001];
long long subtree_size[200001];
vector<vector<int>> edges;
void dfs(int cur, int par) {
    ret[cur] = 1;
    subtree_size[cur] = 1;
    for(auto i = 0; i < edges[cur].size(); ++i)
    {
        auto nxt = edges[cur][i];
        if(nxt == par)
            continue;
        
        dfs(nxt, cur);
        subtree_size[cur] += subtree_size[nxt];
        ret[cur] = ret[cur] * ret[nxt] % MOD;
        ret[cur] = ret[cur] * pow_mod(fact[subtree_size[nxt]], MOD - 2, MOD) % MOD;
    }

    ret[cur] = ret[cur] * fact[subtree_size[cur] - 1] % MOD;
}

void dfs2(int cur, int par) {
    if(par != -1) {
        long long x = ret[par];
        x = x * pow_mod(ret[cur], MOD - 2, MOD) % MOD;
        x = x * fact[subtree_size[cur]] % MOD;
        x = x * pow_mod(fact[n - 1], MOD - 2, MOD) % MOD;
        x = x * fact[n - subtree_size[cur] - 1] % MOD;

        ret[cur] = ret[cur] * x % MOD;
        ret[cur] = ret[cur] * pow_mod(fact[n - subtree_size[cur]], MOD - 2, MOD) % MOD;
        ret[cur] = ret[cur] * pow_mod(fact[subtree_size[cur] - 1], MOD - 2, MOD) % MOD;
        ret[cur] = ret[cur] * fact[n - 1] % MOD;
    }

    for(auto i = 0; i < edges[cur].size(); ++i)
    {
        auto nxt = edges[cur][i];
        if(nxt == par)
            continue;
        
        dfs2(nxt, cur);
    }
}

void solve(int TestCase) {
    init_fact();

    cin >> n;
    edges = vector<vector<int>>(n, vector<int>());
    for(auto i = 0; i < n-1; ++i)
    {
        int u, v;
        cin >> u >> v;
        u--, v--;
        edges[u].push_back(v);
        edges[v].push_back(u);
    }

    dfs(0, -1);
    dfs2(0, -1);
    for(auto i = 0; i < n; ++i)
    {
        cout << ret[i] << endl;
    }
}
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 
    int t = 1;
    //cin >> t;
    for(auto i = 1; i <= t; ++i) {
        //cout << "Case #"<< i << ": ";
        solve(i);
    }
}

Measured memory_bytes: 18676
import collections
N, K, Q = map(int, input().split())
A = [int(input()) - 1 for _ in range(Q)]
c = collections.Counter(A)
# print(c)
for i in range(N):
  nokori = K - (Q - c[i])
#   print(nokori)
  if (nokori <= 0):
    print("No")
  else:
    print("Yes")


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

using uint = unsigned int;

constexpr int64_t INF = static_cast<int64_t>(1) << 60;

int main()
{
	uint N, K;
	cin >> N >> K;
	vector<int64_t> a(N);
	for (int i = 0; i < N; ++i)
	{
		cin >> a[i];
	}

	int64_t min_yen = INF;
	for (int i = 0; i < 1 << N; ++i)
	{
		if (__builtin_popcount(i) != K)
		{
			continue;
		}

		int64_t max_height = a[0];
		int64_t yen = 0;
		for (int j = 1; j < N; ++j)
		{
			if ((i & (1 << j)) != 0)
			{
				if (a[j] <= max_height)
				{
					yen += max_height - a[j] + 1;
					++max_height;
				}
				else
				{
					max_height = a[j];
				}
			}
			else
			{
				if (a[j] > max_height)
				{
					yen = INF;
					break;
				}
			}
		}

		min_yen = min(yen, min_yen);
	}

	cout << min_yen << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
typedef set<int, greater<int>> rset;

int main() {
    int n, k;
    cin >> n >> k;
    vector<vector<int>> cw(k, vector<int>(k,0)), cb(k, vector<int>(k,0));
    rep(i, n){
        int x, y;
        char s;
        cin >> x >> y >> s;
        x %= 2 * k;
        y %= 2 * k;
        if(x / k != y / k){
            if(s == 'W')s = 'B';
            else s = 'W';
        }
        x %= k;
        y %= k;
        if(s == 'W')cw[y][x]++;
        else cb[y][x]++;
    }
    vector<vector<int>> w(k, vector<int>(k, 0)), b(k, vector<int>(k, 0));
    w[0][0] = cw[0][0];
    b[0][0] = cb[0][0];
    rep(x, k)rep(y, k){
        if(x == 0 && y == 0)continue;
        else if(x == 0){
            w[y][x] = w[y-1][x] + cw[y][x];
            b[y][x] = b[y-1][x] + cb[y][x];
        }else if(y == 0){
            w[y][x] = w[y][x-1] + cw[y][x];
            b[y][x] = b[y][x-1] + cb[y][x];
        }else{
            w[y][x] = w[y-1][x] + w[y][x-1] - w[y-1][x-1] + cw[y][x];
            b[y][x] = b[y-1][x] + b[y][x-1] - b[y-1][x-1] + cb[y][x];
        }
    }

    int ans = 0;
    rep(x, k)rep(y, k){
        int sum1 = w[k-1][k-1] - w[k-1][x] - w[y][k-1] + 2 * w[y][x];
        sum1 += b[k-1][x] + b[y][k-1] - 2 * b[y][x];
        int sum2 = b[k-1][k-1] - b[k-1][x] - b[y][k-1] + 2 * b[y][x];
        sum2 += w[k-1][x] + w[y][k-1] - 2 * w[y][x];
        ans = max({ans, sum1, sum2});
    }
    cout << ans << endl;
}

Measured memory_bytes: 16128
#include <bits/stdc++.h>
#define P pair<int,int>
#define All(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
typedef long long ll;
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const ll LINF = 1e18;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b >= c) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256