akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define FOR0(i,n) for(ll i=0;i<n;i++)
#define FOR1(i,n) for(ll i=1;i<=n;i++)
#define FORl(i,l,n) for(int i=l;i<n;i++)
using namespace std;
#define pi pair<ll,ll>
#define pb push_back
#define ll long long
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define mst0(x) memset(x,0,sizeof(x));
#define vi vector<ll>
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define sp <<" "<<
#define intmax 1e14
ll power(ll num,ll g,ll mod){
  if(g==0)return 1;
  if(g%2==1)return (num*power((num*num)%mod,g/2,mod))%mod;
  return power((num*num)%mod,g/2,mod);
}

int main(){
	string X,Y;
	cin>>X>>Y;
	int m = X.size();
	int n = Y.size();
	int L[m+1][n+1]; 
   int i, j; 
   
   /* Following steps build L[m+1][n+1] in bottom up fashion. Note  
      that L[i][j] contains length of LCS of X[0..i-1] and Y[0..j-1] */
   for (i=0; i<=m; i++) 
   { 
     for (j=0; j<=n; j++) 
     { 
       if (i == 0 || j == 0) 
         L[i][j] = 0; 
   
       else if (X[i-1] == Y[j-1]) 
         L[i][j] = L[i-1][j-1] + 1; 
   
       else
         L[i][j] = max(L[i-1][j], L[i][j-1]); 
     } 
   } 
   int index = L[m][n]; 
   char lcs[L[m][n]+1];
   //lcs[L[m][n]] ='';
   i = m, j = n; 
   while (i > 0 && j > 0) 
   { 
      // If current character in X[] and Y are same, then 
      // current character is part of LCS 
      if (X[i-1] == Y[j-1]) 
      { 
          lcs[index-1] = X[i-1]; // Put current character in result 
          i--; j--; index--;     // reduce values of i, j and index 
      } 
  
      // If not same, then find the larger of two and 
      // go in the direction of larger value 
      else if (L[i-1][j] > L[i][j-1]) 
         i--; 
      else
         j--; 
   } 
   FOR0(i,L[m][n]) cout<<lcs[i];
}




Measured memory_bytes: 35456
n = int(raw_input())
a = map(int, raw_input().split())
b = max(a)
c = min(a)
if b - c > 1:
    print "No"
elif b == c:
    print "Yes" if b == n - 1 or 2 * b <= n else "No"
else:
    t = sum(c == x for x in a)
    if t >= b:
        print "No"
    else:
        print "Yes" if (b - t) * 2 <= n - t else "No"


Measured memory_bytes: 11304
#include <iostream>
using namespace std;
int main(void){
    int H,W;
     while(true){
         cin >>H>>W;
         if(H==0 && W==0){
         break;
         }
     for(int i=0;i<H;i++){
         for(int j=0;j<W;j++){
     cout<<"#";
    }
  cout<<endl;
     }
 cout<<endl;
}
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<10;i++)
    {
        if(n%i==0)
        {
            if(n/i>=1 && n/i<=9)
            {
                cout<<"Yes";return 0;
            }
        }
    }
    cout<<"No";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();


