akhauriyash/Code-Regression huggingface dataset:
import math


# class Comb:
#     m_vals = []
#     _mod = 998244353
#
#     def __init__(self, n: int, r: int):
#         m_ls = [(0, 1)] * (r + 1)
#         for i in range(1, r):
#             x = (m_ls[i - 1][0] * self._mod + m_ls[i - 1][1]) * (n - r / r)
#             if x >= self._mod:
#                 m_ls[i] = (int(x // self._mod), int(x % self._mod))
#             else:
#                 m_ls[i] = (0, int(x))
#         self.m_vals = m_ls
#
#     def vv(self, x):
#         return self.m_vals[x][1]

def create_array(n: int, r: int, mod, mod2):
    m_ls = [1] * (r + 1)

    for i, j in zip(range(n, 0, -1), range(1, r + 1)):
        m_ls[j] = (m_ls[j - 1] * i * pow(j, mod2, mod)) % mod
    return m_ls


def main():
    n, m, k = map(int, input().split())

    _mod = 998244353
    _mod2 = 998244351

    # res_x = m * ((m-1) ** (n-1-x)) * comb(n-1, x)
    # x:0, 2, ... , k
    # xをk->0とすると(m-1) ** (n-1-x)は少しずつかけていける

    # com = Comb(n - 1, k)
    comb_ar = create_array(n-1, k, _mod, _mod2)
    _z = (m - 1) ** (n - 1 - k)
    res = m * _z * comb_ar[k]
    res %= _mod

    if k > 0:
        for x in range(1, k + 1):
            _z *= m - 1
            _z %= _mod
            res += m * _z * comb_ar[k - x]
            res %= _mod

    # res %= _mod

    print(res)
    #
    #
    #
    # for x in range(1, k+1):
    #     res += m * (_z * (m-1) ** x) * comb(n-1, x)
    #
    # _a_n = ((m - 1) ** (n - 1 - k)) % _mod
    # _b_n = 1
    # _c_n = 1
    # _d_n = 1
    #
    # _a = [_a_n]
    # _b = [_b_n]
    # # _c = [_c_n]
    # _d = [_d_n]
    # for i in range(1, k + 1):
    #     _a_n *= m - 1
    #     _a_n %= _mod
    #     _a.append(_a_n)
    #     _b_n *= n - i
    #     _b_n %= _mod
    #     _b.append(_b_n)
    #     _c_n *= i
    #     _d_n = (_c_n ** (_mod - 2)) % _mod
    #     _d.append(_d_n)
    #
    # _a.reverse()
    #
    # if k == 0:
    #     res = m * ((m - 1) ** (n - 1))
    #     print(res % _mod)
    # else:
    #     res = (m * ((m - 1) ** (n - 1))) % _mod
    #     for i in range(1, k + 1):
    #         res += (m * _a[i - 1] * _b[i - 1] * _d[i - 1]) % _mod
    #
    #     print(res % _mod)
    #
    # # res_k = m * ((m-1) ** (n-1-k)) * comb(n-1,k)
    # #
    # # for i in range(1, k + 1):
    # #     z_c *= (n-i)
    # #     z_p *= i
    # #     z_c %= _mod
    # #     z_p %= _mod
    # #
    # #     if z_c % z_p == 0:
    # #         comb_ls.append(int(z_c/z_p))
    # #     else:
    # #         for j in range(1, n-1):
    # #             _ = z_c + j * _mod
    # #             if _ % z_p == 0:
    # #                 comb_ls.append(int(_/z_p))
    # #
    # #
    # # comb_ls.reverse()
    # # for i in range(1, k + 1):
    # #     j = k + 1 - i
    # #
    # #     z_before *= (m-1)
    # #     res_x += (m * comb_ls[i-1] * z_before) % 998244353
    # #
    # # print(res_x % _mod)


main()


Measured memory_bytes: 16740
#include <iostream>
using namespace std;
#define N 99999

int main () {
        int n; cin >> n;

        int req[N] = {0, n/2}, sheet[N] = {};
        string gen[2] = {"Male", "Female"}, s;

        // 最初は座席n-1, 0を聞く
        for (int q = 0; q < 2; q++) {
                int i = q?n-1:0;
                cout << i << endl;
                cin >> s;
                if (s == "Vacant") return 0;
                sheet[i] = s==gen[0]?0:1;
        }

        // low ~ high に問題あり
        int low = 0, high = n-1, mid = (low+high)/2;
        // 質問18回
        for (int q = 0; q < 18; q++) {
                cout << mid << endl;
                cin >> s;
                if (s == "Vacant") return 0;
                sheet[mid] = s==gen[0]?0:1;

                // 前半に問題あり
                if ( (!((mid-low)%2) && sheet[mid] != sheet[low])
                                || (mid-low)%2 && sheet[mid] == sheet[low]) {
                        high = mid;
                } else { // 後半に問題あり
                        low = mid;
                }
                mid = (high+low)/2;
        }
        return 0;
}


Measured memory_bytes: 1236
def foo(n):
    if not n % 10:
        return float('inf')
    return n

n = int(input())
s = []
for i in range(n):
    s.append(int(input()))
s.sort(reverse=True, key=foo)
k = sum(s)
p = n - 1
while not k % 10 and s:
    k -= s[-1]
    s.pop()
print(k)

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
const int INF = 1 << 30;
const ll INFll = 1ll << 60;

int main() {
  int n;
  cin >> n;
  vector<int> A(n);
  for (int i = 0; i < n; i++) cin >> A[i];

  int ans = 0;
  int target = 1;
  for (int i = 0; i < n; i++) {
    if (A[i] == target) {
      target++;
    } else {
      ans++;
    }
  }
  if (ans == n) ans = -1;

  cout << ans << endl;

  return 0;
}

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

