akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <unordered_map>
#include <queue>
using namespace std;

int main(){
    int n;
    cin >> n;
    string s;
    unordered_map<string, int> m;
    int ma = 0;
    for(int i = 0; i < n; i++){
        cin >> s;
        if(m.count(s)) m[s]++;
        else m[s] = 1;
    }
    for(auto& i : m){
        if(i.second > ma) ma = i.second;
    }
    vector<string> x;
    for(auto& i : m){
        if(i.second == ma) x.push_back(i.first);
    }
    sort(x.begin(), x.end());
    for(auto& i : x){
        cout << i << '\n';
    }
}


Measured memory_bytes: 26692
#include <bits/stdc++.h>
#define pb push_back
#define IOS                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define ll long long int
#define ld long double
#define el '\n'
#define PI (ld)3.141592653589793238462643383279502884197169399375105820974944
#define inf (ll)1000000000
#define mod (ll)1000000007
#define mod1 (ll)998244353
#define fo(i, n) for (long long i = 0; i < int(n); i++)
#define pll pair<ll, ll>
#define mll map<ll,ll>
#define vli vector<pair<ll,int>>
#define vpl vector<pll>
#define vvl vector<vector<ll> >
#define vvpl vector< vector<pll> >
#define ff first
#define ss second
#define pqueue priority_queue< ll >
#define pdqueue priority_queue< ll,vl ,greater< ll > >
#define mem(a,b) memset(a,b,sizeof(a));
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define sz(a) (ll)a.size()
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define vl vector<ll>
//#define x ff
//#define y ss
#define pt(a) for(auto it:a)cout<<it<<" ";cout<<endl;
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
using namespace std;

double gcd(double a, double b) { return a < 0.01 ? b : gcd(fmod(b, a), a); }

vector<ll> parent, rak;

void make_set(int f){
    fo(i,f+1)parent.pb(i);
    rak.assign(f+1,1);
}

ll find_set(ll v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}

ll union_sets(ll a, ll b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
        if (rak[a] < rak[b])
            swap(a, b);
        parent[b] = a;
        rak[a]+=rak[b];
        return (rak[a]-rak[b])*(rak[b]);
    }
    return 0;
}

long long bpow(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1)
      res = res * a % m;
      a = a * a % m;
      b >>= 1;
  }
  return res;
}
ll extend_gcd(ll a,ll b,ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1,y1;
    ll ans =extend_gcd(b,a%b,x1,y1);
    x=y1;
    y=x1-(a/b)*y1;

    return ans;
}
ll inverse(ll a,ll m){
    ll x,y;
    extend_gcd(m,a,x,y);
    y%=m;
    y+=m;
    y%=m;
    return y;
}

/*const int N = 1000001;
int lp[N+1];
vector<int> pr;
void s(){
for (int i=2; i<=N; ++i) {
        if (lp[i] == 0) {
            lp[i] = i;
            pr.push_back (i);
        }
        for (int j=0; j<(int)pr.size() && pr[j]<=lp[i] && i*pr[j]<=N; ++j)
            lp[i * pr[j]] = pr[j];
    }
}*/


ld kv;
ll t,n,x,y,h,k,z,p,q,w;
string s;
//vvl v;
//vl vis,d;

int main() {
    IOS;
    cin>>x>>y;
    vl v(y,0);
    fo(i,x){
        cin>>t;
        fo(i,t)cin>>k,v[k-1]++;
    }
    fo(i,y)kv+=v[i]==x;
    cout<<kv;
    return 0;
}


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

using namespace std;

typedef long long ll;

int solve(ll n, ll m){
    if(n==1){
        return solve(2,m) == 0;
    }
    ll l = m/2, r = m, cnt = 0, ev = m%2, od = (m+1)%2;
    while(l >= n){
        r = l;
        l >>= 1;
        cnt++;
        if(r%2){
            if(ev == 0){
                od = 1;
                ev = 2;
            }
            else if(ev == 1){
                od = 0;
                ev = 2;
            }
            else{
                od = 0;
                ev = 1;
            }
        }
        else{
            bool used[3]{};
            int pev = ev;
            used[pev] = true;
            used[od] = true;
            for(int i=0;i<3;i++){
                if(!used[i]){
                    ev = i;
                    break;
                }
            }
            fill(used, used+3, false);
            used[pev] = true;
            used[ev] = true;
            for(int i=0;i<3;i++){
                if(!used[i]){
                    od = i;
                    break;
                }
            }
        }
    }
    return (n%2 ? od : ev);
}

int main(){
    ll k, allxor = 0;
    cin >> k;

    for(int i=0;i<k;i++){
        ll n, m;
        cin >> n >> m;
        allxor ^= solve(n, m);
    }
    if(allxor == 0){
        cout << "tubuann" << endl;
    }
    else{
        cout << "mo3tthi" << endl;
    }
    return 0;
}


Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
int selection_sort(vector<int> &v, int size){
  int i,j,swp,count_n;
  int min, min_n;
  bool is_swp;
  count_n = 0;
  for( i=0; i<size; i++){
    for( j=i; j<size; j++){
      if( j == i){
        min = v[j]; min_n = j; is_swp = false;
      }
      else if( min > v[j]){
        min = v[j]; min_n = j; is_swp = true;
      }
    }
    if( is_swp){
      swp = v[i]; v[i] = v[min_n]; v[min_n] = swp;
      count_n++;
    }
  }
  return count_n;
}
int main(){
  int n; cin>>n;
  vector<int> vec(n);
  for(int i=0; i<n; i++){
    cin>>vec[i];
  }
  int count;
  count = selection_sort(vec, n);
  for(int i=0; i<n; i++){
    cout << vec[i];
    if( i != n-1) cout<< ' ';
  }
  cout << endl;
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 3092
#include<stdio.h>
#define MAX 10000

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}



