akhauriyash/Code-Regression huggingface dataset:
/* 実行時間1s制限の場合
  10^6 1,000,000   : 余裕をもって間に合う
  10^7 10,000,000  : おそらく間に合う
  10^8 100,000,000 : 非常にシンプルな処理でないと厳しい
 */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#include <bits/stdc++.h>
using namespace std;

typedef long long ll; // long longはデータモデル(LLP64, LP64, ...)によらず64bit.
ll gcd(ll a, ll b) {return b ? gcd(b, a%b) : a;}  // Greatest Common Divisor ユークリッドの互除法（aが長辺）
vector<pair<ll,int>> factorize(ll n) {            // a,bの公約数 = GCD(a, b)の約数
    vector<pair<ll,int>> res;
    for (ll i = 2; i*i <= n; i++) { // √nまで探せばよい
        if (n%i) continue;
        res.emplace_back(i, 0);     // 割り切れたら
        while (n%i == 0) {
            n /= i;
            res.back().second++;
        }
    }
    if (n != 1) res.emplace_back(n, 1); // この時点で1でなかったら、残りは素数.
    return res;
}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}         // Least Commont Multiple オーバーフローしないように先に割る
ll ceil(ll a, ll b) {return (a+b-1)/b;}

const ll INF = LONG_MAX;
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 main(int argc, char* argv[])
{
#ifdef LOCAL
    // 以降 cin の入力元が 'xxx.txt' になる
    // std::ifstream in(argv[1]);
    //std::cin.rdbuf(in.rdbuf());
    std::ifstream in("c.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    string s;
    cin >> s;

    int ans = 0;

    char pre = 'x';

    for (char& c : s) {
        if (pre == c) {
            ans++;
            if (c == '0') {
                pre = '1';
            }
            else
            {
                pre = '0';
            }
        }
        else {
            pre = c;
        }
    }

    cout << ans;

    return 0;
}

/*
  - 1e9 : 10^9
  - container一般
    - 合計
      accumulate(a.begin(), a.end(), 0LL)  0LLはオーバーフロー用
  - vector
    vector<int> A(N, 0); // 0で初期化(省略可)
    - loop
      for  (int i = 0; i < A.size(); i++) {}
      for  (int elem : A) {}
    - sort
      std::sort(v.begin(), v.end());  // 昇順
      std::sort(v.begin(), v.end(), std::greater<int>()); //降順
      - vector<vector<int>> cnt(h, vector<int>(w))
    - sort(struct)
        struct st_t {
            string name;
            int p;
            bool operator<(const st_t& another) const {
                if (name == another.name)
                {
                    return p > another.p;
                }
                return name < another.name;
            }
        };
        vector<st_t> st(n);
        sort(st.begin(), st.end());
  - pair
    - pairのソートの定義 : firstが優先的に比較。同じだったらsecond。
    - pair<pair<string,int>,int> p[110];
      std::sort(p,p+a);
        こうすると、first.first -> first.second -> secondの順にソートされる
    - sort
      - sort(a.begin(), cb.end(), greater<pair<int, int>>());
  - map
    - for (auto x : map) {}  // x.first:key  x.second:value.
  - priority_queue<int> q;
    - q.top()に最大値が入っている
  - string
    - loop
      for (char& c : s) {}
 */



Measured memory_bytes: 512
#include<iostream>
#include<stdio.h>
#include<fstream>
#include<algorithm>
#include<ctime>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<set>
#include<string>
#include<queue>
#include<map>
#include<iomanip>
#include<cassert>
#include<complex>
#include<functional>
#include<list>
#include<cmath>
#include<stack>
#include<assert.h>
#define LL long long
#define PB push_back
#define MP make_pair
#define PII pair<int,int>
#define F first
#define S second
using namespace std;
int a,b;
int main(){
  cin>>a>>b;
  if(a<b)
    cout<<"0";
  else
    cout<<"10";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define per(i,j,n) for(int i=(int)(j);(int)(n)<=i;i--)
#define int long long
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define endl "\n"
#define vi vector<ll>
#define pii pair<ll,ll>
#define vii vector<vi>
const int MOD=1e9+7;
//const int MOD=998244353;
const int INF=(1ll<<62)-1;
signed main(){
  ll A,B,K; cin>>A>>B>>K;
  bool flag=1;
  rep(i,0,K){
    if(flag){
      A/=2;
      B+=A;
    }
    else{
      B/=2;
      A+=B;
    }
    flag=!flag;
  }
  cout<<A<<" "<<B<<endl;
}

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

int main(){
  using P = priority_queue<int, vector<int>, greater<int>>;
  int N;
  string S;
  cin >> N >> S;
  vector<vector<int>> L(26, vector<int>(0));
  vector<P> M(5000);
  rep(i, N) L.at(S.at(i) - 'a').push_back(i);
  

  
  rep(i, 26){
    int count = L.at(i).size();
    if(count <= 1) continue;
    for(int j = 0; j < count; j++){
      for(int k = j + 1; k < count; k++){
        int l1 = L.at(i).at(j), l2 = L.at(i).at(k);
        M.at(l2-l1).push(l1);
      }
    }
  }
  
  
  
  int ans = 0;
  
  rep(i, 5000){
    int m_size = M.at(i).size(), ans0 = 1;
    if(m_size == 0) continue;
    while(!M.at(i).empty()){
      int l1 = M.at(i).top();
      M.at(i).pop();
      int l2 = M.at(i).top();
      if(l2 - l1 != 1){
        if(ans0 > ans) ans = ans0;
        ans0 = 1;
      }
      else if(ans0 < i) ans0++;
    }
    
  }
  
  cout << ans << endl;
  
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
#define INF 1000000000


int dp[3005][3005];

int main()
{
    char a[3005],b[3005];
    int al,bl,i,j,l,pre;
    vi v;
    cin>>a>>b;

    al=strlen(a);
    bl=strlen(b);

    for(i=0;i<=bl;i++) dp[0][i]=0;
    for(i=0;i<=al;i++) dp[i][0]=0;

    for(i=1;i<=al;i++){
        for(j=1;j<=bl;j++){
            if(a[i-1]==b[j-1]) dp[i][j] = dp[i-1][j-1]+1;
            else dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
        }
    }


/*
aabdewkjl
racnbkewa


    for(i=1;i<=al;i++){
        for(j=1;j<=bl;j++){
           cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }
    */

    //if(a[al-1]==b[bl-1]) v.push_back(al-1);
    pre = dp[al][bl];
    i=al;j=bl;

    //cout<<pre<<" "<<i<<" "<<j<<endl;
    while(i>0 && j>0){

        while(dp[i][j]==pre && i>0) i--;
        i++;
        while(dp[i][j]==pre && j>0) j--;
        j++;
        if(dp[i][j]!=0)
        v.push_back(i);
        pre=dp[i-1][j-1];

        i--;
        j--;
        //cout<<pre<<" "<<i<<" "<<" "<<j<<endl;

    }

    l=v.size();
    for(i=l-1;i>=0;i--){
        printf("%c",a[v[i]-1]);
    }
    cout<<endl;
    return 0;
}


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

int max_matching(const deque<int> &aite, const deque<int> &jibun) {
    int i = 0, j = 0;
    for (; i < aite.size() && j < jibun.size(); ) {
        if (aite[i] < jibun[j]) ++i, ++j;
        else ++j;
    }
    return i;
}

int main() {
    int N; cin >> N;
    deque<int> aite(N), jibun(N);
    for (int i = 0; i < N; ++i) cin >> aite[i];
    for (int i = 0; i < N; ++i) cin >> jibun[i];
    deque<int> sortaite = aite;
    sort(sortaite.begin(), sortaite.end());
    sort(jibun.begin(), jibun.end());
    
    int mm = max_matching(sortaite, jibun);
    deque<int> res;
    for (int i = 0; i < N; ++i) {
        deque<int> sortaite_next;
        bool finish = false;
        for (int j = 0; j < sortaite.size(); ++j) {
            if (sortaite[j] == aite[0] && !finish) {
                finish = true;
                continue;
            }
            sortaite_next.push_back(sortaite[j]);
        }

        // check can win
        int first = (int)jibun.size();
        for (int j = 0; j < jibun.size(); ++j) {
            if (jibun[j] > aite[0]) {
                first = j;
                break;
            }
        }
        deque<int> temp_jibun;
        for (int j = 0; j < jibun.size(); ++j) {
            if (j == first) continue;
            temp_jibun.push_back(jibun[j]);
        }
        int tmm = max_matching(sortaite_next, temp_jibun) + 1;
        
        // binary search (low: ok id, high: ng id)
        int low, high;
        if (tmm == mm) low = first, high = (int)jibun.size();
        else low = 0, high = first;
        while (high - low > 1) {
            int mid = (low + high) / 2;
            int val = jibun[mid];
            
            temp_jibun.clear();
            for (int j = 0; j < jibun.size(); ++j) {
                if (j == mid) continue;
                temp_jibun.push_back(jibun[j]);
            }
            tmm = max_matching(sortaite_next, temp_jibun);
            if (val > aite[0]) ++tmm;
            if (tmm < mm) high = mid;
            else low = mid;
        }
        
        // match i-th player
        if (jibun[low] > aite[0]) --mm;
        res.push_back(jibun[low]);
        jibun.erase(jibun.begin() + low);
        aite.pop_front();
        sortaite = sortaite_next;
        
        if (mm == 0) break;
    }
    sort(jibun.begin(), jibun.end(), greater<int>());
    for (auto val : jibun) res.push_back(val);
    
    for (int i = 0; i < res.size(); ++i) {
        cout << res[i];
        if (i != (int)res.size() - 1) cout << " ";
    }
    cout << endl;
}


Measured memory_bytes: 3288
from collections import deque

n = int(input())
cmdlst = [input() for cmd in range(n)]
lst = deque()

for cmd in cmdlst:
    if cmd == 'deleteFirst':
        lst.popleft()
    elif cmd == 'deleteLast':
        lst.pop()
    else:
        cmd,x = cmd.split()
        if cmd == 'insert':
            lst.appendleft(x)
        else:
            try:
                lst.remove(x)
            except:
                pass
print(*lst)


Measured memory_bytes: 212328
//Don't give up too easy bhai
#pragma GCC optimize("-O3")
 
#include<bits/stdc++.h>
using namespace std;

#define int long long int
#define double long double
#define inf 1e18

typedef pair<int,int> pii;
 
#define forall(i,a,n) for(int i=a;i<n;i++)
#define pb push_back
#define fs first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(),v.end()
#define minv(a) *min_element(all(a))
#define maxv(a) *max_element(all(a))
#define vi vector<int>
#define vd vector<double>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod 1000000007
#define br cout<<"\n"
#define whatis(x) cerr << "var "<<#x << " ==> " << x<<"\n"
#define inputv(a) forall(i,0,a.size()) cin>>a[i]
#define outputv(a) for(auto i:a) cout<<i<<" ";br;
#define T int __t;cin>>__t;while(__t--)

int repUnitValue(int n) 
{ 
  
    // To check n is coprime or not 
    if (n % 2 == 0 || n % 5 == 0) 
        return 0; 
  
    // to store R(k) mod n and 10^k 
    // mod n value 
    int rem = 1; 
    int power = 1; 
    int k = 1; 
    while (rem % n != 0) 
    { 
        k++; 
        power = power * 10 % n; 
        rem = (rem + power) % n; 
    } 
      
    return k; 
}

signed main()
{
    int n;cin>>n;
    int x = repUnitValue(n);
    int y = inf;
    if(!(n%7)) y = repUnitValue(n/7);
    if(x==0 and y == inf) cout<<-1;
    else cout<<min(x,y);

    return 0;
}

Measured memory_bytes: 3636
N = int(input())
r = []
for i in range(N):
    r.append(list(map(int, input().split())))
b = []
for i in range(N):
    b.append(list(map(int, input().split())))
r = sorted(r, key=lambda x: x[0])
b = sorted(b, key=lambda x: x[0])
r_selected = [False] * N
ans = 0
for i in range(N):
    y_max = -1
    j_selected = -1
    for j in range(N):
        if r_selected[j]:
            continue
        if b[i][0] > r[j][0] and b[i][1] > r[j][1]:
            if y_max < r[j][1]:
                y_max = r[j][1]
                j_selected = j
    if y_max == -1:
        continue
    else:
        r_selected[j_selected] = True
print(r_selected.count(True))

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

typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;

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

// a[i]-a[j-1]が残った時にそれ以降のX-Yをdp[i][j]とする
// dp[i][j]が決まると、dp[i+1][j]かdp[i][j-1]のどちらかに遷移する
// どちらに遷移するかというと、太郎君の手番の場合は、X-Yを最大値にする方
// 次郎君の手番の場合はX-Yを最小値にする方へと遷移する
// 長さlenは1からNまでスタート地点はj=0からN-lenまでで計算
// どっちの手番かというと、数列にj-iこ残っている状態のとき、つまりN-j+iことった時に
// N-j+iが偶数なら太郎君の手番、N-j+iが奇数なら次郎君の手番

ll N, K;
vector<ll> ai;
vector<vector<ll>> dp;

int main() {
  cin >> N;
  ai = vector<ll>(N+10,0);
  for (ll i=0;i<N;i++) cin >> ai.at(i);

  dp = vector<vector<ll>>(N+10,vector<ll>(N+10,0));

  for (ll len=1;len<=N;len++){
    for (ll i=0;i<N+1-len;i++){
      ll j = i + len;
      if ((N-len)%2 == 0){
        dp.at(i).at(j) = max(dp.at(i+1).at(j)+ ai.at(i), dp.at(i).at(j-1)+ai.at(j-1)); 
      } else {
        dp.at(i).at(j) = min(dp.at(i+1).at(j)- ai.at(i), dp.at(i).at(j-1)-ai.at(j-1));
      }
    }
  }

  cout << dp.at(0).at(N) << endl;
}

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

int main(){
    int n;
    scanf(" %d",&n);
    unordered_map<string,int> fr;
    vector<string> ans;
    int ma = 0;
    for(int i = 0; i < n;++i){
        string re; cin >> re;
        ++fr[re];
        if(fr[re] > ma){ma = fr[re];ans.clear();}
        if(fr[re] == ma) ans.push_back(re);
    }
    sort(ans.begin(),ans.end());
    for(auto va: ans) cout << va << "\n";
    return 0;
}


Measured memory_bytes: 25968
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repbtw(i, a, b) for (int i = a; i <= (int)(b); i++)
#define all(v) v.begin(), v.end()
#define pr(x) cout << x << endl


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

    set<string> items;
    rep(i, n){
        string s;
        cin >> s;
        items.insert(s);
    }

    pr(items.size());
    return 0;
}



Measured memory_bytes: 19068
#define TEMPLATE_USED
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(ll)(a);i<(ll)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(ll)(n);++i)
#define _repe3(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(ll)(b)-1;i>=(ll)(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define _rrepe2(i,n) for(ll i=(ll)(n);i>=0;i--)
#define _rrepe3(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);i--)
#define rrepe(...) _overload3(__VA_ARGS__,_rrepe3,_rrepe2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

ll N;
ll K;
vl A;

void solve();

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin >> N;
    cin >> K;
    A = vl(N);
    for(int i = 0; i < N; ++i){
        cin >> A[i];
    }
    solve();
}

