akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>
using namespace std ;
#define ll long long 
#define all(x) x.begin() , x.end()
int const N = 1e6+1 , MOD = 1e9 + 7; 
ll an;
int main(){
  //    freopen("input.txt" ,"r",stdin);
      ll n , k;
      scanf("%lld%lld",&n,&k);
      if(k%2==1){
         an = (n/k);
         cout<<an*an*an;
         exit(0);
      }
      an = ((n/(k/2))-n/k)*((n/(k/2))-n/k)*((n/(k/2))-n/k)+(n/k)*(n/k)*(n/k) ;
      cout<<an;
}                   

Measured memory_bytes: 256
using System.Collections.Generic;
using System.Linq;
using System;

public class P
{
    public int p { get; set; }
    public List<int> c { get; set; }
    public int d { get; set; }
}

public class P2
{
    public int nowd { get; set; }
    public int id { get; set; }
}

public class hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var ps = new P[n];
        for (int i = 0; i < n; i++) ps[i] = new P { c = new List<int>(), p = -1 };
        for (int i = 0; i < n; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var id = int.Parse(line[0]);
            var jmax = int.Parse(line[1]);
            for (int j = 0; j < jmax; j++)
            {
                var w = int.Parse(line[j + 2]);
                ps[id].c.Add(w);
                ps[w].p = id;
            }
        }
        var parent = -1;
        for (int i = 0; i < n; i++) if (ps[i].p == -1) { parent = i; break; }
        getD(ps, parent);
        print(ps, n);
    }
    static void print(P[] ps, int n)
    {
        for (int i = 0; i < n; i++)
        {
            string type;
            if (ps[i].p == -1) type = "root";
            else if (ps[i].c.Count() == 0) type = "leaf";
            else type = "internal node";
            Console.WriteLine("node {0}: parent = {1}, depth = {2}, {3}, [{4}]", i, ps[i].p, ps[i].d, type, string.Join(", ", ps[i].c));
        }
    }
    static void getD(P[] ps, int parent)
    {
        var q = new Queue<P2>();
        q.Enqueue(new P2 { id = parent, nowd = 0 });
        while (q.Count() > 0)
        {
            var w = q.Dequeue();
            ps[w.id].d = w.nowd;
            foreach (var x in ps[w.id].c)
                q.Enqueue(new P2 { id = x, nowd = w.nowd + 1 });
        }
    }
}



Measured memory_bytes: 40756
#include <iostream>
#include <vector>
#include <deque>
#include <cmath>
#include <map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include "iomanip"
#include <cstdio>
#include <cstring>

using namespace std;