int main(){
  int n,i,j,c=0,key,A[N];
  scanf("%d",&n);
  for(i = 1;i <= n;i++)
    scanf("%d",&A[i]);
 for(i = 1;i <= n;i++){
    key = A[i];    
j = i - 1;
    while(j >=0 && A[j] > key){
      A[j+1] = A[j];
      j--;
    }
  A[j+1] = key;
    trace(A,n);
  }

  return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = (int) 1e9 + 1e6 + 123;
const ll LINF = (ll) 1e18 + 1e9 + 123;

#define rep(i, s, t) for (auto i = s; i < (t); ++i)
#define per(i, s, t) for (auto i = s; i >= (t); --i)
#define sz(x) ((int) (x).size())
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()

template<typename A, typename B> bool mini(A &x, const B &y) {
    if (y < x) {
        x = y;
        return 1;
    }
    return 0;
}

template<typename A, typename B> bool maxi(A &x, const B &y) {
    if (y > x) {
        x = y;
        return 1;
    }
    return 0;
}

void run();

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    run();
    return 0;
}

const int N = (int) 1e5 + 123;

int n, m;
int p[N];
int a[N];
int cnt[N];

int get(int v) {
    return (p[v] == v ? v : (p[v] = get(p[v])));
}

void unite(int u, int v) {
    u = get(u);
    v = get(v);
    p[u] = v;
}

bool used[N];

void run() {
    cin >> n >> m;
    rep(i, 0, n) cin >> a[i], p[i] = i, cnt[i] = 1;
    rep(i, 0, m) {
        int u, v;
        cin >> u >> v;
        unite(u, v);
    }
    
    int k = n - m;
    if (k == 1) {
        cout << "0\n";
        return;
    }
    vector<pair<int, int>> q;
    rep(i, 0, n) q.pb({a[i], get(i)});
    sort(all(q));
    ll ans = 0;
    int ops = k - 2;
    rep(i, 0, n) {
        if (cnt[q[i].second] == 1 && !used[q[i].second]) {
            used[q[i].second] = 1;
            ans += q[i].first;
            continue;
        }
        if (!ops) continue;
        if (cnt[q[i].second] < k - 1) {
            ops--;
            cnt[q[i].second]++;
            ans += q[i].first;
        }
    }
    if (ops) {
        cout << "Impossible\n";
        return;
    }
    cout << ans << "\n";
}


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

using namespace std;

int n, W;
int weight[110], value[110];

int dp[110][10010];



int main()
{
    cin >> n >> W;
    for(int i = 0; i < n; i++)
        cin >> value[i] >> weight[i];

    for(int w = 0; w <= W; w++)
        dp[0][W] = 0;

    for(int i = 0; i < n; i++)
    {
        for(int w = 0; w <= W; ++w)
        {
            if(w >= weight[i]) dp[i + 1][w] = max(dp[i][w - weight[i]] + value[i], dp[i][w]);
            else dp[i + 1][w] = dp[i][w];
        }
    }

    cout << dp[n][W] << endl;
    return 0;
}