using namespace std;
using ll = long long;

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

  int n;
  ll k;
  cin >> n >> k;
  vector<int> p(n);
  vector<ll> c(n);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
    p[i]--;
  }
  for (int i = 0; i < n; i++) {
    cin >> c[i];
  }

  // i地点から始めて一周するのにかかる距離とスコア
  vector<pair<int, ll>> loop_score(n);
  for (int i = 0; i < n; i++) {
    int cur = p[i];
    ll score = c[i];
    int cnt = 1;
    while (cur != i) {
      score += c[cur];
      cur = p[cur];
      cnt++;
    }
    loop_score[i] = make_pair(cnt, score);
  }

  ll ans = -1e18;
  for (int i = 0; i < n; i++) {
    ll cur = i;
    ll sum = 0;
    ll left = k;
    auto [cnt, score] = loop_score[i];
    if (score > 0) {
      sum = score * (k / cnt);
      left = k % cnt;
      if (k > cnt) {
        sum -= score;
        left += cnt;
      }
    } else {
      left = cnt;
    }
    if (left == 0) {
      ans = max(ans, sum);
    }
    for (int j = 0; j < left; j++) {
      sum += c[cur];
      cur = p[cur];
      ans = max(ans, sum);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

int main()
{
  i64 N;
  cin >> N;
  vector<i64> L(N);
  for (i64 i = 0; i < N; i++)
    cin >> L[i];
  i64 ans = 0;
  for (i64 i = 0; i < N; i++)
    for (i64 j = i + 1; j < N; j++)
      for (i64 k = j + 1; k < N; k++)
        if (abs(L[j] - L[k]) < L[i] && L[i] < L[j] + L[k] && L[i] != L[j] && L[j] != L[k] && L[k] != L[i])
          ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>
int main(void){

    int m,n,g,l,work,a,b;

    while(scanf("%d%d",&m,&n)!=EOF){

        a=m;
        b=n;

        if(m<n){
            work=m;
            m=n;
            n=work;
        }

        while(n!=0){
            work=m%n;
            m=n;
            n=work;
        }

        g=m;
        l=a/g;
        l*=b;

        printf("%d %d\n",g,l);

    }
    return 0;
}

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

int main(){
  int N, d[110];
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> d[i];
  }

  int num[110] = {0};
  for (int i = 0; i < N; i++) {
    num[d[i]]++;
  }

  int res = 0;
  for (int i = 1; i <= 100; i++) {
    if(num[i]){
      ++res;
    }
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define ll long long
int main() 
{
    ll s;
    vector<ll> pat(2000, 1);
    cin >> s;
    pat.at(0) = 0;
    pat.at(1) = 0;
    for(ll i = 5; i < 2000; i++) {
        for(ll j = i - 3; j >= 2; j--) {
            pat.at(i) += pat.at(j);
            pat.at(i) %= 1000000007;
        }
    }

    cout << pat.at(s - 1);

    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int n,k,sum=0;
  cin >> n >> k;
  vector<int>p(n);
  for(int i=0; i<n; i++){
    cin >> p.at(i);
  }
  sort(p.begin(),p.end());
  for(int i=0; i<k; i++){
    sum+=p.at(i);
  }
  cout << sum << endl;
}


Measured memory_bytes: 3628
n,x=map(int,input().split())
if x>n/2:
    x = n-x
ans = n
c = x
d = n-x
while c > 0:
    if d%c==0:
        ans += int(d/c)*(2*c) - c
    else:
        ans += int(d/c)*(2*c)
    c,d = d%c,c
print(ans)


Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
#include <random>
using namespace std;

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<int, ll> i_ll;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int v; ll w; };

const int MOD = 1000000007;
const int _MOD = 1000000009;
double EPS = 1e-10;
ll INF = INT_MAX / 2;

ll solve(int N, vector<int> lb, vector<int> ub) {
	map<int, ll> dp; dp[1] = 1;
	ll ans = 0;
	rep(t, 12) {
		map<int, ll> _dp;
		int cnt = 0;
		for (i_ll Sx: dp) {
			int S = Sx.first; ll x = Sx.second;
			rep(d, 10) {
				int _S = 0;
				rep(i, N) if (S>>i & 1) {
					if (lb[i] <= d && d <= ub[i])
						_S |= 1<<(i + 1);
					if (lb[i]/10 < d && d < ub[i]/10)
						_S |= 1<<(N+1 + i);
					if (d && d == lb[i]/10 && d < ub[i]/10)
						_S |= 1<<(N*2+1 + i);
					if (d && lb[i]/10 < d && d == ub[i]/10)
						_S |= 1<<(N*3+1 + i);
					if (d && d == lb[i]/10 && d == ub[i]/10)
						_S |= 1<<(N*4+1 + i);
				}
				rep(i, N) if (S>>(N+1 + i) & 1) {
					_S |= 1<<(i + 1);
				}
				rep(i, N) if (S>>(N*2+1 + i) & 1) {
					if (d >= lb[i]%10)
						_S |= 1<<(i + 1);
				}
				rep(i, N) if (S>>(N*3+1 + i) & 1) {
					if (d <= ub[i]%10)
						_S |= 1<<(i + 1);
				}
				rep(i, N) if (S>>(N*4+1 + i) & 1) {
					if (lb[i]%10 <= d && d <= ub[i]%10)
						_S |= 1<<(i + 1);
				}
				_dp[_S] += x;
			}
		}
		dp = _dp;
		for (i_ll Sx: dp) {
			int S = Sx.first; ll x = Sx.second;
			if (S>>N & 1) ans += x;
		}
	}
	return ans;
}

int main() {
	for (;;) {
		int N; cin >> N;
		if (!N) break;
		vector<int> lb(N), ub(N);
		rep(i, N) cin >> lb[i] >> ub[i];
		cout << solve(N, lb, ub) << endl;
	}
}

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

const long long md = 1e9+7;
const long long maxn = 300100;
long long fac[maxn], inv[maxn];

long long powd(long long x, long long y){
  long long res = 1;
  while(y){
    if(y&1) res=res*x%md;
    x=x*x%md;
    y>>=1;
  }
  return res;
}

void csh(){
  fac[0]=1;
  for (int i=1; i<maxn; i++){
    fac[i] = fac[i-1]*i%md;
  }
  inv[300000] = powd(fac[300000],md-2);
  for (int i=300000; i>0; i--){
    inv[i-1] = inv[i]*i%md;
  }
}

long long C(long long x, long long y){
  if (y<0||y>x) return 0;
  else return fac[x]*inv[y]%md*inv[x-y]%md;
}

int main(){
  long long H, W, A, B;
  cin >> H >> W >> A >> B;
  csh();
  long long ans = C(H+W-2,W-1);
  long long fob = 0;
  for (int i=0; i<B; i++){
    fob += C(H-A+i,i)*C(A-1+W-1-i,A-1)%md - C(H-A+i-1,i-1)*C(A-1+W-1-i,A-1)%md + md;
    fob %= md;
  }
  cout << (ans-fob+md)%md << endl;
}


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

long long int d[3*1000000 + 2];

int main() {

    int n;

    scanf("%lld",&n);

    for(int i=0;i<n;i++){
       scanf(" %lld",&d[i]);
    }

    bool flag = false;

    int npos = 0;

    while(!flag){

        long long int mj = 0;
        int maxpos=0;

        for(int i=npos;i<=npos+d[npos]/10;i++){
            if(i == n-1){
                flag = true;
                break;
            }
            if(i==npos) continue;
            if(mj/10 + maxpos <= i + d[i]/10){
                mj = d[i];
                maxpos = i;
            }
        }
        if(mj<10){
            break;
        }
        npos = maxpos;

    }

    if (!flag) {
        cout << "no" << endl;
        return 0;
    }

    reverse(d,d+n);


    flag = false;

    npos = 0;

    while(!flag){

        long long int mj = 0;
        int maxpos=0;

        for(int i=npos;i<=npos+d[npos]/10;i++){
            if(i == n-1){
                flag = true;
                break;
            }
            if(i==npos) continue;
            if(mj/10 + maxpos <= i + d[i]/10){
                mj = d[i];
                maxpos = i;
            }
            //mj = max(mj,d[i]);
        }
        if(mj<10){
            break;
        }
        npos = maxpos;

    }

    if (!flag) {
        cout << "no" << endl;
    }
    else{
        cout << "yes" << endl;
    }


    return 0;
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

int v[MAXN];

int used_v[MAXN];

int ans[MAXN], used_ans[MAXN];

void solve(){
	int n;
	scanf("%d", &n);
	REP(i, 0, n){
		scanf("%d", &v[i]);
	}
	int ind = 1;
	REP(i, 0, n){
		if (v[i] % 4 == 0 && ind < n){
			used_v[i] = 1;
			ans[ind] = v[i];
			used_ans[ind] = 1;
			ind += 2;
		}
	}
	if (ind < n){
		ind--;
		REP(i, 0, n){
			if (!used_v[i] && v[i] % 2 == 0 && ind < n){
				used_v[i] = 1;
				ans[ind] = v[i];
				used_ans[ind] = 1;
				ind++;
			}
		}
	}
	ind = 0;
	REP(i, 0, n){
		if (!used_v[i]){
			while(used_ans[ind]){
				ind++;
			}
			used_v[i] = 1;
			ans[ind] = v[i];
			used_ans[ind] = 1;
			ind++;
		}
	}
	if (((ans[n - 2] % 4) * (ans[n - 1] % 4)) % 4 != 0){
		printf("No\n");
	} else {
		printf("Yes\n");
	}
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<iostream>
using namespace std;

struct Node {
    int key;
    Node *right, *left, *parent;
};

Node *root, *NIL;

Node * find(Node *u, int k) {
    while(u != NIL && k != u->key) {
        if(k < u->key) u = u->left;
        else u = u->right;
    }
    return u;
}

void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;
    
    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;
    
    while(x != NIL) {
        y = x;
        if(z->key < x->key) {
            x = x->left;
        }else {
            x = x->right;
        }
    }
    z->parent = y;
    if(y == NIL) {
        root = z;
    }else {
        if(z->key < y->key) {
            y->left = z;
        }else {
            y->right = z;
        }
    }
}

void inorder(Node *u) {
    if(u == NIL) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void preorder(Node *u) {
    if(u == NIL) return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

int main() {
    int n, i, x;
    string com;
    
    scanf("%d", &n);
    
    for(i = 0; i < n; i++) {
        cin >> com;
        if(com[0] == 'f') {
            scanf("%d", &x);
            Node *t = find(root, x);
            if(t != NIL) printf("yes\n");
            else printf("no\n");
        }else if(com == "insert") {
            scanf("%d", &x);
            insert(x);
        }else if(com == "print") {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
    
    return 0;
}


Measured memory_bytes: 22020
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <sstream>
#include <fstream>
#include <tuple>
#include <set>
#include <functional> 
#include <string.h>
//#include <assert.h>
//#include <typeinfo.h>
#include <time.h>

#define X first
#define Y second
#define MP make_pair
#define MT make_tuple
#define FOR(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define REP(i, a, n) for(int (i) = (a); (i) < (n); ++(i))
typedef long long ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll > pll;
using namespace std;

const int INIT_SIZE_MAX = (1 << 29) + 10;
const int INIT_SIZE_MIN = -(1 << 29) - 10;
const int INIT_SIZE = 0;
const int MAX = 8;
const int DIR_SIZE = 12;
const double PI = 3.1415926535897932384;

template<class T, class U>
void convert(T &t, U &u){
	stringstream ss;
	ss << t;
	ss >> u;
}

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

int main(){
	int n; cin >> n;
	FOR(k, n){
		cin.ignore();

		vector<vector<char> > tb(MAX, vector<char>(MAX, ' '));
		FOR(i, MAX) FOR(j, MAX) cin >> tb[i][j];

		pii s;
		cin >> s.X >> s.Y;
		--s.X; --s.Y;

		queue<pii> q;
		q.push(s);

		while (!q.empty()){
			pii t = q.front(); q.pop();

			if (tb[t.Y][t.X] == '0') continue;

			tb[t.Y][t.X] = '0';

			FOR(i, DIR_SIZE){
				if (t.X + dx[i] < 0 || t.X + dx[i] >= MAX) continue;
				if (t.Y + dy[i] < 0 || t.Y + dy[i] >= MAX) continue;

				if (tb[t.Y + dy[i]][t.X + dx[i]] == '1'){
					q.push(MP(t.X + dx[i], t.Y + dy[i]));
				}
			}

		}

		cout << "Data " << k + 1 << ":" << endl;
		FOR(i, MAX){
			FOR(j, MAX){
				cout << tb[i][j];
			}
			cout << endl;
		}

	}
	return 0;
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
typedef unsigned long long ull;
using namespace std;

int ans ;
bool countdiv(int n){
	int d =0;
	for(int i=1;i<=n;i++){
		if(n%i==0)d++;
	}
	return d == 8;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);

	int n;
	cin >> n;
	for(int i=1;i<=n;i++){
		if(countdiv(i) && i%2==1){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
S = input()
N = len(S)
K = int(input())

def cmb(n, r):
    if r < 0 or r > n:
        return 0
    if r == 1:
        return n
    elif r == 2:
        return n * (n-1) // 2
    else:
        return n * (n-1) * (n-2) // (3 * 2) 

def rec(i, k, isSmaller):
    if k == 0:
        return 1

    if i == N:
        return 0
    
    if isSmaller:
        return cmb(N-i, k) * pow(9, k)
    else:
        if S[i] == '0':
            return rec(i+1, k, False)
        else:
            zero = rec(i+1, k, True)
            between = rec(i+1, k-1, True) * (int(S[i]) - 1)
            same = rec(i+1, k-1, False)
            return zero + between + same

print(rec(0, K, False))


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

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VL = vector<long long>;
using VVL = vector<VL>;

#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)
#define REPC(var, start, end) for(int var = start; var <= (int)end; ++var)
#define CLEAR(var, with) memset(var, with, sizeof(var))
#define ALL(x) x.begin(), x.end()
#define LL long long
#define ULL unsigned long long
#define TIME cerr << "Time elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms" << endl;
#define DBG(x) cerr << x << endl;

/*
	
*/
int a, b, c, d;
int solve()
{
	if(a > d || b < c)
		return 0;
	return min(b, d) - max(a, c);
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
//	freopen("tmp.in", "r", stdin);
	//freopen("tmp.out", "w", stderr);
#endif
	cin >> a >> b >> c >> d;

	cout << solve() << endl;

	return 0;
}

Measured memory_bytes: 256
from collections import deque
import math

def Next(): return input()
def NextInt(): return int(Next())
def NextInts(): return map(int,input().split())
def Nexts(): return map(str,input().split())
def NextIntList(): return list(map(int,input().split()))
def RowInts(n): return [input() for i in range(n)]

s = input()
t = input()
ans = 0
for i in range(len(s)):
    if s[i] != t[i]:
        ans += 1
print(ans)

Measured memory_bytes: 9756
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define RREP(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    const ll mod = 1e9+7;
    ll H, W; cin >> H >> W;
    vvc A(H, vc(W));
    REP(i, H) REP(j, W) cin >> A[i][j];
    
    vvl dp(H+1, vl(W+1, 0));
    dp[0][1] = 1;
    
    REP(i, H) REP(j, W){
        if(A[i][j] != '#'){
            dp[i+1][j+1] = (dp[i][j+1]+dp[i+1][j]) % mod;
        }
    }
    cout << dp[H][W] << endstr;
    return 0;
}


Measured memory_bytes: 9088
#include <stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

typedef struct Card{
	char suit;
	int value;
} Card;

Card L[MAX / 2 + 2], R[MAX / 2 + 2];

void merge(Card A[], int n, int left, int mid, int right);
void mergeSort(Card A[], int n, int left, int right);
int partition(Card A[], int n, int p, int r);
void quickSort(Card A[], int n, int p, int r);

int main(){
	int n,i,v;
	Card A[MAX], B[MAX];
	char S[10];
	int stable = 1;
	
	scanf("%d", &n);
	
	for(i = 0; i < n; i++){
		scanf("%s %d", S, &v);
		A[i].suit = B[i].suit = S[0];
		A[i].value = B[i].value = v;
	}
	
	mergeSort(A,n,0,n);
	quickSort(B,n,0,n-1);
	
	for(i = 0; i < n; i++){
		if(A[i].suit != B[i].suit){stable = 0;}
	}
	if(stable == 1){printf("Stable\n");}
	else {printf("Not stable\n");}
	for(i = 0; i < n; i++){
		printf("%c %d\n", B[i].suit, B[i].value);
	}
	
	return 0;
}

void merge(Card A[], int n, int left, int mid, int right){
	int n1 = mid - left;
	int n2 = right - mid;
	for(int i = 0; i < n1; i++) {L[i] = A[left + i];}
	for(int i = 0; i < n2; i++) {R[i] = A[mid + i];}
	L[n1].value = R[n2].value = SENTINEL;
	int i = 0, j = 0;
	for(int k = left; k < right; k++){
		if(L[i].value <= R[j].value){
			A[k] = L[i++];
		}
		else{
			A[k] = R[j++];
		}
	}
}

void mergeSort(Card A[], int n, int left, int right){
	if(left + 1 < right){
		int mid = (left + right) / 2;
		mergeSort(A, n, left, mid);
		mergeSort(A, n, mid, right);
		merge(A, n, left, mid, right);
	}
}

int partition(Card A[], int n, int p, int r){
	int i,j;
	Card tmp, x;
	x = A[r];
	i = p-1;
	for(j = p; j < r; j++){
		if(A[j].value <= x.value){
			i++;
			tmp = A[i];
			A[i] = A[j];
			A[j] = tmp;
		}
	}
	tmp = A[i + 1];
	A[i + 1] = A[r];
	A[r] = tmp;
	return i+1;
}

void quickSort(Card A[], int n, int p, int r){
	int q;
	if(p < r){
		q = partition(A,n,p,r);
		quickSort(A,n,p,q-1);
		quickSort(A,n,q+1,r);
	}
}



Measured memory_bytes: 4124
<?php

$data = array();
while (!feof(STDIN)) {
    $data[] = rtrim(fgets(STDIN));
}

$w_scores = array_slice($data, 0, 10);
$k_scores = array_slice($data, 10, 10);

rsort($w_scores);
rsort($k_scores);

$w_scores_top3 = array_splice($w_scores, 0, 3);
$k_scores_top3 = array_splice($k_scores, 0, 3);

$w_sum = array_sum($w_scores_top3);
$k_sum = array_sum($k_scores_top3);

printf("%d %d\n", $w_sum, $k_sum);


Measured memory_bytes: 9248
N = int(input())
s = [int(input()) for _ in range(N)]

s.sort()
ans = sum(s)
if ans%10 != 0:
  print(ans)
else:
  for si in s:
    if si%10 != 0:
      print(ans-si)
      break
  else:
    print(0)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define LL long long
const int N = 1e5 + 11;
const int mod = 1e9 + 7;
int n, K;
LL sum[N], a[N];
LL fac[N], inv[N];
LL C(int n, int m){
    if(m > n)return 0;
    return 1LL * fac[n] * inv[m] % mod * inv[n-m] % mod;
}
int main(){
    cin>>n>>K;
    fac[0] = fac[1] = inv[0] = inv[1] = 1;
    for(int i = 2;i <= 1e5; i++){
        fac[i] = 1LL * fac[i-1] * i % mod;
        inv[i] = mod - 1LL * mod / i * inv[mod%i] % mod;
    }
    for(int i = 2;i <= 1e5; i++)inv[i] = 1LL * inv[i-1] * inv[i] % mod;
    for(int i = 1;i <= n; i++){
        scanf("%lld", &a[i]);
    }
    sort(a + 1, a + 1 + n);
    for(int i = 1;i <= n; i++)sum[i] = sum[i-1] + a[i];
    if(K == 1){
        puts("0");
        return 0;
    }
    int ans = 0;
    for(int p = 1;p <= n - 1; p++){
        LL w = sum[n] - sum[p] - sum[n-p];
        w = (mod + w % mod) % mod;
        ans = (ans + w * C(p - 1, K - 2) % mod) % mod;
    }
    cout<<ans<<endl;
    return 0;
}


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

int main() {
    string str;
    cin >> str;
    if (str[5] == '0') {
        if (str[6] == '1' || str[6] == '2' || str[6] == '3' || str[6] == '4') {
            cout << "Heisei" << endl;
        } else {
            cout << "TBD" << endl;
        }
    } else {
        cout << "TBD" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int gcd(int a, int b){
	while(a > 0 && b > 0){
		if(a >= b) a%=b;
		else b%=a;
	}
	return a + b;
}
int main(){
	int n;
	cin >> n;
	long long ans = 0;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			for(int k = 1; k <= n; k++){
				ans += gcd(gcd(i,j),k);
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int A, B;
    cin >> A >> B;
    int count = 0;
    rep(i, N) {
        int tmp; cin >> tmp;
        if (tmp < A || B <= tmp) count++;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;

int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin>>n;
int a,b,c;
cin>>a>>b>>c;
vector<char> ans;
map<char,int> mp;
mp['A']=a;
mp['B']=b;
mp['C']=c;
string str[n];
for(int i=0;i<n;i++)
{
    cin>>str[i];
}
if(a==0&&b==0&&c==0)
{
    cout<<"No"<<endl;
    return 0;
}

for(int i=0;i<n-1;i++)
{
 char val=str[i][0];
 char res=str[i][1];
 if(mp[val]==0)
 {
     mp[val]+=1;
     ans.pb(val);
     mp[res]-=1;
 }
 else if(mp[res]==0)
 {
     mp[res]+=1;
     ans.pb(res);
     mp[val]-=1;
 }
 else
 {
     if(val==str[i+1][0]||val==str[i+1][1])
     {
         mp[val]+=1;
         mp[res]-=1;
         ans.pb(val);
     }
     else
     {
         mp[val]-=1;
         mp[res]+=1;
         ans.pb(res);
     }
 }
 if(mp['A']<0||mp['B']<0||mp['C']<0)
    {
        cout<<"No"<<endl;
        return 0;
    }
}
char val=str[n-1][0];
 char res=str[n-1][1];
if(mp[val]==0)
 {
     mp[val]+=1;
     ans.pb(val);
     mp[res]-=1;
 }
 else
 {
     mp[res]+=1;
     ans.pb(res);
     mp[val]-=1;
 }
if(mp['A']<0||mp['B']<0||mp['C']<0)
    {
        cout<<"No"<<endl;
        return 0;
    }
cout<<"Yes"<<endl;
for(int i=0;i<ans.size();i++)
    cout<<ans[i]<<endl;
    return 0;
}


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

typedef pair<int, int> P;

int main() {

    int n;
    cin >> n;

    vector<int> a(n);
    rep(i,n)cin >> a[i];
    int ans = 0;
    rep(i,n){
        ans+=a[i];
    }
    ans -= n;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// In the nAme Of Allah
#include<bits/stdc++.h>
#define pb push_back
#define ins insert
#define f first
#define pp pop_back
#define ll long long int
#define fst  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
const ll mod=1e9+7;
using namespace std;
ll n,a[200005],s=0,p=0;
int main()
{
   fst;
   cin>>n;
   for(ll i=0;i<n;i++)
   {
       cin>>a[i];
       p+=(a[i]%mod)*(a[i]%mod)%mod;
       s+=(a[i]%mod);
       s%=mod;
       p%=mod;
       }
       if(((s*s)-p)%2==0)
       {
           cout<<(((s*s)-p)/2)%mod;
       }
       else{
        cout<<(((s*s)-p+mod)/2)%mod;
       }
   return 0;
}


Measured memory_bytes: 5176
import math
from collections import deque

n, m = map(int, input().split())

graph = [[] for _ in range(n+1)]

for i in range(m):
  a, b = map(int, input().split())
  graph[a].append(b)
  graph[b].append(a)

flag = [0] * (n+1)
flag[0] = 1
flag[1] = 1

d = deque()
d.append(1)

guidepost = [-1] * (n+1)

while d:
  v = d.popleft()
  for i in graph[v]:
    if flag[i] != 0:
      continue
    flag[i] = 1
    d.append(i)
    if guidepost[i] != -1:
      print("No")
      exit()
    else:
      guidepost[i] = v
  
if not all(guidepost):
  print("No")
  exit()

ans = guidepost[2:]    

print("Yes")
print(*ans, sep="\n")

Measured memory_bytes: 37220
#include<bits/stdc++.h>
#define fi first
#define se second
#define lc (x<<1)
#define rc (x<<1|1)
#define gc getchar()//(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define mk make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define IT iterator
#define vi vector<int>
#define TP template<class o>
#define SZ(a) ((int)a.size())
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int N=2e5+10,size=1<<20,mod=998244353,inf=2e9;

//char buf[size],*p1=buf,*p2=buf;
template<class o> void qr(o &x) {
    char c=gc; x=0; int f=1;
    while(!isdigit(c)){if(c=='-')f=-1; c=gc;}
    while(isdigit(c)) x=x*10+c-'0',c=gc;
    x*=f;
}
template<class o> void qw(o x) {
    if(x/10) qw(x/10);
    putchar(x%10+'0');
}
template<class o> void pr1(o x) {
    if(x<0)x=-x,putchar('-');
    qw(x); putchar(' ');
}
template<class o> void pr2(o x) {
    if(x<0)x=-x,putchar('-');
    qw(x); putchar('\n');
}

int n,a[N];

ll power(ll a,ll b=mod-2) {
	ll c=1;
	while(b) {
		if(b&1) c=c*a%mod;
		b /= 2; a=a*a%mod;
	}
	return c;
}

int main() {
	qr(n);
//	for(int i=1;i<=n;i++) qr(a[i]);
	pr2(!n);
	return 0;
}


Measured memory_bytes: 3636
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <vector>
#include <queue>
using namespace std;


vector<int> dk;

bool check(int n) {
	bool flag = true;
	while (n > 0 && flag) {
		int v = n % 10;
		if (find(dk.begin(), dk.end(), v) != dk.end()) {
			flag = false;
		}
		n /= 10;
	}
	return flag;
}

int main(){
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < k; ++i) {
		int d;
		cin >> d;
		dk.push_back(d);
	}
	int nn = n;
	while (!check(nn)) {
		nn++;
	}
	cout << nn << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define STARTUP {(cin.tie(0));\
 (ios::sync_with_stdio(false));}

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define CINVEC(vec) const int size = (vec).size(); REP(i,size) cin>>(vec)[i];

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
std::istream& operator>>(std::istream& is, std::pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    STARTUP;

    string S1, S2, S3;
    cin >> S1 >> S2 >> S3;

    cout << (char)(S1[0] - 0x20)<< (char)(S2[0] - 0x20)<< (char)(S3[0] - 0x20) << endl;
    return 0;
}

Measured memory_bytes: 256
unittest
{
	assert( [ "5 3", "1 9", "1 7", "2 6", "2 5", "3 1" ].parse.expand.solve == 26 );
	assert( [ "7 4", "1 1", "2 1", "3 1", "4 6", "4 5", "4 5", "4 5" ].parse.expand.solve == 25 );
	assert( [ "6 5", "5 1000000000", "2 990000000", "3 980000000", "6 970000000", "6 960000000", "4 950000000" ].parse.expand.solve == 4900000016 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nk = input.front.split.to!( long[] );
	auto tds = new long[][]( nk[ 0 ], 2 );
	foreach( ref td; tds )
	{
		input.popFront;
		td = input.front.split.to!( long[] );
	}
	return tuple( nk[ 1 ], tds );
}

auto solve( long k, long[][] tds )
{
	// 種類無視でおいしい順にソート
	tds.sort!( ( a, b ) => b[ 1 ] < a[ 1 ] );
	
	// 全種類数をカウント
	auto tm = tds.map!( ( td ) => td[ 0 ] ).array.sort().uniq.walkLength;
	
	// おいしい順にK個のところで分ける
	auto tds_g = tds.take( k );
	auto tds_l = tds.drop( k );
	
	// おいしい順だけでK個選んだ場合を計算
	auto ts = tds_g.map!( ( td ) => td[ 0 ] ).array.sort().group.assocArray;
	auto tc = ts.length;
	auto dt = tds_g.map!( ( td ) => td[ 1 ] ).sum;
	auto ans = tc * tc + dt;
	
	// 全種類網羅するまで、おいしい順の下から1つずつ選んでない種類に入れ替えて計算
	foreach_reverse( td_r; tds_g )
	{
		if( tm <= tc ) break;
		if( ts[ td_r[ 0 ] ] <= 1 ) continue;
		
		while( !tds_l.empty )
		{
			auto td_i = tds_l.front;
			tds_l.popFront;
			
			if( td_i[ 0 ] in ts ) continue;
			
			// 入れ替えた分を再計算
			ts[ td_r[ 0 ] ]--;
			ts[ td_i[ 0 ] ]++;
			tc++;
			dt -= td_r[ 1 ];
			dt += td_i[ 1 ];
			ans = max( ans, tc * tc + dt );		// 点数が大きいほうを取る
			break;
		}
	}
	
	return ans;
}


Measured memory_bytes: 27260
def b_shift_only(N, A):
    def is_even(lst):
        # リストの要素がすべて偶数か？
        for x in lst:
            if x % 2 == 1:
                return False
        return True
    a = A[:]
    count = 0
    # 奇数が要素に現れるまで要素を2で割る
    while is_even(a):
        a = [x // 2 for x in a]
        count += 1
    return count

N = int(input())
A = [int(i) for i in input().split()]
print(b_shift_only(N, A))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

int e[400000] = {0}, w[400000] = {0};
int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int N;
    cin >> N;
    string S;
    cin >> S;

    REP(i, N) {
        if (S[i] == 'W') {
            w[i + 1] += w[i] + 1;
        } else {
            w[i + 1] = w[i];
        }
    }

    for (int i = N - 1; i >= 0; i--) {
        if (S[i] == 'E') {
            e[i] += e[i + 1] + 1;
        } else {
            e[i] = e[i + 1];
        }
    }

    int ans = INF;
    REP(i, N) { chmin(ans, w[i] + e[i + 1]); }

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


Measured memory_bytes: 3076
/*
    author: Salam_35
    Created at :

*/

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

#define ll long long int
#define pb push_back
#define sc(n) scanf("%d",&n)
#define Max 100005
#define scan(n) scanf("%lld",&n)
#define pi acos(-1.0)
#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ALL(x) x.begin(),x.end()
#define sci(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define load(array,size)  for(ll i=0 ; i<size ; i++) cin>>array[i] ;
#define load1(array,size)  for(ll i=1 ; i<=size ; i++) cin>>array[i] ;
#define INF	1LL<<19
#define pll pair<ll,ll>
#define mst(arr,value) memset(arr,value,sizeof(arr));
#define tst() int t;cin >> t;while(t--)
#define Mod 100000007
#define YES cout<<"Yes"<<endl;
#define NO cout<<"No"<<endl;
void inversemod(ll n, ll mod, ll invmod[],ll MOD){for(int i=2; i<=n; ++i) invmod[i]=MOD-MOD/i*invmod[MOD%i]%MOD;}
//void bigmod( ll a, ll b ,ll mod){ll r = 1;a = a%mod;while(b){if( b%2 ) r = (r*a)%mod;b = b/2;a = (a*a)%mod; }return (ll)r;}

typedef vector<ll>vec;
typedef pair<ll,ll> pii;
typedef map<ll,ll>mpll;
typedef set<ll>seet;

int main()
{
    int n,l;
    cin >> n>>l;
    vector<string> v(n);
    for (int i = 0; i < n; ++i)
    {
    	cin >> v[i];
    }
    sort(ALL(v));
    string s="";
    for(int i = 0; i < n; ++i)
    {
    	s+=v[i];
    }
    cout<<s<<endl;
}


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

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

    long long r = 0, g = 0, b = 0;
    for (auto c : s) {
        r += c == 'R';
        g += c == 'G';
        b += c == 'B';
    }

    long long all = r * g * b;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            // j - i = k - j
            // k = 2j - i
            int k = 2 * j - i;
            if (n <= k || s[i] == s[j] || s[i] == s[k] || s[j] == s[k]) continue;
            --all;
        }
    }

    cout << all << endl;
}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std; 
int main(){
  int64_t n,m;
  cin >> n >> m;
  vector<int64_t> vec(m);
  int64_t i,sum=0;
  for(i=0;i<m;i++){
    cin >> vec.at(i);
    sum+=vec.at(i);
  }
  if(n>=sum){
    cout << n-sum;
  }else{
    cout << -1;
  }
}

Measured memory_bytes: 3712
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
const int MOD = 1e9 + 7;

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

	string s; cin >> s;
	int len = s.length();
	cout << s.substr(0, len - 8);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <functional>

using namespace std;

const int N = 100100;

int main(int argc, const char * argv[]) {

	ios::sync_with_stdio(false);

	int n;

	cin >> n;

	int ans = 0;

	vector<int> a(N,0);

	while (n--) {
		int x;
		cin >> x;
        if (x >= N) {
			ans++;
			continue;
		}
		a[x]++;
	}
	for (int i = 1; i < N; i++) {
		if (a[i] < i)
			ans += a[i];
		else
			ans += a[i] - i;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>

using ll = long long;

int main() {
    ll n, k;
    cin >> n >> k;
    vector<pii>v;
    vector<ll>a(n);
    ll var = 0;
    rep(i, 0, n){
        ll b;
        cin >> b;
        b--;
        if(a[b] == 0)var++;
        a[b]++;
    }
    sort(a.begin(), a.end(), greater<ll>());
    if(var <= k)cout << "0" << endl;
    else{
        ll cnt = 0;
        rep(i, k, n){
            cnt += a[i];
        }
        cout << cnt << endl;
    }
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n)  for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define deb(x) cerr << #x <<": " << x << '\n';
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
typedef long double ld;
typedef long long ll;

int main(){
    ios;
    int n, k; cin >> n >> k;
    vector<int> v(n);
    rep(i,n)
        cin >> v[i];
    sort(v.begin(),v.end());
    int sum = 0;
    rep(i,k){
        sum += v[i];
    }
    cout << sum;
    return 0;
}


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

#define MOD 1000000007
typedef long long ll;

#define rep(i, n) for(i=0;i<(int)(n);i++)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define bit(n) (1LL<<(n))
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(void){
  char s[200001];
  int i=0,result=1,n;
  scanf("%s", s);
  n = strlen(s);
  
  if(n % 2 == 1) result=0;
  
  for(i=0;i<n-1&&result==1;i++){
    if(s[i] == 'h' && s[i+1] == 'i'){
      i++;
    }else{
      result=0;
      break;
    }
  }
  
  if(result==1) printf("Yes");
  else printf("No");
  
  return 0;
}



Measured memory_bytes: 128
n=int(input())
a=list(map(int,input().split()))
c=0
s=set()
for i in a:
  if i<400:
    s.add(0)
  elif i<800:
    s.add(1)
  elif i<1200:
    s.add(2)
  elif i<1600:
    s.add(3)
  elif i<2000:
    s.add(4)
  elif i<2400:
    s.add(5)
  elif i<2800:
    s.add(6)
  elif i<3200:
    s.add(7)
  elif i>=3200:
    c+=1
print(max(len(s),1),len(s)+c)

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename A,typename B>istream&operator>>(istream&is,pair<A,B> &p){is>>p.fi>>p.se;return is;}
template<typename A,typename B>ostream&operator<<(ostream&os,const pair<A,B> &p){os<<"("<<p.fi<<","<<p.se<<")";return os;}
template<typename T>istream&operator>>(istream&is,vector<T> &t){REP(i,t.size())is>>t[i];return is;}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&t){os<<"{";REP(i,t.size()){if(i)os<<",";os<<t[i];}cout<<"}";return os;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int n;
    cin>>n;
    vl vec(n);
    cin>>vec;
    ll dp[n+1][2];
    REP(i,n){
        dp[i+1][0]=dp[i+1][1]=-LINF;
    }
    dp[0][0]=0;
    dp[0][1]=-LINF;
    REP(i,n){
        chmax(dp[i+1][0],dp[i][0]+vec[i]);
        chmax(dp[i+1][0],dp[i][1]-vec[i]);
        chmax(dp[i+1][1],dp[i][1]+vec[i]);
        chmax(dp[i+1][1],dp[i][0]-vec[i]);
    }
    cout<<dp[n][0]<<endl;
    return 0;
}

Measured memory_bytes: 2560
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;

public class Main{
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String[] input = br.readLine().split(" ", 5);
        int[] data = new int[5];

        for (int i = 0; i < 5; i++) {
            data[i] = Integer.parseInt(input[i]);
        }

        for (int j = 0; j < 4; j++) {
            for (int i = 4; i > j; i--) {
                if (data[i - 1] < data[i]) {
                    int swp = data[i];
                    data[i] = data[i - 1];
                    data[i - 1] = swp;
                }
            }
        }
        StringBuilder sb = new StringBuilder();

        for (int i : data) {
            sb.append(i);
            sb.append(" ");
        }

        System.out.println(sb.substring(0 , sb.length()-1));
    }
}

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

//Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

//Type Definitions:
typedef long long ll;
typedef unsigned long long ull;

//Constants:
const int INF = 2e9;
const int MOD = 1e9 + 7;

//Global Variables:

//Prototype Declarations:
int gcd(int, int);

//================ Main Loop ================
int main() {
    int n;
    cin >> n;
    int bf;
    bool flg = 0;
    rep(i, n) {
        cin >> bf;
        if(bf % 2) continue;
        if(!(bf % 3) || !(bf % 5)) {
            continue;
        } else {
            flg = 1;
            break;
        }
    }
    if(flg) {
        cout << "DENIED" << endl;
    } else {
        cout << "APPROVED" << endl;
    }
    return 0;
}
//===========================================

//Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
const int mo=1e9+7;
int f[45][132075];
long long ans;
int n,x,y,z,sum,S;
int main()
{
	scanf("%d%d%d%d",&n,&x,&y,&z);
	sum=(1<<x-1)|(1<<x+y-1)|(1<<x+y+z-1);
	S=(1<<x+y+z)-1;
	ans=1;
	for(int i=1;i<=n;i++) ans=(1LL*ans*10)%mo;
	f[0][0]=1;
	for(int i=1;i<=n;i++)
		for(int j=0;j<=S;j++)
		for(int k=1;k<=10;k++){
			int t=(j<<k)|(1<<k-1);
			t&=S;
			if( (t&sum)!=sum ) 
				f[i][t]=(f[i][t]+f[i-1][j])%mo;
		}
	for(int i=0;i<=S;i++)
		ans=(ans-f[n][i]+mo)%mo;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 22272