akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <string>

#include <cmath>
#include <queue>
#include <stack>

using namespace std;

vector<char> alphaBet;

void makeAlphaBet() {
	alphaBet.clear();
	for (int i = 0; i < 26; ++i) {
		alphaBet.push_back('a' + i);
	}
	for (int i = 0; i < 26; ++i) {
		alphaBet.push_back('A' + i);
	}
	for (int i = 0; i < 10; ++i) {
		alphaBet.push_back('0' + i);
	}
	// for (int i = 0; i < 5; ++i) {
	// 	alphaBet.push_back('0' + i);
	// }
}

vector<string> f;
const int L = 128;
int totalL = 0;
int queryN = 0;
int maxQueryN = 850;

int makeQuery(string s) {
	cout << "? " << s << endl;
	int ans;
	cin >> ans;
	queryN += 1; 
	// if (queryN >= maxQueryN) {
	// 	for (;;);
	// }
	return ans;
}

void makeDecision(string s) {
	cout << "! " << s << endl;
}

void initF() {
	makeAlphaBet();
	int n = alphaBet.size();
	f = vector<string>(n);
	for (int i = 0; i < n; ++i) {
		f[i] = "";
	}
	totalL = 0;
	for (int i = 0; i < n; ++i) {
		string query = "";
		for (int j = 0; j < L; ++j) {
			query.push_back(alphaBet[i]);
		}
		int ans = makeQuery(query);
		f[i] = "";
		if (ans < L) {
			for (int j = 0; j < L - ans; ++j) {
				f[i].push_back(alphaBet[i]);
			}
		}
		totalL += (L - ans);
	}
}

string combine(string a, string b) {
	// cout << "combine " << a << " " << b << endl;
	if (a.length() == 0) {
		return b;
	}
	if (b.length() == 0) {
		return a;
	}
	int curA = 0, curB = 0;
	string res = "", tmp;
	int aL = a.length(), bL = b.length();
	while (curA < aL || curB < bL) {
		if (curA >= aL) {
			res.push_back(b[curB++]);
			continue;
		}
		if (curB >= bL) {
			res.push_back(a[curA++]);
			continue;
		}
		tmp = res + a[curA]; // + b.substr(curB);
		// tmp.push_back(a[curA]);
		// res.push_back(b[curB]);
		tmp += b.substr(curB);
		// for (int i = curB; i < bL; ++i) {
		// 	tmp.push_back(b[curB]);
		// }
		int ans = makeQuery(tmp);
		if (ans + (int)(tmp.size()) == totalL) {
			res.push_back(a[curA++]);
			continue;
		} else {
			res.push_back(b[curB++]);
			continue;
		}
	}
	return res;
}

string getF(int l, int r) {
	if (l == r) {
		return f[l];
	}
	int mid = (l + r) / 2;
	string left = getF(l, mid);
	string right = getF(mid + 1, r);
	return combine(left, right);
}

bool cmp(const string &a, const string &b) {
	return a.length() > b.length();
}

string combineF() {
	while (f.size() > 1) {
		sort(f.begin(), f.end(), cmp);
		if (f.back().empty()) {
			f.pop_back();
			continue;
		}
		int size = f.size();
		string a1 = f[size - 1];
		string a2 = f[size - 2];
		string a = combine(a1, a2);
		f.pop_back(); f.pop_back();
		f.push_back(a);
	}
	return f[0];
}

int main() {
	initF();
	// makeDecision(getF(0, alphaBet.size() - 1));
	string res = combineF();
	cout << "! " << res << "\n";
	// cout << "! " << combineF() << endl;
	// return 0;
}

Measured memory_bytes: 3784
#include<iostream>
#include<vector>
#include<string>
#include<map>

using namespace std;

int main(){
  int N; string S; cin >> N >> S;
  
  int ans = 0;
  
  for(int i = 0; i <= N - 2; i++){
    string X = S.substr(0,i+1);
    string Y = S.substr(i+1, N - i - 1);
    
    map<int,int> mp;
    for(int i = 0; i < (int) X.size(); i++){
      if(mp[X[i] - 'a'] == 0){ mp[X[i] - 'a']++;}}
    
    int cnt = 0;
    
    for(int j = 0; j < (int) Y.size(); j++){
      if(mp[Y[j] - 'a'] == 1){ mp[Y[j] - 'a']--; cnt++;}}
    
    ans = max( cnt, ans);}
  
  cout << ans << endl; return 0;}
        
       
        

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n) for(ll i=0;i<(n);i++)
#define For1(i,n) for(ll i=1;i<(n);i++)
#define MOD 1000000007
ll gcd(ll a,ll b){
    return b?gcd(b,a%b):a;
}
void calc(vector<vector<ll>> &vec){
    For1(i,9){
        ll pw=1;For(j,i)pw*=2;
        for(ll j=pw;j<pw*2;j++){
            for(ll k=0;k<pw;k++){
                vec.at(j).at(k)=i+1;
            }
        }
        for(ll j=pw+1;j<pw*2;j++){
            for(ll k=pw;k<j;k++){
                vec.at(j).at(k)=vec.at(j-pw).at(k-pw);
            }
        }
    }
}
int main(){
    ll n;cin>>n;
    vector<vector<ll>> vec(513,vector<ll> (513));
    vec.at(1).at(0)=1;
    calc(vec);
    For(i,n+1){
        for(ll j=i+1;j<n;j++){
            cout<<vec.at(j).at(i)<<" ";
        }
        cout<<endl;
    }
}


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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 10;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<P> &s, P a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);