Measured memory_bytes: 7016
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    long long n, ans = 0;
    cin >> n;
    vector<long long> a(n+1), b(n);
    for(int i = 0; i < n+1; i++){
        scanf("%d", &a[i]);
    }
    for(int i = 0; i < n; i++){
        scanf("%d", &b[i]);
    }
    for(int i = 0; i < n; i++){
        if(a[i] + a[i+1] <= b[i]){
            ans += (a[i] + a[i+1]);
            a[i+1] = 0;
        }
        else{
            ans += b[i];
            if(a[i] <= b[i]){
                a[i+1] -= (b[i] - a[i]);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<vector>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<string>
 
#define ll long long
using namespace std;
int solve()
{
	ll a;
	double b;
	cin >> a;
	cin >> b;
 	ll c = b*100+0.5;
	
	ll d = a*c;
  	ll res = d/100;
	cout << res << endl;
 
	return 0;
}
int main(){
	solve();
	return 0;
}

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

using ll = long long;
const int INF = INT_MAX;//2147483647
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var)  std::cout<<var<<std::endl
#define PI (acos(-1))
#define rep(i, n)   for(int i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(int i=1, i##_length=(n); i<=i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define pb push_back
inline double isnatural(double a) { return a>=0 && ceil(a)==floor(a); }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/


int main() {

	int n;
	cin >> n;
	vector<int> h(n+1,0);
	repeq(i,n){
		cin >> h[i];
	}

	vector<int> dp(n+1,0);
	dp[2]=abs(h[1]-h[2]);
	for(int i=3;i<=n;i++){
		dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
	}
	p(dp[n]);
	return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/



string S;
//---------------------------------------------------------------------------------------------------
#define yes "YES"
#define no "NO"
string solve() {
    map<char, int> cnt;
    fore(c, S) cnt[c]++;

    vector<char> v;
    rep(i, 0, 3) v.push_back(char('a' + i));
    do {
        char c0 = v[0], c1 = v[1], c2 = v[2];

        if (cnt[c0] == cnt[c1] and cnt[c1] == cnt[c2]) return yes;
        if (cnt[c0] == cnt[c1] + 1 and cnt[c1] + 1 == cnt[c2] + 1) return yes;
        if (cnt[c0] == cnt[c1] and cnt[c1] == cnt[c2] + 1) return yes;
    } while (next_permutation(v.begin(), v.end()));

    return no;
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> S;
    cout << solve() << endl;
}

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

#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pf          push_front
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>

using namespace std;


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

/*int power(int a,int n)
{
    if(n == 1)return a%mod;
    if(n == 0)return 1;
    if(n&1)return ((a%mod)*(power((a*a)%mod,n/2))%mod)%mod;
    return power((a*a)%mod,n/2)%mod;
}*/
//const int md = 998244353;


signed main()
{
    showoff;
    string s;
    cin >> s;
    int ans = 0,pc = 0;
    FOR(i,0,sz(s)){
        if(s[i] == 'C')pc = 0;
        else if(s[i] == 'B'){
            ++i;
            if(i < sz(s) && s[i] == 'C')ans += pc;
            else {pc = 0;--i;}
        }
        else ++pc;
    }
    cout << ans << "\n";
    return 0;
}

//*->dont forget to toggle int->ll
//*->for large size of matrix take int not long long .....

Measured memory_bytes: 720
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

#define nnm(x, y) (((y) + (x) % (y)) % (y))
template<typename T> inline T gcd(T x, T y) { if(x < y) swap(x, y); T mod = x % y; if(mod == 0) return y; return gcd(y, mod); }
template<typename T> inline T lmc(T x, T y) { return x / gcd(x, y) * y; }

int main(int argc, char* argv[])
{
	char s[110];
	scanf("%s", s);
	int l = strlen(s);

	printf("%c%d%c\n", s[0], l - 2, s[l - 1]);

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int a, b;

    cin >> a >> b;

    if(a % 3 == 0) cout << "Possible" << endl;
    else if(b % 3 == 0) cout << "Possible" << endl;
    else if((a + b) % 3 == 0) cout << "Possible" << endl;
    else cout << "Impossible" << endl;

    return 0;
}


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

int main()
{
    string s;
    cin>>s;
    if(s=="SAT")
        cout<<1;
    else if(s=="SUN")
        cout<<7;
    else if(s=="MON")
        cout<<6;
    else if(s=="TUE")
        cout<<5;
    else if(s=="WED")
        cout<<4;
    else if(s=="THU")
        cout<<3;
    else if(s=="FRI")
        cout<<2;

}


Measured memory_bytes: 3588
n = int(input())
for i in range(1, n+1):
    if i % 3 == 0:
        print(' '+str(i), end = '')
    elif i % 10 ==3:
        print(' '+str(i), end = '')
    else:
        x = i
        while x != 0:
            x = x // 10
            if x % 10 == 3:
                print(' '+str(i), end = '')
                break
print('')

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

using namespace std;

const int Nmax = 5005;
typedef long long ll;
const ll inf = 1e18;

ll dp[Nmax][2], dp2[Nmax][2];
int n;


void upd(ll &x, ll y)
{
    if(x > y) x = y;
}

void add_dp(int l, int r, int len, int &nr)
{
    int i, j;

    for(i=0; i<=nr+1; ++i)
        for(j=0; j<2; ++j)
            dp2[i][j] = inf;

    for(i=nr; i>=0; --i)
    {
        /// pun in left
        for(j=0; j<2; ++j)
            upd(dp2[i+1][j], dp[i][j] + (ll) (n/2-i-1) * len + r);

        /// pun in right
        for(j=0; j<2 && i+j <= nr; ++j)
            upd(dp2[i][j], dp[i][j] + (ll) (n/2-(nr-i-j)-1) * len + l);

        upd(dp2[i][1], dp[i][0] + (ll) (n/2) * len);
    }

    for(i=0; i<=nr+1; ++i)
        for(j=0; j<2; ++j)
            dp[i][j] = dp2[i][j];

    ++nr;
}

int main()
{
 //   freopen("input", "r", stdin);
    cin.sync_with_stdio(false); cin.tie(0);


    cin >> n;
    int i, j;
    vector<int> L(n), R(n);

    for(i=0; i<n; ++i) cin >> L[i] >> R[i];

    vector<int> ord(n);

    iota(ord.begin(), ord.end(), 0);

    sort(ord.begin(), ord.end(), [&](int x, int y) { return R[x] + L[x] < R[y] + L[y]; } );

    for(i=0; i<=n/2; ++i)
        for(j=0; j<2; ++j)
            dp[i][j] = inf;

    dp[0][0] = 0;

    int all = 0;
    for(auto it : ord)
        add_dp(L[it], R[it],L[it] + R[it], all);

    cout << dp[n/2][n&1] << '\n';

    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>

int main(void) {
 
  // 入力
  int n,d,result=0;
  scanf("%d %d",&n,&d);

  float tmp1=(n/(d*2.0+1.0));
  int   tmp2=(int)tmp1;
  if(tmp1==tmp2)result=tmp2;
  else          result=tmp2+1;

  printf("%d\n",result);

  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#define MAX 100000007
using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int N,i;
  cin >> N >> i;
  cout << (N-i)+1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<set>
#include<stack>
#include<queue>
#include<map>
#include<cstring>
#include<functional>

using namespace std;

int main()
{
	//freopen("input.txt", "r", stdin);

	int n;

	scanf("%d", &n);

	printf("%d\n", (1000 - n % 1000) % 1000);

	return 0;
}

Measured memory_bytes: 1728
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define yoi cout<<"yo"<<endl;
#define debug(x) cerr << #x << " is " << x << endl;
#define all(x) x.begin(),x.end()
const lli inf=1e18;
const int mod=1e9+7;
int main(){
IOS;
int a,b;
cin>>a>>b;
cout<<max(a-2*b,0)<<endl;
}


Measured memory_bytes: 256
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=100000;
const int MAXLEN=100000;
const int MAXOP=100000;

int n,len,nop;
int op[MAXOP];

int pos[MAXLEN],npos;
int cnt[MAXLEN+1];
int res[MAXLEN];

bool solve() {
	REP(i,len) pos[i]=-1; npos=0;
	REPE(i,len) cnt[i]=0; cnt[0]=n;
	for(int i=nop-1;i>=0;--i) {
		int cur=op[i];
		if(pos[cur]==-1) {
			int p=npos; pos[cur]=npos++;
			assert(cnt[p]>0); --cnt[p],++cnt[p+1];
		} else {
			int p=pos[cur];
			if(cnt[p]>0) --cnt[p],++cnt[p+1];
		}
	}
	REP(i,len) if(pos[i]==-1) pos[i]=npos++;
	REP(i,len) res[pos[i]]=i;
	int need=len-1; while(need>0&&res[need-1]<res[need]) --need;
	//printf("res:"); REP(i,len) printf(" %d",res[i]+1); puts("");
	//printf("cnt:"); REPE(i,len) printf(" %d",cnt[i]); printf(" (need=%d)\n",need);
	REP(i,need) if(cnt[i]>0) return false;
	return true;
}

void run() {
	scanf("%d%d%d",&n,&len,&nop); REP(i,nop) scanf("%d",&op[i]),--op[i];
	printf("%s\n",solve()?"Yes":"No");
}

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


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define N 100010
using namespace std;
int n,t[N],x[N],y[N];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d%d%d",&t[i],&x[i],&y[i]);
	for(int i=1;i<=n;i++)
		if(((abs(x[i]-x[i-1])+abs(y[i]-y[i-1])+t[i]-t[i-1])&1)||(abs(x[i]-x[i-1])+abs(y[i]-y[i-1])>t[i]-t[i-1])) 
			{puts("No");return 0;}
	puts("Yes"); 	
	return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#include<stack>
#include<map>
#include<queue>
#include<set>
#define int long long
using namespace std;
const int INF = 1e10;
const int ZERO = 0;

int comb(int n, int r) {
    if(r > n) {
        return 0;
    }
    if(r * 2 > n) {
        r = n - r;
    }
    if(r == 0) {
        return 1;
    }

    int result = n;
    for(int i = 2;i <= r;i++) {
        result *= (n - i + 1);
        result /= i;
    }
    return result;
}

signed main() {
    int N,A,B;
    cin >> N >> A >> B;
    vector<int> vec(N);
    for(int i = 0;i < N;i++) {
        cin >> vec.at(i);
    }
    sort(vec.begin(),vec.end());
    reverse(vec.begin(),vec.end());
    double ret1 = 0;
    for(int i = 0;i < A;i++) {
        ret1 += vec.at(i);
    }
  	cout << fixed;
    cout << ret1 / A << endl;
    if(vec.at(0) != vec.at(A - 1)) {
        int x = 0;
        int y = 0;
        for(int i = 0;i < A;i++) {
            if(vec.at(A - 1) == vec.at(i)) {
                x++;
                y++;
            }
        }
        for(int i = A;i < N;i++) {
            if(vec.at(A - 1) == vec.at(i)) {
                y++;
            }
        }
        cout << comb(y,x) << endl;
    }
    else {
        int x = 0;
        for(int i = 0;i < N;i++) {
            if(vec.at(0) == vec.at(i)) {
                x++;
            }
        }
        int ret2 = 0;
        for(int i = A;i <= B;i++) {
            ret2 += comb(x,i);
        }
        cout << ret2 << endl;
    }
}

Measured memory_bytes: 256
def ord(N,n):#N,nは正の整数、Nで割り切れる回数
    if n%N!=0:
        return 0
    else:
        return 1+ord(N,n//N)

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

m=0
for i in range(0,N):
    m=m+ord(2,a[i])
print(m)


Measured memory_bytes: 4212
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)     for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = m; i < (int)(n); i++)
#define MOD 1000000007
#define Graph vector<vector<int>>
typedef pair<int, int> PII;
typedef long long int ll;

int main(){
  ll H;
  cin >> H;

  int n_cnt = 0;

  while(H > 1){
    H /= 2;
    n_cnt++;
  }


  ll ans = pow(2,n_cnt+1) - 1;

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


Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{
  int W, H, x, y, r; //W,H=長方形の右上の頂点座標 x,y=円の中心座標 r=円の半径

  scanf("%d %d %d %d %d", &W, &H, &x, &y, &r); //各情報の取得

  if((x+r <= W && y+r <= H) && (x-r >= 0  && y-r >= 0)) //長方形の左辺と下辺がはみ出してない
    printf("Yes\n"); //円が長方形の中に入っている
  else
    printf("No\n"); //円が長方形の中に入っていない

  return 0;

}
    


Measured memory_bytes: 2120
'use strict'


function Main(input) {
  input = input.trim().split(' ').map(s => parseInt(s))
  const a = input[0]
  const b = input[1]
  const c = input[2]

  let flg = false
  if(a === b ) {
    if( b !== c) flg = true
  } else if (b === c) {
    if( b !== a) flg = true
  } else if (c === a) {
    if (b !== a) flg = true
  }

  if(flg) {
    console.log('Yes')
  } else {
    console.log('No')
  }



}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cmath>
#include <string>
#include <string.h>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	int cnt = 0,len;
	string s, t, w;
	cin >> s >> t;
	w = s;
	for (int i = 0; i < s.length(); i++) {
		for (int j = 0; j < s.length() - 1; j++) {
			w.replace(j, 1, s.substr(j + 1, 1));
		}
		w.replace(w.length()-1, 1, s.substr(0, 1));
		s = w;
		if(w==t){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

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

	int n;
	cin >> n;

	int city_id = 1;
	map<string, int> cities;
	map<int, int> score_mapping;
	vector<vector<int> > scores(101);
	string c;
	int s;
	for (int i = 0; i < n; ++i) {
		cin >> c >> s;
		if (cities.count(c)) {
			scores[cities[c]].push_back(s);
		} else {
			cities[c] = city_id;
			scores[city_id].push_back(s);
			++city_id;
		}

		score_mapping[s] = i + 1;
	}

	for (int i = 1; i <= 100; ++i) {
		sort(scores[i].rbegin(), scores[i].rend());
	}

	for (auto it = cities.begin(); it != cities.end(); ++it) {
		int curr_id = it->second;
		for (int i = 0; i < (int) scores[curr_id].size(); ++i) {
			cout << score_mapping[scores[curr_id][i]] << "\n";
		}
	}

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define sc second
#define fr first
#define mk make_pair
#define ll long long
#define ii pair<int,int>
#define mp make_pair
using namespace std;
int n,m;
int memo[300005];
vector < int > v[300005];
int vis[300005];
string s,t;
int solve(int i)
{
    vis[i] = 1;
    int ans = 0;
    for(int j=0;j<v[i].size();j++)
    {
        int u = v[i][j];
        if(!vis[u])
        {
            solve(u);
        }
        ans =max(ans , 1+memo[u]);
    }
    memo[i] = ans;
    return memo[i];
}
int main()
{
   cin>>n>>m;
   for(int i=0;i<m;i++)
   {
       int x,y;
       scanf("%d%d",&x,&y);
       v[x].push_back(y);
   }
   int maxx = 0;
   for(int i=1;i<=n;i++)
   {

       if(!vis[i])
       {
           maxx = max(maxx , solve(i));
       }
   }
   cout<<maxx;
}


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

using namespace std;

int main()
{
    int n,j=0;
    long long x,a=1;
    cin >> n;
    vector<long long> v;
    for(int i=0; i<n; ++i)
    {
        cin >> x;
        v.push_back(x);
    }
    sort(v.begin(),v.end(),greater<int>());
    for(int i=1; i<v.size(); ++i)
    {
        if(v[i]==v[i-1])
        {
            ++j;
            a*=v[i];
            if(j==2)
                break;
            ++i;
        }
    }
    if(j==2)
        cout << a;
    else
        cout << 0;
}




Measured memory_bytes: 1400
/*
 * D.cpp
 *
 *  Created on: 2017/07/01
 *      Author: LitMc
 */

#define MYDEBUG
#include <bits/stdc++.h>

#ifdef MYDEBUG
#define dbp(x) cout<<#x<<": "<<x<<endl
#define dbp2(x,y) cout<<#x<<","<<#y<<": "<<x<<","<<y<<endl
#define dbp3(x,y,z) cout<<#x<<","<<#y<<","<<#z<<": "<<x<<","<<y<<","<<z<<endl
#define dbp4(w,x,y,z) cout<<#w<<","<<#x<<","<<#y<<","<<#z<<": "<<w<<","<<x<<","<<y<<","<<z<<endl
#define ifcin(x) std::ifstream cin(x)
#else
#define dbp(x)
#define dbp2(x,y)
#define dbp3(x,y,z)
#define dbp4(w,x,y,z)
#define ifcin(x)
#endif
#define ll long long
#define ull unsigned long long
#define all(x) x.begin(), x.end()
#define rep(i, from, to) for(int i=from; i<to; ++i)
#define REP(i, from, to) for(int i=from; i<=to; ++i)
#define EPS = 1e-14;
using std::vector;
using std::cout;
using std::cin;
using std::endl;
using std::max;
using std::min;
using std::swap;
using std::string;
using std::fill;
using std::pair;
using std::sort;
using std::reverse;
using std::pair;
using std::greater;
using std::priority_queue;
using std::ostream;
typedef std::complex<int> P;

template<typename T>
ostream& operator<<(ostream& out, const vector<vector<T> >& v) {
  for (size_t i = 0; i < v.size(); ++i) {
    out << v[i] << endl;
  }
  return out;
}

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  out << "[";
  size_t last = v.size() - 1;
  for (size_t i = 0; i < v.size(); ++i) {
    out << v[i];
    if (i != last) {
      out << ",";
    }
  }
  out << "]";
  return out;
}

static const ll MOD = 1000000007;
static const ll MAX_N = 100010;
ll a[MAX_N];
ll c[MAX_N];
ll n;
ll dup, l, r, m;
ll fact[MAX_N];
ll ifact[MAX_N];
ll iv[MAX_N];
ll invn;

void inv_table() {
  iv[1] = 1;
  rep(i,2,MAX_N)
  {
    iv[i] = ((MOD - MOD / i) * iv[MOD % i]) % MOD;
  }
}

ll inv(ll x, ll n) {
  ll sum = 1;
  while (n > 0) {
    if ((n & 1L) == 1L) {
      sum = (sum * x) % MOD;
    }
    x = (x * x) % MOD;
    n = n >> 1L;
  }
  return sum;
}

void factorial() {
  invn = inv(n, MOD - 2);
  fact[0] = 1;
  REP(k,1,n+1)
  {
    fact[k] = (fact[k - 1] * k) % MOD;
  }
  ifact[0] = 1;
  REP(k,1,n+1)
  {
    ifact[k] = (ifact[k - 1] * iv[k]) % MOD;
  }
}

ll nCr(ll n, ll r) {
  if (n < r || r < 0 || n < 0) {
    return 0;
  }
  if (r > n / 2) {
    r = n - r;
  }
  return (((fact[n] * ifact[n - r]) % MOD) * ifact[r]) % MOD;
}

ll adjust(ll N) {
  //左にl個、 右にr個、最低1つ、合わせてN個取る組み合わせ
  if (N == 0) {
    return 1;
  }
  ll L = 0;
  ll R = N - L;
  ll ret = 0;
  while (R >= 0) {
    if (L > l || R > r) {
      L++;
      R = N - L;
      continue;
    }
    ret += (nCr(l, L) * nCr(r, R)) % MOD;
//    dbp3(ret, L, R);
    L++;
    R = N - L;
  }
  return ret;
}

void solve() {
  cin >> n;
  invn = inv(n, MOD - 2);
  inv_table();
  factorial();
  REP(i,1,n+1)
  {
    cin >> a[i];
    c[a[i]]++;
    if (c[a[i]] == 2) {
      dup = a[i];
      r = n + 1 - i;
    }
  }
  REP(i,1,n+1)
  {
    if (c[a[i]] == 2) {
      l = i - 1;
      break;
    }
  }
  REP(i,1,n+1)
  {
    cout << (nCr(n + 1, i) + MOD - nCr(l + r, i - 1)) % MOD << endl;
  }
}

int main() {
  solve();
}



Measured memory_bytes: 5120
#include <iostream>
#include <string>
using namespace std;
int main()
{
bool A[200000];
long long  h[200000];
int n,m;
int x,y;
cin>>n>>m;
for(int i=0;i<=n;i++)
A[i]=true;
for(int i=0;i<n;i++)
cin>>h[i];

for(int i=0;i<m;i++)
{
cin>>x>>y;x--;y--;
if(h[x]>h[y])A[y]=false;
else if(h[y]>h[x])A[x]=false;
else if(h[x]==h[y]){A[x]=false;A[y]=false;}
}
int sum=0;
for(int i=0;i<n;i++)
{
    if(A[i]==true)sum++;
}

cout <<sum;
}

Measured memory_bytes: 4488
m, d = map(int, input().split())
c = 0
for i in range(1, m + 1):
  for j in range(1, d + 1):
    if len(str(j)) == 2 and int(str(j)[0]) >= 2 and int(str(j)[1]) >= 2 and int(str(j)[0]) * int(str(j)[1]) == i:
      c += 1
print(c)

Measured memory_bytes: 3060
using System;

class TakHotels
{
	static void Main(String[] args)
	{
		int N, K, X, Y;

		N = int.Parse(Console.ReadLine());
		K = int.Parse(Console.ReadLine());
		X = int.Parse(Console.ReadLine());
		Y = int.Parse(Console.ReadLine());

		if(N > K)
		{
			Console.WriteLine(K * X + (N-K) * Y);
		}
		else
		{
			Console.WriteLine(N * X);
		}
	}

}


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

struct Edge {
    int to;
    int cost;
};
using Graph = vector<vector<Edge>>;

const int INF = 2e9;
// 深さ優先探索
vector<int> dis;  // 既に見たことがある頂点か記録
bool dfs(const Graph &G, int v) {
    bool flag = true;
    for (auto e : G[v]) {
        if (dis[e.to] == INF) {  // 訪問済みでなければ探索
            dis[e.to] = dis[v] + e.cost;
            flag &= dfs(G, e.to);
        } else {
            if (dis[e.to] != dis[v] + e.cost) {
                //cout << v << " " << e.to << " " << dis[e.to] << " " << dis[v] << " " << e.cost << endl;
                flag = false;
            }
        }
    }
    return flag;
}

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

    int V, E;
    cin >> V >> E;

    Graph G(V);
    for (int i = 0; i < E; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        G[a].push_back({b, c});
        G[b].push_back({a, -c});
    }

    dis.assign(V, INF);  // 初期化
    bool flag = true;
    for (int v = 0; v < V; v++) {
        if (dis[v] == INF) {
            dis[v] = 0;
            flag &= dfs(G, v);
        }
    }
    if (flag) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 12928
N, M = [int(_) for _ in input().split()]

if abs(N - M) > 1:
    print(0)
    exit()

if N > M:
    N, M = M, N
tmp = 1

MOD = 10 ** 9 + 7
for i in range(1, N + 1):
    tmp = (tmp * i) % MOD

if N == M:
    ans = ((tmp ** 2) * 2) % MOD
else:
    ans = (tmp * (tmp * M)) % MOD
print(ans)


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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define int ll

const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define m0(x) memset((x), 0, sizeof((x)))
#define m1(x) memset((x), -1, sizeof((x)))

// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define RALL(x) (x).rbegin(), (x).rend()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())     // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))  //最大値を求める
#define MIN(x) *min_element(ALL(x))  //最小値を求める
#define all(x) (x).begin(), (x).end()

//略記
#define pb emplace_back  // vectorヘの挿入
#define mp make_pair     // pairのコンストラクタ
#define F first          // pairの一つ目の要素
#define S second         // pairの二つ目の要素

#define BITCOUNT __builtin_popcount
#define BITCOUNT_LL(x) __builtin_popcountll(x)

#define perm(c)             \
  sort(all(c));             \
  for (bool c##p = 1; c##p; \
       c##p = next_permutation(all(c)))  //順列 123 132 213 231 312 321

#define BIT(n) (1LL << (n))

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ": " << (A) << std::endl;
#else
#define PRINT(A)
#endif

//入力高速化
struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

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

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

signed main() {
  string A; cin >> A;
  vector<int> charCount(100,0);

  rep(i, A.length()) {
    charCount[A[i] - 'a'] ++;
  }

  int ans = A.length();
  ans = ans*(ans-1)/2;

  rep(i, 50) {
    PRINT(charCount[i])
    PRINT((char)(i+'a'))
    if(charCount[i] != 0){
      ans -= charCount[i]*(charCount[i]-1)/2;
    }
  }
  ans ++;

  cout << ans << endl;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
const long long MOD = 1000000007;

//最大最小の入れ替え
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
//コンビネーション
ll nCr(ll n, ll r) {
    ll ans = 1;
    for (int i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (int i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}
//素因数分解
map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

//切り上げの割り算は(a + b - 1) / bでできる
//時間を意識しろ
//コードテストちゃんとして
//画面とにらめっこするな書け
//WA出すたびにABCは五億円払え
//わからない問題はとばせ
//躊躇なくぐぐれ

//ここから
int main(){
    ll X;
    cin>>X;
    vl a;
    a=divisor(X);
    ll s=a.size();
    rep(i,s){
        for(ll A=0;A<800;A++){
            ll B=A-a.at(i);
            ll res=A*A*A*A*A-B*B*B*B*B;
            if(res==X){
                cout<<A<<" "<<B<<endl;
                return 0;
            }
        }
    }

}


Measured memory_bytes: 3580
def solve():
  N = int(input())
  A = list(map(int, input().split()))
  a = sum(A)
  ans = float('inf')
  s = 0
  for i in range(N-1):
    s += A[i]
    ans = min(abs(a-2*s),ans)
  return ans
print(solve())

Measured memory_bytes: 30676
import sys
from pprint import pprint

def solve(n, m, a, ops):
    a.sort()
    ops.sort(reverse=True)
    # pprint(a)
    # pprint(ops)
    start = 0
    for ope, count in ops:
        i = 0
        for a_i in xrange(start, start+count):
            if a_i >= n:
                break
            if a[a_i] < ope and count > 0:
                count -= 1
                # print a_i, '=>', ope, ' count:', count
                a[a_i] = ope
                i += 1
            else:
                break
        start += i

    print sum(a)

if __name__ == '__main__':

    ops = []
    n, m = map(int, sys.stdin.readline().strip().split(" "))
    a = map(int, sys.stdin.readline().strip().split(" "))
    for _ in range(m):
        b, c = map(int, sys.stdin.readline().strip().split(" "))
        ops.append((c, b))

    solve(n, m, a, ops)

Measured memory_bytes: 21684
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;

fn main() {
    let (n, a, b): (usize, i64, i64) = readln();
    let xs: Vec<i64> = readln();

    let mut res = 0;
    for i in 1..n {
        res += min((xs[i] - xs[i - 1]) * a, b);
    }
    println!("{}", res);
}

#[allow(dead_code)]
fn get_line() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_string()
}

#[allow(dead_code)]
fn get_chars() -> Vec<char> {
    get_line().chars().collect()
}

#[allow(dead_code)]
fn readln<T: Read>() -> T {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    T::read(buf.trim_right())
}

trait Read {
    fn read(s: &str) -> Self;
}

macro_rules! read_impl{
    ($($t:ty)*) => ($(
        impl Read for $t {
            fn read(s: &str) -> $t{
                s.parse().unwrap()
            }
        }
    )*)
}
read_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 }

impl<T: Read> Read for Vec<T> {
    fn read(s: &str) -> Self {
        s.split_whitespace().map(T::read).collect()
    }
}

impl<A: Read, B: Read> Read for (A, B) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]))
    }
}

impl<A: Read, B: Read, C: Read> Read for (A, B, C) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]), C::read(tokens[2]))
    }
}

