akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#define REL

#pragma GCC optimize("Ofast")

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <string>
#include <set>
#include <bitset>
#include <cstdint>
#include <cstring>
#include <cassert>
#include <complex>
#include <stack> 

using namespace std;

typedef int64_t i64;
typedef long long LL;
typedef long long ll;
typedef long double LD;
typedef complex <LD> cld;
typedef unsigned int uint;
typedef complex <double> cd;
typedef unsigned long long ULL;

#define endl "\n"
#define dendl "\n\n"
#define mp make_pair
#define mt make_tuple
#define size(v) (int)v.size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

/////////////////////////////////////////////////////////////////////

template <typename T>
T sqr(T a) {
	return a * a;
}

template <typename T>
int sign(T a) {
	if (a == 0)
		return 0;
	return (a > 0 ? 1 : -1);
}

template <typename T1, typename T2>
T2 sum_mod(T1 x, T2 MOD) {
	if (x < 0)
		x += MOD;
	if (x >= MOD)
		x -= MOD;
	return x;
}

template <typename T1, typename T2>
T2 mul_mod(T1 x, T2 MOD) {
	if (x < 0)
		return (abs(x) % MOD == 0 ? 0 : MOD - abs(x) % MOD);
	return x % MOD;
}

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

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

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

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

const int LOG = 18;
const int N = (int)1e5 + 7;
const int MAXN = (int)2e3 + 7;
const int MOD = (int)998244353;
const int INF = (int)1e9 + 7;
const int CONST = 300;
const LL LINF = (i64)2e15;
const LD PI = 3.1415926535897932384626433832795;
const LD EPS = 1;

/////////////////////////////////////////////////////////////////////

int n, m, a[N];

int main() {
	double start = clock();
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	cout << fixed << setprecision(20);
	cerr << fixed << setprecision(20);
#else
	cout << fixed << setprecision(20);
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
#endif

	cin >> n >> m;
	int sum = 0;
	for (int i = 0; i < n; i++)
		cin >> a[i], sum += a[i];
	int cnt = 0;
	for (int i = 0; i < n; i++)
		cnt += 4 * a[i] * m >= sum;
	cout << (cnt >= m ? "Yes" : "No");

#ifdef _DEBUG
	cout << endl << "Time is " << (clock() - start) / 1000.0;
#endif
}

Measured memory_bytes: 256
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

int32_t nextint(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); bool s=false; if(c=='-'){s=true;c=getchar_unlocked();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); int s=0; if(c=='-'){s=1;c=getchar_unlocked();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }

long a[100000];
int main(void){
	int n=nextint();
	long ans=1;
	for(int i=0; i<n; i++){
		a[i]=nextlong();
		if(a[i]==0){
			ans=0;
		}
	}
	for(int i=0; i<n; i++){
		if(__builtin_smull_overflow(ans, a[i], &ans)){
			ans=-1;
			break;
		}else if(ans>1000000000000000000L){
			ans=-1;
			break;
		}
	}
	printf("%ld\n", ans);
}


Measured memory_bytes: 2380
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    string s; cin >> s;
    if(s.size() == 2)cout << s << endl;
    else{
        reverse(all(s));
        cout << s << endl;
    }
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;
int main()
{
  int N;
  cin >> N;
  vector<int> a(N + 1);
  for (int i = 1; i <= N; i++) {
    cin >> a[i];
  }

  int c = 0;
  vector<int> done(N + 1);
  for (int i = 1; i <= N; i++) {
    if (done[i]) continue;
    int j = a[i];
    if (a[j] == i) {
      c++;
      done[j] = 1;
      done[i] = 1;
    }
  }
  cout << c << endl;
  return 0;
}


Measured memory_bytes: 1024
use std::io;

fn read() -> Vec<i32> {
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();
    input.trim().split(' ').map(|x| x.parse().ok().unwrap()).collect()
}
fn main() {
    let input = read();
    let ans = if input[1] % input[0] == 0 {input[0] + input[1]} else {input[1] - input[0]};
    println!("{}", ans);
}


Measured memory_bytes: 4352
// Harshad Number
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;