int main() {
    int n, val;
    cin >> n;
    multiset<ll> s1, s2, s3;
    ll acc1 = 0;
    vector<ll> arr(n*2, 0);
    for(int i = 0; i < n; i++) {
        cin >> val;
        s1.insert(val);
        acc1 += val;
    }
    for(int i = 0; i < n*2; i++) {
        cin >> arr[i];
        s3.insert(arr[i]);
    }
    ll acc2 = 0;
    while(s3.size() > n) {
        auto it = s3.begin();
        s2.insert(*it);
        acc2 += *it;
        s3.erase(it);
    }
    ll ans = acc1 - acc2;
    for(int i = 0; i < n; i++) {
        if (arr[i] >= *s3.begin()) {
            auto it = s3.find(arr[i]);
            s1.insert(*it);
            acc1 += *it;
            s3.erase(it);
        } else {
            auto it = s2.find(arr[i]);
            s1.insert(*it);
            acc1 += *it;
            acc2 -= *it;
            s2.erase(it);
            auto it2 = s3.begin();
            s2.insert(*it2);
            acc2 += *it2;
            s3.erase(it2);
        }
        auto it = s1.begin();
        acc1 -= *it;
        s1.erase(it);
        ans = max(ans, acc1 - acc2);
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
vector<vector<char>> c(3, vector<char>(3));
int main() {
    for(int i = 0; i < 3; ++i) {
        for(int j = 0; j < 3; ++j) {
            cin >> c.at(i).at(j);
            if(i == j) {
                cout << c.at(i).at(j);
            }
        }
    }
}

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int A,B;
    Scd2(A,B);
    int a = max( A+B, A-B );
    printf ("%d\n", max(a,A*B));

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
ll a[305][305],p[1005],hell=998244353;
vector<ll> basis[305];
ll insert(vector<ll> &v){
	ll n=ll(v.size());
	for(ll i=0;i<n;i++){
		if(!v[i])
		continue;
		if(basis[i].empty()){
			basis[i]=v;
			return 1;
		}
		for(ll j=0;j<n;j++)
		v[j]^=basis[i][j];
	}
	return 0;
}
void solve(){
	ll n,m,res=0;
	cin>>n>>m;
	for(ll i=0;i<n;i++)
	for(ll j=0;j<m;j++)
	cin>>a[i][j];
	for(ll j=0;j<m;j++){
		vector<ll> v;
		for(ll i=0;i<n;i++)
		v.push_back(a[i][j]);
		res+=insert(v);
	}
	ll ans=(p[n+m-1]-p[n+m-res-1])%hell;
	if(ans<0)
	ans+=hell;
	cout<<ans;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    p[0]=1;
    for(ll i=1;i<1005;i++)
    p[i]=(2*p[i-1])%hell;
    ll qc=1;
    //cin>>qc;
    for(ll i=1;i<=qc;i++)
	solve();
}


Measured memory_bytes: 4132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e3+9;
int d[maxn][maxn],inf=1e9,cnt[maxn];
int d_min(int a,int b,int c,int d,int e)
{
    return min(a,min(b,min(c,min(d,e))));
}
int main()
{
    int n,x,y;
    cin>>n>>x>>y;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            if(i==j) d[i][j]=0;
            else d[i][j]=inf;
    for(int i=x;i<=y;i++)
        for(int j=i+1;j<=y;j++)
            d[i][j]=min(j-i,y-x+1-(j-i));
    for(int i=n-1;i>=1;i--)
        for(int j=i+1;j<=n;j++)
            d[i][j]=d_min(j-i,d[i][x]+d[x][j],d[i][x]+1+d[y][j],d[i][y]+d[y][j],d[i][j]);
    for(int i=1;i<=n;i++)
        for(int j=i+1;j<=n;j++)
            cnt[d[i][j]]++;
    for(int i=1;i<=n-1;i++) cout<<cnt[i]<<endl;
}


Measured memory_bytes: 16000
// code by MC
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#include<sstream>
#include<cmath>
#include<string>
#include<vector>
#include<deque>
#include<set>
#include<bitset>
#include<map>
#include<functional>
#include<utility>
#include<cstdio>
#include<cstdlib> 
#include<ctime>
#include<algorithm> 
#include<set>
#include<stack>
#include<queue>
//#include<IOS>
using namespace std;
string s;
long long ans;
long long num[1000000];
set <string> p; 
long long dealing(string z)
{
	int l=0,r=0;
	//memset(num,1000000,0);
	vector <string> v;
	long long cnt=0;
	z+='+';
	for (int i=0;i<z.size();i++,r++)
		if (z[i]=='+') v.push_back(z.substr(l,r)),l=i+1,r=-1;
	for (int i=0;i<v.size();i++)
		for (int j=0;j<v[i].size();j++)
			num[i]*=10,num[i]+=(v[i][j]-'0');
	for (int i=0;i<v.size();i++)
		cnt+=num[i],num[i]=0;
		
	//cout<<"b"<<" "<<cnt<<" "<<ans<<endl;
		
	return cnt;
}
void dfs(int x,string z)
{
	string ss=z.substr(0,x)+'+'+z.substr(x,z.size()-x);
	int t=x+2;
	while (t<ss.size()) 
	{
		dfs(t,ss);
		t++;
	}
	if (p.count(ss)) return ;
	p.insert(ss);
	ans+=dealing(ss);
	
	//cout<<"a"<<" "<<ans<<endl;
	return ;
}
int main()
{
	cin>>s;
	ans+=dealing(s);
	for (int i=1;i<s.size();i++)
		dfs(i,s);
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

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

   if(n%2==0){
  cout << (n/2)*(n/2) << endl ;   
   }else{
  cout << ((n/2)+1)*(n/2) << endl ;      
   }
    
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)

{

   int a,b,c,i,count=0;

   scanf("%d %d %d",&a,&b,&c);

   for(i=a;i<=b;i++){

      if((c%i) == 0){

         count++;

      }

   }

   printf("%d\n",count);

   return 0;

}

Measured memory_bytes: 596
#include <stdio.h>
int main()
{
  int a,b;
  scanf("%d %d",&a,&b);
  if (a >= 13)
  {
    printf("%d",b);
  }
  else if (a >= 6)
  {
    printf("%d",b/2);
  }
  else
    printf("%d",0);
}

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

using namespace std;

int main()
{
    int x;
    cin >> x;
    if(x == 1)
    {
       cout << "Hello World"<<endl;
    }
    else
    {
        int a,b;
        cin >> a >> b;
        cout << a+b;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int,P> P3;
const ll MOD = ll(1e9+7);
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-6;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int N, M, E, S, T, R;
int g[105][105];
int d[105][105], ans = IINF;
vector<P3> es;

void warshall_floyd(){
    REP(i,N) fill(d[i], d[i]+N, IINF/3);
    REP(i,N)REP(j,N) d[i][j] = g[i][j];
    REP(k,N)REP(i,N)REP(j,N){
        d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
    }
}

int main() {
    cin >> N >> M >> E >> S >> T >> R;
    REP(i,N) fill(g[i], g[i]+N, IINF/3);
    REP(i,M){
        int a, b;
        cin >> a >> b;
        g[a][b] = 1;
        g[b][a] = 1;
    }
    REP(i,E){
        int a, b, c;
        cin >> a >> b >> c;
        if(c!=S)es.push_back({c,{a,b}});
        else{
            g[a][b] = 1;
            g[b][a] = 1;
        }
    }
    E = es.size();
    vector<int> v;
    REP(i,E) v.push_back(i);

    while(true){
        REP(i,E){
            int a, b;
            a = es[i].second.first;
            b = es[i].second.second;
            g[a][b] = IINF/3;
            g[b][a] = IINF/3;
        }
        int sum = 0, tmp = 0, pre = S;
        for(int i=0; i<=E; i++){
            warshall_floyd();
            if(tmp+d[pre][T] <= R) ans = min(ans, sum+d[pre][T]);
            if(tmp+d[S][T] <= R) ans = min(ans, sum+1+d[S][T]);
            if(i==E)break;
            int a, b, c;
            a = es[v[i]].second.first;
            b = es[v[i]].second.second;
            c = es[v[i]].first;
            if(tmp+d[pre][c] <= R && d[pre][c] < d[S][c]+1){
                tmp += d[pre][c];
                sum += d[pre][c];
                pre = c;
                g[a][b] = 1;
                g[b][a] = 1;
            }
            else if(pre != S){
                pre = S;
                sum++;
                tmp = 0;
                i--;
            }
            else break;
        }
        

        if(!next_permutation(ALL(v)))break;
    }

    cout << (ans<=IINF/3?ans:-1) << endl;

    return 0;
}



Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
vector<double> vi;
bool cmp(int a, int b){
    return a>b;
}

int main(){
  double n,m;
  double sum=0;
  int cnt=0;
  scanf("%lf%lf",&n,&m);
  for(int i=0;i<n;i++){
    double k;
    scanf("%lf",&k);
    vi.push_back(k);
    sum+=k;
  }
  sum*=1.0/(4*m);
  for(int i=0;i<n;i++){
    if(vi[i]>=sum){
        cnt++;
    }
  }
  printf("%s",cnt<m?"No":"Yes");
   return 0;
}


Measured memory_bytes: 256
#include <iostream>
    #include <cstdio>
    #include <algorithm>
    #include <vector>
    #include <string>
    #include <string.h>
     
    typedef long long ll;
    using namespace std;
    const ll INF = 1000000000000000000ll;
    const ll MOD = 1000000007ll;
     
    const double EPS = 1e-8;
     
    int main()
    {
    	string A,B;
		long As,Bs,N,i;
		bool H =false;

		cin >> A >>B;
		As=A.length();
		Bs=B.length();

		if(As>Bs){
			cout << "GREATER" <<endl;
		}else if(As<Bs){
			cout << "LESS" << endl;
		}else if(As==Bs){
			for(i=0;i<As;i++){
				if(A[i]>B[i]){
					cout << "GREATER" << endl;
					break;
				}else if(A[i]<B[i]){
					cout << "LESS" << endl;
					break;
				}else{

				}
			}
			if(i==As){cout << "EQUAL" << endl;}
		}
		
		return 0;
    }

Measured memory_bytes: 256
N = int(input())
res = dict()
for i in range(N):
    S, P = input().split()
    if S in res.keys():
        res[S].append([int(P),i+1])
        res[S].sort(reverse = True)
    else:
        res[S] = [[int(P), i+1]]
dct = sorted(res.items())
for name, plist in dct:
    for i in range(len(plist)):
        print(plist[i][1])



Measured memory_bytes: 3060
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>

#define PB push_back
#define MP make_pair
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<30)
#define LLINF (1<<60)
#define MOD 1000000007
#define REP(i, n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;

int main() {
    int n, a[100005];
    bool two = false;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] == 2)two = true;
    }
    if (!two) {
        cout << -1 << endl;
        return 0;
    }
    else {
        int count = 0, i = 0, check[100005] = {};
        while (1) {
            count++;
            if (a[i] == 2) {
                cout << count << endl;
                break;
            }
            else {
                check[i]++;
                if (check[i] == 2) {
                    cout << -1 << endl;
                    break;
                }
                i = a[i]-1;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 1152
H, W = map(int, input().split())
S = [0 for _ in range(H)]
for i in range(H):
    S[i] = list(input())

dx = [1, 0, -1, 0, 1, -1, -1 ,1]
dy = [0, 1, 0, -1, 1, 1, -1, -1]

for i in range(H):
    for j in range(W):
        count = 0
        if S[i][j] == '#':
            continue
        else:
            for k in range(8):
                ni = i + dx[k]
                nj = j + dy[k]
                if 0 <= ni and ni < H and 0 <= nj and nj < W:
                    if S[ni][nj] == '#':
                        count += 1
            S[i][j] = str(count)

for i in range(H):
    print(''.join(S[i]))


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

using namespace std;

#define inf 1<<30
#define llong long long
#define usd unsigned
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef pair<int, int> P;
typedef struct data{
	int now;
	int cost;
}data;
int nw[9] = {0, 1, 0, -1, -1, 1, 1, -1, 0};
int nh[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};

usd llong int N, a[30001];

usd llong int gcd(usd llong int a, usd llong int b){
	if(b == 0) return a;
	return gcd(b, a%b);
}

usd llong int lcm(usd llong int a, usd llong int b){
	return a/gcd(a, b)*b;
}

int main(){
	cin >> N;
	usd llong int in, ans = 0;
	for(int i = 0; i < N; i++){
		cin >> in;
		ans += in-1;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
/*
/ ￣￣￣＼　
|　ー　ー \　
|　 ◉　◉ |   / ￣￣￣ ＼
\ 　  ▱ 　 / ∠    114514
＼　　 イ    \
／　　　＼    \_________/
/　|　　 \ \　
|　|　　　 | |
*/
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<algorithm>
#include<string.h>
#include<queue>
#include<set>
#include<string>
#include<sstream>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

namespace FastIO{
    const int SIZE = 1 << 16;
    char buf[SIZE], obuf[SIZE], str[60];
    int bi = SIZE, bn = SIZE, opt;
    int read(char *s){
        while (bn){
            for (; bi < bn && buf[bi] <= ' '; bi++);
            if (bi < bn) break;
            bn = fread(buf, 1, SIZE, stdin);
            bi = 0;
        }
        int sn = 0;
        while (bn){
            for (; bi < bn && buf[bi] > ' '; bi++) s[sn++] = buf[bi];
            if (bi < bn) break;
            bn = fread(buf, 1, SIZE, stdin);
            bi = 0;
        }
        s[sn] = 0;
        return sn;
    }
    bool read(int& x){
        int n = read(str), bf;

        if (!n) return 0;
        int i = 0; if (str[i] == '-') bf = -1, i++; else bf = 1;
        for (x = 0; i < n; i++) x = x * 10 + str[i] - '0';
        if (bf < 0) x = -x;
        return 1;
    }
};

ll Pow_mod(ll a, ll b, ll c){
    ll ans = 1;
    a %= c;
    while (b){
        if (b & 1) ans = (ans * a) % c;
        a = (a * a) % c;
        b >>= 1;
    }
    return (ans % c);
}

ll mul(ll a, ll b, ll c){
    ll ans = 0;
    a %= c;
    while (b){
        if (b & 1) ans = (ans + a) % c;
        a = (a + a) % c;
        b >>= 1;
    }
    return (ans % c);
}

ll gcd(ll a, ll b){
    return b ? gcd(b, a % b) : a;
}

int n, ans, s;

int main(){
    scanf("%d", &n);
    for (int i = 1; i <= n; i ++ ){
        int t = i, s = 0;
        while (t){
            t /= 10;
            s ^= 1;
        }
        if (s) ans ++ ;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()


int main(){
    int n,k;
    cin>>n>>k;
    vector<int> p(n);

    rep(i,n){
        cin>>p[i];
        p[i]++;
    }
    vector<int> s(n+1,0);
    rep(i,n) s[i+1]=s[i]+p[i];

    int tmp=0;
    rep(i,n){
        tmp=max(tmp,s[min(n,i+k)]-s[i]);
    }

    double ans=tmp/2.0;
    cout<<fixed<<setprecision(10)<<ans<<endl;
}



Measured memory_bytes: 4836
import java.util.*;
import java.io.*;

public class Main {	
	private static void solve(){
		//Implement solution here.
		int K = ni();		
		String S = next();
		if(S.length() <= K) {
			System.out.println(S);
		} else {
			System.out.println(S.substring(0, K) + "...");
		}
	}

	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		boolean hasNext = true;
		while(hasNext){
			solve();	
			try{
				br.mark(1);
				if(br.read() > 0){
					br.reset();			
					System.out.println("---");
				} else {
					hasNext = false;
				}
			}catch(Exception e){
				throw new RuntimeException(e);
			} 
		}
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}


Measured memory_bytes: 25408
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using ll = long long;
using namespace std;

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

  if((s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3])) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int maxv = -100, a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    if((a * 10 + b) + c > maxv)maxv = (a * 10 + b) + c;
    if((a * 10 + c) + b > maxv)maxv = (a * 10 + c) + b;
    if((b * 10 + a) + c > maxv)maxv = (b * 10 + a) + c;
    if((b * 10 + c) + a > maxv)maxv = (b * 10 + c) + a;
    if((c * 10 + a) + b > maxv)maxv = (c * 10 + a) + b;
    if((c * 10 + b) + a > maxv)maxv = (c * 10 + b) + a;
    if(a + (b * 10 + c) > maxv)maxv = a + (c * 10 + b);
    if(a + (c * 10 + b) > maxv)maxv = a + (c * 10 + b);
    if(b + (a * 10 + c) > maxv)maxv = b + (a * 10 + c);
    if(b + (c * 10 + a) > maxv)maxv = b + (c * 10 + a);
    if(c + (a * 10 + b) > maxv)maxv = c + (a * 10 + b);
    if(c + (b * 10 + a) > maxv)maxv = c + (b * 10 + a);
    printf("%d", maxv);
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc;

	static final int INF=1<<28;
	static final double EPS=1e-9;

	void run(){
		sc=new Scanner(System.in);
		int n=sc.nextInt();
		for(int i=0; i<n; i++){
			char[] cs=sc.next().toCharArray();
			sort(cs);
			int min=Integer.parseInt(new String(cs));
			int max=Integer.parseInt(new StringBuffer(new String(cs)).reverse()
					.toString());
			println((max-min)+"");
		}
		sc.close();
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}
}

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

int main() {
    int h,w;
    cin >> h >> w;
    char x[h][w];
    int cnt = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> x[i][j];
            if(x[i][j] == '#'){
                cnt++;
            }
        }
    }
    if(cnt == h+w-1){
        cout << "Possible" << endl;
    }else{
        cout << "Impossible" << endl;
    }
    return 0;
}

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

using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

int main(){
  map<string, int> m;
  int q; cin >> q;
  int command;
  string key;
  int x;
  rep_i(i, q){
    cin >> command;
    if(command == 0){
      cin >> key >> x;
      auto it = m.find(key);
      if(it == m.end()){
        m.insert(make_pair(key, x));
      }else{
        m[key] = x;
      }
    }else if(command == 1){
      cin >> key;
      auto it = m.find(key);
      if(it == m.end()){
        say(0);
      }else{
        say(m.at(key));
      }
    }else if(command == 2){
      cin >> key;
      auto it = m.find(key);
      if(it != m.end()){
        m.erase(key);
      }
    }
  }
}
  


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

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
using ll = long long;
using pi = pair<int, int>;
const int INF = 0x3f3f3f3f;
const ll LINF = 1ll * INF * INF;

const int MAX_N = 1e5 + 100;
const int MOD = 1e9 + 7;

int N, Cnt[MAX_N];
int main() {
	cin >> N;
	for(int i=0; i<N; i++) {
		int x; scanf("%d", &x);
		if((x+1)%2 != N%2) return puts("0") < 0;
		Cnt[x / 2]++;
	}
	if(N % 2 == 1 && Cnt[0] != 1) return puts("0") < 0;
	if(N % 2 == 0 && Cnt[0] != 2) return puts("0") < 0;
	ll ans = (N+1)%2 + 1;
	for(int i=1; i<(N+1)/2; i++) {
		if(Cnt[i] != 2) return puts("0") < 0;
		ans *= 2;
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a>=0 && b>=0 && c>=0 && a<=100 && b<=100 && c<=100)
    {

        if(a<b && b<c)
        {
            cout<<"Yes"<<endl;
        }
        else
        {
            cout<<"No"<<endl;
        }
        
    }
    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int gcd(int a,int b){if (b == 0) return a; return gcd(b , a%b);}
int lcm(int a, int b){ return a/gcd(a,b)*b;}
inline int read(){
    int f = 1, x = 0;char ch = getchar();
    while (ch > '9' || ch < '0'){if (ch == '-')f = -f;ch = getchar();}
    while (ch >= '0' && ch <= '9'){x = x * 10 + ch - '0';ch = getchar();}
    return x * f;
}
map<string, int> mp;
int main(){
    int n,tag = 0;
    cin >> n;
    string s,now;
    cin >> s; mp[s]++;
    for (int i=1; i<n; i++) {
        cin >> now;
        if (mp[now] != 0 || s[s.size()-1] != now[0]){
            tag = 1;
            break;
        }else{
            mp[now]++;
        }
        s = now;
    }
    if (tag == 1) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll n;
  cin >> n;
  
  vl f(n+1);
  rep2(x, 100) rep2(y, 100) rep2(z, 100) {
    ll num = x*x+y*y+z*z+x*y+y*z+z*x;
    if(num<=n) f[num]++;
  }
  
  rep2(i, n) cout << f[i] << newl;
  return 0;
}

Measured memory_bytes: 3648
#include<stdio.h>
#include<math.h>

int main (void)
{
	double a,b,c,s,C;
	double S,L,h;
	
	scanf("%lf %lf %lf",&a,&b,&C);
	c = sqrt(a * a + b * b - 2 * a * b * cos(C * M_PI / 180));
	L = a + b + c;
	s = L / 2;
	S = sqrt(s * (s - a) * (s - b) * (s - c));
	h = 2 * S / a;
	printf("%lf\n%lf\n%lf\n",S,L,h);
	
	return 0;
}


Measured memory_bytes: 2100
#!/usr/bin/env python3
n, *x = map(int, open(0).read().split())
s = sorted(x)
m1 = s[n // 2 - 1]
m2 = s[n // 2]
for i in x:
    if i < m2:
        print(m2)
    else:
        print(m1)


Measured memory_bytes: 31500
import itertools
h,w,k = map(int, input().split())
g = []
for _ in range(h):
  i = input()
  g.append(i)
l = [0 for j in range(h)]
d = [0 for j in range(w)]
c =0
for i in range(h):
  a = 0
  for j in range(w):
    if g[i][j] == '#':
      a +=1
  l[i]+=a
  c+=a
for i in range(w):
  b = 0
  for j in range(h):
    if g[j][i] == '#':
      b +=1
  d[i]+=b
ans = 0
for i in list(itertools.product([0,1], repeat=h)):
  e = c
  for x in range(h):
    if i[x] == 1:
      e-= l[x]
  for j in list(itertools.product([0,1], repeat=w)):
    f = e
    for y in range(w):
      if j[y] == 1:
        f -= d[y]
    for x in range(h):
      for y in range(w):
        if i[x] == 1 and j[y] == 1 and g[x][y]=='#':
          f+=1
    if f==k:
      ans+=1
print(ans)

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

int main() {
	int n;
	cin >> n;
	vector<int> t(n);
	int sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> t[i];
		sum += t[i];
	}
	int m;
	cin >> m;
	vector<int> p(m), x(m);
	for (int i = 0; i < m; i++) {
		cin >> p[i] >> x[i];
		p[i]--;
	}
	for (int i = 0; i < m; i++)
		cout << sum - t[p[i]] + x[i] << endl;
	return 0;
}

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



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

	ll N, K, Q; cin >> N >> K >> Q;
	ll a[110000];
	ll A;
	fill(a, a + N, K - Q);
	for (int i = 0; i < Q; i++) {
		cin >> A;
		a[A-1]++;
	}
	for (int i = 0; i < N; i++) {
		if (a[i] > 0)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}

Measured memory_bytes: 1408
using System;

namespace ABC026A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c;

            var word = Console.ReadLine().Split(' ');

            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            c = int.Parse(word[2]);

            if (a<=c && b<=c)
                Console.WriteLine(a+b);

            else if (a<=b && c<=b)
                Console.WriteLine(a + c);

            else
                Console.WriteLine(b+c);


            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
 
struct Node{
  int key;
  Node *right,*left,*p;
};
 
Node *NIL,*root;
 
void insert(int k){
  Node *x=root;
  Node *y=NIL;
  Node *T;
   
  T=(Node *)malloc(sizeof(Node));
  T->key=k;
  T->left=NIL;
  T->right=NIL;
   
  while(x!=NIL){
    y=x;
    if(T->key<x->key) x=x->left;
    else x=x->right;  
  }
  T->p=y;
  if(y==NIL) root=T;
  else if(T->key<y->key) y->left=T;
  else y->right=T;
}
 
void in(Node *T){
  if(T!=NIL){
    in(T->left);
    cout<<' '<<T->key;
    in(T->right);
  }
} 

void pre(Node *T){
  if(T!=NIL){
    cout<<' '<<T->key;
    pre(T->left);
    pre(T->right);
  }
}
 
int main(){
  int m,k;
  string str;
  cin>>m;
  for(int i=0;i<m;i++){
    cin>>str;
    if(str[0]=='i'){
      cin>>k;
      insert(k);
    }
    else {
      in(root);
      cout<<endl;
      pre(root);
      cout<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 24636
#include<stdio.h>
#define max 100000
#define sen 2000000000

struct Card{
  char s;
  int v;
};

struct Card L[max/2+2], R[max/2+2];

void merge(struct Card A[], int n, int left, int mid, int right){
  int i, j, k;
  int n1=mid-left;
  int n2=right-mid;
  for(i=0 ; i<n1 ; i++)L[i]=A[left+i];
  for(i=0 ; i<n2 ; i++)R[i]=A[mid+i];
  L[n1].v=R[n2].v=sen;
  i=j=0;
  for(k=left ; k<right ; k++){
    if(L[i].v<=R[j].v){
      A[k]=L[i++];
    }else{
      A[k]=R[j++];
    }
  }
}

void mergeSort(struct Card A[], int n, int left, int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(A, n, left, mid);
    mergeSort(A, n, mid, right);
    merge(A, n, left, mid, right);
  }
}

int partition(struct Card A[], int n, int p, int r){
  int i, j;
  struct Card t, x;
  x=A[r];
  i=p-1;
  for(j=p ; j<r ; j++){
    if(A[j].v<=x.v){
      i++;
      t=A[i];
      A[i]=A[j];
      A[j]=t;
    }
  }
  t=A[i+1];
  A[i+1]=A[r];
  A[r]=t;
  return i+1;
}

void quickSort(struct Card A[], int n, int p, int r){
  int q;
  if(p<r){
    q=partition(A, n, p, r);
    quickSort(A, n, p, q-1);
    quickSort(A, n, q+1, r);
  }
}

int main(){
  int n, i, v;
  struct Card A[max], B[max];
  char S[10];
  int sta=1;
  scanf("%d",&n);
  for(i=0 ; i<n ; i++){
    scanf("%s%d",S, &v);
    A[i].s=B[i].s=S[0];
    A[i].v=B[i].v=v;
  }
  mergeSort(A, n, 0, n);
  quickSort(B, n, 0, n-1);
  for(i=0 ; i<n ; i++){
    if(A[i].s!=B[i].s)sta=0;
  }
  if(sta==1)printf("Stable\n");
  else printf("Not stable\n");
  for(i=0 ; i<n ; i++){
    printf("%c %d\n",B[i].s, B[i].v);
  }
  return 0;
}



Measured memory_bytes: 3996
N = int(input())
A = list(map(int, input().split()))
# N = 9
# A = [1, 2, 1, 2, 1, 2, 1, 2, 1]
# N = 7
# A = [1, 2, 3, 2, 1, 999999999, 1000000000]
# N = 6
# A = [1, 2, 3, 2, 2, 1]
# N = 2
# A = [1, 1]
A = A + [A[-1]]

d = 0
i = 0

inc = None
while i < N:
    if inc is None:
        if A[i] < A[i + 1]:
            inc = True
            d += 1
        elif A[i] > A[i + 1]:
            inc = False
            d += 1
        else:
            inc = None
    else:
        if inc:
            if A[i] > A[i + 1]:
                inc = None
        else:
            if A[i] < A[i + 1]:
                inc = None
    i += 1

if inc is None:
    d += 1
print(d)


Measured memory_bytes: 15020
#include <bits/stdc++.h>
 
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long
 
const int N=3e3+5,MAX=3e7,MOD=1e9+7;
 
using namespace std;
 
int n;

double a[N];

double memo[N][N];

double solve(int indx,int gain){

	 if(indx == n){

	 	 if(gain>n/2)return 1;
	 	 return 0;
	 }

	 double &ret = memo[indx][gain];

	 if(ret != -1)return ret;

	 ret = 1;

	 ret = ret * ( (1-a[indx]) * (solve(indx+1,gain)) + a[indx] * solve(indx+1,gain+1) );

	 return ret;
}


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //#ifndef ONLINE_JUDGE
      //freopen("test.txt","r",stdin);
    //#endif

      scanf("%d",&n);

      for(int i=0;i<n;i++)scanf("%lf",&a[i]);


      for(int i=0;i<N;i++)for(int j=0;j<N;j++)memo[i][j]=-1;


      printf("%.10lf\n",solve(0,0) );


    
   
     
}

Measured memory_bytes: 71040
n,k=map(int,input().split())
h=list(map(int,input().split()))

dp=[int(10e8)]*n
dp[0]=0
for i in range(1,n):
    for j in range(min(i,k)):
        dp[i]=min(dp[i],dp[i-j-1]+abs(h[i]-h[i-j-1]))

print(dp[n-1])


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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

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

int main(void)
{
  ll N, T;
  cin >> N >> T;
  vector<ll> t(N);
  REP(i, N) cin >> t[i];

  ll ans = 0;
  REP(i, N-1) {
    ans += min(T, t[i+1]-t[i]);
  }
  ans += T;
  cout << ans << endl;
}


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

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main() {
	long long n, m;
	cin >> n >> m;

	long long ans = 0;

	if (n < m) {
		swap(n, m);
	}

	if (m == 1 && n == 1) ans = 1;
	else if (m == 1 && n == 2) ans = 0;
	else if (m == 1) ans = n - 2;
	else if (m == 2) ans = 0;
	else ans = n*m - 2 * m - 2 * n + 4;

	ANS(ans);


	return 0;
}



Measured memory_bytes: 256
#合計宿泊数
N = input()
#通常宿泊数
K = input()
#通常宿泊費
X = input()
#割引宿泊費
Y = input()
#宿泊日数カウント
S = 1
#合計金額カウント
P = 0

#合計日数が割引日数以上
if int(N) >= int(K):
    #通常宿泊出力
    while S <= int(K):
        P = P + int(X)
        S = S + 1

    #割引宿泊出力
    while S <= int(N):
        P = P + int(Y)
        S = S + 1
#合計日数が割引日数未満
else :
    #通常宿泊出力
    while S <= int(N):
        P = P + int(X)
        S = S + 1

#合計金額出力
print(P)

Measured memory_bytes: 3060
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

int main(){
    ll N,K;
    cin>>N>>K;
    vector<ll> A(N);
    vector<ll> bit(60,0);
    
    REP(i,N) cin>>A[i];

    ll tmp=0;
    REP(i,60){
        ll mask = 1LL<<i;
        REP(j,N){
            if(mask&A[j]) bit[i]++;
        }
    }

    ll ans=tmp;
    REP2(i,-1,60){
        if(i!=-1&&!(K&(1LL<<i))) continue;
        tmp=0;
        REP(j,60){
            ll mask=1LL<<j;
            if(j<i){
                tmp+=mask*max(N-bit[j],bit[j]);
            }

            if(j==i){
                tmp+=mask*bit[j];
            }

            if(j>i){
                if(K&mask){
                    tmp+=mask*(N-bit[j]);
                }else{
                    tmp+=mask*bit[j];
                }
            }
        }

        ans=max(tmp,ans);
    }
    cout<<ans<<endl;
}

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

using namespace std;

int main() {
	int r, g, b, n, c = 0;
	cin >> r >> g >> b >> n;
	for (int i = 0; i <= n; i++)
		for (int j = 0; j <= n; j++)
			if (0 <= n - i * r - j * g && (n - i * r - j * g) % b == 0)
				c++;
	cout << c << endl;
	return 0;
}


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

using namespace std;

int main() {
	int n, s[200] = {}, num[200] = {}, result = 0, lamp = 1, in, ax, h, w, m,a,b,c,r,tmp;
	string str[106];
	cin >> a>>b>>c;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	if (c%b == 0) { cout<<"YES"; }
	else {
		cout << "NO";
	}
	
}

Measured memory_bytes: 256
import java.util.*;

public class Main {


    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);
        final long N = sc.nextLong();
        final long M = sc.nextLong();

        final long[] A = new long[(int)N];
        final long[] B = new long[(int)N];

        final PriorityQueue<Map.Entry<Long, Integer>> pq = new PriorityQueue<>((e1, e2) -> {
            if (e1.getKey() < e2.getKey()) {
                return -1;
            }
            if (e1.getKey() > e2.getKey()) {
                return +1;
            }
            return 0;
        });

        for (int i = 0; i < N; ++i) {
            A[i] = sc.nextLong();
            pq.offer(new AbstractMap.SimpleEntry<>(A[i], i));
            B[i] = sc.nextLong();
        }

        long leftToBuy = M;
        long money = 0;

        while (!pq.isEmpty() && leftToBuy > 0) {
            final Map.Entry<Long, Integer> entry = pq.poll();
            final long price = entry.getKey();
            final int index = entry.getValue();
            money += (Math.min(B[index], leftToBuy)) * price;
            leftToBuy -= Math.min(B[index], leftToBuy);
        }

        System.out.println(money);
        System.out.flush();
        sc.close();
    }
}


Measured memory_bytes: 98852
import java.util.Scanner;
public class Main {
	static long mod=(long)(Math.pow(10.0, 9.0)+7);
	static Scanner scan=new Scanner(System.in);
	static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
	static long lcm (int a, int b) {return a*b/gcd(a,b);}
	static int max(int a,int b) {return a>b?a:b;}
	static int min(int a,int b) {return a<b?a:b;}
	static long factorial(int i) {return i==1?1:i*factorial(i-1);}
	static int lower_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<=key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static int upper_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2)if(n%i==0){return false;}
		return true;
	}
	static int upper_division(int a,int b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lupper_division(long a,long b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lmax(long a,long b) {return Math.max(a, b);}
	static long lmin(long a,long b) {return Math.min(a, b);}
	static int[] setArray(int a) {
		int b[]=new int[a];
		for(int i=0;i<a;i++) {
			b[i]=scan.nextInt();
		}
		return b;
	}
	//Arrays.sort(array, (a, b) -> Integer.compare(a[0], b[0]));
	
	public static void main(String[] args) {
		int a=scan.nextInt();
		int b=scan.nextInt();
		int c=a-b;
		int ans=c*100+b*1900;
		int z=0;
		switch(b) {
		case 1:z=2;break;
		case 2:z=4;break;
		case 3:z=8;break;
		case 4:z=16;break;
		case 5:z=32;break;
		}
		ans*=z;
		System.out.println(ans);
	}
}

Measured memory_bytes: 21972
s = int(input())
def f(s):
    return s/ 2 if s % 2 == 0 else 3 * s + 1
a = [s]
while len(a) > 0:
    if f(s) in a:
        print(len(a)+1)
        break
    else:
        s = f(s)
        a.append(s)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

    ll N, L; cin >> N >> L;
    ll sum = 0LL;
    vel a(N); rep(i,N) cin >> a[i];
    int index = -1; vei ans;
    rep(i,N-1) {
        if(a[i] + a[i+1] >= L) index = i+1;
    }
    if(index == -1) {cout << "Impossible" << endl; return 0;}
    for(int i = index; i <= N-1; i++) ans.pub(i);
    for(int i = index-1; i>= 1;i--) ans.pub(i);
    reverse(all(ans));
    cout << "Possible" << endl;
    rep(i,N-1) cout << ans[i] << endl;
    return 0;
    
}



Measured memory_bytes: 2168
//Author:  Pranta
//Date:    2020-Aug-15
//Problem: A_Rainy_Season
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
using namespace std;
void solve()
{
  string s;
    cin>>s;
    bool ok=false;
    int cnt=0;
    for(int i=0;i<3;++i){
        if(s[i]=='R'){
            ok=true;
            if(s[i+1]=='R'){
                cnt++;
            }
        }
    }
    if(ok){
        if(cnt>0) cout<<cnt+1;
        else cout<<1;
    }
    else
    {
        cout<<0;
    }
    
}
int main()
{
    fast;
    int t;
    solve();
}

Measured memory_bytes: 3636
#include<stdio.h>
int main(void)
{
	int a,s,d,f,g,h,j,i;
	while(1){
		scanf("%d %d",&a,&s);
		if(a==0&&s==0)
			break;
		for(i=0;i<s;i++)
			printf("#");
		printf("\n");
		for(i=1;i<a-1;i++){
			printf("#");
			for(j=1;j<s-1;j++)
				printf(".");
			printf("#\n");
		}
		if(a!=1){
			for(i=0;i<s;i++)
				printf("#");
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 2540
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

manzoku = 0
manzoku+=sum(B)
for i in range(1,N):
  if A[i]-A[i-1]==1:
    #print(i)
    manzoku+=C[A[i-1]-1]
    #print(C[A[i-1]-1])
    
print(manzoku)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//(a+b-1)/b
using pl = pair<long long,long long>;

signed main(){
	ll n,k; cin>>n>>k;
	vector<pl> v(n);
	rep(i,0,n)cin>>v[i].first>>v[i].second;
	ll ans=0;
	sort(all(v));
	rep(i,0,n){
		if(k<=v[i].second){
			ans+=v[i].first*k;
			break;
		}
		else{
			ans+=(v[i].first)*(v[i].second);
			k-=v[i].second;
		}
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 4768
using System;
using System.Collections.Generic;

public class Program222
{
    public static void Main(string[] args)
    {
        var s = Console.ReadLine();
        var n1 = int.Parse(s[0].ToString());
        var n2 = int.Parse(s[1].ToString());
        var n3 = int.Parse(s[2].ToString());

        var r = n1;
        if (n1 <= n2)
        {
            if (n1<n2)
            {
                r++;
            }
            else if (r < n3)
            {
                r++ ;
            }

        }


        Console.WriteLine(r.ToString() + r.ToString() + r.ToString());


    } // Main
}     // Class




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

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 long long INF = 1000000000000000000;

int main(){
  int n; cin >> n;
  vector<ll> a(n);
  rep(i, n){
    ll b; cin >> b;
    if(b == 0){
      cout << 0 << endl;
      return 0;
    }
    a[i] = b;
  }

  ll res = 1;
  rep(i, n){
    if(INF / a[i] < res){
      cout << -1 << endl;
      return 0;
    } 
    res *= a[i];
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 4052