int main() {

    long long n, m;
    cin >> n >> m;
    long long a = n % 2019;
    long long b = m % 2019;
    long long c = n / 2019;
    long long d = m / 2019;
    long long res = INT64_MAX;
    int MIN = min(a, b);
    int MAX = max(a, b);
    if (c != d) {
        cout << 0;
    } else {
        for (int i = MIN; i < MAX; ++i) {
            for (int j = MIN + 1; j <= MAX; ++j) {
                res = res > (i * j) % 2019 ? (i * j) % 2019 : res;
            }
        }
        cout << res;
    }
    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;


int main() {

    lli N;
    cin >> N;

    vector<lli> a(N + 1);
    for (lli i = 1; i < N + 1; ++i) {
        cin >> a[i];
    }

    vector<bool> answer(N + 1);
    for (lli i = 0; i < N + 1; ++i) {
        answer[i] = false;
    }
    lli answerCounter = 0;


    for (lli i = N; i > 0; --i) {
        lli num = a[i];

        //  倍数がなんこあるか調べる
        lli nankoBaisu = N / i;
        lli counter = 0;
        for (int j = 0; j < nankoBaisu; ++j) {
            // 既に値が入っているのか調べる
            if (answer[i * (j + 1)]) {
                ++counter;
            }
        }

        //
        if (counter % 2 == num) {
            // 一致しているので何もしない
        } else {
            // 条件にあっていないので、ボールがある
            answer[i] = true;
            ++answerCounter;
        }
    }

    // 1つもボールが無い時
    if (answerCounter == 0) {
        cout << 0 << endl;
        return 0;
    }

    cout << answerCounter << endl;
    for (lli i = 1; i < N + 1; ++i) {
        if (answer[i]) {
            cout << i << " ";
        }
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 2560
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
int i;
#define rep2(i, a, b) for(i = a; i <= b; ++i)
#define rep(i, n) for(i = 0; i < n; ++i)
using namespace std;
// _________コーディングはここから！！___________
template <const int sz = 5 * 10000000, typename T = long long> struct IO {
    char reader[sz], writer[sz];
    char *now, *now2 = writer;
    IO() {
        reader[fread(reader, sizeof(char), sizeof(char) * sz, stdin)];
        now = reader;
    }
    inline T read() {
        while(*now && *now <= 32) now++;
        if(*now == '-') {
            now++;
            T res = 0;
            while('0' <= *now and *now <= '9') { res = res * 10 + *now++ - '0'; }
            return -res;
        } else {
            T res = 0;
            while('0' <= *now and *now <= '9') { res = res * 10 + *now++ - '0'; }
            return res;
        }
    }
    inline string read_str() {
        string res;
        while(*now and *now != '\n' and *now != ' ') res += *now++;
        now++;
        return res;
    }
    inline void write(T x, char margin = ' ') {
        if(x == 0) {
            putchar('0');
            putchar(margin);
            return;
        }
        if(x < 0) {
            putchar('-');
            x = -x;
        }
        while(x) {
            *now2 = '0' + x % 10;
            now2++;
            x /= 10;
        }
        do {
            now2--;
            putchar(*now2);
        } while(now2 != writer);
        putchar(margin);
    }
    inline void write_str(string s, char margin = ' ') {
        for(auto c : s) putchar(c);
        putchar(margin);
    }
};
IO io;
inline int read() { return io.read(); }
inline void write(int x) { io.write(x); }
inline void write(int x, char c) { io.write(x, c); }
constexpr int N = 500010;
int c[N];
using T = tuple<int, int, int>;
T q[N];
int ans[N];
int last[N];
int dat[N];

inline void add(int k) {
    for(++k; k < N; k += k & -k) dat[k]++;
}
inline void dec(int k) {
    for(++k; k < N; k += k & -k) dat[k]--;
}
inline int sum(int k) {
    int res = 0;
    for(++k; k > 0; k -= k & -k) res += dat[k];
    return res;
}
int n, Q, now = 1;

// 頑張れ！！
#pragma GCC target("avx2")
#pragma GCC optimize("unroll-loops")
// 頑張れ！！

main() {
    n = read(), Q = read();
    rep2(i, 1, n) c[i] = read();
    rep(i, Q) get<1>(q[i]) = read(), get<0>(q[i]) = read() + 1, get<2>(q[i]) = i;
    sort(q, q + Q);
    int now = 1;
    rep(i, Q) {
        for(; now < get<0>(q[i]); ++now) {
            if(last[c[now]]) dec(last[c[now]]);
            last[c[now]] = now;
        }
        ans[get<2>(q[i])] = sum(get<0>(q[i]) - 1) - sum(get<1>(q[i]) - 1) + get<0>(q[i]) - get<1>(q[i]);
    }
    rep(i, Q) write(ans[i], '\n');
}

Measured memory_bytes: 26692
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int N=2e5+10;
int m,d=0;
int main(){
	cin>>m>>d;
	int ans=0;
	for(int i=1;i<=m;++i){
		for(int j=1;j<=d;++j){
			if(j%10<2) continue;
			if((j/10)<2) continue;
			if((j%10)*(j/10)==i) ++ans;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
// #include {{{
#include <array>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iterator>
#include <tuple>
#include <utility>
#include <random>
#include <limits>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cstdint>
#include <cassert>
// }}}

using namespace std;

// macros {{{
template<typename T, size_t N>
constexpr size_t NELEMS(T (&)[N]) { return N; }

template<typename InputIt>
void PRINT_RANGE(InputIt first, InputIt last)
{
    for(; first != last; ++first)
        cout << *first << (first==last ? "" : " ");
    cout << "\n";
}

template<typename T>
void PRINT_MATRIX(T mat, size_t nr, size_t nc)
{
    for(size_t r = 0; r < nr; ++r) {
        for(size_t c = 0; c < nc; ++c) {
            cout << mat[r][c] << (c==nc-1 ? "" : " ");
        }
        cout << "\n";
    }
}

#define FOR(i, start, end) for(int i = (start); i < (end); ++i)
#define REP(i, n) FOR(i, 0, n)
// }}}

// types {{{
using ll  = long long;
using ull = unsigned long long;
// }}}

int A, B, C, D, E, F;

void solve()
{
    double ratio_ans = -1.0; // TODO: ここ min() だと正しく動かない?
    int water_ans = -1;
    int suger_ans = -1;

    int a_max = F / (100*A);
    FOR(a, 0, a_max+1) {
        int b_max = (F-(100*A*a)) / (100*B);
        FOR(b, 0, b_max+1) {
            int water = 100*A*a + 100*B*b;
            if(water == 0) continue;
            if(water > F) continue;

            int suger_max = min(E*water/100, F-water);
            int c_max = suger_max / C;
            FOR(c, 0, c_max+1) {
                int d = (suger_max-C*c) / D;
                int suger = c*C + d*D;
                if(suger > suger_max) continue;

                double rat = 100.0*suger / (water+suger);
#ifdef DEBUG
                cout << "water: " << water << ", suger: " << suger << ", ratio: " << rat << "\n";
#endif
                if(rat > ratio_ans) {
                    ratio_ans = rat;
                    water_ans = water;
                    suger_ans = suger;
                }
            }
        }
    }

    cout << water_ans+suger_ans << " " << suger_ans << "\n";
}

int main()
{
    cin >> A >> B >> C >> D >> E >> F;

    solve();

    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define  ll long long
#define  ull unsigned long long
#define  ul unsigned long
#define all(v) v.begin(),v.end()
#define sz(n) (int)n.size()
#define pb(s) push_back(s);
#define format(n) fixed<<setprecision(n)
#define finl "\n"
#define Mohammed_Atef_Hassan fast();
#define INF LLONG_MAX
#define PI acos(-1)
#define clr(dp,n) memset(dp,n,sizeof dp)
#define ex(n) return cout<<n<<finl,0;
#define N (int)1e6+10
int dx[] = { 0, 1, 0, -1, 1, 1, -1, -1 };
int dy[] = { 1, 0, -1, 0, 1, -1, 1, -1 };
void fast() {

	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL);

#ifdef ONLINE_JUDGE
	//	freopen("palindrome.in", "r", stdin);

	//freopen("palindrome.out", "w", stdout);
#endif
#ifndef ONLINE_JUDGE
	//freopen("9000000.txt", "r", stdin);

	//freopen("ConsoleApplication1.zip", "w", stdout);
#endif
}
int main()
{
	Mohammed_Atef_Hassan
		int n; int x, sum = 0, mx = 0;
	cin >> n;
	while (n--)
	{
		cin >> x;
		sum += x;
		mx = max(mx, x);
	}
	cout << sum - mx / 2 << finl;
}

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

int main() {
  int n; cin >> n;
  vector<pair<int,int>> ab(n);
  rep(i,n){
    int a,b; cin >> a >> b;
    ab.at(i) = make_pair(b,a);
  }

  sort(ab.begin(),ab.end());

  int nowTime = 0;
  string ans = "Yes";
  rep(i,n){
    int simekiri = ab.at(i).first;
    nowTime += ab.at(i).second;
    if(simekiri < nowTime){
      ans = "No";
      break;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 1792
#include<cstdio>
#define pritnf printf
#define scnaf scanf
#define retrun return
#define sizoef sizeof
#define inl inline
#define br break
#define con continue
#define mst(a,b) memset(a,b,sizeof(a))
#define fora(x,a,b) for(re nti (x)=(a);(x)<=(b);++(x))
#define forb(x,a,b) for(re nit (x)=(a);(x)>=(b);--(x))
#define foral(x,a,b) for(re ll (x)=(a);(x)<=(b);++(x))
#define forbl(x,a,b) for(re ll (x)=(a);(x)>=(b);--(x))
#define re register
#define stt struct
#define infa (0x3f3f3f3f)
#define infb (0x7fffffff)
#define infd (0x7f)
#define abss(x) ((x)>(0)?(x):(-1)*(x))
#define maxx(a,b) ((a)>(b)?(a):(b))
#define minn(a,b) ((a)<(b)?(a):(b))
#define in(a) freopen("D:/""/in"a".in","r",stdin)
#define out(a) freopen("D:/""/out"a".out","w",stdout)
typedef long long ll;
typedef int itn,nti,tin,tni,nit;
using namespace std;
const nit maxa=104;
const nit maxb=1e2;
const nit maxc=5;
#include<iostream>

string x;
nit s;

tni main()
{
	cin>>x;
	s=x.size();
	for(re nit i=0;i<s;i=i+2)
	{
		pritnf("%c",x[i]);
	}
	pritnf("\n");
	//
	return 0;
}

Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#define lp(i,n) for(int i=0;i<n;i++)
#include<bits/stdc++.h>


using namespace std;
int main() {
	char c[3];
	int ans = 700;
	lp(i, 3)
		cin >> c[i];
	lp(i, 3)
		if (c[i] == 'o')
			ans += 100;
	cout << ans << endl;
	return 0;
}

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

int main(){
  int n;
  cin>>n;
  vector<ll> a;
  vector<ll> a1;
  int ans;
  int count=0;
  for(int i=0;i<n;i++){
    int b;
    cin>>b;
    a.push_back(b);
  }
  for(int i=0;i<n;i++){
    while(a[i]%2==0){
      a[i]/=2;count++;
    }
    a1.push_back(count);
    count=0;
  }
  ans=*min_element(a1.begin(),a1.end());
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;

// Graph Templates
using Weight = ll;
// using Flow = int;
struct Edge {
    int src, dst;
    Weight weight;
    // Flow cap;
    Edge() : src(0), dst(0), weight(0) {}
    Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;
const Weight inf = numeric_limits<Weight>::max() / 8;

// add edge a <--(weight = w)--> b
void add_edge(Graph &g, int a, int b, Weight w) {
    g[a].push_back(Edge(a, b, w));
    g[b].push_back(Edge(b, a, w));
}

// add edge a --(weight = w)--> b
void add_arc(Graph &g, int a, int b, Weight w) { g[a].push_back(Edge(a, b, w)); }

// topological sort
// g : directed acyclic graph
// return : ord or empty vector array
vector<int> tsort(const Graph &g) {
    int n = g.size(), k = 0;
    std::vector<int> ord(n), in(n);
    for (auto &es : g)
        for (auto &e : es) in[e.dst]++;
    std::queue<int> q;
    for (int i = 0; i < n; ++i)
        if (in[i] == 0) q.push(i);
    while (q.size()) {
        int v = q.front();
        q.pop();
        ord[k++] = v;
        for (auto &e : g[v])
            if (--in[e.dst] == 0) q.push(e.dst);
    }
    return *std::max_element(in.begin(), in.end()) == 0 ? ord : std::vector<int>();
}

int main(){
    int v, e;
    cin >> v >> e;
    int s, t;
    Graph g;
    g.resize(v);
    for (int i=0; i<e; ++i){
        cin >> s >> t;
        add_arc(g, s, t, 1);
    }
    vector<int> ans = tsort(g);
    for (int i=0; i<v; ++i){
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 4448
n = int(input())
song = []
if n == 1:
    print(0)
else:
    for i in range(n):
        title, time = input().split()
        song.append([title, int(time)])

    check = input()
    flag = False
    ans = 0
    for k, v in song:
        if k == check:
            flag = True
            continue
        if flag:
            ans += v
    print(ans)


Measured memory_bytes: 3060
#C
n = int(input())
h = list(map(int, input().split()))
tmpn = 0
maxn = 0
for i in range(n-1):
    if h[i] >= h[i+1]:
        tmpn += 1
        maxn = max(tmpn, maxn)
    else:
        tmpn = 0
print(maxn)


Measured memory_bytes: 15020
#include <bits/stdc++.h>
#include <cstring>
#include <map>
#include <set>
#define int long long int
using namespace std;
const int MAX = 1000000007;

bool dp[400000];

signed main() {
 
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    #ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    //  freopen("output.txt", "w", stdout);
    #endif
    
    int n, k, i, j;
    cin>>n>>k;
    int a[n];
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    dp[0]=false;
    for(i=0;i<=k;i++){
        for(j=0;j<n;j++){
            if((i-a[j]>=0)&&!dp[i-a[j]])
                dp[i]=true;
        }
    }
    if(dp[k])
        cout<<"First"<<endl;
    else
        cout<<"Second"<<endl;
    
}


Measured memory_bytes: 384
#include <stdio.h>
 
int main() {
    int n, mm, x;
    int votos[100];
    double t = 0;
    int v = 0;
    
    scanf("%d%d", &n, &mm);
    
    double m = mm;
    
    for (int i = 0; i < n; ++i) {
        scanf("%d", &x);
        votos[i] = x;
        t += x;
    }
    
    for (int i = 0; i < n; ++i) {
        double vot = t / (4 * m);
        
        if (votos[i] >= t / (4 * m))
            v += 1;
    }      
    if (v >= m)
        printf("Yes\n");
    else
        printf("No\n");
        
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int N=20,M=5e4+50,mod=1e9+7;
int n,m,f[M],mx,b[N],c[N],pw[M],bit[M];
int main(){
	scanf("%d%d",&n,&m);mx=1<<n;f[0]=pw[0]=1;
	for(int i=1;i<=m;i++)pw[i]=pw[i-1]*2%mod;
	for(int i=1;i<mx;i++)bit[i]=bit[i>>1]+(i&1);
	for(int i=1,x,y;i<=m;i++){
		scanf("%d%d",&x,&y);x--;y--;
		b[x]|=1<<y;c[y]|=1<<x;
	}
	for(int i=1;i<mx;i++){
		if((i&1)^(i>>1&1))continue;
		if(i&1){
			for(int j=i;j;j=(j-1)&i){
				if((j&1)^(j>>1&1))continue;
				int dat=1,c2=0;
				for(int k=0;k<n;k++)if((i^j)>>k&1){
					int c1=bit[b[k]&j];c2+=bit[c[k]&j];
					dat=1ll*dat*(pw[c1]-1)%mod;
				}
				f[i]=(f[i]+1ll*f[i^j]*dat%mod*pw[c2])%mod;
			}
		}
		else{
			int c1=0;
			for(int j=0;j<n;j++)if(i>>j&1)c1+=bit[b[j]&i];
			f[i]=pw[c1];
		}
	}
	cout<<(pw[m]-f[mx-1]+mod)%mod;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <queue>
#include <cstring>
#define N 2001
using namespace std;

vector<int> adj[N];
bool visited[N];
int track[N] = {0};
int level[N];

void bfs(int s) {
    memset(visited, false, sizeof(visited));
    memset(level, -1, sizeof(level));
    
    queue<int> q;
    q.push(s);
    visited[s] = true;
    level[s] = 0;
    
    int i, p;
    
    while(!q.empty()) {
        p = q.front();
        q.pop();
        
        for(i=0; i<adj[p].size(); i++) {
            if (!visited[adj[p][i]]) {
                visited[adj[p][i]] = true;
                q.push(adj[p][i]);
                level[adj[p][i]] = level[p] + 1;
            }
        }
    }
}

int main() {
    int n, x, y, i, j;
    cin>>n>>x>>y;
    
    adj[x].push_back(y);
    adj[y].push_back(x);
    
    for(i=1; i<=n-1; i++) {
        adj[i].push_back(i+1);
        adj[i+1].push_back(i);
    }
    
    for(j=1; j<=n; j++) {
        bfs(j);

        for(i=1; i<=n; i++) {
            track[level[i]]++;
        }
    }
    
    for(i=1; i<n; i++) {
        cout<<track[i]/2<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };



signed main() {
	int i, j;
	int n;

	cin >> n;

	if (n == 25) {
		cout << "Christmas" << endl;
	}
	else if (n == 24) {
		cout << "Christmas Eve" << endl;
	}
	else if (n == 23) {
		cout << "Christmas Eve Eve" << endl;
	}
	else if (n == 22) {
		cout << "Christmas Eve Eve Eve" << endl;
	}


	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
//Zory-2019
#include<bits/stdc++.h>
using namespace std;
namespace mine
{
    typedef long long ll;
    #define pr pair<int,int>
    #define FR first
    #define SE second
    #define MP make_pair
    #define PB push_back
    #define vc vector
    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())
    #define bin(x) (1ll<<(x))
    #define GG(x) if(x) {puts("error");exit(666);}
    #define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
    #define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num)
    {
        if(num<0) putchar('-'),num=-num;
        if(num>=10) write(num/10);
        putchar('0'+num%10);
    }
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

    const int INF=0x3f3f3f3f;
    const int MOD=998244353;
    int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
    ll qpower(ll x,ll e,int mod=MOD){ll ans=1;GG(e<0)while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=1e5+10;

    
	void main()
	{
	    int x=qread(),y=qread();if(x<y) swap(x,y);
	    write(ceil(1.0*qread()/x));
	}
};//(ans+MOD)%MOD
signed main()
{
//	freopen("z.txt","r",stdin);
    srand(time(0));
    mine::main();
}


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

const int MAXN = 200001;
int road[MAXN], railway[MAXN];

int father(int fa[], int p) {
    if (fa[p] == p) { return p; }
    fa[p] = father(fa, fa[p]);
    return fa[p];
}

int main() {
    int n, k, l;
    scanf("%d%d%d", &n, &k, &l);
    for (int i = 1; i <= n; i++) {
        road[i] = railway[i] = i;
    }
    while (k--) {
        int p, q;
        scanf("%d%d", &p, &q);
        road[father(road, p)] = father(road, q);
    }
    while (l--) {
        int p, q;
        scanf("%d%d", &p, &q);
        railway[father(railway, p)] = father(railway, q);
    }
    map<long long, int> result;
    for (int i = 1; i <= n; i++) {
        road[i] = father(road, i);
        railway[i] = father(railway, i);
        result[(long long)road[i] * (long long)(n + 1) + (long long)railway[i]]++;
    }
    for (int i = 1; i <= n; i++) {
        cout << result[(long long)road[i] * (long long)(n + 1) + (long long)railway[i]] << ((i != n) ? " " : "\n");
    }
    return 0;
}


Measured memory_bytes: 13568
N = int(input())

amin, amax, bmin = float('inf'), 0, float('inf')

for _ in range(N):
    A, B = map(int, input().split())
    amin = min(amin, A)
    amax = max(amax, A)
    bmin = min(bmin, B)

ans = (amin-1) + (amax-amin+1) + bmin
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>
#include <bitset>
#include <sstream>
#include <cassert>
#include <time.h>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}
void printvec (vec &v) {
    Rep (i, (ll)v.size()) {
        cout << v[i] << " \n"[i+1 == (ll)v.size()];
    }
}

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

    ll X, Y, N;
    cin >> X >> Y >> N;
    auto on_edge = [&] (ll x, ll y) -> bool {
        if (x == 0 or x == X or y == 0 or y == Y) return true;
        else return false;
    };
    auto encode = [&] (ll x, ll y) -> ll {
        if (x == 0) return y;
        else if (y == Y) return x+y;
        else if (x == X) return 2*Y+X-y;
        else return 2*Y+2*X-x;
    };
    set<pair<ll, ll>> points;

    Rep (i, N) {
        ll x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        if (on_edge(x1, y1) and on_edge(x2, y2)) {
            points.insert({encode(x1, y1), i});
            points.insert({encode(x2, y2), i});
        }
    }

    stack<ll> st;
    for (auto e : points) {
        ll now = e.second;
        // cout << now << "\n";
        if (st.size() and st.top() == now) st.pop();
        else st.push(now);
    }

    if (st.empty()) cout << "YES\n";
    else cout << "NO\n";

}

Measured memory_bytes: 16396
N = int(input())
B = [int(i) for i in input().split()]

result = []
for i in range(N):
    for j in range(N - i - 1, -1, -1):
        if j + 1 == B[j]:
            result.insert(0, B.pop(j))
            break
    else:
        print(-1)
        quit()

for ri in result:
    print(ri)


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

bool IsPrime(ll num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (ll i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main(){
    ll N,kotae=1000000000000,a,b;
    cin >> N;
    if(IsPrime(N)){
        cout << N-1 << endl;
    }else{
        for(ll i=2;i<1000001;i++){
            if(N%i==0){
                a=i;
                b=N/i;
                kotae=min(kotae,a+b-2);
            }
        }
        cout << kotae << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: f64,
        b: f64,
    }
    let ans = ((b - 1.) / (a - 1.)).ceil() as usize;
    println!("{}", ans);
}


Measured memory_bytes: 4352
(let* ((n (read))
       (a (make-array `(,(1+ n))))
       (x))
  (loop :for i :from 1 :to n
        :do (setf (aref a i) (read)))
  ;
  (setf x (aref a 2))
  (loop :for i :from 3 :to n
        :do (setf x (logxor x (aref a i))))
  (format t "~A" x)
  (loop :for i :from 2 :to n
        :do (progn
              (setf x (logxor (aref a (1- i)) (aref a i) x))
              (format t " ~A" x))))
(format t "~%")


Measured memory_bytes: 78684
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;cin>>n;
  int prime = 0;
  if(n==2 || n==3){cout<<n;return 0;}
  for(int i=n;i<10000000;i++){
  	int div=0;
  			for(int j=2;j*j<=i;j++){
            	if(i%j==0){div=1;break;}
            }
    if(div==0){prime=i;break;}
  }
  cout<<prime;
}

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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	long long n;
	cin >> n;
	vector <char> c;
	while (n) {
		n -= 1;
		c.emplace_back(n%26 + 'a');
		n /= 26;
	}
	for (auto it = c.end()-1; it >= c.begin(); --it) cout << *it;
	cout << '\n';
}


Measured memory_bytes: 3564
//
//  main.cpp
//  prison
//
//  Created by Dong Truong on 5/28/19.
//  Copyright © 2019 Dong Truong. All rights reserved.
//

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <fstream>

using namespace std;
#define maxn 1000001

struct elem
{
    int l,r;
};

int n,m;elem a[maxn];
bool cmp(elem a,elem b)
{
    return (a.l<b.l);
}
void nhap()
{
    cin>>n>>m;
    for (int i=1;i<=m;++i)
        cin>>a[i].l>>a[i].r;
    sort(a+1,a+m+1,cmp);
}
void sol()
{
    int left=a[1].l,right=a[1].r;
    for (int i=2;i<=m;++i)
    {
        left=max(left,a[i].l);
        right=min(right,a[i].r);
    }
    if (left>right) cout<<0;
    else
    cout<<min(right-left+1,n);
}
int main(int argc, const char * argv[]) {
    // insert code here...
    //std::cout << "Hello, World!\n";
    //freopen("a.inp","r",stdin);
    nhap();
    sol();
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
set<int> st;
int n, x;
int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
    {
        scanf("%d", &x);
        if (st.find(x) != st.end())
            st.erase(st.find(x));
        else
            st.insert(x);
    }
    return printf("%d\n", st.size()), 0;
}

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

int main() {
  set<int> s;
  int N;
  cin >> N;
  rep(i,N) {
    int d;
    cin >> d;
    s.insert(d);
  }  

  cout << s.size() << endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input())
nums = list(map(int, input().split(" ")))
def frog(n, nums):
    cost = [0, abs(nums[1] - nums[0])]
    for i in range(2, len(nums)):
        cost.append(min(cost[i-2] + abs(nums[i-2] - nums[i]), cost[i-1] + abs(nums[i-1] - nums[i])))
    return cost[n - 1]
print(frog(n, nums))

Measured memory_bytes: 14056
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#include <numeric>
#include <math.h>

#define user spaesk
#define pi acos(-1)
#define lli long long int
#define ld long double
#define ff first
#define ss second
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

typedef vector<vector<lli> > matrix ;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;
const int NN = 5e3 + 6;

lli n, k;
lli a[N];

bool ok(lli X) {

    vector<lli> ps = {0};
    vector<lli> rem = {0};
    for(int i = 1; i <= n; i ++) {
        rem.push_back(a[i] % X);
    }
    sort(rem.begin(), rem.end());
    for(int i = 1; i <= n; i ++) {
        ps.push_back(ps.back() + (rem[i]));
    }

    for(int i = 1; i <= n; i ++) {
        lli choice1 = ps[i];
        lli choice2 = (n - i) * X - (ps[n] - ps[i]);
        if(max(choice1, choice2) <= k) {
            return 1;
        }
    }
    return 0;
}

void solve()
{

    cin>>n>>k;
    lli s = 0;
    for(int i = 1; i <= n; i ++) {
        cin>>a[i];
        s += a[i];
    }
    lli ans = 0;
    for(lli i = 1; i * i <= s; i ++) {
        if(s % i == 0) {
            if(ok(i)) {
                ans = max(ans, i);
            }
            if(ok(s / i)) {
                ans = max(ans, s / i);
            }
        }
    }
    cout<<ans;
    cout<<"\n";
    return ;
}

/*
*/

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

    int t = 1;
//    cin>>t;
    while(t --)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <locale>
#include <iomanip>

#define nl '\n';

using namespace std;

int a, k, t;

int main(){

    vector<int> v;

    for(int i = 0; i < 3; i++){
        cin >> a;
        v.push_back(a);
    }

    cin >> k;

    for(int i = 0; i < k; i++){
        sort(v.begin(), v.end());
        v[2] = v[2]*2;
    }

    for(int i = 0; i < 3; i++){
        t = t + v[i];
    }

    cout << t;



}

//g++ -std=c++14 comp.cpp -o b; ./b.exe
//g++ -std=c++14 comp.cpp && ./a.out

// char** arr = new char*[r];
// for(long long i = 0; i < r; i++) arr[i] = new char[c];

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    char c[3];
    scanf("%s",c);
    
    if ((c[0] == c[1] && c[1] == c[2] && c[2] == 'A') || (c[0] == c[1] && c[1] == c[2] && c[2] == 'B')){
        printf("No\n");
    }
    else {
        printf("Yes\n");
    }
    return 0;
}




Measured memory_bytes: 128
//無向グラフ→BFSで解く
//BFS木の特徴
//・二つ離れた層の間に辺がない
//・根以外のどの頂点も一つ前の層につながる辺が必ず一本以上ある

using System;
using System.Collections.Generic;


namespace D
{
    class Program
    {
        public const int INF = 1001001001;
        static void Main(string[] args)
        {
            string[] In = Console.ReadLine().Split(' ');
            int n = int.Parse(In[0]);
            int m = int.Parse(In[1]);
            var L = new List<int>[100005];//縦100005,横Listの二次元配列
            for(int i=0; i < 100005; i++)
            {
                L[i] = new List<int>();
            }
            string[] In2;
            int a, b;
            for (int i = 0; i < m; i++)
            {
                In2 = Console.ReadLine().Split(' ');
                a = int.Parse(In2[0])-1;
                b = int.Parse(In2[1])-1;
                L[a].Add(b);
                L[b].Add(a);
            }
            Queue<int> q =new Queue<int>();
            List<int> dist = new List<int>();//distance
            List<int> pre = new List<int>();//一個前の部屋
            for (int i=0; i < n; i++)
            {
                dist.Add(INF);
                pre.Add(-1);
            }
            dist[0] = 0;
            q.Enqueue(0);
            int v;
            while (q.Count != 0)
            {
                v = q.Dequeue();//キューの先頭から出す
                foreach(int u in L[v])//出したものの隣を全部つるし上げる
                {
                    if (dist[u] != INF) continue;
                    dist[u] = dist[v] + 1;
                    pre[u] = v;//普段のBFSはここがない？
                    q.Enqueue(u);
                }
            }
            Console.WriteLine("Yes");
            int ans;
            for(int i=1; i < n; i++)
            {
                ans = pre[i];
                ans++;
                Console.WriteLine(ans);
            }
        }
    }
}


//original
//namespace D
//{
//    class Program
//    {
//        static void Main(string[] args)
//        {
//            string[] In = Console.ReadLine().Split(' ');
//            int n = int.Parse(In[0]);
//            int m = int.Parse(In[1]);
//            int[,] L = new int[m, 2];
//            string[] In2;
//            for(int i=0; i<m; i++)
//            {
//                In2 = Console.ReadLine().Split(' ');
//                L[i, 0] = int.Parse(In2[0]);
//                L[i, 1] = int.Parse(In2[1]);
//            }
//            bool[] IsVisited = new bool[n];
//            List<int> NextRoom = new List<int>();
//            List<int> NowRoom = new List<int>();
//            NextRoom.Add(0);
//            while (!IsAllVisited(IsVisited))
//            {
//                foreach(int i in NextRoom)
//                {
//                    IsVisited[i] = true;
//                    for(int j=0; j < m; j++)
//                    {
//                        if()
//                    }
//                }
//                NextRoom.Clear();

//            }

//        }
//        public static bool IsAllVisited(bool[] IsVisited)
//        {
//            foreach(bool b in IsVisited)
//            {
//                if (!b) return false;
//            }
//            return true;
//        }
//    }
//}


Measured memory_bytes: 51592
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define MOD 1000000007
#define int int64_t

signed main(){
	int n;
	cin>>n;
	int bottle_neck=5;
	rep(i,5){
		int c; cin>>c;
		bottle_neck=max(bottle_neck,4+(n+c-1)/c);
	}
	cout<<bottle_neck<<endl;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007

ll floor_sum(ll n,ll m,ll a,ll b){
  ll res = 0;
  if(a >= m){
    res += (n-1)*n*(a/m)/2;
    a %= m;
  }
  if(b >= m){
    res += n*(b/m);
    b %= m;
  }
  ll y_max = (a*n+b)/m;
  if(y_max == 0)return res;
  res += floor_sum(y_max,a,m,a*n+b-y_max*m);
  return res;
}

int main(){
  
  int T;
  cin >> T;
  while(T--){
    ll n,m,a,b;cin >> n >> m >> a >> b;
    cout << floor_sum(n,m,a,b) << "\n";
  }
  


  return 0;
}

Measured memory_bytes: 3608
def main():
    M = int(input())
    ans = 0
    dc_sum = 0
    for i in range(M):
        d, c = (int(i) for i in input().split())
        dc_sum += d*c
        ans += c
    if dc_sum % 9 == 0:
        print(ans - 1 + dc_sum//9 - 1)
    else:
        print(ans - 1 + dc_sum//9)


if __name__ == '__main__':
    main()


Measured memory_bytes: 47832
using System;
using System.Text;

namespace AtCoder.Abcdef
{
    public class QuestionC
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            //Input integer
            long n = long.Parse(Console.ReadLine());

            var sb = new StringBuilder();
            while (n > 0) 
            {
                n--;
                var remainder = (int) (n % 26);
                sb.Insert(0, (char)('a' + remainder));
                n = n / 26;
            }

            Console.WriteLine(sb.ToString());
            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 27512
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char ch;
	int year=0,mon=0,day=0;
	ch=getchar();
	while (ch!='/' && ch>='0' && ch<='9') year=year*10+ch-48,ch=getchar();
	ch=getchar();
	while (ch!='/' && ch>='0' && ch<='9') mon=mon*10+ch-48,ch=getchar();
	ch=getchar();
	while (ch>='0' && ch<='9') day=day*10+ch-48,ch=getchar();
//	printf("%d %d %d\n",year,mon,day);
	if (year<2019 || year==2019 && mon<4 || year==2019 && mon==4 && day<=30) printf("Heisei\n");
		else printf("TBD\n");
	return 0;
}

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

int main(){
    string S;
    cin >> S;
    string A[4] = {"dream", "dreamer", "erase", "eraser"};
    int k = 0;

    bool a = true;

    reverse(S.begin(), S.end());

    for(int i = 0; i < 4; i++){
        reverse(A[i].begin(), A[i].end());
    }

    for(int i = 0; i < S.size();){
        if(a){
          bool b = false;
          for(int j = 0; j < 4; j++){
              if(S.substr(i, A[j].size()) == A[j]){
                    i += A[j].size();
                    b = true;
              }
              a = b;
          }   
        }
        else{
            break;
        }
    }

    if(a){
        cout << "YES" << endl;
    }

    else{
        cout << "NO" << endl;
    }

}

Measured memory_bytes: 512
// I can

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"

typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const ll maxn=1000001,mod=1e9+7;

int main(){
sync

int n,m;
cin>>n>>m;
pair<int,int> p[n];

forn(i,n) cin>>p[i].fi, cin>>p[i].se;
sort(p,p+n);
ll ans=0;
forn(i,n){
    ll val=min(m,p[i].se);
    ans+=val*p[i].fi;
    m-=val;
}
cout<<ans;
return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
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; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    cout << a * (n / (a+b)) + (n % (a+b) > a ? a : n % (a+b)) << endl;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;

#define PI         acos(-1.0)
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)

typedef long long ll;

//////////////////////////////////////BIT
struct BIT{
    vector<ll> data;
    int n;
    // 最大値求めたいとき最初は0を入れておく？
    // データはaddで随時追加してもいいし最初に全部入れても良い問題による
    BIT(int n) : data(n + 1, 0), n(n){
        return;
    }
    ll sum(int l, int r){
        return sum_(r) - sum_(l);
    }
    ll sum_(int i){
        ll res = 0;
        while(i > 0){
            res += data[i];
            i -= i & -i;
        }
        return res;
    }
    void add(int i, int x){
        while(i <= n){
            data[i] += x;
            i += i & -i;
        }
        return;
    }
};

ll a[200020]; // 累積和

int main(){
    ll n, k;
    cin >> n >> k;
    a[0] = 0;
    FOR(i,1,n+1){
        cin >> a[i];
        a[i] -= k; // 平均を引いておっく
        a[i] += a[i-1]; // 累積和
    }

    // 圧縮 小さい方から1,2,3...

    vector<int> ind(n+1);
    FOR(i,0,n+1) ind[i] = i;
    sort(ind.begin(), ind.end(), [](int i, int j){
        return a[i] < a[j];
    });
    ll bef = a[ind[0]];
    a[ind[0]] = 1;
    int j = 1;
    FOR(i,1,n+1){
        if(a[ind[i]]>bef){
            bef = a[ind[i]];
            j++;
            a[ind[i]] = j;
        }
        else a[ind[i]] = j;
    }
    /*
    vector<ll> vx;
    FOR(i,0,n+1) vx.push_back(a[i]);
    sort(vx.begin(), vx.end());
    vx.erase(unique(vx.begin(), vx.end()), vx.end());
    */
    // BIT 0 ~ n
    ll ans = 0;
    BIT S(200020);
    FOR(i,0,n+1){
        //int pos = lower_bound(vx.begin(), vx.end(), a[i]) - vx.begin() + 1;
        int pos = a[i];
        ans += S.sum(0,pos);
        S.add(pos,1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using mii = map<int, int>;
using mll = map<ll, ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vpi = vector<pii>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpl = vector<pll>;
using vs = vector<string>;

int main()
{
    string s;
    cin >> s;
    for(auto &c : s)
    {
        c = 'x';
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256