int main()
{
  int N, X;
  cin >> N;
  
  X = N;
  
  int sum = 0;
  while(X > 0){
      sum+=X%10;
      X/=10;
  }

  if(N%sum==0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 256
from queue import Queue
n, q = map(int, input().split())
que = Queue()
for i in range(n):
    name, time = input().split()
    que.put((name, int(time)))

total = 0
while que.qsize() > 0:
    name, time = que.get()
    total += min(q, time)
    if q < time:
        que.put((name, time-q))
    else:
        print(name, total)

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

int main()
{
    int n, c, maxxyz, x, y, z, val;
    cin >> n;
    int a [n];
    for ( int i = 0; i < n; i ++) {
        a[i] = 0;
    }
    maxxyz = sqrt(n-5);
    for  ( x = 1; x <= maxxyz; x++){
            for ( y = 1; y <= maxxyz; y++) {
                for ( z = 1; z <= maxxyz; z++) {
                    val =x*x + y*y + z*z + x*y + y*z + z*x;
                    if ( val <= n) a[val-1]++;
            }
        }
    }
    for ( int i = 0; i < n; i ++) {
        cout << a[i] <<endl;
    }
}

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

# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;

long long int dp[51][51][2501];

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

    int x[51]={};
    int max_x=A;
    for(int i=1;i<=n;i++){
        cin >> x[i];
        max_x=max(max_x,x[i]);
    }
    for(int j=0;j<=n;j++){
        for(int k=0;k<=n;k++){
            for(int s=0;s<=max_x*n;s++){
                if(j==0 && k==0 && s==0){
                    dp[0][0][0]=1;
                } else if(j>=1 && s<x[j]){
                    // x_jは取ら(れ)ない
                    dp[j][k][s]=dp[j-1][k][s];
                } else if(j>=1 && k>=1 && s>=x[j]) {
                    // x_jを取る場合の数と取らない場合の数の和
                    dp[j][k][s]=dp[j-1][k][s] + dp[j-1][k-1][s-x[j]];
                } else {
                    // その他は0
                    dp[j][k][s]=0;
                }
            }
        }
    }
    long long int ans=0;
    for(int k=1;k<=n;k++){
        ans += dp[n][k][k*A];
    }
    p(ans)

}

Measured memory_bytes: 51072
from itertools import product
from math import ceil
D,G = map(int,input().split(" "))
p,c = [0]*D,[0]*D

for i in range(D):
    p[i],c[i] = map(int,input().split(" "))

ans = float('inf')
for pat in range(1<<D):
    point,prob,maxv = 0,0,0
    for b in range(D):
        if (pat >> b) & 1:
            point += ((100*(b+1))*p[b] + c[b])
            prob += p[b]
        else:
            maxv = max(maxv,b+1)

    if point >= G:
        ans = min(ans,prob)

    elif maxv != 0:
        if G <= (point + (maxv*100)*p[maxv-1]):
            ans = min(ans,prob+ceil((G-point)/(maxv*100)))

print(ans)




Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define MAX_N 10000
#define INF 1e9

using namespace std;

typedef int long long ll;
typedef int long l;
typedef pair<int, int> Pii;
const ll MOD = 1000000007;

int n;
int a[200000];


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    vector<int> r(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        r[i] = a[i] + i;
    }
    sort(r.begin(), r.end());
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ans += upper_bound(r.begin(), r.end(), i - a[i]) - lower_bound(r.begin(), r.end(), i - a[i]);
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 4784
using System;
    using System.Text;
    using System.Collections.Generic;
    using static System.Math;
    using System.Linq;
    using static System.Array;
    
    namespace ConsoleApp2
    {
    class Program
    {
        static string S;
        static long ans = 0;
        static long N;
        static long M;
        static Node[] Nodes;
        static void Main(string[] args)
        {

            //var N = long.Parse(Console.ReadLine());
            var NK = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            N = NK[0];
            M = NK[1];
            Nodes = new Node[N + 1];
            for (int i = 1; i <= N; i++)
            {
                Nodes[i] = new Node(i);
            }

            for (int i = 0; i < M; i++)
            {
                var AB = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
                var A = AB[0];
                var B = AB[1];

                Nodes[A].adj.Add(B);
                Nodes[B].adj.Add(A);
            }

            cul(1, new bool[N + 1]);

            Console.WriteLine(ans);
        }

        static void cul(long st,bool[] used)
        {
            used[st] = true;
            foreach (var item in Nodes[st].adj)
            {
                if (!used[item])
                {
                    var nused = new bool[N + 1];
                    Copy(used, nused, N + 1);
                    cul(item,nused);
                }
            }

            var fl = true;

            for (int i = 1; i <= N; i++)
            {
                if (!used[i])
                {
                    fl = false;
                    break;
                }
            }

            if (fl) ans++;

        }
    }

    class Node
    {
        long num = -1;
        public List<long> adj;
        public Node(long inp)
        {
            this.num = inp;
            adj = new List<long>();
        }
    }
}


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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	while (1) {
		int n, k, s;
		cin >> n >> k >> s;
		if (!n)break;
		
		int ans = 0;
		REP(i, 1 << n) {
			int sum = 0;
			int cnt = 0;
			REP(j, n) {
				if (i & (1 << j)) {
					sum += j + 1;
					cnt++;
				}
			}
			if (sum == s&&cnt==k)ans++;
		}
		cout <<ans << endl;
	}
	return 0;
}

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

