akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
int dp[3010][6010];
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, T;
    cin >> N >> T;
    int A[3010], B[3010];
    rep(i, N) cin >> A[i] >> B[i];
    rep(i, N) {
        rep(j, T) dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
        rep(j, T) {
            if (j - A[i] >= 0)
                dp[i + 1][j] = max(dp[i + 1][j], max(dp[i][j], dp[i][j - A[i]] + B[i]));
        }
    } 
    int ans = 0;
    /*
    rep(i, N + 1) {
        rep(j, T + 1) {
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }
    //*/
    //rep(i, 6010) ans = max(ans, dp[N][i]);
    int i = N, j = T - 1;
    vector<int> v;
    while(i > 0) {
        //cout << i << " " << j << " " << dp[i][j] << endl;
        RREP(k, j, 0) {
            //cout << "*" << i - 1 << " "<< k << " " << dp[i - 1][k] + B[i - 1] << endl;
            if (dp[i - 1][k] + B[i - 1] == dp[i][j]) {
                i--;
                j = k;
                break;
            }
            if (dp[i - 1][k] == dp[i][j]) {
                i--;
                j = k;
                v.push_back(i);
                break;
            }
        }
    }
    rep(i, v.size()) ans = max(ans, B[v[i]]);
    //rep(i, v.size()) cout << B[v[i]] << " ";
    //cout << endl;

    cout << dp[N][T - 1] + ans << endl;
    return 0;
}


Measured memory_bytes: 140800
import java.util.Scanner

object Main {
  def solve(sc: => Scanner): Unit = {
    val Arr = Array.fill[Int](sc.nextInt)(sc.nextInt).groupBy(c => c).foldLeft[(Long, Long)]((0, 0))((A, B) => (
      if (B._2.length >= 4) ((math.max(A._1, B._1), math.max(A._2, B._1))) else if (B._2.length >= 2) (if (A._1 < A._2) ((math.max(A._1, B._1), A._2)) else ((A._1, math.max(A._2, B._1))))
      else (A)
      ))
    println(Arr._1 * Arr._2)
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}


Measured memory_bytes: 107248
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) \
    for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) \
    for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(), v.end()
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e15 + 7LL;
constexpr ll MOD = 1e9 + 7LL;
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (int i = 0; i < v.size(); ++i) {
        is >> v[i];
    }
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    for (int i = 0; i < v.size() - 1; ++i) {
        os << v[i] << " ";
    }
    if (v.size() > 0) {
        os << v[v.size() - 1] << endl;
    }
    return os;
}

int main() {
    int h,w,k;
    cin>>h>>w>>k;
    vector<vector<char>> G(h, vector<char>(w));
    REP(i,h){
        REP(j, w) { cin >> G[i][j]; }
    }
    int ans = 0;
    for (int i = 0; i < (1 << h); ++i) {
        for (int j = 0; j < (1 << w); ++j){
            vector<bool> xflag(h,true), yflag(w,true);
            REP(k, h){
                if (i & (1 << k)){
                    xflag[k] = false;
                }
            }
            REP(k, w) {
                if (j & (1 << k)) {
                    yflag[k] = false;
                }
            }
            int cnt = 0;
            REP(k,h){
                REP(l,w){
                    if (G[k][l] == '#'){
                        if (xflag[k] && yflag[l]){
                            ++cnt;
                        }
                    }
                }
            }
            if (cnt == k) ++ans;
        }
    }
    cout << ans << endl;
}

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

const int MAXN = 3000 + 10;

typedef long long ll;

int n, m, k, val[MAXN][MAXN];
ll f[4][MAXN][MAXN];

int main() {
	scanf("%d %d %d", &n, &m, &k);
	for (int i = 1; i <= k; ++i) {
		int x, y, _val; scanf("%d %d %d", &x, &y, &_val);
		val[x][y] = _val;
	}
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) {
			for (int pre = 0; pre <= 3; ++pre) f[0][i][j] = max(f[0][i][j], f[pre][i - 1][j]), f[1][i][j] = max(f[1][i][j], f[pre][i - 1][j] + val[i][j]);
			f[0][i][j] = max(f[0][i][j], f[0][i][j - 1]);
			for (int cnt = 1; cnt <= 3; ++cnt) {
				f[cnt][i][j] = max(f[cnt][i][j], max(f[cnt][i][j - 1], f[cnt - 1][i][j - 1] + val[i][j]));
			}
		}
	}
	ll ans = 0;
	for (int cnt = 0; cnt <= 3; ++cnt) ans = max(ans, f[cnt][n][m]);
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 321176
import sys

a, b = map(int, sys.stdin.readline().split())

def main():
    res = -1
    for i in range(1, 2000):
        if i * 8 // 100 == a and i // 10 == b:
            res = i
            break
    print(res)

if __name__ ==  '__main__':
    main()

