akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

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

    if(s.length() < 26){
        char x = 'a';
        while(1){
            bool judge = true;
            for(int i = 0; i < s.length(); i++){
                if(s[i] == x)   judge = false;
            }
            if(judge)   break;
            else    x = (char)(x+1);
        }
        cout << s << x << endl;
    }else{
        s = s.substr(0, 26);
        int i;
        for(i = 25; i >= 0; i--){
            if(s[i] == 'z') continue;
            bool judge;
            char next = (char)(s[i]+1);
            while(next <= 'z'){
                judge = true;
                for(int j = i-1; j >= 0; j--){
                    if(next == s[j])    judge = false;
                }

                if(judge){
                    s[i] = next;
                    break;
                }else{
                    next = (char)(1+next);
                }
            }
            if(judge)   break;
        }

        if(i == -1)
            cout << -1 << endl;
        else 
            cout << s.substr(0, i+1);
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int i = sc.nextInt();
		int box[][] = new int[i][3];
		int check[][] = new int[i][3];
		int kei[] = new int[i];
		
		for(int j = 0; j < i; j++){
			kei[j] = 0;
			for(int k = 0; k < 3; k++){
				check[j][k] = 0;
			}
		}
		
		for(int j = 0; j < i; j++){
			for(int k = 0; k < 3; k++){
				box[j][k] = sc.nextInt();
			}
		}
		
		for(int j = 0; j < 3; j++){
			for(int k = 0; k < i; k++){
				for(int l = k + 1; l < i; l++){
					if(box[k][j] == box [l][j]){
						check[k][j] = 1;
						check[l][j] = 1;
					}
				}
			}
		}
		
		for(int j = 0; j < i; j++){
			for(int k = 0; k < 3; k++){
				if(check[j][k] == 1){
					box[j][k] = 0;
				}
				kei[j] = kei[j] + box[j][k];
			}
		}
		
		for(int j = 0; j < i; j++){
			System.out.println(kei[j]);
		}
	}
}

Measured memory_bytes: 21452
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#define ll long long
#define si(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define pi(n) prllf("%d",n)
#define pl(n) prllf("%d",n)
using namespace std;

int main(){
  ll n;
  cin >> n;
  ll arr[n];
  for(ll i=0;i<n;i++){
    cin >> arr[i];
  }
  sort(arr,arr+n);
  ll start = 0;
  ll ans = 0;
  while(true){
    if(start>=n)
      break;
    ll k1 = arr[start];
    // cout << k1 << endl;
    if(start+1<n && arr[start+1]==k1){
      ll cnt = 1;
      start+=1;
      while(start<n && arr[start]==k1){
        start+=1;
        cnt++;
      }
      // cout << cnt << endl;
      if(cnt>=k1){
        ans+=cnt-k1;
      }
      else{
        ans+=cnt;
      }
    }
    else{
      start+=1;
      if(k1!=1)
        ans+=1;
    }
  }
  cout << ans << endl;
}


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

typedef vector<int> vi;
typedef pair<int, int> pii;
#define endl "\n"
#define sd(val) scanf("%d", &val)
#define ss(val) scanf("%s", &val)
#define sl(val) scanf("%lld", &val)
#define debug(val) printf("check%d\n", val)
#define all(v) v.begin(), v.end()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define ull unsigned long long
#define MOD 1000000007
#define clr(val) memset(val, 0, sizeof(val))
#define what_is(x) cerr << #x << " is " << x << endl;
#define OJ                            \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#define FIO                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

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

    double prob[N + 1];
    double dp[N + 1][N + 1], res = 0;

    for (int i = 1; i <= N; ++i)
        cin >> prob[i];

    for (int i = 0; i <= N; ++i)
    {
        for (int j = 0; j <= N; ++j)
            dp[i][j] = 0;
    }

    dp[1][0] = 1.0 - prob[1];
    for (int i = 2; i <= N; ++i)
        dp[i][0] = dp[i - 1][0] * (1.0 - prob[i]);

    dp[1][1] = prob[1];
    for (int i = 2; i <= N; ++i)
        dp[i][i] = dp[i - 1][i - 1] * prob[i];

    for (int i = 1; i <= N; ++i)
    {
        for (int j = 1; j < i; ++j)
            dp[i][j] = dp[i - 1][j] * (1.0 - prob[i]) + dp[i - 1][j - 1] * prob[i];
    }

    for (int i = N / 2 + 1; i <= N; ++i)
        res += dp[N][i];

    cout << fixed << setprecision(10) << res;

    return 0;
}

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

int main(){
	int n, odd = 0, a;
	cin >> n;
	
	while(n-- > 0){
		cin >> a;
		if(a%2 == 1)	odd++;
	}
	
	if(odd%2)	cout << "NO" << endl;
	else			  cout << "YES" << endl;
	
	return 0;
}

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

using namespace std;
using vi = vector<int>;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IN(v) int v;cin>>v;
#define OUT(v) cout<<v<<"\n"

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

  IN(N);

  vi T(N);
  int sum = 0;
  REP(i, N) {
    cin >> T[i];
    sum += T[i];
  }

  IN(M);
  REP(i, M) {
    IN(P); IN(X);
    --P;
    OUT(sum - T[P] + X);
  }

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define NUM (3000000)
int pt[NUM], sum[NUM];