// 1 <= N <= 2 × 10^5
// 0 <= K <= 10^9
// 1 <= A_i <= 10^9
// 入力はすべて整数である。

// ll N, ll K, vl A
// 答えとなる整数を出力せよ。
void solve(){
    ll ok=INF,ng=0;
    while(ok-ng>1){
        ll mid=(ok+ng)/2;
        ll cnt=0;
        rep(i,N){
            cnt+=(A[i]+mid-1)/mid-1;
        }
        if(cnt<=K)ok=mid;
        else ng=mid;
    }
    cout<<ok<<endl;
}


Measured memory_bytes: 4760
#include <iostream>
#include <map>
#include <vector>
using namespace std;
map<int,int> m;
vector<int> v;
int main()
{
	ios::sync_with_stdio(false);
	int n,i,x,ans=0;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>x;
		if(m[x]==0)v.push_back(x);
		m[x]++;
	}
	for(i=0;i<v.size();i++){
		if(v[i]>m[v[i]])ans+=m[v[i]];
		else if(v[i]<m[v[i]])ans+=m[v[i]]-v[i];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 5112
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;


int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin >> n;
    ll ans = 0;
    for(ll i = 1; i <= n; i++) ans += (i * (i + 1) / 2);
    for(int i = 1; i < n; i++){
        int u, v;
        cin >> u >> v;
        if(u > v) swap(u, v);
        ll mn = u, mx = n - v + 1;
        ans -= mn * mx;
    }
    cout << ans << '\n';


    return 0;
}





Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#include <numeric>
#include <functional>
#include <stack>