void print_line(vector<ll> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}


typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;
const int mod = 1000000007;

// https://onlinejudge.u-aizu.ac.jp/solutions/problem/DSL_2_F/review/3380631/face4/C++14
struct STlazy{
private:
    int n;
    vector<ll> node, lazy;

public:
    STlazy(){
        n = (1<<17)-1;
        node.resize(2*n-1, 0);
        lazy.resize(2*n-1, 0);
    }

    void eval(int k, int l, int r){
        if(lazy[k] == 0)    return;
        node[k] += lazy[k];
        if(r - l > 1){
            lazy[2*k+1] += lazy[k]/2;
            lazy[2*k+2] += lazy[k]/2;
        }
        lazy[k] = 0;
    }

    void add(int a, int b, ll x, int k=0, int l=0, int r=-1){
        if(r < 0)   r = n;
        eval(k, l, r);
        if(r <= a || b <= l)    return;
        if(a <= l && r <= b){
            lazy[k] += (r-l) * x;
            eval(k, l, r);
            return;
        }
        add(a, b, x, 2*k+1, l, (l+r)/2);
        add(a, b, x, 2*k+2, (l+r)/2, r);
        node[k] = node[2*k+1] + node[2*k+2];
    }

    ll query(int a, int b, int k=0, int l=0, int r=-1){
        if(r < 0)   r = n;
        if(r <= a || b <= l)    return 0;
        eval(k, l, r);
        if(a <= l && r <= b)    return node[k];
        ll lx = query(a, b, 2*k+1, l, (l+r)/2);
        ll rx = query(a, b, 2*k+2, (l+r)/2, r);
        return lx + rx;
    }
};

int main() {

    int n, q;
    cin >> n >> q;

    STlazy st;

    rep(i, q) {
        int query;
        cin >> query;

        if (query == 0) {
            int s, t, x;
            cin >> s >> t >> x;
            t++;
            st.add(s, t, x);
        } else if (query == 1) {
            int s, t;
            cin >> s >> t;
            t++;
            cout << st.query(s, t) << endl;
        }

    }

}



Measured memory_bytes: 7092
#include <bits/stdc++.h>
using namespace std;
int res[100100];