Measured memory_bytes: 2684
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int main(){

	int r;
	scanf("%d",&r);

	printf("%d\n",3*r*r);

	return 0;
}


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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}

signed main()
{   
    gearup;
    int n;
    string s; cin >> n >> s;
    ll res = 1;
    char pre = s[0];
    rep1(i,s.size()){
        if(s[i] != pre){
            res++;
            pre = s[i];
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define int long long
using namespace std;
int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

signed main(){
    int N;
    cin >> N;
    
    int P[N];
    for(int i=0;i<N;i++){
        cin >> P[i];
    }
    
    int ans = 1;
    int m = P[0];
    for(int i=1;i<N;i++){
        if(m>P[i]) ans++;
        m = min(m,P[i]);
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 1792
import java.util.*;

class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int w = scan.nextInt();
		int h = scan.nextInt();

		int count = 0;
		for(int i = 0; i < w; i++) {
				char[] arr = scan.next().toCharArray();
				for(char k : arr) {
					count += ((k == '#')?1:0);
			}
		}

		System.out.println((w+h-1==count)?"Possible":"Impossible");
	}
}


Measured memory_bytes: 9800
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector<pi> vp;
typedef set<ll> si;
typedef map<string, ll> msi;
#define REP(i,a,b) \
for(ll i=ll(a);i<=ll(b);i++)
#define DEP(i,a,b) \
for(ll i=ll(a);i>=ll(b);i--)
#define TR(c, it) \
for (auto it = (c).begin(); it != (c).end(); it++)
#define mp make_pair
#define pb push_back
#define F first
#define S second

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  
  int T;
  T=1;
  while(T--)
  {
      ll n,i,j,k,l,m;
      char c;
      cin>>c;
      if(c>='A'&&c<='Z')cout<<"A";
      else cout<<"a";
      string s;
  }
  return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std ;
int main(){
    int W,H,x,y;
    cin >> W >> H >> x >>y;
    double Ans = double(W)*double(H) / 2;
    cout << Ans << endl;
    if(2*x==W&&2*y==H)cout << 1 << endl;
    else cout << 0 << endl;

}


Measured memory_bytes: 3796
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n,k;
	cin>>n>>k;
	map<ll,ll>a;
	for(int i=0;i<n;i++){
		ll x,y;
		cin>>x>>y;
		a[x]+=y;
	}
	ll ans=0;
    for(auto itr = a.begin(); itr != a.end(); ++itr) {
        ll val= itr->second ;
        ll key=itr->first;
        if(val<=k){
        	k-=val;
        	ans+=val*key;
        }
        else{
        	ans+=k*key;
        	break;
        }
    }	
    cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 6528
#%%
n = int(input())
s = []
a = 0
b = 0
c = 0
for i in range(n):
    s.append(input())
    if s[i][0] == 'B' and s[i][-1] != 'A':
        b += 1
    if s[i][-1] == 'A' and s[i][0] != 'B':
        a += 1
    if s[i][0] == 'B' and s[i][-1] =='A':
        c += 1

ans = 0
for i in range(n):
    tmp = list(s[i])
    for j in range(len(tmp)-1):
        if tmp[j] == 'A' and tmp[j+1] == 'B':
            ans += 1

if c == 0:
    ans += min(a, b)
elif c != 0 and a+b != 0:
    ans += c + min(a, b)
else:
    ans += c - 1 
print(ans)

Measured memory_bytes: 3700
package main

import (
	"fmt"
	"strings"
)

func main() {
	// Code for B - Cut and Count
	var N int
	fmt.Scanf("%d", &N)

	var S string
	fmt.Scanf("%s", &S)

	var max int = 0
	for i := 1; i < N; i++ {
		X := S[0:i]
		Y := S[i:N]
		count := 0
		for j := 0; j < 26; j++ {
			if strings.Index(X, string('a'+j)) != -1 && strings.Index(Y, string('a'+j)) != -1 {
				count++
			}
		}
		if max < count {
			max = count
		}
	}

	fmt.Println(max)
}


Measured memory_bytes: 1840
mod = 10 ** 9 + 7

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

ans = 0
for i in range(len(format(max(a), 'b'))):
    x = 0
    for j in range(n):
        if a[j] >> i & 1:
            x+=1
    now = x * (n - x) % mod
    for j in range(i):
        now = now * 2 % mod
    ans+=now
    ans%=mod

print(ans)

Measured memory_bytes: 122808
input_num = int(input())

input_line = input().split(" ")
number_line = []
for i in range(0, input_num):
	number_line.append(int(input_line[i]))

number_line.sort()

temp = int(input_num/2)

print(int(number_line[temp]) - int(number_line[temp - 1]))

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

int n;

int main()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
        if (i * 108 / 100 == n) { printf("%d\n", i); return 0; }
    printf(":(\n");
    return 0;
}


Measured memory_bytes: 256