int main (){
	int n;

	std::cin >> n;

	std::vector<int> a(n), b(n), c(n);

	for (size_t i = 0; i < n; i++)
	{
		std::cin >> a[i];
	}

	for (size_t i = 0; i < n; i++)
	{
		std::cin >> b[i];
	}

	for (size_t i = 0; i < n - 1; i++)
	{
		std::cin >> c[i];
	}

	long long total = 0;
	for (size_t i = 0; i < n; i++)
	{
		total += b[a[i] - 1];
		if (i != 0 && a[i] == a[i - 1] + 1) {
			total += c[a[i - 1] - 1];
		}
	}

	std::cout << total << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <ctype.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
int main() {
	int n;
	string s;
	cin >> n >> s;

	if (n >= 3200) {
		cout << s << endl;
	}
	else {
		cout << "red" << endl;
	}
}

Measured memory_bytes: 256
def p_d():
    n = int(input())
    mod = 10 ** 9 + 7
    # dp[i][j][k][l]: 長さiの文字列でi-2番目がj、i-1番目がk、i番目がlであるものの総数
    dp = [[[[0] * 4 for _ in range(4)] for _ in range(4)] for _ in range(n + 1)]
    for j in range(4):
        for k in range(4):
            for l in range(4):
                if j == 1 and k == 2 and l == 3:
                    continue
                if j == 2 and k == 1 and l == 3:
                    continue
                if j == 1 and k == 3 and l == 2:
                    continue
                dp[3][j][k][l] = 1
    for i in range(4, n + 1):
        for j in range(4):
            for k in range(4):
                for l in range(4):
                    for m in range(4):
                        if j == 1 and k == 2 and l == 3:
                            continue
                        if j == 2 and k == 1 and l == 3:
                            continue
                        if j == 1 and k == 3 and l == 2:
                            continue
                        if m == 1 and k == 2 and l == 3:
                            continue
                        if m == 1 and j == 2 and l == 3:
                            continue
                        dp[i][j][k][l] += dp[i - 1][m][j][k]
                        dp[i][j][k][l] %= mod

    ans = 0
    for j in range(4):
        for k in range(4):
            for l in range(4):
                ans += dp[n][j][k][l]
                ans %= mod
    print(ans)


if __name__ == '__main__':
    p_d()


Measured memory_bytes: 45296
INT_MAX=10**18+7
x=10**9+7
def INPUT():return list(int(i) for i in input().split())
def LIST_1D_ARRAY(n):return [0 for _ in range(n)]
def LIST_2D_ARRAY(m,n):return [[0 for _ in range(n)]for _ in range(m)]
GETA=123
###############################################################################
import math as M
n,k=INPUT()
print(M.floor(M.log(n,k))+1)


Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int n,l;
int a[111111];
int main(void){
  cin >> n >> l;
  for(int i = 0; i < n; i++)
    cin >> a[i];

  int x = -1;
  for(int i = 0; i < n-1; i++){
    if(x < 0 && a[i]+a[i+1] >= l)
      x = i;
  }

  if(x < 0){
    cout << "Impossible" << endl;
    return 0;
  }

  cout << "Possible" << endl;
  for(int i = 0; i < x; i++){
    cout << i+1 << endl;
  }
  for(int i = n-2; i >= x; i--){
    cout << i+1 << endl;
  }
}


Measured memory_bytes: 1280
#include <iostream>
using namespace std;
int main(void){
     int temp,a;
     int t[30];
     a=0;
     for(int i=0;i<31;i++){
     t[i]=0;
     }
    for(int i=0;i<29;i++){
     cin>>temp;
     t[temp]=1;
     }
    for(temp=1;temp<=30;temp++){
        if(t[temp]==0){
            cout<<temp<<endl;
        }
    }
}



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

using namespace std;

int main(void)
{
    int X,Y;
    cin >> X>>Y;

    vector<int> jun;
    jun.push_back(X);
    jun.push_back(Y);
    int result=0;
    for(int i=0;i<jun.size();i++){
        if(jun[i]==3){
            result += 100000;
        }
        else if(jun[i]==2){
            result += 200000;
        }
        else if(jun[i]==1){
            result += 300000;
        }
    }

    if(jun[0]==1 && jun[1] == 1){
        result += 400000;
    }

    cout<<result<<endl;
}

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

class Main {

    public static void main(String[] args) throws Exception {

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            String[] inputString = br.readLine().split(" ");
            int cookieCount = Integer.parseInt(inputString[0]);
            int numberOfPeople = Integer.parseInt(inputString[1]);

            int result = 0;
          	if (cookieCount % numberOfPeople != 0) {
            	result = 1;
            }
          
          	System.out.println(result);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

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

#define N 
#define MP make_pair

int main()
{
	//freopen("in.txt", "r", stdin);
	
	int n, a, b;
	cin >> n >> a >> b;
	
	cout << min(a, b) << " " << max(0, a + b - n) << endl;
	
	return 0;	
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)

def main():
    N = int(input())
    rg = []

    for i in range(N):
        a,b = map(int,input().split())
        rg.append((a,b))

    def disasm(i):
        rg.sort()
        a,_ = rg[i]
        rg.sort(key=lambda x: x[1])
        _,b = rg[i]
        return a,b


    if N % 2 == 1:
        a,b = disasm(N//2)
        print(b-a+1)
        exit()

    a,b = disasm(N//2-1)
    c,d = disasm(N//2)

    print(b+d-a-c+1)


if __name__ == "__main__":
  main()

Measured memory_bytes: 109988
{-# LANGUAGE FlexibleInstances    #-}
{-# LANGUAGE TypeSynonymInstances #-}

import           Control.Applicative
import           Control.DeepSeq
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                  as A
import qualified Data.Array.IArray           as IA
import qualified Data.Array.IO               as AI
import qualified Data.Array.MArray           as MA
import qualified Data.Array.ST               as STA
import qualified Data.Array.Unboxed          as AU
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import qualified Data.Graph                  as G
import           Data.Int
import qualified Data.IntMap                 as IM
import qualified Data.IntSet                 as IS
import           Data.List
import qualified Data.Map.Strict             as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Sequence               as SQ
import qualified Data.Set                    as S
import           Data.Time
import qualified Data.Tree                   as T
import qualified Data.Vector                 as V
import qualified Data.Vector.Mutable         as VM
import qualified Data.Vector.Unboxed         as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

class Printable a where
  format :: a -> String

instance Printable Int where
  format = show

instance Printable Integer where
  format = show

instance Printable Double where
  format = show

instance Printable Float where
  format = show

instance Printable Char where
  format = show

instance Printable String where
  format x = x

instance Printable Bool where
  format = show

put :: Printable a => a -> IO ()
put = putStr . format

putLn :: Printable a => a -> IO ()
putLn = putStrLn . format

putList :: Printable a => [a] -> IO ()
putList [a] = put a
putList (a:as) = do
  put a
  putStr " "
  putList as

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readInteger :: IO [Integer]
readInteger = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegers :: Int -> IO [[Integer]]
readIntegers n = replicateM n readInteger

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

main = do
  [x, y] <- readInt
  put $ x + y `div` 2


Measured memory_bytes: 380
using System;
using System.Linq;

namespace C___GCD_on_Blackboard
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

            if(N == 2)
            {
                Console.WriteLine(Math.Max(A[0],A[1]));
            }else{

                var GCD = new long[N,2];
                
                GCD[2,0] = euclid(euclid(A[0],A[1]),A[2]);
                GCD[2,1] = Math.Max(Math.Max(euclid(A[0],A[1]),euclid(A[0],A[2])),euclid(A[1],A[2]));

                for(int i = 3 ; i < N ; i++)
                {
                    GCD[i,0] = euclid(GCD[i-1,0],A[i]);
                    GCD[i,1] = Math.Max(euclid(GCD[i-1,1],A[i]),GCD[i-1,0]);
                }

                Console.WriteLine(GCD[N-1,1]);
            }
        }
        
        static long euclid(long M,long N)
        {
            if(M<N)
            {
                return euclid(N,M);
            }
            while(N != 0)
            {
                var temp = M % N;
                M = N;
                N = temp;
            }
            return M;
        }
    }
}


Measured memory_bytes: 27868
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <algorithm>
int main() {
  int N,i,M,sum;
  cin>>N>>M;
  if(N<M){
  int X[M]={0};
int D[M-1]={0};
  
  for(i=0;i<M;i++){
  cin>>X[i];
  }
  sort(X,X+M);
  
  sum=X[M-1]-X[0];
 
 for(i=1;i<M;i++){
  D[i-1]=X[i]-X[i-1];
  }
  sort(D,D+M-1);
  for(i=1;i<N;i++){
  sum=sum-D[M-i-1];
  }
 
   cout<<sum<<endl;
  }else{
  cout<<0<<endl;
  }
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

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

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

    ll n, k;
    cin >> n >> k;

    ll ans = n % k;
    cout << min(ans, abs(ans - k)) << endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll a, b, c; cin >> a >> b >> c;
    set<ll> st;
    st.insert(a);
    st.insert(b);
    st.insert(c);
    cout << st.size() << endl;
}

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
bool chmin(T &a,T b){if(a>b){a=b;return true;}else return false;}
template<typename T>
bool chmax(T &a,T b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
ostream &operator<<(ostream &os, pair<ll, ll>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n,k;cin>>n>>k;
  while(n){
    res++;
    n/=k;
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define mod 1000000007
using namespace std;
ll binpow(ll x,ll y)/* (x^y)%p in O(log y) */{ll res=1;while (y > 0){if(y&1)res=(res*x);y = y>>1;x=(x*x);}return res;}
ll binpowmod(ll x,ll y,ll p)/* (x^y)%p in O(log y) */{ll res=1;x=x%p;while (y > 0){if(y&1)res=(res*x)%p;y = y>>1;x=(x*x)%p;}return res;}
ll mod_inverse(ll n,ll p)/* Returns n^(-1) mod p */{return binpowmod(n,p-2,p);}
ull gcd(ull x,ull y)
{
    if(y==0)
        return x;
    return gcd(y,x%y);
}
bool comp(pair<ll,ll> x,pair<ll,ll> y)
{
    return x.first>y.first;
}
bool comp_pairs_by_s(pair<ll,ll> &x ,pair<ll,ll> &y)
{
    return x.second<y.second;
}
bool isPowerOfTwo (ll x)  
{  
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));  
}

class cmp      //comparator for priority_queue 
{               //declaration: priority_queue<int,vector<int>,cmp>
public:         
    bool operator()(pair<int,int> A,pair<int,int> B)
    {
        if(abs(A.first-A.second)==abs(B.first-B.second))
            return A.first>B.first;
        return abs(A.first-A.second)<abs(B.first-B.second);
    }
};
// int prime[100005]={0};
// void sieve(void)
// {
//  int i,j;
//  for(i=0;i<100005;i++)
//         prime[i]=1;
//  prime[0]=0,prime[1]=0;
//  for(i=2;i<=sqrt(100005);i++){
//      if(prime[i]){
//          for(j=i*i;j<100005;j+=i){
//              prime[j]=0;
//          }
//      }
//  }
    
// }
void swap(int &x,int &y){
    int temp=x;
    x=y;
    y=temp;
}
char mat[1001][1001];
ll dp[1001][1001];
bool isvalid(int i,int j,int h,int w)
{
    if(i>=h || j>=w || i<0 || j<0)
        return false;
    else if(mat[i][j]=='#')
        return false;
    else
        return true;
}
void solve()
{   
    int h,w;
    cin>>h>>w;
    for(int i=0;i<h;i++)
        for(int j=0;j<w;j++)
            cin>>mat[i][j];
    for(int i=0;i<=h;i++)
        for(int j=0;j<=w;j++)
            dp[i][j]=0;
    dp[1][1]=1;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(i==1 && j==1) continue;
            if(mat[i-1][j-1]=='#') continue;
            if(isvalid(i-1,j-2,h,w))
                dp[i][j]=(dp[i][j]+dp[i][j-1])%mod;
            if(isvalid(i-2,j-1,h,w))
                dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;
        }
    }
    cout<<dp[h][w];
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
}


Measured memory_bytes: 9088
# include<bits/stdc++.h>
using namespace std;
int n;
string g(int ind)
{
	printf("%d\n",ind);
	fflush(stdout);
	string s;
	cin>>s;
	return s;
}
int main()
{
	cin>>n;
	int i;
	string a=g(0);
	if(a=="Vacant")  return 0;
	string b=g(n-1);
	if(b=="Vacant")  return 0;
	int l=1,r=n-2;
	while(l<=r)
	{
		int mid=l+r>>1;
		string m=g(mid);
		if(m=="Vacant")  return 0;
		if(mid%2==0)
		  if(m==a)  l=mid+1;
		  else  r=mid-1;
		else if(m==b) l=mid+1;
		  else  r=mid-1;
	}
	return 0;
}

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

using namespace std;

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

    string s;
    cin >> s;

    string ans;
    string cand[4] = {"SS", "SW", "WS", "WW"};
    for (int i = 0; i < 4; i++) {
        for (int j = 2; j <= N; j++) {
            if (cand[i][j - 1] == 'S' and s[j - 1] == 'o') {
                if (cand[i][j - 2] == 'S') {
                    cand[i] += 'S';
                } else {
                    cand[i] += 'W';
                }
            } else if (cand[i][j - 1] == 'S' and s[j - 1] == 'x') {
                if (cand[i][j - 2] == 'S') {
                    cand[i] += 'W';
                } else {
                    cand[i] += 'S';
                }
            } else if (cand[i][j - 1] == 'W' and s[j - 1] == 'o') {
                if (cand[i][j - 2] == 'S') {
                    cand[i] += 'W';
                } else {
                    cand[i] += 'S';
                }
            } else if (cand[i][j - 1] == 'W' and s[j - 1] == 'x') {
                if (cand[i][j - 2] == 'S') {
                    cand[i] += 'S';
                } else {
                    cand[i] += 'W';
                }
            }
        }

        if (cand[i][0] != cand[i][N]) {
            continue;
        }

        if ((cand[i][0] == 'S' and s[0]== 'o' and cand[i][N - 1] == cand[i][1])
            or (cand[i][0] == 'S' and s[0] == 'x' and cand[i][N - 1] != cand[i][1])
            or (cand[i][0] == 'W' and s[0] == 'o' and cand[i][N - 1] != cand[i][1])
            or (cand[i][0] == 'W' and s[0] == 'x' and cand[i][N - 1] == cand[i][1])) {
            ans = cand[i].substr(0, N);
            break;
        } 
    }

    if (ans.size() > 0) {
        cout << ans << endl;
    } else {
        cout << -1 << endl;
    }

    return 0;
}

Measured memory_bytes: 1024
from collections import Counter
n,*s = open(0).read().split()
s_count = Counter(s).most_common()
long_word=[]
max_count = s_count[0][1]
for word,count in s_count:
    if count < max_count: break
    long_word.append(word)

for word in sorted(long_word):
    print(word)

Measured memory_bytes: 45300
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;  
#define ordered_set tree<int, null_type , less<int> , rb_tree_tag , tree_order_statistics_node_update> 
#define ll long long
#define ull unsigned long long
#define pb push_back
#define inf 1e18
#define mk make_pair
#define ld long double
#define mod 1000000007
#define fi first
#define se second
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test ll t; cin>>t; while(t--)
ull power(ull a,ull n)
{
    ull p;
    if(n==0)
    {
        return 1;
    }
    p=power(a,n/2);
    p=p*p;
    if(n%2==1)
    {
        p*=a;
    }
    return p;
}
int main()
{
    fastIO;
    ull n;
    cin>>n;
    ull val,val1,count=0,count1=0,x,y;
    x=0;
    if(n%2==0)
    {
        val=0;
        x=n;
        count=0;
        while(x!=0)
        {
            count++;
            x/=2;
        }
        count1=0;
        x=n;
        while(x!=0)
        {
            count1++;
            x/=5;
        }
        for(int i=1;i<=count1;i++)
        {
            x=power(5,i);
            val1=n/x;
            y=val1/2;
            val+=y;
        }
        cout<<val<<'\n';
    }       
    else
    {
        cout<<0<<'\n';
    }  
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10;
using ll = long long ;
int n;
char s[nax];
ll a[nax];
ll basis[70];

bool ins (ll * basis, ll x) {

    for (int j = 61 ; j >= 0 ; -- j) {
        if (!(x >> j & 1)) continue;
        if (basis[j] == -1) {
            basis[j] = x;
            return true;
        } else {
            x ^= basis[j];
        }
    }

    return x > 0;
}

bool is_in (ll * basis, ll x) {

    for (int j = 61 ; j >= 0 ; -- j) {
        if (!(x >> j & 1)) continue;
        if (basis[j] == -1)
            return false;
        x ^= basis[j];
    }

    return x == 0;
}


bool solve () {
    scanf("%d", &n);

    for (int i = 1 ; i <= n ; ++ i) {
        scanf("%lld", a + i);
    }

    scanf("%s", s + 1);

    memset(basis, -1, sizeof(basis));

    for (int i = n ; i >= 1 ; -- i) {
        if (s[i] == '0') {
            ins(basis, a[i]);
        } else {
            if (!is_in(basis, a[i]))
                return false;
        }
    }

    return true;
}

int main () {
    int T;

    for (scanf("%d", &T) ;  T-- ; ) {
        puts(solve() ? "0" : "1");
    }
}
/*
    Good Luck
        -Lucina
*/


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

int main(void)
{
	int i,j,k,l;
	int n;
	int w,h;
	int a[100][100];
	int x,y;
	int s,t;
	int sum,max;
	
	while(1)
	{	
		scanf("%d",&n);	
		if(n==0)break;
		
		scanf("%d %d",&w,&h);
		
		for(i=0;i<w;i++)
		{
			for(j=0;j<h;j++)
			{
				a[i][j] = 0;
			}
		}
		
		for(i=0;i<n;i++)
		{
			scanf("%d %d",&x,&y);
			a[x-1][y-1] = 1;
		}

		scanf("%d %d",&s,&t);
		
		max = 0;
		for(i=0;i<=w-s;i++)
		{
			for(j=0;j<=h-t;j++)
			{
				sum = 0;
				for(k=i;k<i+s;k++)
				{
					for(l=j;l<j+t;l++)
					{
						sum+=a[k][l];
					}
				}
				if(max<sum)max=sum;
			}
		}
		
		printf("%d\n",max);
	}
	
	return 0;
}
		

Measured memory_bytes: 0
A, B = map(int, input().split())



if A < B and A != 1 and B != 1:
    print('Bob')
elif A > B and A != 1 and B != 1:
    print('Alice')
elif A < B:
    print('Alice')
elif A > B:
    print('Bob')
else:
    print('Draw')



Measured memory_bytes: 2940
import sys,collections as cl,bisect as bs,math
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l(): #intのlist
	return list(map(int,input().split()))
def m(): #複数文字
	return map(int,input().split())
def onem(): #Nとかの取得
	return int(input())
def s(x): #圧縮
	a = []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa == x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): #listをスペースごとに分ける
	return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
	return max(map(max,x))

n,d = m()

a =[]
for i in range(n):
	a.append(l())
co = 0
su = 0
for i in range(n-1):
	for j in range(i+1,n):
		su = 0
		for k in range(d):
			su += (a[i][k] - a[j][k])**2
		if math.sqrt(su) == int(math.sqrt(su)):
			co += 1
print(co)



Measured memory_bytes: 38384
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
typedef long long int ll;
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
//#define EFOR(i,a,b) for (int i=(a);i<=(b);i++)
const ll MOD = (10*10*10*10*10*10*10*10*10+7);
ll N,a,b,ans=1
    ,X[100010];
stack<long long int> st;
int main(){
    scanf("%lld",&N);
/*    for(int i=0;i<N;i++){
        scanf("%lld",&X[i]);
    }*/
    for(ll i=1;i<=N;i++){
        scanf("%lld",&X[i]);
        st.push(X[i]);
        if(X[i]<2*st.size()-1){
            ans*=st.size();
            st.pop();
        }
        ans%=MOD;
    }
    for(ll i=1;i<=st.size();i++){
        ans*=i;
        ans%=MOD;
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, n) for (int i = (a); i < (n); i++)
#define repb(i, n) for (int i = (n - 1); i >= 0; i--)
#define repb2(i, a, n) for (int i = (n - 1); i >= (a); i--)
#define all(x) x.begin(), x.end()
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
inline void fastio() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); }

int main() {
    fastio();

    int N, M;
    vector<pair<ll, ll>> X;
    cin >> N >> M;
    rep(i, N) {
        int a, b;
        cin >> a >> b;
        X.push_back({a, b});
    }
    sort(all(X));

    ll ans = 0;
    for (auto &x : X) {
        int price = x.first;
        int bottles = x.second;
        ll t = (bottles <= M) ? bottles : M; // 今回の購入本数
        ans += t * price;
        M -= t; // 残りの購入本数
        if (!M) {
            break;
        }
    }
    co(ans);
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
// ascii 97~122

int main(){
    int N,M;
    cin >> N >> M;
    vector<int> vec(N,0);
    int a,b;
    for(int i=0;i<M;i++){
        cin >> a >> b;
        vec.at(a-1)++;
        vec.at(b-1)++;
    }
    for(int x: vec){
        cout << x <<endl;
    }
}

Measured memory_bytes: 3608
n=int(input())
for i in range(n):
    s=input()
    station_list=[]
    for si in s[::3]:
        station_list.append(si)
    st_l=list(dict.fromkeys(station_list))
    ans=[0]*51
    ans[25]=station_list[0]
    for j in st_l[1:]:
        place=s.index(j)
        now=s[place-3:place+1]
        if now[1:3]=="->":
            ans[ans.index(now[0])+1]=now[3]
        elif now[1:3]=="<-":
            ans[ans.index(now[0])-1]=now[3]
    ans_l=list(dict.fromkeys(ans))
    ans_l.remove(0)
    print(''.join(map(str,ans_l)))


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

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

  for(int i = 0;i <= n;i++) {
    for(int j = 0;i+j <= n;j++) {
      int sum = 1000*i + 5000*j + 10000*(n-i-j);
      if(sum == y) {
        cout << n-i-j << " " << j << " " << i << endl;
        return 0;
      }
    } // 5000 yen
  } // 1000 yen

  cout << "-1 -1 -1\n";
  return 0;
}

Measured memory_bytes: 256
#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 q=1;
  cin >> q;
  vector<int> l(q), r(q);
  rep(i,q){
    l.at(i) = 3; r.at(i) = 7;
    cin >> l.at(i) >> r.at(i);
  }

  vector<bool> prime(100001,true);
  prime.at(0) = false;
  prime.at(1) = false;
  int rootN = (int)sqrt(100000);
  int i=2;
  while(i<=rootN){
    if(prime.at(i)){
      int mul = 2*i;
      while(mul<=100000){
        prime.at(mul) = false;
        mul += i;
      }
    }
    i++;
  }

  vector<int> s(100002,0);
  i=3;
  while(i<=100000){
    s.at(i+2) = s.at(i);
    if( (prime.at(i)) && (prime.at((i+1)/2)) )  s.at(i+2)++;
    i += 2;
  }

  int ans=0;
  rep(i,q){
    ans = s.at(r.at(i)+2)-s.at(l.at(i));
    cout << ans << endl;
  }
}

Measured memory_bytes: 4512
//   __________________
//  | ________________ |
//  ||          ____  ||
//  ||   /\    |      ||
//  ||  /__\   |      ||
//  || /    \  |____  ||
//  ||________________||
//  |__________________|
//  \\#################\\
//   \\#################\\
//    \        ____       \
//     \_______\___\_______\
// An AC a day keeps the doctor away.

#pragma GCC optimize("Ofast")
#pragma loop_opt(on)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define debug(x) 0//(cerr<<#x<<" = "<<(x)<<'\n')
#define all(v) begin(v),end(v)
#define siz(v) (ll(v.size()))
#define get_pos(v,x) (lower_bound(all(v),x)-begin(v))
#define pb emplace_back
#define ff first
#define ss second
#define mid (l+(r-l>>1))
#define rep(i,n) for(int i = 0; i < (n); i++)
#define REP(i,n) for(int i = 1; i <= (n); i++)

using namespace std;
using namespace __gnu_pbds;
typedef int64_t ll;
typedef uint64_t ull;
typedef long double ld;
typedef pair<ll,ll> pll;
template <typename T> using rkt = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
constexpr ld PI = acos(-1), eps = 1e-8;
constexpr ll N = 502525, INF = 1e18, MOD = 998244353, K = 2;
constexpr inline ll cdiv(ll x, ll m) { return (x+m-1)/m; } // ceiling divide, x/m for flooring divide
template <typename T> void M(T &x, ll m = MOD){x%=m; if(x<0) x+=m;}

ll n,v[N],u[N];
signed main(){
    ios_base::sync_with_stdio(0), cin.tie(0);
    cin >> n;
    for(int i = 0; i < n; i++) cin >> v[i], u[i] = v[i];
    sort(u,u+n);
    for(int i = 0; i < n; i++) cout << u[n-1-(v[i]==u[n-1])] << '\n';
}


Measured memory_bytes: 7296
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		long n = Long.parseLong(sc.next());
		long k = Long.parseLong(sc.next());
		
		if(n == 1) {
			System.out.println(k);
		}
		else {
			int []a = fac(k);
			long p = 1;
			for(int i = 2 ; i <= Math.sqrt(k) ;i++) {
				if(a[i] >= n) {
					p *= (long)Math.pow(i, a[i]/n);
				}
			}
			
			System.out.println(p);
			
			
		}
		
	}
	
	public static int[] fac(long k) {
		int []a = new int [(int)(Math.sqrt(k)+1)];
		
		long tmp = k;
		for(int i = 2 ; (long)i*i <= k ;i++) {
			int cnt = 0;			
				while(tmp % i == 0) {
					tmp /= i;
					cnt++;
				}
				a[i] = cnt;
		}
		return a;
	}

}