int main() {
    int N; cin >> N;
    for(int x=1; x<=100; ++x) {
        for(int y=1; y<=100; ++y) {
            for(int z=1; z<=100; ++z) {
                res[x * x + y * y + z * z + x * y + y * z + z * x] += 1;
            }
        }
    }

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

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

int main() {
    int n, m;
    cin >> n;
    vector<string> s(n);
    rep(i, 0, n) cin >> s[i];
    cin >> m;
    vector<string> t(m);
    rep(i, 0, m) cin >> t[i];

    int ans = 0;
    rep(i, 0, n) {
        int cnt = 0;
        rep(j, 0, n) {
            if (s[i] == s[j]) cnt++;
        }
        rep(j, 0, m) {
            if (s[i] == t[j]) cnt--;
        }
        ans = max(ans, cnt);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3624
#include<stdio.h>

#define A_MIN -1000
#define B_MAX  1000

int main(void)
{

    int a, b;


    scanf("%d %d", &a, &b);

    if(a < A_MIN || b > B_MAX)
    {
        return -1;
    }

    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: 2080
# 2019/08/13

n=int(input())
a=list(map(int,input().split()))

amin=float('inf')
for i in range(n):
    a[i]-=i+1

a.sort()
b=a[n//2]
ans=0
for e in a:
    ans+=abs(e-b)
print(ans)

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 2e5 + 5;

int n, k, l, x, y;
vector<int> e1[N];
vector<int> e2[N];
int id1, id2;
int gp1[N], gp2[N];
map<int, map<int, int>> mp;

void dfs1(int u, int id) {
    for (int v : e1[u]) {
        if (gp1[v] != -1) continue;
        gp1[v] = id;
        dfs1(v, id);
    }
}
void dfs2(int u, int id) {
    for (int v : e2[u]) {
        if (gp2[v] != -1) continue;
        gp2[v] = id;
        dfs2(v, id);
    }
}

int main() {
    memset(gp1, 255, sizeof gp1);
    memset(gp2, 255, sizeof gp2);
    cin >> n >> k >> l;
    for (int i = 0; i < k; ++i) {
        cin >> x >> y;
        e1[x].push_back(y);
        e1[y].push_back(x);
    }
    for (int i = 0; i < l; ++i) {
        cin >> x >> y;
        e2[x].push_back(y);
        e2[y].push_back(x);
    }
    for (int i = 1; i <= n; ++i) {
        if (gp1[i] == -1) {
            gp1[i] = id1;
            dfs1(i, id1++);
        }
    }
    for (int i = 1; i <= n; ++i) {
        if (gp2[i] == -1) {
            gp2[i] = id2;
            dfs2(i, id2++);
        }
    }
    for (int i = 1; i <= n; ++i) {
        ++mp[gp1[i]][gp2[i]];
    }
    for (int i = 1; i <= n; ++i) {
        cout << mp[gp1[i]][gp2[i]] << ' ';
    }
    return 0;
}


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

#include <algorithm>
#include <vector>
using namespace std;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)

typedef long long ll;

int main() {
    int x, n, ans = 0;
    int minabs = INF;
    cin >> x >> n;
    vector<int> A(111);
    if (n == 0) {
        cout << x << endl;
        return 0;
    }

    for (int i = -9; i <= 101; i++) {
        A[i + 9] = i;
    }
    rep(i, n) {
        int a;
        cin >> a;
        A[a + 9] = -1;
    }

    for (int i = -9; i <= 101; i++) {
        if (A[i + 9] == -1) {
            continue;
        }

        int a = abs(A[i + 9] - x);
        if (minabs > a) {
            ans = A[i + 9];
            minabs = a;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <limits>
#include <cmath>

using namespace std;

int main() {
    size_t n;
    cin >> n;
    vector<size_t> a(n, 0);
    for (size_t i = 0; i < n; ++i) {
        cin >> a[i];
    }
    size_t b = 1;
    size_t c = 0;
    for (size_t i = 0; i < n; ++i) {
        if (a[i] == b)
            ++b;
        else
            ++c;
    }
    if (c == a.size())
        cout << -1 << endl;
    else
        cout << c << endl;
    return 0;
}




Measured memory_bytes: 1792
s = input().strip()
a = -1
b = -1
if s[0]==s[1]:
    a = 1
    b = 2
elif len(s)>2 and s[1]==s[2]:
    a = 2
    b = 3
elif len(s)>2 and s[0]==s[2]:
    a = 1
    b = 3
else:
    for i in range(3,len(s)):
        if s[i]==s[i-1]:
            a = i
            b = i+1
            break
        elif s[i]==s[i-2]:
            a = i-1
            b = i+1
            break
print(a,b)

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

#ifdef AZN

#include "Azn.cpp"

#else
#define pln(...)
#endif

using namespace std;

template <int MOD> struct IntMod {
  typedef long long ll;
  int val;

  IntMod()
    : val(0) {
  }

  IntMod(ll x)
    : val((int) (x % MOD)) {
    if (val < 0)
      val += MOD;
  }

  IntMod& operator+=(const IntMod& x) {
    val += x.val;
    if (val >= MOD)
      val -= MOD;
    return *this;
  }

  IntMod operator+(const IntMod& x) const {
    IntMod res(*this);
    return res += x;
  }

  IntMod& operator-=(const IntMod& x) {
    val -= x.val;
    if (val < 0)
      val += MOD;
    return *this;
  }

  IntMod operator-(const IntMod& x) const {
    IntMod res(*this);
    return res -= x;
  }

  IntMod& operator*=(const IntMod& x) {
    val = (int) ((ll) (val) * x.val % MOD);
    return *this;
  }

  IntMod operator*(const IntMod& x) const {
    IntMod res(*this);
    return res *= x;
  }

  IntMod& operator/=(const IntMod& x) {
    return *this *= x.inv();
  }

  IntMod operator/(const IntMod& x) const {
    IntMod res(*this);
    return res /= x;
  }

  IntMod power(long long expon) const {
    IntMod ans, temp(*this);
    ans.val = 1;
    for (; expon > 0; expon >>= 1) {
      if (expon & 1)
        ans *= temp;
      temp *= temp;
    }
    return ans;
  }

  IntMod inv() const {
    return power(MOD - 2);
  }

  friend ostream& operator<<(ostream& out, const IntMod& x) {
    return out << x.val;
  }
};


typedef long long ll;
typedef double dd;
typedef IntMod<1000000007> Int;

Int calc(vector<pair<int, int>>& segs) {
  Int res = 1;
  queue<int> ends;
  for (const auto& seg : segs) {
    while (!ends.empty() && ends.front() < seg.first) {
      ends.pop();
    }
    ends.push(seg.second);
    res *= ends.size();
  }
  /*
  queue<int> starts;
  reverse(segs.begin(), segs.end());
  for (const auto& seg : segs) {
    while (!starts.empty() && starts.front() > seg.second) {
      starts.pop();
    }
    starts.push(seg.first);
    res *= starts.size();
  }*/
  return res;
}

void solve(ll test_num) {
  (void) test_num;
  int N;
  cin >> N;
  vector<int> a(N), b(N);
  for (int& aa : a)
    cin >> aa;
  for (int& bb : b)
    cin >> bb;
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  vector<pair<int, int>> lef, rig;
  for (int i = 0; i < N; ++i) {
    if (a[i] < b[i])
      lef.push_back({a[i], b[i]});
    else
      rig.push_back({b[i], a[i]});
  }
  Int res_lef = calc(lef);
  Int res_rig = calc(rig);
  Int res = res_lef * res_rig;
  cout << res << endl;
}

void init() {

}

int main() {
#ifdef AZN
  const auto start_time = chrono::system_clock::now();
  freopen("/home/azneye/Documents/Stuff/input.txt", "r", stdin);
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  init();
  ll tests = 1;
  //cin >> tests;
  for (ll test = 1; test <= tests; ++test) {
    solve(test);
  }
#ifdef AZN
  cerr << "Took: " << ((chrono::system_clock::now() - start_time).count() / 1e9) << " s" << endl;
#endif
  return 0;
}

Measured memory_bytes: 2424
#include<stdio.h>
#include<stdlib.h>
int main(void){
	long h;
	long x = 0;
	long y = 1;
	scanf("%ld", &h);
	while(y<=h){
		x += y;
		y *= 2;
	}
	printf("%ld\n", x);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define cs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;

int main(){
    cs
    int n;
    cin>>n;
    queue<string> q;
    q.push("a");
    while(!q.empty()) {
        string t=q.front();int l=t.size();
        if(l==n) break;
        q.pop();char z='a';
        rep(i,l) z=max(z,t[i]);
        for(char c='a';c<=z+1;c++) q.push(t+c);
    }
    while(!q.empty()) {
        cout<<q.front()<<'\n';
        q.pop();
    }
}

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

int main(){
  int N, K, Q;
  cin >> N >> K >> Q;
  vector<int> correct_ans_cnt(N, 0);
  for(int i = 0; i < Q; i++){
    int a;
    cin >> a;
    correct_ans_cnt.at(a - 1)++;
  }
  for(int i = 0; i < N; i++){
    if(Q - correct_ans_cnt.at(i) < K){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
#define sz(x) (int)(x).size()
/* --- */

int main() {
  int n, m, d[4];

  cin >> n >> m;
  for (int i = 0; i < n; i++) d[i] = -1;
  
  int s, c;
  bool valid = true;
  for (int i = 0; i < m; i++) {
    cin >> s >> c;
    if (d[s - 1] != -1 && d[s - 1] != c) {
      valid = false;
      break;
    }
    d[s - 1] = c;
  }
  
  if (n > 1 && d[0] == 0) valid = false;
  if (d[0] == -1) d[0] = (n == 1 ? 0 : 1);
  for (int i = 1; i < n; i++) if (d[i] == -1) d[i] = 0;

  if (valid) {
    for (int i = 0; i < n; i++) cout << d[i];
    cout << '\n';
  }
  else cout << -1 << '\n';
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (long long i=0;i<(n);i++)



using namespace std;
/*
struct Monoid {
    using T = _underlying_set_;
    static  T op(const T& a, const T& b) { return _a_op_b_; }
    static constexpr T id() { return _identity_element_; }
    static T update(const T& a,const T& b) {return _a_update_b_;}
};
*/

template <class Monoid>
class SegTree {
   private:
    using T = typename Monoid::T;
    const size_t n;
    vector<T> t;
    void prop_to(size_t i) { t[i] = Monoid::op(t[2*i+1],t[2*i+2]); }
    // 更新
   public:
    SegTree(size_t m,T val) : n(m){
        t.resize(2*n-1,Monoid::id());
        for (long long i = 0;i < n;i++) t[i+(n-1)] = val;
        for (long long i = (n-2); i >= 0; --i) prop_to(i);
    }

    SegTree(vector<T> &a)
        : n(a.size()){ 
        t.resize(2*n-1,Monoid::id());
        for (long long i = 0;i < n;i++) t[i+(n-1)] = a[i];
        for (long long i = (n-2); i >= 0; --i) prop_to(i);
    }

    T operator[](size_t i) {return t[i+(n-1)];} // 列のi番目を返す

    void update(size_t i, const T& v) { // 列のi番目に対し、vを作用。
        t[i += (n-1)] = Monoid::update(t[i],v);
        while (i && ((--i) >>= 1)) prop_to(i);
        if(n >= 2) prop_to(0);
    }

    T find(size_t l, size_t r) { // [l,r)の範囲で見つける。
        T accl = Monoid::id(), accr = Monoid::id();
        for (l += (n-1), r += (n-1); l < r; l >>= 1, (--r) >>= 1) {
            if(!(l & 1)) accl = Monoid::op(accl, t[l]);
            if(!(r & 1)) accr = Monoid::op(t[r-1], accr);
        }
        return Monoid::op(accl, accr);
    }
};

//モノイド
struct RMQ { //区間の最小値
    using T = int;
    static T op(const T& a, const T& b) { return min(a, b); }         //モノイド演算
    static constexpr T id() {return numeric_limits<T>::max(); } //モノイド単位元
    static T update(const T& a,const T& b) {return b != id() ? b : a;}    //更新関数
};

struct RSQ { //区間の合計
    using T = int;
    static T op(const T&a,const T& b) {return a+b;}
    static constexpr T id() {return 0;}
    static T update(const T& a,const T& b) {return a+b;}
};

int main(void) {
    int n,q,com,x,y;
    cin >> n >> q;
    vector<int> a(n,0);
    SegTree<RSQ> sg(a);
    REP(i,q) {
        cin >> com >> x >> y;
        if (com) cout << sg.find(x,y+1) << endl;
        else sg.update(x,y);
    }
}



Measured memory_bytes: 3864
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <bitset>
using namespace std;

#define int long long


signed main() { 
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    for(int i = 0; i < n; i++) cin >> p[i];

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

    int ans = 0;
    for(int i = 0; i < k; i++) ans += p[i];

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

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

int main(){
  int n,m;cin >> n >> m;
  int s[m],c[m];rep(i,m)cin >> s[i] >> c[i];
  
  for(int i = 0;i < 1000;++i){
    string num = to_string(i);
    int ans = 1;
    rep(j,m){
      string cj = to_string(c[j]);
      if(num[s[j]-1] != cj[0])ans = 0;
    }
    if(ans == 1){
      if(n == 3 && i >= 100 && i < 1000){cout << i << endl;return 0;}
      else if(n == 2 && i >= 10 && i < 100){cout << i << endl;return 0;}
      else if(n == 1 && i >= 0 && i < 10){cout << i << endl;return 0;}
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

const ll INF=(1LL<<50);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}



int main(){
  cout<<setprecision(1000);
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;
  cin>>N;
  vector<ll> A(N);
  REP(N)cin>>A[i];
  REP(N){
    if(A[i]%2==0&&(A[i]%3!=0&&A[i]%5!=0)){
      cout<<"DENIED"<<endl;
      return 0;
    }
  }
  cout<<"APPROVED"<<endl;
  return 0;
}


Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding("utf8");

const reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
});

const lines = [];

reader.on("line", (line) => {
  lines.push(line);
});

reader.on("close", () => {
  const a = Array(26).fill(0);
  lines.forEach((s) => {
    for (let i = 0; i < s.length; i++) {
      a[s[i].toLowerCase().charCodeAt(0) - 97]++;
    }
  });
  for (let i = 0; i < 26; i++) {
    console.log(`${String.fromCharCode(i + 97)} : ${a[i]}`);
  }
});



Measured memory_bytes: 20356
#include "bits/stdc++.h"
using namespace std;

int64_t gcm(int64_t x,int64_t y)
{
  if(x%y==0)
   return y;
  return gcm(y,x%y);
}

int main()
{
  int64_t a,b,c,d,ans;
  ans=1;
  cin>>a>>b;
  c=gcm(a,b);
  d=c;
  if(c!=1)
  {
    for(int64_t i=2;i<=sqrt(d);i++)
    {
      if(c%i==0)
      {
        ans++;
        while(c%i==0)
        {
          c=c/i;
        }
      }
    }
    if(c!=1)
      ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3644
/*
Author: Babin Dutta
*/
 
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define f(i,n) for(int i=0;i<n;i++)
#define ff(i,a,b) for(int i=a;i<=b;i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define inf 1e18
#define mm 998244353
 
ll power(ll x, ll y, ll p)
{
    ll res = 1;  
    x = x % p;  
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1; 
        x = (x*x) % p;  
    }
    return res;
}
ll modInverse(ll A,ll M)
{
    return power(A,M-2,M);
}

const int N = 2e6+10;
ll fact[N], pow25[N];

ll NCR1(ll n, ll k){
	ll nCr = fact[n];
	ll d = (fact[n-k] * fact[k])%mod;
	d = modInverse(d,mod);
	nCr = ((nCr%mod)*(d%mod))%mod;
	return nCr;
}


void solve(){
	ll k; cin>>k;
	string s; cin>>s;
	fact[0] = 1;
	pow25[0] = 1;
	ll n = s.length();
	for(int i=1;i<=n+k+5;i++){
		fact[i] = (fact[i-1]*i)%mod;
		pow25[i] = (pow25[i-1]*25)%mod;
	}
	ll ans = 1ll, tmp = 0ll;
	ans = power(26ll,n+k,mod);
	for(ll i=0;i<n;i++){
		ll z = NCR1(n+k, i);
		z = ((z%mod)*(pow25[n+k-i]%mod))%mod;
		ans = (ans-z+mod)%mod;
	}
	cout<<ans<<endl;
}
 
int main(){
	#ifdef JUDGE
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
    #endif
	boost;
	int t=1; //cin>>t;
	for(int i=1;i<=t;i++) solve();
	return 0;
}

Measured memory_bytes: 35596
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include<cstdio>
#include<bits/stdc++.h>
using namespace std;
using ll =double;

int main (void) {
  ll A,B;
  cin >> A >> B;
  if (A>B) cout <<"GREATER";
  else if(A==B)cout <<"EQUAL";
  else if (A<B) cout <<"LESS";
  else {
    cout << "MISS";
  }
}

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

int main() {
	int a, b, C;
	double S, L, h, d;
	cin >> a >> b >> C;

	d = (acos(-1.0)*C) / 180.0;
	S = a*b*sin(d) / 2.0;
	L = a + b + sqrt(a*a + b*b - 2 * a*b*cos(d));
	h = b*sin(d);

	printf("%1f\n%1f\n%1f\n",S,L,h);

	return 0;
}

Measured memory_bytes: 3532
#include <stdio.h>
int main(void){
	int x,y,a=99,v=0,n;
	scanf("%d",&n);
	for(;n>0;n--){
		scanf("%d %d",&x,&y);
		if(y>v || (y==v && x<a)){a=x;v=y;}
	}
	printf("%d %d\n",a,v);
	return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<cstdio>
#include<string>
#include<stdlib.h>
#include<queue>
#include<stack>
#include<list>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<string.h>
#include<limits.h>
#include<functional>
using namespace std;

signed main()
{
	int a; cin >> a;
	int b[26][50]{};
	for (int c = 0; c < a; c++) {
		string d; cin >> d;
		for (char e : d) {
			b[e - 'a'][c]++;
		}
	}
	string ans;
	for (int i = 0; i < 26; i++) {
		for (int j = 0; j < *min_element(b[i], b[i] + a); j++) {
			ans += char(i + 'a');
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define  rep(i,n) for(li i=0;i<(n);i++)
#define  Rep(i,j,n) for(li i=(j);i<(n);i++)
using namespace std;
typedef long int li;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<li> vli;


int main(int argc,char* argv[])
{
    int H,W,cnt=0;
    char c;
    cin>>H>>W;
    rep(i,H*W){
        cin>>c;
        if(c=='#') cnt++;
    }
    if(cnt==H+W-1) cout<<"Possible\n";
    else cout<<"Impossible\n";


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int N;
  string S;
  cin >> N;
  cin >> S;
  int te = 0;
  int tw = 0;
  int sum_e[N],sum_w[N];
  for(int i = 0;i < N;i++){
    if(S[i] == 'E') te++;
    sum_e[i] = te;
    if(S[i] == 'W') tw++;
    sum_w[i] = tw;
  }
 
  int left,right,min1;
  min1 = 10000000;
  for(int i = 0;i < N;i++){
    left = 0;
    right = 0;
    if(S[i] == 'E'){
      right = sum_e[N-1] - sum_e[i];
      left = sum_w[i];
    } else if(S[i] == 'W'){
      right = sum_e[N-1] - sum_e[i];
      left = sum_w[i] - sum_w[0];
    }
    min1 = min(min1,(left + right));
  }
  cout << min1 << endl;
  return 0;
}

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


int main(void){
	int N,M;
	cin >> N >> M;
	priority_queue <pair<int,int>>q;
	long long ans = 0;
	vector<int> A(N),B(M),C(M);
	for(int i=0;i<N;i++)cin >> A[i];
	for(int i=0;i<M;i++)cin >> B[i] >> C[i];
	for(int i=0;i<N;i++){
		q.push(make_pair(A[i],1));
	}
	for(int i=0;i<M;i++){
		q.push(make_pair(C[i],B[i]));
	}
	for(int i=0;i<N;i++){
		auto p = q.top();
		q.pop();
		ans += p.first;
		if(p.second>1){
			p.second--;
			q.push(p);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long a, b, ans;
    string s;
    cin >> a >> s;
    b=(s[0]-'0')*100+(s[2]-'0')*10+(s[3]-'0');
    ans=a*b/100;
    cout <<ans << endl;

    return 0;
}


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

#define FOR(i,b,e) for(int i=(b); i <= (e); ++i)
#define FORD(i,b,e) for(int i=(b); i >= (e); --i)
#define SIZE(c) (int) (c).size()
#define FORE(i,c) FOR(i,0,SIZE(c)-1)
#define FORDE(i,c) FORD(i,SIZE(c)-1,0)

#define pb push_back
#define mp make_pair
#define st first
#define nd second


using namespace std;

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

typedef vector <int> VI;
typedef vector <bool> VB;
typedef vector <pii> VP;
typedef vector <ll> VL;
typedef vector <pll> VPL;

typedef vector <VI> VVI;
typedef vector <VL> VVL;
typedef vector <VB> VVB;
typedef vector <VP> VVP;

typedef ll dist_t;
const dist_t INF = 1LL << 60;

vector <dist_t> dijkstra(int src, VVP &g) {
    int n = SIZE(g);
    vector <dist_t> dist(n, INF);

    dist[src] = 0;
    
    priority_queue <pair<dist_t,int>> q;
    q.push({0, src});
    
    while (!q.empty()) {
        auto e = q.top(); q.pop();
        int v = e.nd;
        
        if (e.st != -dist[v]) continue;
        
        for (auto &e : g[v]) {
            int u = e.st;
            
            if (dist[u] > dist[v] + e.nd) {
                dist[u] = dist[v] + e.nd;
                q.push({-dist[u], u});
            }
        }
    }
    
    return dist;
}

/*************************************************************************/

int main() {
    ios_base::sync_with_stdio(0);
    
    int k;
    cin >> k;
    
    VVP g(k+1);
    
    FOR(i,1,9) {
        g[k].pb({i % k, i});
    }
    
    FOR(rem,0,k-1) FOR(dig,0,9) {
        int newRem = (10 * rem + dig) % k;
        g[rem].pb({newRem, dig});
    }
    
    auto dist = dijkstra(k, g);
    cout << dist[0];

    return 0;
}

/*************************************************************************/


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

using namespace std;

int main() {
	int n,x,a;
	int ans = 1;
	cin >> n >> x;
	int l[n+1] = {0};
	for (int i = 0;i < n;i++){
		cin >> a;
		l[i+1] = l[i] + a;
		if(l[i+1] <= x){
			ans+=1;
		}
	}
	cout << ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define F first
#define S second
#define pb emplace_back
#define mt make_tuple
#define gcd __gcd
#define PI 3.141592653589
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define llin(a) cin >> a
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llout(a) cout << a << "\n"
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
// Iterator
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define what(x) cerr << #x << " : " << x << "\n"
#define ck printf("continue\n")
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define triple tuple<int,int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define M 1000000007
#define N 100005  //check the limits, man
int cnt[N],ar[N];
int check1(int l,int r)
{
    int a,b,x;
    a=cnt[r];
    if(l>0)
        a-=cnt[l-1];
    b=(r-l+1-a);
    x=min(a,b);
    a-=x,b-=x;
    if(a==0)
        a=2*b;
    a%=3;
    return a;
}
int check2(int l,int r)
{
    int a,b,x;
    a=ar[r];
    if(l>0)
        a-=ar[l-1];
    b=(r-l+1-a);
    x=min(a,b);
    a-=x,b-=x;
    if(a==0)
        a=2*b;
    a%=3;
    return a;
}
int main()
{
    int i,n,x,q,a,b,c,d;
    string str;
    llin(str);
    n=str.size();
    rep(i,n)
    {
        x=str[i]-'A';
        if(x==0)
            cnt[i]++;
    }
    lp(i,1,n)
        cnt[i]+=cnt[i-1];
    llin(str);
    n=str.size();
    rep(i,n)
    {
        x=str[i]-'A';
        if(x==0)
            ar[i]++;
    }
    lp(i,1,n)
        ar[i]+=ar[i-1];
    in(q);
    while(q--)
    {
        in2(a,b);
        in2(c,d);
        if(check1(a-1,b-1)==check2(c-1,d-1))
            yes;
        else
            no;
    }
}








Measured memory_bytes: 1536
#include <bits/stdc++.h> 
#define ll long long
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define F first
#define S second
#define mp make_pair
#define PII pair<int,int>
#define PLL pair<long long,long long>
#define pq priority_queue
#define M map
#define UM unordered_map
#define graph unordered_map<int,vector<int>>
#define graphw unordered_map<int,vector<pair<int,int>>>
#define V vector
#define mod 1000000007
#define inf 3000000000000000007ll
#define P pair
#define Fast ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(), a.rend()
#define sz(a) signed(a.size())
#define FIXED cout << fixed << setprecision(12)
#define L list
#define D deque
#define ld long double
using namespace std;
// pair operation
template<class T, class U>istream& operator>>(istream& in, pair<T,U> &rhs){in >> rhs.first;in >> rhs.second;return in;}
template<class T, class U>ostream& operator<<(ostream& out,const pair<T,U> &rhs){out << rhs.first;out << " ";out << rhs.second;return out;}
template<class T, class U>pair<T,U> operator+(pair<T,U> &a, pair<T,U> &b){return pair<T,U>(a.first+b.first,a.second+b.second);}
template<class T, class U>pair<T,U> operator-(pair<T,U> &a, pair<T,U> &b){return pair<T,U>(a.first-b.first,a.second-b.second);}
// Linear STL
// VECTOR
template<class T>istream& operator>>(istream& in, vector<T> &a){for(auto &i: a)cin >> i;return in;}
template<class T>ostream& operator<<(ostream& out, const vector<T> &a){for(auto &i: a)cout << i << " ";return out;}
// SET
template<class T>ostream& operator<<(ostream& out, const set<T> &a){for(auto &i: a)cout << i << " ";return out;}
template<class T>ostream& operator<<(ostream& out, const unordered_set<T> &a){for(auto &i: a)cout << i << " ";return out;}
template<class T>ostream& operator<<(ostream& out, const multiset<T> &a){for(auto &i: a)cout << i << " ";return out;}
// MAP
template<class T,class U>ostream& operator<<(ostream& out, const map<T,U> &a){for(auto &i: a)cout << "(" << i.first << ", " << i.second << "(\n";return out;}
template<class T,class U>ostream& operator<<(ostream& out, const unordered_map<T,U> &a){for(auto &i: a)cout << "(" << i.first << ", " << i.second << "(\n";return out;}

int main() {
    Fast;
    int t=1;
    // cin>>t;
    while(t--){
        string s;
        cin>>s;
        if(s[2]==s[3] && s[4]==s[5])
        cout<<"Yes";
        else
        cout<<"No";
    }
}


Measured memory_bytes: 256
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

fn main() {
    let mut v: Vec<Vec<isize>> = input_vector2d(3);
    let buf1 = (0, v[0][1] - v[0][0], v[0][2] - v[0][0]);
    let buf2 = (0, v[1][1] - v[1][0], v[1][2] - v[1][0]);
    let buf3 = (0, v[2][1] - v[2][0], v[2][2] - v[2][0]);

    if buf1 == buf2 && buf2 == buf3 {
        println!("Yes");
    } else {
        println!("No");
    }
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) int(a.size())

int gi() {
	int x=0,o=1;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*o;
}

int h1,m1,h2,m2,k;

int main() {
	cin>>h1>>m1>>h2>>m2>>k;
	int len=(h2-h1)*60+m2-m1;
	cout<<max(len-k,0);
	return 0;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

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

	LL N; 
	
	cin >> N;
	// 共通の個数を求めれば良い
	VS vs(N);
	FOR(i, 0, N) {
		cin >> vs[i];
	}
	VVI cnt(26, VI(N, 0));
	FOR(i, 0, N) {
		FOR(j, 0, SZ(vs[i])) {
			cnt[vs[i][j] - 'a'][i]++;
		}
	}
	FOR(i, 0, 26) {
		int val = INF;
		FOR(j,0,N){
			val = min(val, cnt[i][j]);
		}
		string ans = string(val, 'a' + i);
		cout << ans;
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define db(x) cout<<#x<<"="<<x<<endl
template<class T>bool maxi(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool mini(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF2 4000000000000000037
#define INF 1000000007
#define PI (acos(-1))
//#define MOD 1000000007
#define EPS 1e(-9);
using namespace std;
typedef long long ll;

ll MOD;

const int MAX = 3010;
ll fac[MAX], finv[MAX], inv[MAX];
void cinit() { // O(nlogn)
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  reps(i, 2, MAX){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
ll c(int n, int k){ // 二項係数計算
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll modpow(ll a, ll n, ll mod=MOD){ // a^n % MOD の計算
  ll res = 1;
  while (n > 0){
    if(n & 1) res = res * a % mod;
    a = a * a  % mod;
    n >>= 1;
  }
  return res;
}

void Main(){

  ll p; cin>>p;
  MOD=p;

  cinit();

  ll b[p];
  rep(i,p){
    b[i]=0;
  }

  rep(i,p){
    ll a; cin>>a;
    if(a==0) continue;

    b[0]++;
    ll pows[p];
    pows[0]=1;
    reps(j,1,p){
      pows[j]=pows[j-1]*(-i)%MOD;
    }
    rep(j,p){
      //b[j]-=(c(p-1,j)*modpow(-i,(p-1)-j));
      b[j]-=c(p-1,j)*pows[p-1-j];
      b[j]+=MOD*MOD;
      b[j]%=MOD;
    }
  }

  rep(i,p){
    cout<< b[i] <<" ";
  }
  cout<<"\n";

}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#define INF 0x3f3f3f3f
#define lowbit(x) x & -x
#define lson root<<1,l,mid
#define rson root<<1|1,mid+1,r
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int N=2e5+5;
int main(){
#ifdef Mizp
    freopen("in.txt","r",stdin);
#endif
    int n,cnt=0;
    scanf("%d",&n);
    string s;
    cin>>s;
    s=" "+s;
    for(int i=1;i<s.size();i++){
        if(s[i]=='W')
            cnt++;
    }
    int tmp=cnt;
    for(int i=n;i>=n-tmp+1;i--){
        if(s[i]=='W')
            cnt--;
    }
    printf("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 3972
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = std::vector<T>;
using vvi = std::vector<vt<int>>;

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

  std::set<char> set;
  rep(i,s.size())
    set.insert(s[i]);

  if(set.size()==26) {
    std::cout << "None" << '\n';
    return 0;
  }

  for(char check = 'a'; check <= 'z'; check++) {
    if(set.count(check))
      continue;
    else {
      std::cout << check << '\n';
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 512
using System.Linq;
using System.Text;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Security.Cryptography.X509Certificates;
using System.Diagnostics;
using System.Reflection.Metadata;
using System.Threading;

namespace AtCoder
{
    class Program
    {

        struct Point
        {
            public int x;
            public int y;

            public Point(int x, int y)
            {

                this.x = x;
                this.y = y;

            }

        }


        const int BiggestMod = 1000000007;

        public static void Main()
        {

            Console.ReadLine();
            var data = Console.ReadLine().Select(x => x == 'R').ToArray();
            var numR = 0;
            var numW = 0;
            var compare = new int[2] { 0, 0 };

            foreach (var load in data)
                if (load)
                    numR++;
                else
                    numW++;

            for (int i = 0; i < numR; i++)
                if (!data[i])
                    compare[0]++;

            for (int i = numR; i < data.Length; i++)
                if (data[i])
                    compare[1]++;

            Console.WriteLine(Math.Max(compare[0], compare[1]));

        }

    }

}

Measured memory_bytes: 27900
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.HashSet;
import java.util.NoSuchElementException;

public class Main {

	final long MOD = (long) 1e9 + 7;

	void run() {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		char[] cs = sc.next().toCharArray();
		for (int i = 0; i < cs.length; ++i) {
			int num = (int) (cs[i] - 'A');
			num = (num + N) % 26;
			System.out.print((char) ('A' + num));
		}
		System.out.println();
	}

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

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

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

Measured memory_bytes: 23380
//Coded by Dy.
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
typedef long long ll;
#define re register
const int Maxn = 2e5 + 10;
int n;
ll ans, m;
ll a[Maxn], b[Maxn];
inline bool cmp(ll x, ll y) {
	return x > y;
}
inline int check(ll now) {
	ll num = 0;
	for(re int i = 1; i <= n; ++i) {
		ll tem = a[i] * b[i];
		if(tem > now)
//			return 1;
			num += a[i] - now / b[i];
		if(num > m)
			return 0;
	}
	if(num > m)
		return 0;
	return 1;
}
int main() {
	scanf("%d%lld", &n, &m);
	for(re int i = 1; i <= n; ++i)
		scanf("%lld", &a[i]);
	for(re int i = 1; i <= n; ++i)
		scanf("%lld", &b[i]);
	std :: sort(a + 1, a + 1 + n, cmp);
	std :: sort(b + 1, b + 1 + n, cmp);
	ll l = 0, r = a[1] * b[1];
	while(l <= r) {
		ll mid = l + r >> 1;
		if(check(mid))
			ans = mid, r = mid - 1;
		else
			l = mid + 1;
	}
	std :: reverse(b + 1, b + 1 + n);
	l = 0, r = a[1] * b[n];
	ll lst_ans = ans;
	while(l <= r) {
		ll mid = l + r >> 1;
		if(check(mid))
			ans = mid, r = mid - 1;
		else
			l = mid + 1;
	}
	printf("%lld\n", std :: min(lst_ans, ans));
	return 0;
}

Measured memory_bytes: 3328