int main() {
    for (int i = 2; i < NUM; i++) {
        sum[i] = sum[i-1];
        if (pt[i] == 0) {
            sum[i]++;
            for (int j = i+i; j < NUM; j += i) pt[j] = i;
        }
    }
    for (;;) {
        int n;
        scanf("%d", &n);
        if (n == 0) return 0;
        printf("%d\n", sum[2*n]-sum[n]);
    }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
#define vecout(V) for(int i=0;i<V.size();i++) {cout<<V[i]<<endl;}
typedef long long ll;

int main(void){
    int n;
    cin>>n;
    vector<int> v(n);
    rep(i, n) cin>>v[i];
    double ans=0;
    rep(i, n) ans+=1/(double)v[i];
    ans=1/ans;
    printf("%.10f", ans);
    cout<<endl;
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  long N;
  cin >> N;
  for(long i = 1; i <= 3500; i++){
    for(long j = 1; j <= 3500; j++){
      if((4 * i * j - N * i - N * j) == 0)continue;
      if((N * i * j) % (4 * i * j - N * i - N * j) == 0 && (N * i * j) / (4 * i * j - N * i - N * j) > 0){
        cout << i << ' ' << j << ' ' << (N * i * j) / (4 * i * j - N * i - N * j) << endl;
        return 0;
      }
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n-1); i >= 0; i--)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
const int IINF = 1000000000;
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(){

	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int N, L; cin >> N >> L;
	vector<string> S(N);
	rep(i,N){
		cin >> S[i];
	}
	sort(S.begin(), S.end());

	string ans = "";
	rep(i,N){
		ans += S[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, start, n) for (ll i = (ll)(start); i < (ll)(n); ++i)
static const ll INFTY = 1L << 62L;
ll solver(string S, ll K)
{
    ll ans = 0, tmp = 0;
    bool flag = true;
    rep(i, 0, S.size() - 1)
    {
        if (S[i] != S[i + 1])
        {
            flag = false;
            break;
        }
    }
    if (flag)
        ans = S.size() * K / 2;
    else
    {
        ll front = 0, back = S.size() - 1, cnt = 0;
        if (S.front() == S.back())
        {
            rep(i, 1, S.size())
            {
                if (S.front() != S[i])
                {
                    front = i;
                    break;
                }
            }
            for (int i = S.size() - 2; i >= 0; --i)
            {
                ++cnt;
                if (S.back() != S[i])
                {
                    back = i;
                    break;
                }
            }
            ans = (front + cnt) / 2 * (K - 1);
            rep(i, 0, front)
            {
                if (S[i] == S[i + 1])
                {
                    ++ans;
                    ++i;
                }
            }
            rep(i, back + 1, S.size())
            {
                if (S[i] == S[i + 1])
                {
                    ++ans;
                    ++i;
                }
            }
        }
        rep(i, front, back)
        {
            if (S[i] == S[i + 1])
            {
                ++tmp;
                ++i;
            }
        }
        ans += tmp * K;
    }
    return ans;
}
int main()
{
    string S;
    ll K;
    cin >> S >> K;
    cout << solver(S, K) << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int c[3][3];
  REP(i,3)REP(j,3) cin >> c[i][j];
  int a[3],b[3];
  a[0] = 0;
  REP(i,3) b[i] = c[0][i];
  REP(i,2) a[i+1] = c[i+1][0] - b[0];
  REP(i,3) REP(j,3){
    if(a[i]+b[j]!=c[i][j]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,a,b) for (int i = (a); i < (b); i++ )
typedef pair<int,int> P;
typedef long long ll;
const int INF = 100000000;
const double PI=3.14159265358979323846;

int main (){
    int N;
    cin >>N;
    int p[N];
    vector<int> a(N+10,0);
    rep(i,0,N) {
        cin >> p[i];
        p[i]--;
    }

    int s = 0;
    rep(i,0,N) {
        if (p[i]==i) {
            s++;
        }
        else {
            a[s]++;
            s=0;
        }
    }
    a[s]++;


    int ans = 0;
    rep(i,1,N+1) {
        if (i%2==1) {
            ans += (i/2+1)*a[i];
        }
        else {
            ans += i/2*a[i];
        }
    }
    cout << ans << endl;
    


}





Measured memory_bytes: 1024
#include<stdio.h>
int main(void)
{
	int w,h,n,i,x[1000],y[1000],xsa,ysa,sum;
	scanf("%d %d %d",&w,&h,&n);
	for(i=0;i<n;i++){
		scanf("%d %d",&x[i],&y[i]);
	}
	sum=0;
	for(i=0;i<n-1;i++){
		xsa=x[i+1]-x[i];
		ysa=y[i+1]-y[i];
		if(xsa>=0&&ysa>=0||xsa<0&&ysa<0){
			if(xsa<0){
				xsa*=-1; ysa*=-1;
			}
			if(xsa>=ysa) sum+=xsa;
			else sum+=ysa;
		}
		if(xsa>=0&&ysa<0||xsa<0&&ysa>=0){
			if(xsa<0) xsa*=-1;
			if(ysa<0) ysa*=-1;
			sum+=xsa+ysa;
		}
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 604
def calc_tax_ex(tax_in, rate)
  tax_ex = tax_in / rate
  return tax_ex.floor.to_i if (tax_ex.floor * rate).floor == tax_in
  return tax_ex.floor.to_i + 1 if ((tax_ex.floor + 1) * rate).floor == tax_in
  ':('
end

puts calc_tax_ex(gets.to_i, 1.08)

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

int N;
int d[110];

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

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

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

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

int h,w;
int n;
int nxt[252521];
int pos[252521];

const int DEG = 20;
int sps[252521][DEG];

bool hit[252521];

int main(){
  scanf("%d%d%d",&h,&w,&n);
  REP(i,h)REP(j,w){
    int id = i*w+j;
    int r,c;
    scanf("%d%d",&r,&c);
    nxt[id] = r*w+c;
  }
  REP(i,n){
    int r,c;
    scanf("%d%d",&r,&c);
    pos[i] = r*w+c;
  }
  // doubling
  REP(i,h*w)sps[i][0] = nxt[i];
  FOR(j,1,DEG){
    REP(i,h*w)sps[i][j] = sps[sps[i][j-1]][j-1];
  }

  int low = 0, high = 252521;
  // high gawa de shoutotu
  while(low+1 < high){
    int mid = (low+high)/2;
    // step mid
    REP(i,h*w)hit[i]=false;
    bool ok = true;
    REP(i,n){
      int p = pos[i];
      int k = mid;
      REP(j,DEG){
        if(k&1)p = sps[p][j];
        k >>= 1;
      }
      if(hit[p]){
        ok = false;
        break;
      }else{
        hit[p] = true;
      }
    }
    if(ok)low = mid;
    else high = mid;
  }
  if(high == 252521){
    puts("-1");
  }else{
    printf("%d\n",high);
  }
  return 0;
}

Measured memory_bytes: 24904
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main implements Closeable {

  private InputReader in = new InputReader(System.in);
  private PrintWriter out = new PrintWriter(System.out);

  public void solve() {
    int x = in.ni(), y = in.ni();
    for (int cranes = 0; cranes <= x; cranes++) {
      int turtles = x - cranes;
      int legs = 2 * cranes;
      int remaining = y - legs;
      if (turtles * 4 == remaining) {
        out.println("Yes");
        return;
      }
    }
    out.println("No");
  }

  @Override
  public void close() throws IOException {
    in.close();
    out.close();
  }

  static class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream), 32768);
      tokenizer = null;
    }

    public String next() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public int ni() {
      return Integer.parseInt(next());
    }

    public long nl() {
      return Long.parseLong(next());
    }

    public void close() throws IOException {
      reader.close();
    }
  }

  public static void main(String[] args) throws IOException {
    try (Main instance = new Main()) {
      instance.solve();
    }
  }
}


Measured memory_bytes: 32872
#include<bits/stdc++.h>
using namespace std;
#define int unsigned long long
signed main(){
  int a,b,c,d,e=0,f;
  cin>>a>>b>>c>>d;
  for(int i=0;i<=3000;i++){
    for(int j=0;j<=3000;j++){
      f=i*a+j*b;
      if(d>=f&&(d-f)%c==0) e++;
    }
  }
  cout<<e<<"\n";
}

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

int dp[100005][4];
int mod = 1e9+7;

signed main() {
	string s;cin>>s;
	
	dp[0][0]=1;
	for(int i=1;i<=s.size();i++)
	{
		if(s[i-1] == 'A')
		{
			for(int j=0;j<=3;j++)dp[i][j] = dp[i-1][j];
			dp[i][1]+=dp[i-1][0];
			dp[i][1] %= mod;
		}
		else if(s[i-1]=='B')
		{
			for(int j=0;j<=3;j++)dp[i][j] = dp[i-1][j];
			dp[i][2] += dp[i-1][1];
			dp[i][2] %= mod;
		}
		else if(s[i-1]=='C')
		{
			for(int j=0;j<=3;j++)dp[i][j] = dp[i-1][j];
			dp[i][3] += dp[i-1][2];
			dp[i][3] %= mod;
		}
		else if(s[i-1]=='?')
		{
			for(int j=0;j<=3;j++)dp[i][j] = dp[i-1][j]*3;
			for(int j=0;j<=3;j++)dp[i][j] %= mod;
			
			dp[i][1]+=dp[i-1][0];
			dp[i][1] %= mod;
			dp[i][2] += dp[i-1][1];
			dp[i][2] %= mod;
			dp[i][3] += dp[i-1][2];
			dp[i][3] %= mod;
		}
	
	}
	cout << dp[s.size()][3] << endl;
}

Measured memory_bytes: 3584
///AJoy Sarker ,CSE JAHANGIRNAGAR UNIVERSITY 48 Batch

#include<bits/stdc++.h>

using namespace std;
#define SORT(c) sort((c).begin(),(c).end());
#define inf INT_MAX/3
#define pb push_back
#define MP make_pair
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 3.141592653589793
#define in scanf
#define out printf
#define ll long long
#define ull unsigned long long
typedef unsigned long long UL;
template<typename T>inline T  S(T a)
{
    return a*a;
}
template<class T>inline string tostring(T a)
{
    ostringstream os("");
    os << a;
    return os.str();
}
template<typename T>inline ll tolong(T a)
{
    ll res;
    istringstream os(a);
    os>>res;
    return res;
}
template<typename T>inline T gcd(T a, T b)
{
    if (b == 0)return a;
    else return gcd(b, a % b);
}
template<typename T>inline T bigmod(T a, T b, T m)
{
    if (b == 0)return 1;
    else if (b % 2 == 0)return S(bigmod(a, b / 2, m)) % m;
    else return (a % m*bigmod(a, b - 1, m)) % m;
}
int ara[50001];

int main()
{

    ios_base::sync_with_stdio(0);

    ll x,hp=0;
    cin>>x;
    while(1)
    {
        if(x>=500)
        {
            hp+=(x/500)*1000;
            x-=(x/500)*500;
        }
        if(x>=100&&x<500)
        {
            hp+=(x/100)*100;

            x-=(x/100)*100;
        }
        if(x>=50&&x<100)
        {
            hp+=(x/50)*50;
            x-=(x/50)*50;

        }
        if(x>=10&&x<50)
        {
            hp+=(x/10)*10;
            x-=(x/10)*10;
        }
        if(x>=5&&x<50)
        {
            hp+=(x/5)*5;
            x-=(x/5)*5;
        }
        if(x<5) break;
    }
    cout<<hp<<endl;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char arr[2005][2005];
int cs[2005][2005],he[2005][2005],ve[2005][2005];

int main(){
	int n,m,q,x1,y1,x2,y2;
	scanf("%d%d%d",&n,&m,&q);
	for(int i=1;i<=n;i++){
		scanf("%s",arr[i]+1);
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cs[i][j]=(arr[i][j]-'0')+cs[i-1][j]+cs[i][j-1]-cs[i-1][j-1];
			ve[i][j]=ve[i-1][j]+ve[i][j-1]-ve[i-1][j-1];
			if(arr[i][j]=='1' && arr[i-1][j]=='1') ve[i][j]+=1;
			he[i][j]=he[i-1][j]+he[i][j-1]-he[i-1][j-1];
			if(arr[i][j]=='1' && arr[i][j-1]=='1') he[i][j]+=1;
		}
	}
	while(q--){
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		int v=cs[x2][y2]-cs[x1-1][y2]-cs[x2][y1-1]+cs[x1-1][y1-1];
		int hor=he[x2][y2]-he[x1-1][y2]-he[x2][y1]+he[x1-1][y1];
		int ver=ve[x2][y2]-ve[x1][y2]-ve[x2][y1-1]+ve[x1][y1-1];
		printf("%d\n",v-hor-ver);
	}
	
	return 0;
}

Measured memory_bytes: 52864
#include <cstdio>

int main(){
    long long x;
    scanf("%lld",&x);
    long long n[100000];

    long long i;

    for(i=0;i<100000;i++){
        n[i] = 0;
    }

    long long sum = 0;
    for(i=1; sum< x; i++){
        sum += i;
        n[i] = 1;
    }
    n[x-sum] = 0;

    printf("%lld\n",i-1);

    return 0;
}


Measured memory_bytes: 128
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

const double PI = atan2(1, 1) * 4.0;

int main() {
    fastio();

    double r;
    cin >> r;

    cout << setprecision(15) << 2.0 * r * PI << endl;

    return 0;
}

Measured memory_bytes: 3804
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf=0x3f;

//和上一题不一样，这个卡空间复杂度了 
//转换思路：要达到这个价值需要的最小体积，代码不变，最后要最大的价值而且体积小于等于W的 
ll w[105],v[105],dp[100005];

signed main()
{
	ll N,W;
	while(cin>>N>>W){
		for(ll i=1;i<=N;i++)
		cin>>w[i]>>v[i];
		
		memset(dp,inf,sizeof dp);
		dp[0]=0;//边界 
		
		for(ll i=1;i<=N;i++){
			for(ll j=100000;j>=v[i];j--)
			dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
		}
		
		ll ans=0;
		for(ll i=1;i<=100000;i++){
			if(dp[i]<=W)
			ans=max(ans,i);
		}
		cout<<ans<<endl;
	}
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }



int main()
{
	
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, m;
	cin >>n >>m;
	unordered_map<int, VI> mp;
	mp.reserve(n+100);
	rep(i, n){
		int a, b; cin >> a >>b;
		mp[m-a].push_back(b);
	}
	
	priority_queue<int> pq;
	ll ans =0;
	
	repr(j, m, 0){
		for(auto k: mp[j]) pq.push(k);
		if(sz(pq)){
			ans += pq.top(); pq.pop();
		}
	}
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 8704
#include <cstdio>
#include <algorithm>
#include <climits>

using std::min;

int main(){
	int n;
	scanf("%d",&n);
	int ans=INT_MAX;
	for(int i=1,a,cnt;i<=n;++i){
		scanf("%d",&a);
		cnt=0;
		while(a && !(a&1))
			a>>=1,++cnt;
		ans=min(ans,cnt);
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <iomanip>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>

#include <numeric>
#include <algorithm>
#include <functional>

#include <cctype>

#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define rep(i,n) for(unsigned int i=0;i<(n);i++)
#define tr(it,container) for(typeof(container.begin()) it = container.begin(); \
                             it != container.end(); ++it)

typedef long long ll;
typedef complex<double> P;
const int dx[] = {1,0,-1,0};
const int dy[] = {0,-1,0,1};
const double EPS = 1e-9;
const int days[] = {31,28,31,30,31,30,31,31,30,31,30,31};
const int daysleap[] = {31,29,31,30,31,30,31,31,30,31,30,31};


int main(){
    while(true){
        int N,M;
        vector<vector<char> > F(21,vector<char>(21,'0'));
        cin >> N;
        if(N==0) break;
        rep(i,N){
            int x,y;
            cin >> x >> y;
            F[y][x] = '1';
        }

        int x=10,y=10;
        cin >> M;
        rep(i,M){
            char c;int l;
            int ind = 0;
            cin >> c >> l;
            if(c=='N') ind = 3;
            if(c=='E') ind = 0;
            if(c=='W') ind = 2;
            if(c=='S') ind = 1;
            rep(j,l){
                x += dx[ind];
                y += dy[ind];
                F[y][x] = '0';
            }
        }
        bool ok = true;
        rep(i,21) rep(j,21){
            if(F[i][j] == '1') ok = false;
        }
        if(ok) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 1216
// A.

#include <iostream>
#include <sstream>

using namespace std;

int main(int argc, char *argv[])
{
	int a, b, c;
	cin >> a >> b >> c;
	bool ans = (b - a) == (c - b);
	cout << (ans ? "YES" : "NO") << endl;
	return 0;
}


Measured memory_bytes: 256
N=int(input())
*A,=sorted(map(int,input().split()))
 
a=True
if N%2==0:
 for i in range(1,N,2):
  if A[i-1]!=i or A[i]!=i:
    a=False
    break
else:
 if A[0]!=0:a=False
 else:
    for i in range(2,N,2):
     if A[i-1]!=i or A[i]!=i:
        a=False
        break
print(2**(N//2)%(10**9+7) if a else 0)

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

int main(){
	int S;
	cin >> S;
	int XX=S/100,YY=S%100;
	bool x,y;
	x=(0<XX && XX<=12);
	y=(0<YY && YY<=12);
	
	if(x && y)cout << "AMBIGUOUS" << endl;
	if(!x && y)cout << "YYMM" << endl;
	if(x && !y)cout << "MMYY" << endl;
	if(!x && !y)cout << "NA" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    #define all(x) (x).begin(), (x).end()
    #define mp make_pair
    #define pb push_back
    #define ff first
    #define ss second
    #define ll long long
    typedef pair<ll,ll> pll;
    typedef vector <ll> vi;
    #define out(x) return cout<<x,0;
    #define precision(x,d) cout<<fixed<<setprecision(d)<<x
    #define coutif(a,b,c) cout<<(a?b:c)
     
    int main(){
        ll n,m,j,k=0,x=0,y=0,i,ans=0;
        cin>>n>>m;
        priority_queue < ll > q;
        vi v[100005];
        for(i=0;i<n;i++){
            cin>>x>>y;
            v[x].pb(y);
        }
        for(i=1;i<=m;i++){
             for(j=0;j<v[i].size();j++){
                 q.push(v[i][j]);
             }
             if(!q.empty()){
                ans+=q.top();
                q.pop();
             }
        }
        cout<<ans;
    }

Measured memory_bytes: 5632
#include <iostream>
#include <stdio.h>
#include <vector> 
#include <math.h> 
#include <map> 
using namespace std;
int main(void){
    int N; cin >> N;
    map<string,int> m;
    int i = 0;
    while (N > i) {
        string tmp;
        cin >> tmp;
        if (m.count(tmp)) {
            m[tmp] += 1;
        } else {
            m[tmp] = 1;
        }
        i++;
    }
    cout << "AC x " << m["AC"] << endl;
    cout << "WA x " << m["WA"] << endl;
    cout << "TLE x " << m["TLE"] << endl;
    cout << "RE x " << m["RE"] << endl;
}

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main(void){
    int n, m, l, i, j, k;
    long A[101][101], B[101][101], C[101][101] = {};
    
    cin >> n >> m >> l;
    for(i = 0; i < n; i++){
        for(j = 0; j < m; j++){
            cin >> A[i][j];
        }
    }

    for(i = 0; i < m; i++){
        for(j = 0; j < l; j++){
            cin >> B[i][j];
        }
    }
    
    for(i = 0; i < n; i++){
        for(j = 0; j < m; j++){
            for(k = 0; k < l; k++){
                C[i][k] +=  A[i][j] * B[j][k];
            }
        }
    }

    for(i = 0; i < n; i++){
        for(j = 0; j < l; j++){
            if(j != 0)  cout << " ";
            cout << C[i][j];
        }
        cout << endl;
    } 
    
    return 0;
}



Measured memory_bytes: 3336
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int N;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  while (cin >> N, N) {
    using P = tuple<int,int,int>;
    vector<P> v;
    REP(i,N) {
      char c;
      cin >> c;
      if (c == 'W') {
        int I,S;
        cin >> I >> S;
        int pos = 0;
        vector<P> w;
        for (int j = 0; j < v.size(); j++) {
          int x,l,r;
          tie(x,l,r) = v[j];
          if (S > 0 && pos < l) {
            if (pos+S <= l) {
              w.emplace_back(I,pos,pos+S);
              S = 0;
            } else {
              w.emplace_back(I,pos,l);
              S -= l-pos;
            }
          }
          w.emplace_back(x,l,r);
          pos = r;
        }
        if (S > 0) w.emplace_back(I,pos,pos+S);
        swap(v,w);
      } else if (c == 'D') {
        int I;
        cin >> I;
        vector<P> w;
        for (int j = 0; j < v.size(); j++) {
          int x,l,r;
          tie(x,l,r) = v[j];
          if (x == I) continue;
          w.emplace_back(x,l,r);
        }
        swap(v,w);
      } else {
        int P;
        cin >> P;
        int ans = -1;
        for (int j = 0; j < v.size(); j++) {
          int x,l,r;
          tie(x,l,r) = v[j];
          if (l <= P && P < r) {
            ans = x;
            break;
          }
        }
        cout << ans << endl;
      }
    }
    cout << endl;
  }

  return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n)-1;(i)>=0;(i)--)
#define forin(x,n) for(auto& (x) : n)
#define all(v) (v).begin(),(v).end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define mp make_pair
#define pb push_back
#define MOD 1000000007
#define inf 1000000000
#define llinf 1000000000000000
#define MAX 1000000


typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef vector<pint> vpint;
typedef pair<int,pint> P;

int main(){
    int k;
    string str;
    cin>>str;
    k=str.length();
    int count=0;
    rep(i,k){
        if(str[i]=='o')count++;
    }
    if(count+(15-k)>=8)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int lcm(long long x,long long y);
int gcd(long long x,long long y);
int main()
{
    long long a,b;
    while(cin>>a>>b)
    {
        cout<<lcm(a,b)<<" "<<gcd(a,b)<<endl;
    }

    return 0;
}
int lcm(long long x,long long y)
{
    long long s,b,r;
    if(x>y)
    {
        b=x;
        s=y;
    }
    else
    {
        b=y;
        s=x;
    }
    r=b%s;
    while(r!=0)
    {
        b=s;
        s=r;
        r=b%s;
    }
    return s;


}
int gcd(long long x,long long y)
{
    return ((x*y)/lcm(x,y));

}

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

int main() {
  ll x,k,d;cin>>x>>k>>d;
  x=abs(x);
  if(k<=x/d)cout<<x-k*d<<endl;
  else {
    if((k-x/d)%2==0)cout<<x-x/d*d<<endl;
    else cout<<d-(x-x/d*d)<<endl;
  }
}


Measured memory_bytes: 3608
def get_prime_factorized(N):
    result    = []
    base, exp = 2, 0
    while base ** 2 <= N:
        while N % base == 0:
            N    = N // base
            exp += 1
        if exp > 0:
            result.append([base, exp])
        base, exp = base + 1, 0
    if N > 1:
        result.append([N, 1])
    return result


N = int(input())

L = get_prime_factorized(N)
R = 0

for p, e in L:
    sum = 1
    num = 1
    while True:
        if e >= sum + num + 1:
            num += 1
            sum += num
        else:
            break
    R += num

print(R)


Measured memory_bytes: 9216
#include <stdio.h>
#include <string.h>
int main(void){
	int a,k,b;
	scanf("%d %d %d",&a,&b,&k);
	for(int i=0;i<k;i++){
		if(i%2==0){
			if(a%2==0){
				b=b+a/2;
				a=a/2;
			}else{
				a--;
				b=b+a/2;
				a=a/2;
			}
		}else{
			if(b%2==0){
				a=a+b/2;
				b=b/2;
			}else{
				b--;
				a=a+b/2;
				b=b/2;
			}
		}
	}
	printf("%d %d\n",a,b );
	return 0;
}

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

#define int long long
#define pb push_back
#define F first
#define S second

typedef pair<int, int> PII;

signed main(){
    int N, K;
    cin>>N>>K;
    int dp[N];
    int h[N];
    for(int i=0; i<N; i++){
        cin>>h[i];
    }
    dp[0] = 0;
    dp[1] = abs(h[1]-h[0]);
    for(int i=2; i<N; i++){
        int curr_min = INT_MAX;
        int idx = i - K >= 0 ? i-K : 0; 
        for(int j=idx; j<i; j++){
            curr_min = min(curr_min, dp[j] + abs(h[i]-h[j]));
        }
        dp[i] = curr_min;
    }
    cout<<dp[N-1]<<endl;
    return 0;
}

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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define foe(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); it++)
#define long long long 
#define db double 
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

const int INF = 1e9+7;
const int MOD = 1e9+7;
const int dx[4] = {0,0,-1,1};
const int dy[4] = {-1,1,0,0};

int main()
{
  fastio;
  string s; cin >> s;
  deque <char> D;
  for (char c : s) D.push_back(c);
  int cur = 0;
  int Q; cin >> Q;
  while (Q--){
    int T; cin >> T;
    if (T == 1) cur ^= 1;
    else{
      int f; char c; cin >> f >> c;
      if ((f == 1 && cur == 0) || (f == 2 && cur == 1)) D.push_front(c);
      else D.push_back(c);
    }
  }
  if (cur == 1) reverse(all(D));
  for (char c : D) cout << c;
  return 0;
}

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

using ll = long long;

const ll mod = 1e9 + 7;

int main() {
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<ll> a(n); for(ll &i : a) cin >> i;
    
    vector<int> bits(61, 0);
    ll s = 0;

    for(int i = 0; i < n; i++) {
        for(int b = 0; b < 61; b++) {
            ll val = 1LL << b;
            val %= mod;
            ll addo = (val * bits[b]) % mod;
            ll addz = (val * (i - bits[b])) % mod;
            if(a[i] & (1LL << b)) {
                s = (s + addz) % mod;
                bits[b]++;
            }
            else {
                s = (s + addo) % mod;
            }
        }
    }


    cout << s << '\n';

    return 0;
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 1e4+23;

vector<int> g[N];
int c[N], bio[N];

void solve() {
  int n; scanf("%d", &n);
  int mo = 0;
  for (int u, v, i = 0; i < n-1; ++i) {
    scanf("%d %d", &u, &v);
    g[--u].push_back(--v);
    g[v].push_back(u);
    if (g[u].size() > g[mo].size()) mo = u;
    if (g[v].size() > g[mo].size()) mo = v;
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", c+i);
  }
  sort(c, c+n, greater<int>());
  queue<int> q;
  q.push(mo);
  int ind = 0;
  bio[mo] = c[ind++];
  long long ans = 0;
  while (!q.empty()) {
    int u = q.front(); q.pop();
    for (int v: g[u]) {
      if (bio[v]) continue;
      bio[v] = c[ind++];
      ans += min(bio[v], bio[u]);
      q.push(v);
    }
  }
  printf("%lld\n", ans);
  for (int i = 0; i < n; ++i) {
    printf("%d ", bio[i]);
  }
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


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

int main()
{
    string a, s, c, title;
    cin >> a >> s >> c;
//  cout<<a<<endl;
 // cout<<s<<endl;
 // cout<<c<<endl;
//    title = a.at(0) + s.at(0) + c.at(0);
    cout << a.at(0) << s.at(0) << c.at(0) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int n, m;
    cin >> n >> m;
    vector<P> a(n);
    rep(i,n) cin >> a[i].first >> a[i].second;
    sort(all(a));

    priority_queue<int> pq;
    int left = 0;
    ll ans = 0;
    rep(i,m){
        int d = i + 1;
        while(left < n){
            if (a[left].first > d) break;
            pq.push(a[left].second);
            left++;
        }
        if (pq.size() == 0) continue;
        ans += pq.top(); pq.pop();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4684
#include <stdio.h>

#define N 100000

int partition(int*,int,int);

int p,q,r,n;
int A[N];

int main(){

  int i,part;

  scanf("%d",&n);

  for(i=0;i<n;i++)  scanf("%d",&A[i]);


  r=n-1;

  part=partition(A,0,r);


  printf("%d",A[0]);

  for(i=1;i<n;i++){

    if (part==i)  printf(" [%d]",A[i]);

    else printf(" %d",A[i]);


  }

  printf("\n");

  return 0;

}

int partition(int *A,int p,int r){

  int x,temp,i,j;

  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if (A[j]<=x){
      i=i+1;
      temp=A[i];
      A[i]=A[j];
      A[j]=temp;
    }
  }
    temp=A[i+1];
    A[i+1]=A[r];
    A[r]=temp;

    return i+1;


}

Measured memory_bytes: 992
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
const int N=1e6;
char s[N+10];
int len;
int main() {
    scanf("%s",s);
    len=strlen(s);
    int cnt1=0,cnt2=0;
    for (int i=0;i<len;i++) {
        if (s[i]=='S') {
            cnt2++;
            continue;
        }
        if (cnt2) cnt2--;
        else cnt1++;
    }
    printf("%d\n",cnt1*2);
    return 0;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

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

    bool having[n];
    for (int i = 0; i < n; ++i) {
        having[i] = false;
    }


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

        for (int j = 0; j < d; ++j) {
            int a;
            cin >> a;

            having[--a] = true;
        }
    }

    int count = 0;
    for (int i = 0; i < n; ++i) {
        if (!having[i]) count++;
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  string N;
  cin >> N;
  if(N=="ABC")
  {
    cout << "ARC" << endl;
  }
  else
  {
    cout << "ABC" << endl;
  }
  return 0;
}


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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int sum=0;
  vector<int> X(N);
  rep(i,N){
    cin >> X.at(i);
    sum += X.at(i);
  }
  int P;
  P=sum/N;
  int ans1,ans2;
  rep(i,N){
    ans1+=(X.at(i)-P)*(X.at(i)-P);
    ans2+=(X.at(i)-P-1)*(X.at(i)-P-1);
  }
  cout << min(ans1,ans2) << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <string.h>

using namespace std;
typedef pair<long long, long long> P;


void solve()
{
	long long N, M;
	cin >> N >> M;
	vector<P> vec(N);
	for (int i = 0; i < N; ++i)
	{
		cin >> vec[i].first >> vec[i].second;
	}
	sort(vec.begin(), vec.end());
	long long ans = 0;
	for (int i = 0; i < N; ++i)
	{
		long long buy = min(M, vec[i].second);
		ans += buy * vec[i].first;
		M -= buy;
	}
	cout << ans << endl;
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1920
//In the name of God
#include<bits/stdc++.h>

using namespace std ;

const int N = 3000 + 10 ;

int n , a[N] , dp[N] ; 
vector < int > adj[N] ; 

int32_t main() {
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin >> n ;
	for(int j = 0 ; j < n ; ++j)
		cin >> a[j] ;
	for(int j = 0 ; j < n - 1 ; ++j) {
		int u , v ;
		cin >> u >> v ;
		--u , --v ;
		adj[u].push_back(v) ;
		adj[v].push_back(u) ; 
	}
	set < pair < int , int > > topo ; 
	for(int j = 0 ; j < n ; ++j) {
		int okay = 1 ;
		for(int u : adj[j])
			okay &= (a[u] >= a[j]) ;
		if(okay)
			topo.insert({a[j] , j}) ;  
	}
	while(!topo.empty()) {
		auto pi = *topo.begin() ; topo.erase(topo.begin()) ;
		int v = pi.second ; 
		for(int u : adj[v]) {
			if(a[u] > a[v]) {
				dp[u] |= !dp[v] ;
				topo.insert({a[u] , u}) ;
			}
		}
	}
	for(int v = 0 ; v < n ; ++v)
		if(dp[v])
			cout << v + 1 << ' ' ;
	cout << endl ; 
}


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

#define int long long
#define ll long long
#define f1(i,a,b) for(i=a;i<b;i++)
#define f2(i,a,b) for(i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod=1000000007;
int i,j;
ll temp;

#define ld long double
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // #ifndef ONLINE_JUDGE
    // 	freopen("/home/akmittal/Desktop/Competitive Programming/in.txt","r",stdin);
    // 	freopen("/home/akmittal/Desktop/Competitive Programming/out.txt","w",stdout);
    // #endif
    ld w,h,x,y;
    cin>>w>>h>>x>>y;
    long double ans=((long double)w*h)/2.0000;
    //cout<<ans;
    int ans2=0;
    
    if(x==w/2&&y==h/2)
    	ans2=1;
    
    //printf("%.15llf %lld",ans,ans2);
    cout<<fixed<<setprecision(19)<<ans<<gp<<ans2;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()+"0"
s2 = input()##要らない

i = 0

d = []#0が縦、1が横
while i<n:
    try:
        if s[i]==s[i+1]:
            d.append(1)
            i+=1
        else:
            d.append(0)
        i+=1
    except:
        break

ans = 1
#print(d)
if d[0]==0:
    ans = 3
else:
    ans = 6
mod = 10**9+7
for j in range(1,len(d)):
    if d[j]==0:
        if d[j-1]==0:
            ans*=2
    else:
        if d[j-1]==1:
            ans*=3
        else:
            ans*=2####
    ans%=mod
    

    
print(ans)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
const int MAXN=1e5+100;
typedef long long LL;
int main()
{
    int n;
    cin>>n;
    int mx=0,my=0;
    int flag=1;
    int lt=0;
    int tt=0;
    for(int i=0;i<n;i++)
    while(n--){
        int t,x,y;
        cin>>t>>x>>y;
        if(flag==0) continue;
        lt=abs(x+y-mx-my);
        if(lt+tt>t) flag=0;
        else if(lt+tt==t){
            mx=x;my=y;tt=t;
        }else{//跳得到,还有多
            if((t-lt-tt)%2==0){mx=x;my=y;tt=t;}
            else flag=0;
        }
    }
    cout<<(flag?"Yes":"No")<<endl;
    return 0;
}


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

int main()
{
	
	int s;
	cin >> s;
	
	int l = s / 100;
	int r = s % 100;
	
	if (1 <= l and l <= 12)
	{
		if (1 <= r and r <= 12)
		{
			cout << "AMBIGUOUS" << endl;
		}
		else
		{
			cout << "MMYY" << endl;
		}
	}
	else
	{
		if (1 <= r and r <= 12)
		{
			cout << "YYMM" << endl;
		}
		else
		{
			cout << "NA" << endl;
		}
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)

int main(){
    int n;
    cin >> n;
    set<int> st;
    bool flag = 0;
    int c = 1;
    rep(i,n){
        int a;
        cin >> a;
        if(flag){
            cout << "No" << endl;
            continue;
        }
        if(a==c-1){
            if(st.lower_bound(a+1)==st.end()){
                cout << "Yes" << endl;
                flag = 1;
            }else{
                cout << "No" << endl;
            }
        }else if(a < c){
            cout << "No"<< endl;
        }else{
            cout << "Yes" << endl;
            int k= -1;
            for(int i=a;i>=1;i--){
                if(st.find(i)!=st.end()){
                    st.erase(i);
                    if(i==1)flag = 1;
                }else{
                    k = i;
                    st.insert(i);
                    break;
                }
            }
            if(k==c){
                while(st.count(c)){
                    c++;
                }
            }
        }            
    }    
    return 0;
}


Measured memory_bytes: 14792
package main

import (
	"fmt"
)


func main() {
	var r,d,x int
	fmt.Scan(&r, &d, &x)

	ans := 0
	for i := 0; i < 10; i++ {
		if i == 0 {
			ans = r*x-d
			fmt.Println(ans)
			continue
		}

		ans = r*ans-d
		fmt.Println(ans)
	}

}



Measured memory_bytes: 1764
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int[] array = new int[n];
        int count = 0;
        
        //初期化
        for(int i = 0; i < n; i++){
		    array[i] = sc.nextInt();
		}
		
		Arrays.sort(array);
		
		int m = n/2;
		System.out.println(array[m]-array[m-1]);
    }
}

Measured memory_bytes: 51000
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define ll int
#define bits_count __builtin_popcountll
#define endl '\n'
#define double long double
#define ld double
#define FOR(i,a,n) for (ll i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (ll i=(n);i>=(a);--i)
#define FI(i,n) for (ll i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
#define sz(x) (ll)x.size()
#define pr pair<int,int>
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }

// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int MAXN = 205;
int cnt[MAXN];

void solve(){

    int k; cin>>k;

    int ans = 0;

    FOR(i,1,k){
        FOR(j,1,k){
            int val = __gcd(i,j);
            cnt[val]++;
        }
    }

    FOR(i,1,k){
        FOR(j,1,k){
            int val = __gcd(i,j);
            ans += val*cnt[i];
        }
    }
    cout<<ans<<endl;
}

signed main(){

   FastRead; 


    int t = 1; 
    // cin>>t;
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}





Measured memory_bytes: 3648