Measured memory_bytes: 40276
#include<bits/stdc++.h>
#define ret( a ) return cout << a ,0;
using namespace std;

string s;
int cnt[600];
main(){
	cin >> s;
	for(int i = 0 ; i < s.size()  ; i++){
		cnt[s[i]]++;
	}
	if(cnt['W'] == 0 && cnt['E'] != 0)
		ret("No");
	if(cnt['E'] == 0 && cnt['W'] != 0)
		ret("No");
	if(cnt['N'] == 0 && cnt['S'] != 0)
		ret("No");
	if(cnt['S'] == 0 && cnt['N'] != 0)
		ret("No");
	cout <<"Yes";
		
}

Measured memory_bytes: 256
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int sol, ans, q;
            int x = int.Parse(Console.ReadLine());
            int a = int.Parse(Console.ReadLine());
            int b = int.Parse(Console.ReadLine());
            sol = x - a;
            q = sol / b;
            ans = sol - b * q;
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define bitsz(x) int(__builtin_popcount(x))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb(x) push_back(x)
#define INF 1e9
#define LINF 1e18
#define mod 1000000007
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
const int di[4] = {1,0,-1,0};
const int dj[4] = {0,1,0,-1};


int main() {
    int n; cin >> n;
    int cnt = 1;
    while (1000*cnt < n) cnt++;
    cout << 1000*cnt - n << endl;
}

Measured memory_bytes: 3588