Measured memory_bytes: 3064
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    int n;
    ll x;
    cin >> n >>x;
    ll ans = 0;
    ll now = 0;
    rep(i, n) {
        ll a;
        cin >> a;
        if(!i) {
            if(a>x) {
                ans += a-x;
                now = x;
            } else {
                now = a;
            }
        }
        else {
            if(now+a<=x) {
                now = a;
            } else {
                ans += now+a-x;
                now = x-now;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    if(count(s.begin(), s.end(), 'o') + 15 - (int)s.size() >= 8) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 256
// vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv
#include <bits/stdc++.h>
using namespace std; using ll = long long; using P = pair<ll, ll>;
const ll linf = 1e18; const double eps = 1e-12, pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define each(i,a) for (auto&& i : a)
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
#define min(x,y) (x < y ? x : y)
#define max(x,y) (x < y ? y : x)
template<typename Head> void out(Head h) { cout << h << endl; } template<typename Head, typename... Tail>void out(Head h, Tail... t) { cout << h << " "; out(t...); }
template<typename T> istream& operator>>(istream& is, vector<T>& v) { each(x,v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<string>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
struct yes_no : std::numpunct<char> { string_type do_truename() const { return "Yes"; } string_type do_falsename() const { return "No"; } };
void solve(); int main() {
  ios::sync_with_stdio(false); cin.tie(0); locale loc(locale(), new yes_no); cout.imbue(loc); cout << fixed << setprecision(10) << boolalpha;
  solve();
}
// ^^^^^^^^^^^^ TEMPLATE ^^^^^^^^^^^^

ll solve(ll t, ll k) {
  if (t == 0) return 0;
  ll res = 0, speed = 1;
  rep(i, k) {
    t -= speed;
    ++res;
    if (0 < i && i < k-1) {
      t -= speed;
      ++res;
    }
    speed *= 3;
    if (t < 0) return linf;
  }
  if (t < 0) return linf;
  rrep(i, k) {
    speed /= 3;
    ll use = t / speed;
    t -= use * speed;
    res += use;
  }
  return res;
}

void solve() {
  ll t; cin >> t;
  ll ans = linf;
  // solve(t, 2);
  // return;
  // rep(i, 35) cout << i << " " << solve(t, i) << endl;
  rep(i, 40) chmin(ans, solve(t, i+1));
  cout << ans << endl;
}



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

int main(){
    int n; cin >> n;
    vector<int> a(n), b(n-1);
    rep(i,n-1) cin >> b[i];

    a[0] = b[0];
    for(int i = 0; i < n-1; i++){
        a[i+1] = min(b[i+1],b[i]);
    }
    a[n-1] = b[n-2];

    cout << accumulate(a.begin(),a.end(),0) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <limits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <array>
#include <map>
#include <set>
#include <deque>
#include <list>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cstring>
#include <bitset>
#include <stack>
#include <queue>

using namespace std;

static const uint64_t MOD = 1e9 + 7;

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

    int coins;
    cin >> coins;

    vector<double> dp(coins + 1);
    dp[0] = 1;

    for (int coin = 0; coin < coins; ++coin) {
        double head;
        cin >> head;
        double tail = 1 - head;

        for (int i = coin + 1; i >= 0; --i) {
            dp[i] = (i == 0 ? 0 : dp[i - 1] * head) + dp[i] * tail;
        }
    }

    double res = 0;
    for (int heads = 0; heads <= coins; ++heads) {
        int tails = coins - heads;
        if (heads > tails) {
            res += dp[heads];
        }
    }
    printf("%.10lf\n", res);
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

char c;

int main() { 

  cin >> c;
  c++;
  cout << c << endl;

  return 0;
}


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

int main()
{
  int64_t q, h, s, d, n;
  cin >> q >> h >> s >> d >> n;
  q *= 4;
  h *= 2;
  int64_t a = min({q, h, s});
  int64_t ans;
  if (a * 2 <= d) {
    ans = n * a;
  } else {
    ans = n / 2 * d;
    if (n % 2 != 0)
      ans += a;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int h,w,i,j,k,cnt;
	int a[100][100];
	char s[100][101];
	scanf("%d %d",&h,&w);
	for(i=0;i<h;i++){ 
		scanf("%s",s[i]);
	}
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			a[i][j]=-1;
		}
	}
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			if(s[i][j]=='c')	a[i][j]=0;
			else if(s[i][j]=='.'){
				cnt=1;
				for(k=j-1;k>=0;k--){
					if(s[i][k]=='.')	cnt++;
					else if(s[i][k]=='c'){
						a[i][j]=cnt;
						cnt=1;
						break;
					}
				}
			}
		}
	}
	for(i=0;i<h;i++){
		j=0;
		printf("%d",a[i][j]);
		for(j=1;j<w;j++){
			printf(" %d",a[i][j]);
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2804
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int n; cin >> n;
  vii s(n);
  rep(i,n) {
    int t; cin >> t;
    s[i] = ii(i+1,t);
  }
  sort(s.begin(), s.end(), [](ii a, ii b) {return a.second<b.second;} );
  rep(i,n) {
    cout << s[i].first << ' ';
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 1664
n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]

a = sorted([x[0] for x in ab])
b = sorted([y[1] for y in ab])

if n % 2 == 0:
    print((b[n // 2 - 1] + b[n // 2]) - (a[n // 2 - 1] + a[n // 2]) + 1)
else:
    print(b[(n - 1) // 2] - a[(n - 1) // 2] + 1)

Measured memory_bytes: 50724
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define FOR(i, n, m) for(int (i) = (n); (i) < (m); ++(i))

constexpr int INF = 1e9;
//constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;


vector<pair<ll, ll>> k_dp(85, {0, 0}), c_dp(85, {0, 0});

void k_update(pair<ll, ll> current, int idx){
  if(current.first > k_dp[idx].first){
    k_dp[idx] = current;
  }
  else if(current.first == k_dp[idx].first && current.second > k_dp[idx].second){
    k_dp[idx] = current;
  }
}

void c_update(pair<ll, ll> current, int idx){
  if(current.second > c_dp[idx].second){
    c_dp[idx] = current;
  }
  else if(current.second == c_dp[idx].second && current.first > c_dp[idx].first){
    c_dp[idx] = current;
  }
}
int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  REP(i, N){
    cin >> A[i];
  }
  k_dp[0] = c_dp[0] = {1000, 0};
  REP(i, N){
    pair<ll, ll> current = k_dp[i];
    k_update(current, i+1);
    c_update(current, i+1);
    current.first += current.second * A[i];
    current.second = 0;
    k_update(current, i+1);
    c_update(current, i+1);
    current = k_dp[i];
    current.second += current.first / A[i];
    current.first = (current.first % A[i]);
    k_update(current, i+1);
    c_update(current, i+1);
    current = c_dp[i];
    current.first += current.second * A[i];
    current.second = 0;
    k_update(current, i+1);
    c_update(current, i+1);
    current = c_dp[i];
    current.second += current.first / A[i];
    current.first = (current.first % A[i]);
    k_update(current, i+1);
    c_update(current, i+1);
  }
  cout << k_dp[N].first << endl;
  return 0;
}


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

#define int        long long
// #define mp      make_pair
#define eb         emplace_back
#define pb         push_back
#define ss         second
#define ff         first
#define IOS        ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod        998244353
#define MOD        (1000*1000*1000+7)
#define MN         LLONG_MIN
#define MX         LLONG_MAX
#define v1d        vector<int>
#define v2d        vector<vector<int>>
#define vip        vector<pair<int,int> >
#define v1s        vector<string>
#define pa         pair<int,int>
#define mxpq(T)    priority_queue <T>
#define mnpq(T)    priority_queue<T,vector<T>,greater<T>>
#define print(v)   for(auto i:v)cout<<i<<" ";cout<<"\n";
#define p2d(v)     for(auto a:v){for(auto b:a)cout<<b<<" ";cout<<endl;}
#define p1d(v)     for(auto a:v)cout<<a<<" ";cout<<endl;
#define ppd(v)     for(auto a:v)cout<<a.ff<<" "<<a.ss<<endl;
#define endl       "\n"
#define input(b,n) for(int i=0;i<n;i++)cin>>b[i];
#define Sort(v)    sort(v.begin(),v.end())
#define RSort(v)   sort(v.rbegin(),v.rend())
#define all(v)     v.begin(),v.end()
int gcd(int a,int b){return b?gcd(b,a%b):a;}
//string s = bitset<64>(a).to_string();

void azmuth(int n=12){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout<<setprecision(n)<<fixed;
    
}
int lb = 1000000000;

//____________________________________________________________________________________

vip v;
int n,W;

void solve(){
    cin>>n>>W;
    v.resize(n+1);
    for(int i=1;i<=n;i++){
        int w,val;cin>>w>>val;
        v[i] = {w,val};
    }
    int k = 1e12;
    v2d dp(n+1,v1d(100005,k));
    for(int i=0;i<=n;i++)dp[i][0] = 0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=100000;j++){
            dp[i][j] = dp[i-1][j];
            if(j-v[i].ss >= 0){
                dp[i][j] = min(dp[i][j],dp[i-1][j-v[i].ss]+v[i].ff);
            }
        }
    }

    // for(int i=0;i<=6;i++){
    //     for(int j=0;j<30;j++)cout<<dp[i][j]<<" ";cout<<"\n";
    // }

    int ans = 0;
    for(int i=100000;i>0;i--)
        if(dp[n][i] <= W){//cout<<dp[n][i]<<"\n";
            ans = i;break;
        }
    cout<<ans<<"\n";
}

int32_t main(){
    azmuth();
    int t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
    


    return 0;
}

Measured memory_bytes: 80384
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <climits>
using namespace std;

typedef ostringstream OSS;
typedef istringstream ISS;

typedef vector<int> VI;
typedef vector< VI > VVI;

typedef long long LL;

typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define X first
#define Y second

int main(void) {
	string needle;
	int N;
	cin >> needle >> N;

	int cnt = 0;
	
	for (int i = 0; i < N; i++) {
		string s;
		cin >> s;
		string heystack = s + s;

		cnt += heystack.find(needle) != string::npos;
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 1212
#include <stdio.h>

int main(){
    int l[10];
    int v1, v2, km, i;
    double eki;

    while(scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", &l[0],&l[1],&l[2],&l[3],&l[4],&l[5],&l[6],&l[7],&l[8],&l[9],&v1,&v2) != EOF){
        km = 0;
        eki = 0;

        for(i = 0; i < 10; i++) km += l[i];
        eki = (double)km / (v1 + v2) * v1;

        for(i = 0; i < 10; i++){
            if(eki <= l[i]){
                printf("%d\n", i+1);
                break;
            }
            eki -= (double)l[i];
        }
    }
    return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 10;
ll n, k;
int main()
{
	cin >> n >> k;
	ll cnt = 0;
	while (n)
	{
		cnt++;
		n /= k;
	}
	cout << cnt << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	while(true){
		int t,n;
		int a,f;
		int sum=0;

		cin >> t;
		if(t==0)
			break;

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

			cin >> a >> f;

			sum += (f - a);
		}

		if(sum >= t){
			cout << "OK" << endl;
		}
		else if(sum < t){
			cout << t - sum << endl;
		}

	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

int p(int x){
  if(x==3) return 100000;
  if(x==2) return 200000;
  if(x==1) return 300000;
  return 0;
}

int main(){
  int x,y;
  cin>>x>>y;
  int ans = p(x) + p(y);
  if(x==1 &&  y==1) ans += 400000;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  string s;
  cin >> s;
  rep(i,3)cout<<s[i];
  cout << endl;
  
  return 0;
}


Measured memory_bytes: 3652
from collections import defaultdict 
import math
if __name__ == '__main__':
    s = input().rstrip().split(' ')
    N,K = int(s[0]), int(s[1]) 
    d = []
    candycount = defaultdict(int)
    for k in range(K):
        d.append(int(input()))
        s = input().rstrip().split(' ')
        for elem in s:
            candycount[int(elem)] += 1

    c = 0

    for k in range(1,N+1):
        if not k in candycount:
            c += 1

    print(c)


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

typedef pair <int, int> ii;

const int Maxn = 105;

int n;
ii A[Maxn], B[Maxn];
bool tk[Maxn];
int res;

int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d %d", &A[i].first, &A[i].second);
	for (int i = 0; i < n; i++)
		scanf("%d %d", &B[i].first, &B[i].second);
	sort(A, A + n);
	sort(B, B + n);
	for (int i = n - 1; i >= 0; i--) {
		int bj = -1;
		for (int j = 0; j < n; j++)
			if (A[i].first < B[j].first && A[i].second < B[j].second && !tk[j])
				if (bj == -1 || B[j].second < B[bj].second) bj = j;
		if (bj != -1) {
			res++;
			tk[bj] = true;
		}
	}
	printf("%d\n", res);
	return 0;
}

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

int main() {
	int a, b;
	cin >> a >> b;
	vector<int> v(5);
	int count = 0;
	for (int i = a; i <= b; i++) {
		int keep = i;
		for (int j = 0; j < 5; j++) {
			v[j] = keep % 10;
			keep /= 10;
		}
		if (v[0] == v[4] && v[1] == v[3])
			count++;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int,input().split()))
M = h[0]
for i in range(n-1):
    if h[i] >= h[i+1] + 2:
        print("No")
        exit()

    if M > h[i+1] + 1:
        print("No")
        exit()

    M = max(M,h[i+1])
print("Yes")

Measured memory_bytes: 14252
#include <stdio.h>
#include <string.h>
 
int main(){
  int n;
  int i, j;
  int l;
 
  scanf("%d", &n);
  char w[n][11];
  for (i = 0; i < n; ++i){
  	scanf("%s", w[i]);
  }
  for (i = 0; i < n-1; ++i){
  	l = strlen(w[i]);
    if(w[i][l-1] != w[i+1][0]){
      printf("No");
      return 0;
    }
  }
  for (i = 0; i < n; ++i){
    for (j = i+1; j < n; ++j){
      if(strcmp(w[i],w[j]) == 0){
        printf("No");
        return 0;
      }
    }
  }
  printf("Yes");
  return 0;
}

Measured memory_bytes: 128
n,m=map(int,input().split())
a=[]
b=[]
for i in range(m):
    ab=list(map(int,input().split()))
    a.append(ab[0])
    b.append(ab[1])

islands1=set() #islands can reach from island 1
islands2=set() #islands can reach to island N

for i in range(m):
    if a[i]==1:
        islands1.add(b[i])
    
    if b[i]==n:
        islands2.add(a[i])

ans=islands1 & islands2
print("POSSIBLE" if ans else "IMPOSSIBLE")

Measured memory_bytes: 128688
#include<bits/stdc++.h>
using namespace std;
int mp[4][4];
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	int tot = 3*c;
	mp[1][1] = a;
	mp[1][2] = b;
	mp[2][2] = c;
	mp[1][3] = tot - a - b;
	mp[3][2] = tot - mp[2][2] - mp[1][2];
	mp[3][1] = tot - mp[2][2] - mp[1][3];
	mp[3][3] = tot - mp[3][1] - mp[3][2];
	mp[2][1] = tot - mp[1][1] - mp[3][1];
	mp[2][3] = tot - mp[1][3] - mp[3][3];
	for(int i = 1;i <= 3;i ++){
		for(int j = 1;j <= 3;j ++){
			printf("%d ",mp[i][j]);
		}
		printf("\n");
	}
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    int A[n];
    for(int i = 0; i < n; i++) cin >> A[i];
    
    bool flag = true;
    int count = 0;
    while(flag){
        flag = false;
        for(int i = n-1; i > 0; i--){
            if(A[i] < A[i-1]){
                swap(A[i-1], A[i]);
                flag = true;
                count++;
            }
        }
    }
    
    cout << A[0];
    for(int i = 1; i < n; i++) cout << " " <<A[i];
    cout << endl << count << endl;
}


Measured memory_bytes: 3076
#include<bits/stdc++.h> 
using namespace std;
#define For(i,n) for(int i=1;i<=n;i++)
#define Fork(i,k,n) for(int i=k;i<=n;i++)
#define ForkD(i,k,n) for(int i=n;i>=k;i--)
#define Rep(i,n) for(int i=0;i<n;i++)
#define ForD(i,n) for(int i=n;i;i--)
#define RepD(i,n) for(int i=n;i>=0;i--)
#define Forp(x) for(int p=pre[x];p;p=next[p])
#define Forpiter(x) for(int &p=iter[x];p;p=next[p])  
#define Lson (o<<1)
#define Rson ((o<<1)+1)
#define MEM(a) memset(a,0,sizeof(a));
#define MEMI(a) memset(a,0x3f,sizeof(a));
#define MEMi(a) memset(a,128,sizeof(a));
#define MEMx(a,b) memset(a,b,sizeof(a));
#define INF (0x3f3f3f3f)
#define F (1000000007)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vi vector<int> 
#define pi pair<int,int>
#define SI(a) ((a).size())
#define Pr(kcase,ans) printf("Case #%d: %lld\n",kcase,ans);
#define PRi(a,n) For(i,n-1) cout<<a[i]<<' '; cout<<a[n]<<endl;
#define PRi2D(a,n,m) For(i,n) { \
						For(j,m-1) cout<<a[i][j]<<' ';\
						cout<<a[i][m]<<endl; \
						} 
#pragma comment(linker, "/STACK:102400000,102400000")
#define ALL(x) (x).begin(),(x).end()
#define gmax(a,b) a=max(a,b);
#define gmin(a,b) a=min(a,b);
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
ll mul(ll a,ll b){return (a*b)%F;}
ll add(ll a,ll b){return (a+b)%F;}
ll sub(ll a,ll b){return ((a-b)%F+F)%F;}
void upd(ll &a,ll b){a=(a%F+b%F)%F;}
inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(!isdigit(ch)) {if (ch=='-') f=-1; ch=getchar();}
	while(isdigit(ch)) { x=x*10+ch-'0'; ch=getchar();}
	return x*f;
} 
int dig(int t) {
	int c=0;
	while(t) c+=t%10,t/=10;return c;
}
int main()
{
//	freopen("A.in","r",stdin);
//	freopen(".out","w",stdout);
	int n=read();
	ll c=dig(n-1)+1;
	For(i,n-1) {
		c=min(c,(ll)dig(i)+dig(n-i));
	}
	cout<<c<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,n) for(ll i=0;i<n;i++)
#define print(arr,a,n) for(ll i=(a);i<(n);i++)cout<<(arr)[i]<<" ";

int main(){
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
    #endif
    ll n,ans;
    cin>>n;
    ll p[n+2]={};
    for(ll i=1;i<=n;i++){
        for(ll j=i;j<=n;j+=i){
            p[j]++;
        }
    }
    ans=0;
    for(ll i=1;i<=n;i++){
        ans=ans+i*p[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 81704
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double r = sc.nextDouble();
		double men = Math.PI * r * r;
		double ens = 2 * Math.PI * r;
		System.out.println(String.format("%.6f", men)+
				 " " + String.format("%.6f", ens));

	}

}

Measured memory_bytes: 28260
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 12 20:58:46 2020

@author: Kanaru Sato
"""

n = int(input())
s = list(input())

rdic = {}
gdic = {}
bdic = {}

for i in range(len(s)):
    if s[i] == "R":
        if i not in rdic:
            rdic[i] = 1
    elif s[i] == "G":
        if i not in gdic:
            gdic[i] = 1
    elif s[i] == "B":
        if i not in bdic:
            bdic[i] = 1

bnum = len(bdic)            
count = 0
for rplace in rdic:
    for gplace in gdic:
        if rplace >= gplace:
            ex1 = gplace - (rplace- gplace)
            ex2 = rplace + (rplace- gplace)
            ex3 = (rplace + gplace)/2
            e1 = 1 if ex1 in bdic else 0
            e2 = 1 if ex2 in bdic else 0
            e3 = 1 if ex3 in bdic else 0
            count += bnum - (e1 + e2 + e3)
        elif rplace < gplace:
            ex1 = rplace - (gplace- rplace)
            ex2 = gplace + (gplace- rplace)
            ex3 = (rplace + gplace)/2
            e1 = 1 if ex1 in bdic else 0
            e2 = 1 if ex2 in bdic else 0
            e3 = 1 if ex3 in bdic else 0
            count += bnum - (e1 + e2 + e3)

print(count)

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

int main() {
    int x, t;
    cin >> x >> t;
    cout << max(x - t, 0) << endl;
}

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

string s = "0123456789AB";
string goal = "0123456789AB0";

vector<vector<int>> adj = {
    {2},
    {2,5},
    {0,1,3,6},
    {2,7},
    {5},
    {1,4,6,9},
    {2,5,7,10},
    {3,6,8,11},
    {7},
    {5,10},
    {6,9,11,12},
    {7,10},
    {10}
};

int solve(string stat) {
    if (stat == goal) return 0;
    map<string, int> dist;
    dist[stat] = 0;
    queue<string> q;
    q.push(stat);
    while ( ! q.empty()) {
        string s = q.front();
        q.pop();
        for (int i=0; i<13; ++i) {
            if (s[i] != '0') continue;
            for (int j : adj[i]) {
                string next = s;
                next[i] = s[j];
                next[j] = s[i];
                int diff = 0;
                for (int k=0; k<13; ++k) {
                    diff += next[k] != goal[k];
                }
                if ( ! diff) {
                    return dist[s] + 1;
                }
                if (dist.find(next) == dist.end()) {
                    dist[next] = dist[s] + 1;
                    if (dist[next] + diff - 2 <= 20) {
                        q.push(next);
                    }
                }
            }
        }
    }
    return 21;
}

int main() {
    while (1) {
        string stat = "";
        int k;
        for (int i=0; i<13; ++i) {
            if (cin >> k && !~k) return 0;
            stat += s[k];
        }
        int ans = solve(stat);
        if (ans <= 20) {
            cout << ans << endl;
            continue;
        }
        cout << "NA" << endl;
    }
    return 0;
}

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

long long gcd(long long x, long long y){
    if(x < y) swap(x, y);
    long long r = x % y;
    if(r == 0) return y;
    else return gcd(y, r);
}
 
long long lcm(long long x, long long y){
    return x * y / gcd(x, y);
}

pair<long long, long long> div2Times(long long num){
    long long cnt = 0;
    while(num % 2 == 0){
        cnt++;
        num /= 2;
    }
    return {cnt, num};
}

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

    long long n, m;
    cin >> n >> m;
    vector<long long> A(n);
    for(int i = 0; i < n; i++){
        cin >> A[i];
    }

    long long dtt = -1;
    set<long long> st;
    for(int i = 0; i < n; i++){
        pair<long long, long long> res = div2Times(A[i]);
        st.insert(A[i] / 2);
        if(i == 0) dtt = res.first;
        else{
            if(dtt != res.first){
                cout << 0 << endl;
                return 0;
            }
        }
    }

    long long l = 1;
    for(auto x: st){
        l = lcm(l, x);
        if(l > m){
            cout << 0 << endl;
            return 0;
        }
    }

    // l /= 2;
    long long ans = (m / l + 1) / 2;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char* argv[])
{
	string S,T;
	cin>>S;
	cin>>T;
	int ans=0;
	for (int i=0;i<S.size();i++){
		if (S[i]!=T[i]){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
	int d, n;
	cin >> d >> n;
	if (d == 0) {
		if (n == 100) {
			cout << 101 << endl;
		} else {
			cout << n << endl;
		}
	} else if (d == 1) {
		if (n == 100) {
			cout << 10100 << endl;
		} else {
			cout << n * 100 << endl;
		}
	} else if (d == 2) {
		if (n == 100) {
			cout << 1010000 << endl;
		} else {
			cout << n * 10000 << endl;
		}
	}
	return 0;
}


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

using namespace std;

int main()
{
    string S, T;
    cin >> S >> T;
    int result = 0;

    for (int i = 0; i < 3; i++) {
        if (S[i] == T[i]) {
            result++;
        }
    }

    cout << result;

    return 0;
}


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

int N;
int K, P;
int ans;

int main(void)
{
	cin >> N;
	for (int i=0; i<N; i++)
	{
		cin >> K >> P;
		ans = K % P;
		if (ans == 0) ans = P;
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(), v.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;

int main()
{
  ll D1, D2, N,temp=0,maxtemp=0;
  cin >> N;
  rep(i,N)
  {
    cin >> D1 >> D2;
    if(D1==D2)
      temp++;
      else
        temp = 0;
      maxtemp = max(maxtemp, temp);
  }
  if(maxtemp>=3)
    cout << "Yes" << endl;
    else
    {
      cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3620
//use itertools::Itertools;
use std::cmp;
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        s: chars
    }

    let mut tot = 0;

    for i in 0..s.len() {
        let num = match s[i] {
            '1' => 1,
            '2' => 2,
            '3' => 3,
            '4' => 4,
            '5' => 5,
            '6' => 6,
            '7' => 7,
            '8' => 8,
            '9' => 9,
            _ => 0,
        };
        tot += num;
    }

    if tot % 9 == 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 2356
from heapq import heappush, heappop
from collections import defaultdict


def main():
    X, Y, Z, K = list(map(int, input().split(' ')))
    A = list(map(int, input().split(' ')))
    B = list(map(int, input().split(' ')))
    C = list(map(int, input().split(' ')))
    A.sort(reverse=True)
    B.sort(reverse=True)
    C.sort(reverse=True)
    que = [(- A[0] - B[0] - C[0], 0, 0, 0)]  # multiply -1 to change min to max
    already_inserted = defaultdict(int)
    answer = list()
    for _ in range(K):
        q, i, j, k = heappop(que)
        answer.append(-q)
        if i + 1 < X:
            item_a = (- A[i + 1] - B[j] - C[k], i + 1, j, k)
            if already_inserted[item_a] == 0:
                heappush(que, item_a)
                already_inserted[item_a] = 1
        if j + 1 < Y:
            item_b = (- A[i] - B[j + 1] - C[k], i, j + 1, k)
            if already_inserted[item_b] == 0:
                heappush(que, item_b)
                already_inserted[item_b] = 1
        if k + 1 < Z:
            item_c = (- A[i] - B[j] - C[k + 1], i, j, k + 1)
            if already_inserted[item_c] == 0:
                heappush(que, item_c)
                already_inserted[item_c] = 1
    for ans in answer:
        print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 5012
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main() {
    int s;
    int count = 0;
    vector<int> a;
    vector<int>::iterator p;

    cin >> s;
    a.push_back(s);

    for (;;) {
        count += 1;
        if (s % 2 == 0) { //偶数なら
            s = s / 2;
            p = find(a.begin(), a.end(), s);
            if (p != a.end()) {
                cout << count + 1 << endl;
                break;
            }
            a.push_back(s);
        } else {
            s = 3 * s + 1;
            p = find(a.begin(), a.end(), s);
            if (p != a.end()) {
                cout << count + 1 << endl;
                break;
            }
            a.push_back(s);
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string s="aiueo";
    char c;
    cin>>c;
    if (c=='a' || c=='i' || c=='u' || c=='e' || c=='o'){
        cout<<"vowel"<<endl;
    }
    else cout<<"consonant"<<endl;
}


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

using namespace std;

long int NUM_E[300005], NUM_W[300005];

int main(void)
{
	int N;
	cin >> N;

	string S;
	cin >> S;

	NUM_E[0] = 0;
	for (int i = 0; i < N-1; i++) {
		if (S.substr(i, 1) == "E") { NUM_E[i + 1] = NUM_E[i] + 1; }
		else { NUM_E[i + 1] = NUM_E[i]; }
	}

	NUM_W[N - 1] = 0;
	for (int i = N - 1; i >= 1; i--) {
		if (S.substr(i, 1) == "W") { NUM_W[i - 1] = NUM_W[i] + 1; }
		else { NUM_W[i - 1] = NUM_W[i]; }
	}

	/*for (int i = 0; i < N; i++) {
		cout << i << " " << NUM_E[i] << " " << NUM_W[i]<<" : " << N-1-NUM_E[i]-NUM_W[i]  << endl;
	}*/

	int ans = N;
	int num;
	for (int i = 0; i < N; i++) {
		num = N - 1 - NUM_E[i] - NUM_W[i];
		if (num < ans) { ans = num; }
	}

	cout << ans << endl;
	//system("pause");
	return 0;

}

Measured memory_bytes: 5380
fun main(args: Array<String>) {
    abc058c()
}

fun abc058c() {
    val n = readLine()!!.toInt()
    val sMaps = (1..n).map { readLine()!!.groupBy { it } }

    val alphaCount = ('a'..'z').map { c ->
        Pair(c, sMaps.map { sMap -> sMap[c]?.size ?: 0 }.min()!!)
    }

    val answer = alphaCount.joinToString(separator = "") { alp -> alp.first.toString().repeat(alp.second) }

    println(answer)
}


Measured memory_bytes: 33604
import sys
sys.setrecursionlimit(10000)

class UnionFindTree:
	def __init__(self,size):
		"""
		size個の集合を作成
		負の値は、ルートで集合の個数
		正の値は、次の要素
		"""
		self.table=[-1 for _ in range(size)]

	def find(self,x):
		"""
		グループ番号を取得
		"""
		# 本質的には、木を上に辿るだけ
		# ただし、通常、UnionFindでは経路圧縮を行うのが普通らしい
		if self.table[x] < 0:
			# 一個上がルートならば、それを返して終わり
			return x
		else:
			# そうでなければ、ルートまで辿るついでに経路圧縮
			self.table[x] = self.find(self.table[x])
			return self.table[x]
		return x

	# 併合
	def union(self,x,y):
		# s1,s2は正
		# table[s1],table[s2]は負
		s1=self.find(x)
		s2=self.find(y)
		if s1!=s2:
			# 個数が小さい方をルートにくっつける
			# ルートサイズは負なので、ルートが大きい方が個数が小さい?
			if self.table[s2]<=self.table[s1]:
				# s1が小さい
				self.table[s1]+=self.table[s2]
				self.table[s2]=s1
			else:
				# s2が小さい
				self.table[s2]+=self.table[s1]
				self.table[s1]=s2
			return True
		return False

	def groupCount(self):
		ret=0
		for i in range(len(self.table)):
			if self.table[i] < 0:
				ret+=1
		return ret

N,M=map(int,input().split())

UF=UnionFindTree(N)

for _ in range(M):
	A,B=map(int,input().split())
	UF.union(A-1,B-1)


print(UF.groupCount()-1)



Measured memory_bytes: 11072
import itertools
import sys
sys.setrecursionlimit(1000000)
h, w = map(int, input().split())
s_list = []
for i in range(h):
  s_list.append(list(input()))
res = 0
check_list = set()

def rec_create_area(point, tmp_area, current_str):
  new_point_list = []
  new_point_list.append((point[0] + 1, point[1]))
  new_point_list.append((point[0], point[1] + 1))
  new_point_list.append((point[0] - 1, point[1]))
  new_point_list.append((point[0], point[1] - 1))
  for new_point in new_point_list:
    if new_point[0] >= h or new_point[1] >= w or new_point[0] < 0 or new_point[1]  < 0:
      continue
    if new_point in check_list:
      continue
    new_str = s_list[new_point[0]][new_point[1]]
    if new_str == current_str:
      continue
    if new_str == "#":
      tmp_area[0] += 1
    else:
      tmp_area[1] += 1
    check_list.add(new_point)
    rec_create_area(new_point, tmp_area, new_str)
  
for a, b in itertools.product(range(h), range(w)):
  check_point = (a, b)
  if check_point in check_list:
    continue
  check_list.add(check_point)
  current_str = s_list[check_point[0]][check_point[1]]
  if current_str == "#":
    tmp_area = [1, 0]
  else:
    tmp_area = [0, 1]
  rec_create_area(check_point, tmp_area, current_str)
  res += tmp_area[0] * tmp_area[1]
  
print(res)

Measured memory_bytes: 215528
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int K;
long N,mod=1e9+7;
int L[2<<17],R[2<<17];
long dp[101][2<<17];
main()
{
	cin>>N>>K;
	int id=0;
	for(int i=1;i*i<=N;i++)
	{
		L[id]=R[id]=i;
		id++;
	}
	int T=L[id-1];
	if(T*T==N)T--;
	for(;T>=1;T--)
	{
		L[id]=R[id-1]+1;
		R[id]=N/T;
		id++;
	}
	for(int i=0;i<id;i++)dp[0][i]=R[i]-L[i]+1;
	for(int i=0;i<K-1;i++)
	{
		for(int j=1;j<id;j++)dp[i][j]=(dp[i][j]+dp[i][j-1])%mod;
		for(int j=0;j<id;j++)
		{
			dp[i+1][j]=(dp[i+1][j]+dp[i][id-j-1]*(R[j]-L[j]+1)%mod)%mod;
		}
	}
	long ans=0;
	for(int j=0;j<id;j++)ans=(ans+dp[K-1][j])%mod;
	cout<<ans<<endl;
}


Measured memory_bytes: 205568
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();

            Console.WriteLine((s.IndexOf('a') >= 0 && s.IndexOf('b') >= 0 && s.IndexOf('c') >= 0) ? "Yes" : "No");
        }
    }



Measured memory_bytes: 11092
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
///////////////////////////

int main(){fastio
    ll m;cin>>m;
    ll ans=0;
    ll sum=0;
    rep(i,1,m){
        ll d;cin>>d;
        ll c;cin>>c;
        if(d==0){
            ans+=c-1;
        }else{
            ll s=c*d;
            ll r=(s-1)/9;
            ll q=s%9;
            if(q==0)q=9;
            ans+=c-1+r;
            sum+=q;
        }
    }
    ans+=m-1;
    ans+=(sum-1)/9;
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ll long long
#define ld long double
#define PB push_back
#define lc 2 * v
#define rc 2 * v + 1
#define mid (s + e) / 2
#define pii pair <int , int>
#define pll pair <long long , long long>
#define FAST ios::sync_with_stdio(false);cin.tie(0);
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

const ll maxn = 3e5 + 20 , N = 60000 + 20 , mod = 1e9 + 7 , INF = 1e9 + 1 , lg = 32;

ll dis , d[maxn] , sz[maxn] , root;
vector <int> edges[maxn];
map <ll , int> mp;
set <ll> s;

void dfs(int v , int par, int h) {
    dis += h;
    for (auto u : edges[v]) {
        if(u != par) {
            dfs(u , v , h + 1);
        }
    }
}

void sfd(int v , int par) {
    for (auto u : edges[v]) {
        if(u != par) {
            cout << v << ' ' << u << '\n';
            sfd(u , v);
        }
    }
}

int main() {
    FAST
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> d[i];
        mp[d[i]] = i;
        s.insert(d[i]);
    }
    // sort(D , D + n);
    fill(sz , sz + maxn , 1);

    while(s.size() > 1) {
        ll di = *s.rbegin(); s.erase(di);
        ll v = mp[di];
        ll val_par = di - n + (2 * (sz[v]));
        ll par = mp[val_par];

        if(par == 0) {
            cout << -1 << '\n';
            return 0;
        }
        else {
            edges[v].PB(par);
            edges[par].PB(v);
            sz[par] += sz[v];
        }

    }
    dfs(1 , -1 , 0);
    // cout << dis << ' ' << d[1] << endl;
    // sfd(1 , -1);
    if(dis == d[1]) {
        sfd(1 , -1);
    }
    else {
        cout << -1 << '\n';
    }
}


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

int ans = 0;

void judge(int a,int b, int x)
{
	if (a<=x && x<=b) {
		ans += 1;
	}
}
int main()
{
	int a,b,c;
	cin >> a >> b >> c;
	for (int i = 1; i <= c; i++) {
		if (c%i == 0) {
			judge(a,b,i);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3080