int main(){
  int n;
  cin>>n;
  int cnt=0;
  int a,b;
  int flag=0;
  for(int i=0;i<n;i++){
    cin>>a>>b;
    if(a==b)
       cnt++;
    if(cnt==3)
      flag=1;
    if(a!=b)
      cnt=0;
  }
  
  if(flag==1)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

Measured memory_bytes: 3632
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int h, w;
vector<vector<char>> s;

void solve() {
	cin >> h >> w;
    s.assign(h, vector<char>(w));
    rep(i, h) {
        rep(j, w) {
            cin >> s[i][j];
        }
    }
    vector<vector<int>> check(h, vector<int>(w - 1));
    rep(j, w - 1) {
        rep(i, h) {
            check[i][j] = ((s[i][j] == '#') ^ (s[i][j + 1] == '#'));
        }
    }
    // rep(i, h) {
    //     rep(j, w - 1) {
    //         cerr << check[i][j];
    //     }
    //     cerr << endl;
    // }
    vector<vector<int>> cnt(h, vector<int>(w - 1, 1));
    rep(j, w - 1) {
        int cur = 1, now = check[0][j];
        for(int i = 1; i < h; ++ i) {
            if(now == check[i][j]) {
                ++ cur;
                cnt[i][j] = cur;
            } else {
                cur = 1;
                cnt[i][j] = cur;
                now = check[i][j];
            }
        }
    }
    // rep(i, h) {
    //     rep(j, w - 1) {
    //         cerr << cnt[i][j];
    //     }
    //     cerr << endl;
    // }
    int ans = max(h, w);
    rep(i, h) {
        vector<int> l(w - 1), r(w - 1);
        stack<int> st;
        rep(j, w - 1) {
            while(st.size() and cnt[i][st.top()] >= cnt[i][j]) st.pop();
            l[j] = (st.empty() ? 0 : st.top() + 1);
            st.push(j);
        }
        while(st.size()) st.pop();
        per(j, w - 1) {
            while(st.size() and cnt[i][st.top()] >= cnt[i][j]) st.pop();
            r[j] = (st.empty() ? w - 1 : st.top());
            st.push(j);
        }
        rep(j, w - 1) {
            chmax(ans, cnt[i][j] * (r[j] - l[j] + 1));
        }
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 69740
H, W = map(int, input().split())

if H == 1:
    print(1)
elif W == 1:
    print(1)
elif W%2 == 0:
    print((H*W)//2)
else:
    if H%2 == 0:
        print((H*(W-1)//2) + (H//2))
    else:
        print((H*(W-1)//2) + (H//2) + 1)

Measured memory_bytes: 38384
#include <iostream>
#include <algorithm>
using namespace std;
int a,b,c,x,y;
int ans=0;

int main(){
	cin>>a>>b>>c>>x>>y;
	if(a+b>c*2){
		ans+=min(x,y)*c*2;
	}else{
		ans+=min(x,y)*(a+b);
	}
	if(x>y){
		if(a>c*2){
			ans+=(x-y)*c*2;
		}else{
			ans+=(x-y)*a;
		}
	}else{
		if(b>c*2){
			ans+=(y-x)*c*2;
		}else{
			ans+=(y-x)*b;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;

int main()
{
	int N;
	vector<int> B;
	cin >> N;

	for (int i = 0; i < N; i++)
	{
		int tmp;
		cin >> tmp;
		B.push_back(tmp - i - 1);
	}

	sort(B.begin(), B.end());
	int b;
	if (N % 2 == 0)
		b = (B[N / 2 - 1] + B[N / 2]) / 2;
	else
		b = B[N / 2];

	long long int result = 0;
	for (int i = 0; i < N; i++)
	{
		result += abs(B[i] - b);
	}


	cout << result << endl;

	return 0;
}

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

struct piece{
	int width;
	int depth;
	inline bool operator < (const piece &p) const {
		return width * depth < p.width * p.depth;
	}
};
int n, w, d;
vector<piece> pieces;

int main(int argc, char const* argv[])
{
	while (cin >> n >> w >> d, n || w || d) {
		pieces.clear();
		piece newp; newp.width = w; newp.depth = d;
		pieces.push_back(newp);
		for (int i = 0; i < n; i++) {
			int p, s; cin >> p >> s;
			p = p - 1;
			int bw = pieces[p].width; int bd = pieces[p].depth;
			int round = 2 * bw + 2 * bd;
			s = s % round;

			piece newp1, newp2;
			if (s < bw) {
				newp1.width = s; newp2.width = bw - s;
				newp1.depth = bd; newp2.depth = bd;
			} else if (s < bw + bd) {
				s = s - bw;
				newp1.width = bw; newp2.width = bw;
				newp1.depth = s; newp2.depth = bd - s;
			} else if (s < bw + bd + bw) {
				s = s - bw - bd;
				newp1.width = s; newp2.width = bw - s;
				newp1.depth = bd; newp2.depth = bd;
			} else {
				s = s - bw - bd - bw;
				newp1.width = bw; newp2.width = bw;
				newp1.depth = s; newp2.depth = bd - s;
			}

			vector<piece>::iterator it;
			it = pieces.begin() + p;
			pieces.erase(it);
			if (newp1.width * newp1.depth < newp2.width * newp2.depth) {
				pieces.push_back(newp1);
				pieces.push_back(newp2);
			} else {
				pieces.push_back(newp2);
				pieces.push_back(newp1);
			}
		}
		sort(pieces.begin(), pieces.end());
		cout << pieces[0].width * pieces[0].depth;
		for (int i = 1; i < pieces.size(); i++) {
			cout << " " << pieces[i].width * pieces[i].depth;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,x; cin >> n >> m >> x;
  set<int> a;
  for(int i = 0; i < m; i++){
    int b; cin >> b;
    a.insert(b);
  }
  int cnt = 0;
  if(x < n/2){
    for(int i = 0; i <= x; i++){
      if(a.count(i)) cnt++;
    }
  }
  else{
    for(int i = x; i <= n; i++){
      if(a.count(i)) cnt++;
    }
  }
  
  cout << cnt;
}

Measured memory_bytes: 3588
H, W = map(int, input().split())
S = [input() for _ in range(H)]
newS = [[0 for _ in range(W)] for _ in range(H)]
for i in range(H):
    for j in range(W):
        if S[i][j] == '.':
            counter = 0
            for k in [-1,0,1]:
                for l in [-1,0,1]:
                    if 0 <= i+k < H and 0 <= j+l <W:
                        if S[i+k][j+l] == '#':
                            counter += 1
            newS[i][j] = counter
        else:
            newS[i][j] = '#'

for i in range(H):
    for j in range(W):
        print(newS[i][j], end='')
    print('\n',end='')


Measured memory_bytes: 3444
n = int(input())
# n, m = list(map(int, input().split()))
s = []
a = ""
_min = 50
for i in range(n):
    b = input()
    if len(b) <= _min:
        _min = len(b)
        a = b
    s.append(b)

for i in range(len(s)):
    if s[i] == a:
        s.pop(i)
        break

ans = []
for i in range(len(a)):
    flag = True
    for j in range(n-1):
        if a[i] in s[j]:
            for k in range(len(s[j])):
                if a[i] == s[j][k]:
                    s[j] = s[j][:k]+s[j][k+1:]
                    break
        else:
            flag = False

    if flag == True:
        ans += a[i]

ans.sort()
for a in ans:
    print(a, end="")



Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;

int n, k;
vector<int> c[10];
int memo[10][5000];

int calc(int g, int b)
{
	int ret = 0;

	if(b == 0) return 0;
	if(g == 0) {
		for(int i = 0; i < b; ++i)
			ret += c[g][i];
		return ret;
	}

	if(memo[g][b] != -1)
		return memo[g][b];

	int sum = 0;

	ret = calc(g - 1, b);

	for(int i = 1; i <= b; ++i) {

		sum += c[g][i - 1];
		ret = max(ret, sum + calc(g - 1, b - i));	
	}

	return memo[g][b] = ret;
}


int main()
{
	memset(memo, -1, sizeof(memo));

	scanf("%d%d", &n, &k);
	for(int i = 0; i < 10; ++i) c[i].reserve(n);
	for(int i = 0; i < n; ++i) {
		int tc, tg;
		scanf("%d%d", &tc, &tg);
		c[tg - 1].push_back(tc);
	}

	for(int i = 0; i < 10; ++i) {

		sort(c[i].rbegin(), c[i].rend());
		for(int j = 1; j < c[i].size(); ++j)
			c[i][j] += (2 * (j + 1) - 2);
	}

	printf("%d\n", calc(9, k));
	

	return 0;
}

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

int main()
{
    int a, b;
    char op;
    
    cin >> a >> op >> b;
    
    if(op == '+')
    {
        cout << a + b << endl;
        return 0;
    }
    else if(op == '-')
    {
        cout << a - b << endl;
        return 0;
    }
    return 0;
}

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

#define FOR(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greater<int>()
#define MAX(a) *max_element(all(a))

using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;

const int INF = 1001001001;
const int MOD = 1000000007;
const long long INFL = (1LL << 60);
const double EPS = 1e-9;

int main() {
  int N;
  cin >> N;
  vi d(N);
  rep(i, N) cin >> d[i];
  sort(all(d));

  int mid = N / 2;
  int res = 0;
  rep(k, d[mid] + 1) {
    if (d[mid - 1] < k && k <= d[mid]) res++;
  }

  cout << res << endl;
}

Measured memory_bytes: 768
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Convert;
using static System.Math;
using static Extentions;

class IO
{
    int idx;
    string[] input = In.ReadToEnd().Split(new[] { " ", "\n", "\r" },
        StringSplitOptions.RemoveEmptyEntries);

    T Get<T>(Func<string, T> parser) => parser(input[idx++]);

    public string S => Get(s => s);
    public char C => Get(char.Parse);
    public int I => Get(int.Parse);
    public long L => Get(long.Parse);
    public double F => Get(double.Parse);
    public decimal D => Get(decimal.Parse);
    public BigInteger B => Get(BigInteger.Parse);

    T[] Gets<T>(int n, Func<string, T> parser)
        => input.Skip((idx += n) - n).Take(n).Select(parser).ToArray();

    public string[] Ss(int n) => Gets(n, s => s);
    public char[] Cs(int n) => Gets(n, char.Parse);
    public int[] Is(int n) => Gets(n, int.Parse);
    public long[] Ls(int n) => Gets(n, long.Parse);
    public double[] Fs(int n) => Gets(n, double.Parse);
    public decimal[] Ds(int n) => Gets(n, decimal.Parse);
    public BigInteger[] Bs(int n) => Gets(n, BigInteger.Parse);

    public void Write<T>(params T[] xs) => WriteLine(string.Join(" ", xs));
    public void Write(params object[] xs) => WriteLine(string.Join(" ", xs));
}

#region Library

static class Extentions
{
}

#endregion

static class Program
{
    public static void Main()
    {
        var sw = new StreamWriter(OpenStandardOutput()) { NewLine = "\n" };
#if DEBUG
        sw.AutoFlush = true;
#else
        sw.AutoFlush = false;
#endif
        SetOut(sw);
        Solve(new IO());
        Out.Flush();
    }

    static void Solve(IO io)
    {
        var n = io.I;
        var xs = io.Is(n);
        var set = new HashSet<int>();
        foreach (var x in xs) if (!set.Add(x)) set.Remove(x);
        io.Write(set.Count);
    }
}

Measured memory_bytes: 29152
x=int(input())

import math

def is_prime(n):
    if n == 1:
        return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

for i in range(10**5):
    if is_prime(x+i) == True:
        print(x+i)
        break
    else:
        continue

Measured memory_bytes: 3060
def emulate(A, x, cumsum, cumsum_skip):
    left = 0
    right = len(A)-2
    while left < right:
        i = (left + right) // 2
        j = len(A) - (len(A) - (i+1)) // 2 - 1
        if x - A[i] <= A[j] - x:
            right = i
        else:
            left = i + 1
    i = (left + right) // 2
    j = len(A) - (len(A) - (i+1)) // 2 - 1
    retval = 0
    if i >= 1:
        retval += cumsum_skip[i-1]
    retval += cumsum[len(A)-1] - cumsum[j-1]
    return retval


def main():
    N, Q = map(int, input().split())
    A = list(map(int, input().split()))
    cumsum = [0] * N
    cumsum_skip = [0] * N
    cumsum[0] = A[0]
    cumsum_skip[0] = A[0] if N % 2 == 1 else 0
    for i in range(1, N):
        cumsum[i] = cumsum[i-1] + A[i]
        if (N - i) % 2 == 1:
            cumsum_skip[i] = cumsum_skip[i-1] + A[i]
        else:
            cumsum_skip[i] = cumsum_skip[i-1]
    for _ in range(Q):
        x = int(input())
        print(emulate(A, x, cumsum, cumsum_skip))


if __name__ == "__main__":
    main()


Measured memory_bytes: 73472
#include<bits/stdc++.h>
#define For(i, n) for(int i=0; i<n; i++)
inline int read(){int x=0; int sign=1; register char c=getchar();while(c>'9'||c<'0'){if(c=='-')sign=-1; c=getchar();}while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+c-'0'; c=getchar();}return x*sign;}
using namespace std;


int main(){
	int n = read();
	if (n % 2 == 0) {
		cout<<(n / 2 - 1);
	} else {
		cout<<(n / 2);
	}
	return 0;
}


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(obj) obj.begin(), obj.end()
#define fcout cout << setprecision(10)

const int iINF = 1e9;
const long long llINF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

template <typename T>
void debug(vector<T> &vec) {
    for (auto x : vec) {
        cout << x << " ";
    }
    cout << endl;
    return;
}

template <typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}

template <typename T>
int getFormer(const vector<T> &vec, T x) {
    return upper_bound(vec.begin(), vec.end(), x) - vec.begin() - 1;
}

template <typename T>
int getLatter(const vector<T> &vec, T x) {
    return lower_bound(vec.begin(), vec.end(), x) - vec.begin();
}

int n, m, b[510], dp[2][(1 << 23)];
string s[510];
bool odd[510];
void solve(int n, int m) {
    FILL(b, 0);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
        for (int j = 0; j < m; j++) {
            if (s[i][j] == '0') continue;
            b[i] |= (1 << j);
        }
    }

    if (n <= 20) {
        int ans = 0;
        for (int S = 0; S < (1 << n); S++) {
            FILL(odd, false);
            int cnt = 0;
            for (int i = 0; i < n; i++) {
                if ((S >> i) & 1) {
                    for (int j = 0; j < m; j++) {
                        if (s[i][j] == '0') continue;
                        odd[j] = !odd[j];
                    }
                    cnt += 1;
                }
            }

            if (accumulate(odd, odd + m, 0)) continue;
            ans = max(ans, cnt);
        }

        cout << ans << endl;
    } else {
        FILL(dp, -1);
        dp[0][0] = 0;
        int ans = 0;
        for (int i = 0; i < n; i++) {
            int now = i % 2;
            for (int S = 0; S < (1 << m); S++) {
                if (dp[now][S] == -1) continue;
                int next = S ^ b[i];
                dp[now ^ 1][S] = max(dp[now ^ 1][S], dp[now][S]);
                dp[now ^ 1][next] = max(dp[now ^ 1][next], dp[now][S] + 1);
                if (next == 0) ans = max(ans, dp[now ^ 1][next]);
                if (S == 0) ans = max(ans, dp[now ^ 1][S]);
            }
            for (int S = 0; S < (1 << m); S++) {
                dp[now][S] = -1;
            }
        }

        cout << ans << endl;
    }
}

int main() {
    int n, m;
    while (cin >> n >> m && n) {
        solve(n, m);
    }
    return 0;
}


Measured memory_bytes: 68716
#include <bits/stdc++.h>
#define max(x, y) ((x) > (y) ? (x) : (y))
#define min(x, y) ((x) < (y) ? (x) : (y))
#define abs(x) ((x) < 0 ? (-(x)) : (x))
#define rep(i,a,m) for((i) = (a) ; (i) < (m) ; ++(i))
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rall(x) x.end(),x.begin()
#define sz(x) ((int)x.size())
#define PI 3.14159265

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pi;

int main ()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t,T;
	cin >> T;	
    vl vec(T);
    vl A(T);
    vl B(T);
    vl C(T);
	for(t = 0; t < T; ++ t){
        cin >> A[t] >> B[t] >> C[t];
	}
    for(int i = 1; i < T; ++ i) {
        A[i] += max(B[i-1], C[i-1]);
        B[i] += max(A[i-1], C[i-1]);
        C[i] += max(A[i-1], B[i-1]);
    }
    cout << max(A[T-1], max(B[T-1], C[T-1])) << endl;
	return 0;
}

Measured memory_bytes: 3456
from queue import deque

class LinkedListNode:
	def __init__(self, value):
		self.value = value
		self.left = self
		self.right = self

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

A_list.sort()

circle = LinkedListNode(A_list.pop())
not_used = deque((circle, ))

total = 0
while len(A_list) > 0:
	value = A_list.pop()
	
	new_node = LinkedListNode(value)
	while True:
		head = not_used[0]
		if head.left.value >= head.value:
#			print("l", head.left.value, value, head.value)
			total += head.value
			new_node.right = head
			new_node.left = head.left
			head.left.right = new_node
			head.left = new_node
			break
		elif head.right.value >= head.value:
#			print("r", head.right.value, value, head.value)
			total += head.value
			new_node.right = head.right
			new_node.left = head
			head.right.left = new_node
			head.right = new_node
			break
		not_used.popleft()
	not_used.append(new_node)

print(total)


Measured memory_bytes: 51152
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>

using namespace std;

#define all(x) (x).begin(),(x).end()
#define ll long long
#define pii pair<int,int>
#define y1 Emilia
#define N 500500
#define dracarys ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);

int n;
pii a[N];

int main(){
    dracarys
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i].first;
        a[i].second = i;
    }
    sort (a + 1, a + n + 1);
    for (int i = 1; i <= n; ++i)
        cout << a[i].second << " ";
    
    return 0;
}


Measured memory_bytes: 1664
#include <iostream>
using namespace std;
int main(void){
    long long int X;
    cin>>X;
    for(long long int i=-1000;i<1001;i++){
        for(long long int j=-1000;j<1001;j++){
           if(i*i*i*i*i-j*j*j*j*j==X){
               cout<<i<<" "<<j<<endl;
               return 0;
           } 
        }
    }
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
LL p = 1000000007ll;

int main(void)
{
  LL n;
  cin >> n;
  vector<vector<pair<LL,LL> > > nei(n+1);
  REP(i,n-1) {
    LL u, v, w;
    cin >> u >> v >> w;
    nei[u].emplace_back(v,w);
    nei[v].emplace_back(u,w);
  }
  queue<pair<LL,LL> > q;
  q.emplace(1,2);
  vector<LL> dist(n+1);
  while(!q.empty()) {
    auto p = q.front();
    q.pop();
    if(dist[p.first]) continue;
    dist[p.first] = p.second;
    for(auto np:nei[p.first]) {
      q.emplace(np.first, p.second + np.second);
    }
  }
  FOR(i,1,n+1) {
    cout << dist[i]%2 << endl;
  }
  return 0;
}


Measured memory_bytes: 8704
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <string.h>
#include <cstring>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define NEWLINE cout << '\n'
#define loop(n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define MULTI_TEST int t; cin >> t; while (t--) 

#define EXTERNAL_FILES 0
#if EXTERNAL_FILES
ifstream fin("input.txt");
ofstream fout("output.txt");
#define cin fin
#define cout fout
#endif

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<vi, int> msi;

ll gcd(ll a, ll b) {
	if (b == 0)
		return a;
	return gcd(b, a % b);
}

string binary(int n) {
	string bin;
	while (n) {
		bin += (n % 2 ? '1' : '0');
		n /= 2;
	}
	reverse(bin.begin(), bin.end());
	return bin;
}
bool isPalindrome(string s) {
	for (int i = 0, j = s.size() - 1; i < j; i++, j--)
		if (s[i] != s[j]) return 0;
	return 1;
}
bool isPrime(ll n) {
	if (n <= 1) return false;
	for (ll i = 2; i * i <= n; i++) {
		if (n % i == 0) return false;
	}
	return true;
}
inline vi sieve(int n) {
	vector<bool> isPrime(n + 1, true);
	for (int i = 2; i <= sqrt(n); i++) {
		if (isPrime[i])
			for (int j = 2 * i; j <= n; j += i) {
				isPrime[j] = false;
			}
	}
	vi primes;
	for (int i = 2; i <= n; i++)
		if (isPrime[i]) primes.push_back(i);
	return primes;
}

inline vi primeFactors(int n) {
	vi factors;
	vi primes = sieve(100000);
	int i = 0;
	while (n != 1 && i < primes.size()) {
		if (n % primes[i] == 0) {
			factors.push_back(primes[i]);
			n /= primes[i];
		}
		else {
			i++;
		}
	}
	return factors;
}

void shift_right(vi& A, int x) {
	int n = A.size();
	x %= n;
	vi B(n);
	for (int i = 0; i < n; i++)
		B[(i + x)%n] = A[i];
	A = B;
}
inline vector<bool> sieveQuery(int n) {
	vector<bool> isPrime(n + 1, true);
	for (int i = 2; i <= sqrt(n); i++) {
		if (isPrime[i])
			for (int j = 2 * i; j <= n; j += i) {
				isPrime[j] = false;
			}
	}
	return isPrime;
}
#define EXTERNAL_OUT 0
#if EXTERNAL_OUT 
ofstream fout("output.txt");
#define cout fout
#endif

struct customer {
	int priority;
	bool isMe;
};

int trailingZeros(int n) {
	int ans = 0;
	while (n % 10 == 0 && n) {
		ans++;
		n /= 10;
	}
	return ans;
}

struct query {
	int l, r, d;
};

int main()
{
	IOS;
	int n, x, t;
	cin >> n >> x >> t;
	cout << int(ceil(n / float(x)) * t);
	
#if EXTERNAL_OUT
	fout.close();
	system("output.txt");
#endif
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	int N, L[210];
	cin >> N;
	for (int i = 0; i < N * 2; i++) cin >> L[i];
	int ans = 0;
	sort(L, L + N * 2);
	for (int i = 0; i < N * 2; i += 2) ans += min(L[i], L[i + 1]);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define MAX 50 
using namespace std; 
int main() 
{ 
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long int n;
    cin>>n; 
    char a[MAX]; 
    int i = 0;
    while (n > 0) { 
        int q = n % 26;  
        if (q == 0) { 
            a[i++] = 'z'; 
            n = (n / 26) - 1; 
        } 
        else
        { 
            a[i++] = (q - 1) + 'a'; 
            n = n / 26; 
        } 
    } 
    a[i] = '\0'; 
    reverse(a, a + strlen(a)); 
    cout << a << endl; 
    return 0; 
} 

Measured memory_bytes: 3628
#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;
	ll ch[200010];
	for(ll i=0;i<k;i++){
		cin>>ch[i];
	}
	ll ans=n-ch[k-1]+ch[0];
	for(ll i=1;i<k;i++){
		ll now=ch[i]-ch[i-1];
		ans=max(now,ans);
	}
	cout <<n-ans;
	return 0;
}

Measured memory_bytes: 5164
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		var di = new Dictionary<int,List<Pair>>();
		for(int i=0;i<M;i++){
			if(!di.ContainsKey(P[i]))di.Add(P[i], new List<Pair>());
			di[P[i]].Add(new Pair(i, Y[i]));
		}
		
		String[] ans = new String[M];
		foreach(var pr in di.Keys){
			var l = di[pr].ToList();
			l.Sort( (p, q) => p.Y.CompareTo(q.Y));
			for(int i=0;i<l.Count;i++){
				ans[l[i].Idx] = String.Format("{0:D06}{1:D06}", pr, i + 1);
			}
		}
		
		Console.WriteLine(String.Join("\n",ans));
		
	}
	
	class Pair{
		public int Idx,Y;
		public Pair(int idx, int y){
			Idx = idx; Y = y;
		}
	}
	
	
	int N,M;
	int[] P,Y;
	public Sol(){
		var d = ria();
		N = d[0]; M = d[1];
		P = new int[M];
		Y = new int[M];
		for(int i=0;i<M;i++){
			d = ria();
			P[i] = d[0]; Y[i] = d[1];
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 46252
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <new>

using namespace std;

typedef long long ll;

#define rep(i, N) for (ll i = 0; i < (ll)(N); ++i)

int main(){
    ll N;
	cin >> N;
	vector<int> A(N,0);
    vector<int> DP(N,0);
    vector<int> flag(N,0);

	rep(i,N){
		cin >> A[i];
		if(A[i] % 2 == 0 && (A[i] % 3 == 0||A[i] % 5 == 0)){
			flag[i] = 1;
		}
		if(A[i] % 2 == 0){
			DP[i] = 1;
		}
		
	}

	rep(i,N){
		if(DP[i] != flag[i]){
			cout << "DENIED" << endl;
			break;
		}
		if(i == N - 1){
			cout << "APPROVED" << endl;
		}
	}



	

	
    
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
#include <string>
#include <algorithm>
#include <map>
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  int ans=0;
  rep(i, 1000){
    ostringstream sout;
    sout << std::setfill('0') << std::setw(3) << i;
    string num = sout.str();
    int p = 0;
    rep(j, N){
      if (S[j] == num[p]){
        p++;
      }
    }
    if (p > 2){
      ans ++;
    }
  }
  cout << ans <<endl;
}  

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long int LL;
typedef vector<int> ivec;
typedef vector<string> svec;

int a[100010];
int main(){
	LL n;
	cin>>n;	
	n--;
	int a=sqrt(8*n+1);
    
	cout<<(a+1)/2<<endl;
	return 0;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
b=A[0]

if(A.count(0)!=0):
    print('0')
    exit()

for i in range(1,len(A)):
    b=b*A[i]
    if(10**18<b):

        print('-1')
        exit()
        
print(b)


Measured memory_bytes: 84688
import math
x = int(input())


def isPrime(n):
    if n == 2:
        return True
    if n % 2 == 0:
        return False

    # nの平方根まで計算する
    m = math.floor(math.sqrt(n)) + 1
    for p in range(3, m, 2):
        if n % p == 0:
            return False
    return True


for i in range(x, x+200):
    if isPrime(i):
        print(i)
        break
    else:
        continue



Measured memory_bytes: 3060
N, K, *A = map(int, open(0).read().split())

A = [a + 1 for a in A]
M = max(A)

N0 = 2 ** (M - 1).bit_length()
data = [0] * (2 * N0)

def update(k, x):
    k += N0 - 1
    data[k] = x
    while k >= 0:
        k = (k - 1) // 2
        data[k] = max(data[2 * k + 1], data[2 * k + 2])

def query(l, r):
    L = l + N0; R = r + N0
    s = 0
    while L < R:
        if R & 1:
            R -= 1
            s = max(s, data[R-1])

        if L & 1:
            s = max(s, data[L-1])
            L += 1
        L >>= 1; R >>= 1
    return s

for a in A:
    x = query(max(1, a - K), min(a + K + 1, M + 1))
    update(a, x + 1)

print(query(1, M))

Measured memory_bytes: 143760
A, B, C, D = $stdin.read.chomp.split(" ").map(&:to_i)

lcm = C.lcm(D)

puts B - B/(C.to_f).floor - B/(D.to_f).floor + B/(lcm.to_f).floor - ((A-1) - (A-1)/(C.to_f).floor - (A-1)/(D.to_f).floor + (A-1)/(lcm.to_f).floor)



Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef vector<lint> vlint;

#define inf 1e+9
#define endl "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define rep_rev(i, n) for (int i = n-1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()

#define pb push_back
#define eb emplace_back
#define Size(c) (int)(c).size()

#define lb(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define ub(c, x) distance((c).begin(), upper_bound(all(c), (x)))

template <class T> using pq = priority_queue<T>;
template <class T> using pqg = priority_queue<T, vector<T>, greater<T>>;

template <class T, class S> inline bool chmax(T &a, S b) {
    if(a < b) {a = b;return 1;} return 0;
}
template <class T, class S> inline bool chmin(T &a, S b) {
    if(a > b) {a = b;return 1;} return 0;
}
template <class T>
void line(vector<T> &x){for (auto&& xi : x) cin >> xi;}

inline void IN(void){ return;}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){ cin >> first; IN(rest...); return;}

#define INT(...) int __VA_ARGS__; IN (__VA_ARGS__)
#define LINT(...) lint __VA_ARGS__; IN (__VA_ARGS__)
#define STR(...) string __VA_ARGS__; IN(__VA_ARGS__)

template <class T> void UNIQUE(vector<T> &x) {
    sort(all(x)); x.erase(unique(all(x)), x.end());
}
template <class T> void print_vec(T first, T end){
    for (auto i = first; i < end - 1; i++) cout << *i << " ";
    cout << *(end-1) << endl;
}

template<class... T>
void debug_print(T... args){
    vector<lint> tmp = initializer_list<lint>{args...};
    print_vec(all(tmp));
}
template<class T>
void print(T a){ cout << a << endl;}

vector<string> Yes = {"No", "Yes"};
vector<string> YES = {"NO", "YES"};

int ord(char x){ return (int)(x - 'a');}
char chr(lint x){ return (char)(x + (lint)('a'));}
lint mod = 1e9+7;
// lint mod = 

lint sum(vlint a){lint ret = 0; for(auto&& v:a) ret += v; return ret;}
lint vmini(vlint a, lint &index){
    lint ret = LLONG_MAX;
    rep(i, Size(a)){ if (chmin(ret, a[i])) index = i;}
    return ret;
}
lint vmaxi(vlint a, lint &index){
    lint ret = -LLONG_MAX;
    rep(i, Size(a)){ if (chmax(ret, a[i])) index = i;}
    return ret;
}

lint vmin(vlint a){
    lint ret = LLONG_MAX; for (auto && v : a) chmin(ret, v); return ret;
}
lint vmax(vlint a){
    lint ret = -LLONG_MAX; for (auto && v : a) chmax(ret, v); return ret;
}


vlint base_3(int k){
    vlint ret; while (k > 0){ ret.pb(k % 3); k /= 3;} reverse(all(ret)); return ret;
}

int main(){
    STR(s);
    int ret = 0;
    int ct = 0;
    rep(i, 3){
        if (s[i] == 'R') ct++;
        else{
            chmax(ret, ct); ct = 0;
        }
    }
    chmax(ret, ct);
    print(ret);
}


Measured memory_bytes: 3624
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		final int h = 50;
		final int w = 100;

		@SuppressWarnings("resource")
		Scanner stdin = new Scanner(System.in);

		int a = stdin.nextInt();
		int b = stdin.nextInt();

		char[][] grid = new char[h][];
		for (int i = 0; i < (h / 2); i++) {
			grid[i] = new char[w];
			Arrays.fill(grid[i], '.');
		}
		for (int i = (h / 2); i < h; i++) {
			grid[i] = new char[w];
			Arrays.fill(grid[i], '#');
		}

		int count = 1;
		int y = (h / 2) + 1;
		int x = (y % 3) + 1;
		while (count < a) {
			grid[y][x] = '.';
			count++;

			x += 3;
			if (x >= (w - 1)) {
				y++;
				x = (y % 3) + 1;
			}
		}

		count = 1;
		y = 1;
		x = (y % 3) + 1;
		while (count < b) {
			grid[y][x] = '#';
			count++;

			x += 3;
			if (x >= (w - 1)) {
				y++;
				x = (y % 3) + 1;
			}
		}

		System.out.println(h + " " + w);
		for (int i = 0; i < h; i++) {
			System.out.println(new String(grid[i]));
		}
	}

}


Measured memory_bytes: 23508
def slove():
    import sys
    input = sys.stdin.readline
    n, m = list(map(int, input().rstrip('\n').split()))
    lr = [list(map(int, input().rstrip('\n').split())) for _ in range(m)]
    a = [0] * (n + 2)
    for l, r in lr:
        a[l] += 1
        a[r + 1] -= 1
    t = 0
    cnt = 0
    for i in range(1, n + 1):
        t += a[i]
        if t == m:
            cnt += 1
    print(cnt)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 57052
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

class Solve{
    static void Main(string[] args){
        var N = int.Parse(Console.ReadLine());
        var P = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var Q = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        int a = 1, b = 1;
        var set = new HashSet<int>();
        for (int i = 0; i < N; i++){
            var pi = P[i];
            int count = 0;
            if(set.Any())
                foreach (var s in set){
                    if (s < pi) count++;}
            var x = pi - count;
            a += i == N - 1 ? 1 : (x - 1) * Factorial(N - 1 - i);
            set.Add(pi);}
        set.Clear();
        for (int i = 0; i < N; i++){
            var qi = Q[i];
            int count = 0;
            if (set.Any())
                foreach (var s in set){
                    if (s < qi) count++;}
            var x = qi - count;
            b += i == N - 1 ? 1 : (x - 1) * Factorial(N - 1 - i);
            set.Add(qi);}
        var answer = Math.Abs(a - b);
        var writer = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(writer);
        Console.WriteLine(answer);
        Console.Out.Flush();}

    public static int Factorial(int n){
        int result = 1;
        for (int i = n; i > 1; i--){
            result *= i;}
        return result;}}

Measured memory_bytes: 28236