akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

const int N = 10000000; // ~ 1e7
s64 fac[N + 1], finv[N + 1];

s64 mypow(s64 x, s64 n)
{
    s64 ret = 1;
    while (n > 0)
    {
        if (n & 1) ret = (ret * x) % MOD;
        x = (x * x) % MOD;
        n >>= 1;
    }
    return ret;
}

void init(int n)
{
    if (n > N) n = N;
    fac[0] = 1;
    rep (i, n)
    {
        fac[i + 1] = (fac[i] * (i + 1)) % MOD;
    }
    finv[n] = mypow(fac[n], MOD - 2);
    for (int i = n; i >= 1; --i)
    {
        finv[i - 1] = (finv[i] * i) % MOD;
    }
}

s64 com(int n, int k)
{
    if (n < k || n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

    int k;
    cin >> k;

    string s;
    cin >> s;
    int n = s.size();

    init(N);
    s64 ans = 0;
    for (int i = 0; i <= k; ++i)
    {
        s64 temp = mypow(25, i);
        temp = (temp * com(n + k, i)) % MOD;
        ans = (ans + temp) % MOD;
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 160464
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
using namespace std;

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

   for(int i = 0; i < s.size(); i++)
   {
       if((i%2) != 0)
       {
           if(s.at(i) == 'R')
           {
               cout << "No" << endl;
               return 0;
           }
       }

       if((i%2) == 0)
       {
           if(s.at(i) == 'L')
           {
               cout << "No" << endl;
               return 0;
           }
       }
   }
   
    cout << "Yes" << endl;
    
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define floop(i,a,n) for (int i=a;i<n;i++)
#define rfloop(i,a,n) for (int i=n-1;i>=a;i--)
#define mloop(it,x) for(it=x.begin();it!=x.end();it++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((ll)(x).size())
#define cases ll t; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;
typedef unsigned long long int ull;
typedef vector<ll> vec;
typedef pair<ll,ll> pll;
typedef double db;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const ll mod=998244353;
ll pm(ll x,ll n) {ll result=1; while(n>0){if(n%2==1) result=((result%mod)*(x%mod))%mod; x=((x%mod)*(x%mod))%mod; n/=2;} return result;}
ll p(ll x,ll n) {ll result=1; while(n>0){if(n%2==1) result=result*x; x=x*x; n/=2;} return result;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll ncr(ll n,ll r) { ll p=1,k=1; if(n-r<r) r=n-r; if(r!=0) {while(r!=0) {p*=n; k*=r; ll temp=gcd(p,k); p/=temp; k/=temp; n--; r--;} } else p=1; return p;}
ll factorial[300000+1];
void fact(ll n) { factorial[0]=1; factorial[1]=1; floop(i,2,n+1) factorial[i] = (i * factorial[i-1]%mod) % mod; }
ll d,coeff1,coeff2; 
void euclid(ll a, ll b) { if(b==0) { d=a; coeff1=1; coeff2=0; } else { euclid(b,a%b); ll temp=coeff1; coeff1=coeff2; coeff2=temp-(a/b)*(coeff2); } }
ll modinv(ll a) { euclid(a,mod); return (coeff1%mod+mod)%mod; }
int prime[1000001]={};
int spf[1000001]={};
void sieve(ll n)
{
	prime[0]=1;
	prime[1]=1;
	for(ll i=2;i*i<=n;i++)
	{
		if(prime[i]==0)
		{
			for(ll j=i*i;j<=n;j+=i)
			{
				prime[j]=1;	
				if(spf[j]==j)
				spf[j]=i;	
			}		
		}
	}
}
/*
vec s(300000,0);
vec si(300000,1);
ll root(ll a)
{
	while(s[a]!=a)
	a=s[a];
	return a;
}
void uni(ll a,ll b)
{
	ll r1=root(a);
	ll r2=root(b);
	if(si[r1]<si[r2])
	{
		s[r1]=s[r2];
		si[r2]+=si[r1];
	}
	else
	{
		s[r2]=s[r1];
		si[r1]+=si[r2];
	}
}
vector<vec > adj(300000);
vec vis(300000,0);
vec dist(300000,0);
void dfs(ll t,ll n)
{
	vis[t]=1;
	floop(i,0,sz(adj[t]))
	{
		if(vis[adj[t][i]]==0)
		{
			dist[adj[t][i]]=dist[t]+1;
			vis[adj[t][i]]=1;
		//	sum[adj[t][i]]=sum[t]+c[t][adj[t][i]];
			dfs(adj[t][i],n);
		}
	}
}*/
int main()
{
	ll n,m,k;
	cin>>n>>m>>k;
	ll ans=0;
	fact(300000);
	floop(i,0,k+1)
	{
		ll temp=factorial[n-1]%mod;
		ll temp2=((factorial[i]%mod)*(factorial[n-1-i]%mod))%mod;
		ll temp3=((temp*(modinv(temp2)%mod))%mod+mod)%mod;
		ll temp4=((m*(pm(m-1,n-1-i)%mod))%mod+mod)%mod;
		ans=((ans%mod+((temp3%mod)*(temp4%mod)))%mod+mod)%mod;
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 5988
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<set>
#define SF scanf
#define PF printf
#define MAXN 100010
using namespace std;
int dist[MAXN];
vector<int> a[MAXN],w[MAXN];
struct node{
	int col,sum,x;
	node () {}
	node (int col1,int sum1,int x1):col(col1),sum(sum1),x(x1) {}
	bool operator < (const node &a) const{
		return sum>a.sum;
	}
};
priority_queue<node>q;
map<pair<int,int>,int>vis;
set<pair<int,int> >used[MAXN];
int n;
void spfa(){
	dist[1]=0;
	while(!q.empty()){
		node x=q.top();
		q.pop();
		if(dist[x.x]<x.sum||used[x.x].count(make_pair(x.col,x.sum)))
			continue;
		used[x.x].insert(make_pair(x.col,x.sum));
		int u=x.x;
		for(int i=0;i<a[u].size();i++){
			if(x.col!=-1&&x.col!=w[u][i])
				continue;
			int len=dist[u]+(w[u][i]!=x.col);
			int v=a[u][i];
			if(dist[v]==-1||(dist[v]>=len&&(vis.count(make_pair(v,w[u][i]))==0||vis[make_pair(v,w[u][i])]>len))){
				dist[v]=len;
				vis[make_pair(v,w[u][i])]=len;
				q.push(node(w[u][i],dist[a[u][i]],a[u][i]));
				if(vis.count(make_pair(v,-1))==0||vis[make_pair(v,-1)]>len){
					q.push(node(-1,dist[a[u][i]],a[u][i]));	
					vis[make_pair(v,-1)]=len;
				}
			}
		}
	}
}
int main(){
	memset(dist,-1,sizeof dist);
	int m,u,v,val;
	SF("%d%d",&n,&m);
	int col=0;
	for(int i=1;i<=m;i++){
		SF("%d%d%d",&u,&v,&val);
		a[u].push_back(v);
		a[v].push_back(u);
		w[u].push_back(val);
		w[v].push_back(val);
		col=max(col,val);
	}
	q.push(node(-1,0,1));
	vis[make_pair(0,-1)]=0;
	spfa();
	PF("%d",dist[n]);
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

vector<pair<int,pair<int,LL>>> uf;

int root(int x){
  if(uf[x].first==x) return x;
  else{
    int rt=root(uf[x].first);
    uf[x].second.second+=uf[uf[x].first].second.second;
    return uf[x].first=rt;
  }
}

LL dist(int x){
  root(x);
  return uf[x].second.second;
}

void uni(int x,int y,LL d){
  LL tmp=dist(x)-dist(y);
  x=root(x);
  y=root(y);
  if(x!=y){
    if(uf[x].second.first>uf[y].second.first){
      uf[y].first=x;
      uf[y].second.second+=d+tmp;
    }else if(uf[x].second.first<uf[y].second.first){
      uf[x].first=y;
      uf[x].second.second-=d+tmp;
    }else{
      uf[y].first=x;
      uf[y].second.second+=d+tmp;
      uf[x].second.first++;
    }
  }
}


int main(){
  while(1){
    int n,m;
    cin >> n >> m;
    if(n==0) return 0;
    uf=vector<pair<int,pair<int,LL>>>(n);
    for(int i=0;i<n;i++){
      uf[i]={i,{0,0}};
    }
    char c;
    LL a,b,w;
    for(int i=0;i<m;i++){
      cin >> c;
      if(c=='!'){
        cin >> a >> b >> w;
        uni(a-1,b-1,w);
      }else{
        cin >> a >> b;
        // for(int i=0;i<n;i++) cout << dist(i) << " ";
        // cout << endl;
        if(root(a-1)==root(b-1)){
          cout << dist(b-1)-dist(a-1) << endl;
        }else{
          cout << "UNKNOWN" << endl;
        }
      }
    }
  }
  return 0;
}



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

#define Fast           ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO             freopen("in.txt", "r", stdin)
#define FC             freopen("out.txt", "w", stdout)
#define aise           cout<<"aise"<<endl
#define pb             push_back
#define pf             push_front
#define ppb            pop_back
#define ppf            pop_front
#define mp             make_pair
#define ll             long long
#define all(x)         x.begin(), x.end()
#define mset(v, a)     memset(v, a, sizeof(v))
#define pll            pair< ll, ll >
#define pd             pair< double, double >
#define ff             first
#define ss             second
#define pi             acos(-1.0)
#define mxN            2010
#define inf            1e14
#define mod            1000000007
#define tc             ll tc;scanf("%lld",&tc);while(tc--)

//NCR iterative
/*voidcomb_table(intN)
{
    for(inti=0; i<=N; ++i)
    {
        for(intj=0; j<=i; ++j)
        {
            if(j==0or j==i)
            {
                C[i][j]=1LL;
            }
            else
            {
                C[i][j]=(C[i-1][j-1]+C[i-1][j]);
            }
        }
    }
}*/


//NCR recursive
/*ll dp[55][55];

ll NCR(ll n,ll r)
{

    if(n==r)
        return dp[n][r]=1;
    if(r==0)
        return dp[n][r]= 1;
    if(r==1)
        return dp[n][r]=n ;
    if(dp[n][r] != -1)
        return dp[n][r];
    return dp[n][r] = NCR(n-1,r)+NCR(n-1,r-1);
}*/

//Sieve:
/*bool Flag[1000010];
vector<ll> Prime;

void sieve()
{

    ll val=sqrt(1000010);
    for(ll i=4;i<=1000005; i+=2) Flag[i]=1;
    for(ll i=3;i <= val;i+=2)
    {

        if(Flag[i]==0)
        {

            for(ll j=i*i;j<=1000005;j+=i) Flag[j]=1;
        }
    }
    Flag[1]=1;
    for(ll i=1;i<=1000000;i++)
        if(Flag[i]==0) Prime.pb(i);
}*/


//Conversion
/*string bin(ll x)
{

    string ret;
    while(x)
    {

        ll t=x%2;
        char c;
        if(t==1)
            c='1';
        else
            c='0';
        ret.pb(c);
        x/=2;
    }
    reverse(all(ret));
    return ret;
}*/

/*ll lcm(ll x, ll y)
{

    ll ret=__gcd(x,y);
    return (x*y)/ret;
}*/

/*ll dx[]= {0,0,1,-1};
ll dy[]= {1,-1,0,0};*/


int main()
{
    string ss, ans="";
    cin >> ss;
    for(ll i=0;i<ss.size();i++)
    {

        if(ss[i]=='1' || ss[i]=='0') ans+=ss[i];
        else
        {

            if(ans.size()) ans.pop_back();
        }
    }
    cout << ans;
}


Measured memory_bytes: 3620
#include<cstdio>

int main() {
    int a,b,c,d,e;
    d = 0, e = 0;
    scanf("%d %d %d",&a,&b,&c);
    for(int i = 1; i <= c; i++){
        if(c % i == 0 && i >= a){
            for(int d = a; d <= b; d++){
                if(d % i == 0){
                    e = e + 1;
                    break;
                }
            }
        }
    }
    printf("%d\n",e);
return 0;
}


Measured memory_bytes: 2716
#include <iostream>
#include <string>
// #include <algorithm>

using namespace std;

int main(){
  string w;
  int m;
  while (true){
    int card_num;
    cin >> w;
    if(w == "-"){
      break;
    }
    cin >> m;
    for (int i = 0; i < m; i++){
      cin >> card_num;
      string shuffle_card = w.substr(0, card_num);
      w = w + shuffle_card;
      // https://cpprefjp.github.io/reference/string/basic_string/erase.html
      w.erase(0, card_num);
    }
    cout << w << endl;
  }
}


Measured memory_bytes: 3164
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
struct qaq{int a,i;}a[100010];
int main(){
#ifdef XZZSB
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	int n=gi(),ans=0;
	for(int i=1;i<=n;++i)a[i]={gi(),i};
	std::sort(a+1,a+n+1,[](qaq a,qaq b){return a.a<b.a;});
	for(int i=1;i<=n;++i)ans+=a[i].i-i&1;
	printf("%d\n",ans>>1);
	return 0;
}


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

#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
#define ALL(x) x.begin(),x.end()
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

int N,A,B;
pair<ll,ll> dp [51] [51];

ll gcd(ll x,ll y)
{
	return y ? gcd(y,x % y) : x;
}

int main()
{
	scanf("%d%d%d",&N,&A,&B);
	vector<ll> V(N);
	FOR(i,0,N){
		scanf("%lld",&V [i]);
	}

	dp [0] [0] = {0,1};
	FOR(i,0,N) FOR(j,0,B + 1) if(dp [i] [j].second){
		{
			ll x = dp [i] [j].first,y = dp [i] [j].second;
			if(x == dp [i + 1] [j].first){
				dp [i + 1] [j].second += y;
			}
			else{
				chmax(dp [i + 1] [j],dp [i] [j]);
			}
		}
		if(j + 1 <= B){
			ll x = dp [i] [j].first + V [i],y = dp [i] [j].second;
			if(x == dp [i + 1] [j + 1].first){
				dp [i + 1] [j + 1].second += y;
			}
			else{
				chmax(dp [i + 1] [j + 1],make_pair(x,y));
			}
		}
	}

	int idx = -1;
	FOR(i,A,B + 1){
		if(idx == -1 || 1.0 * dp [N] [i].first / i > 1.0 * dp [N] [idx].first / idx){
			idx = i;
		}
	}
	double mxAvg = 1.0 * dp [N] [idx].first / idx;

	ll ans = dp [N] [idx].second,g = gcd(dp [N] [idx].first,idx);
	FOR(i,A,B + 1) if(i != idx){
		ll x = gcd(dp [N] [i].first,i);
		if(dp [N] [idx].first / g == dp [N] [i].first / x && idx / g == i / x){
			ans += dp [N] [i].second;
		}
	}

	printf("%.10f %lld\n",mxAvg,ans);

	return 0;
}


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

int main() {
    int a, b;
    cin >> a >> b;
    int ans = 0;
    if (a == b) {
        ans = a + a;
    } else {
        ans = max(a, b) + max(a, b) - 1;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
s = str(n)
ans = 0
for i in range(len(s)):
    if (i + 1) % 2 != 0:
        if len(s) == i + 1:
            ans += n - (10 ** i - 1)
        else:
            ans += 10 ** (i + 1) - 1 - (10 ** i - 1)
print(ans)

Measured memory_bytes: 3060
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n = ni()
fs = []
for i in range(n):
    x = na()
    ptn = 0
    for j in range(10):
        ptn |= x[j]<<j
    fs.append(ptn)
ps = []
for i in range(n):
    ps.append(na())

def bct(x):
    ret = 0
    while x > 0:
        ret += x&1
        x >>=1
    return ret

ans = -9999999999999999
for i in range(1, 1024):
    s = 0
    for j in range(n):
        s += ps[j][bct(fs[j]&i)]
    ans = max(ans, s)
print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    ll n,c,k;
    cin >> n >> c >> k;
    vector<ll>t(n);
    REP(i,n)cin >> t[i];
    SORT(t);
    ll answer = 0;
    ll i=0;
    while(i < n){
        ll j=i+1;
        
        while(t[j]-t[i] <= k && (j-i+1)<=c){
            j++;
        }
        i = j;
        answer++;
        cerr<<i << " " << answer << endl;
    }
    
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 1024
#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;
const long long INF = 1LL << 60;
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);
  int N;
  cin >> N;
  if(N%1000==0){
    cout << 0 << endl;
    return 0;
  }
  cout << 1000 - (N % 1000) << endl;
  return 0;
}


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

#define int long long
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define WL(t) while(t --)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;
#define rep(i,a,n) for(int i=a; i<n; i++)
#define endl "\n"
#define e "\n"
#define show(arr) REP(i,arr.size()){cout<<arr[i]<<" ";}
const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

#define N 5010

void solve()
{
    int n,cur=1,ans=0;
    cin>>n;
    vi a(n,0);
    REP(i,n) cin>>a[i];
    RE(i,n-1)
    {
        if (a[i]==a[i-1]){
            cur++;
        }
        else {
            ans+=(int)cur/2;
            cur=1;
        }
    }
    cout<<ans+cur/2;
}

signed main()
{
    int t=1;
    //cin>>t;
    WL(t)solve();

    return 0;
}




Measured memory_bytes: 3596
from sys import stdin
input = stdin.readline

N, K = map(int, input().split())
V = list(map(int, input().split()))
targ = min(N, K)

ans = -float("inf")

#i: 左から取る回数
for i in range(targ+1):
    #j: 右を取る回数
    for j in range(targ+1-i):
        get = sorted(V[:i] + V[N-j:])
        tmp = sum(get)
        for k in range(min(K-i-j, i+j)):
            tmp = max(tmp, tmp-get[k])
        
        ans = max(tmp, ans)

print(ans)

Measured memory_bytes: 9208
#include<math.h>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
#include<array>
#include<iomanip>
#include<iostream>
#include<limits>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<vector>
#include<functional>

using namespace std;

typedef long long ll;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define rep(i, n) for( int i = 0; i < (n); i++)
#define loop(i, a, n) for(int i = a; i < (n); i++)
#define all(in) in.begin(), in.end()
#define vint vector<int> 

bool juge(int N){
    set<int> num;
    for(int i = 1; i <= 9; i++){
        for(int j = 1; j <= 9; j++){
            num.insert(i * j);
        }
    }
    if (num.find(N) != num.end()) return true;
    return false;
}
int main(){
    int N;
    cin >> N;
    if(juge(N)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
#include <cstring>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define repll(i,n) for(long long int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
template <typename T_char>
char ToUpper (char cX) { return toupper(cX); }
//g++ -std=c++1z temp.cpp
//./a.exe
ll digit(ll a){
    ll count = 0;
    for (ll i = 0; i < a; i++)
    {   if (a == 0)
        {
            break;
        }else
        {
            a = a/10;
            count++;
        }
    }
    return count;
}
//pow(x,n) == x^n
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a,   b) * b;}



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

int n,count = 0;
cin >> n;
string s;
cin >> s;

for(int i = 0;i < n-2;i++){
    if(s[i] == 'A' && s[i+1] == 'B' && s[i+2]== 'C') count++;
}

cout << count << endl;

//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());
const double pi = 3.14159265358979;

long double a, b;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> a >> b;
	string str = to_string(a * b);
	for(auto &i : str){
		if(i == '.') break;
		cout << i;
	}
	cout << "\n";
	return 0;
}

Measured memory_bytes: 3852
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};


int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
        rep(i,n) cin>>a.at(i);
    int s=0;
    for(int i=k+1;i<=n;i++){
        if(a[s]<a[i-1]) Yes;
        else No;
        s ++;
    }
}/*
./problem.exe
*/

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

int main () {
  int a;
  int b;
  cin >> a;
  cin >> b;
  if (a > b) {
    cout << "a > b" << endl;
  } else if (a < b) {
    cout << "a < b" << endl;
  } else {
    cout << "a == b" << endl;
  }
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    string s;
    cin >> s;
    rep(i, s.size()) {
        cout << s[i];
        i++;
    }
    cout << endl;
    return 0;
}


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

#include <stdio.h>
int main() {
  int a, b;
  cin >> a >> b;
  
  if (a > b) cout << "a > b" << endl;
  else if (a < b) cout << "a < b" << endl;
  else cout << "a == b" << endl;
  
  return 0;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    a = (a==1) ? 14 : a;
    b = (b==1) ? 14 : b;
    cout << ((a > b) ? "Alice" : ((a==b) ? "Draw" : "Bob")) << 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 rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()

int main() {
	int H,W;
	cin>>H>>W;
	vector<string> S(H);
	rep(i,H){
		cin>>S[i];
	}
	string ans = "Yes";
	rep1(i,H-1)rep1(j,W-1)
	if(S[i][j] == '#')
	if(S[i+1][j]!='#'&&S[i][j+1]!='#'&&S[i-1][j]!='#'&&S[i][j-1]!='#')
	ans = "No";

	cout<<ans<<endl;
}

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

using v1 = vector<int>;
using v2 = vector<vector<int>>;
using ll = long long;
int H;
int W;
vector<int> move_x = {1, 0, -1, 0,1,-1,1,-1};
vector<int> move_y = {0, 1, 0, -1,1,1,-1,-1};

int main(){
	cin >> H>>W;
	vector<vector<char>> a(H, vector<char>(W));
	string s;
	for(int i =0; i<H; i++){
		cin>>s;
		for(int j = 0; j <W; j++){
			a.at(i).at(j) = s.at(j);
		}
	}

	for(int i = 0; i<H; i++){
		for(int j=0; j<W;j++){
			int count = 0;
			if(a.at(i).at(j)=='#') continue;
			for(int t=0;t<8;t++){
				int n_h = i + move_y.at(t);
				int n_w = j + move_x.at(t);
				if(n_h<0 || n_w<0 || n_h>=H || n_w>=W) continue;
				if(a.at(n_h).at(n_w) == '#') count++;
			}
			a.at(i).at(j) = static_cast<char>(count+48);

		}
	}
	for(int i =0; i<H; i++){
		for(int j=0; j<W; j++){
			cout << a.at(i).at(j);
		}
		cout << endl;
	}
}


Measured memory_bytes: 256
import fractions
from functools import reduce

d = 10**9+7
n = int(input())
A = list(map(int, input().split()))

def lcm(l):
    return reduce(lambda x, y: (x * y) // fractions.gcd(x, y), l, 1)

base = lcm(A)
print(sum(map(lambda n: base // n, A))%d)

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

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

    if (x == 0)
        cout << 1 << endl;
    else
        cout << 0 << endl;

    return 0;
}

Measured memory_bytes: 3636
S = input()
N=len(S)
M = [0 for _ in range(2019)]
# 0は予め右端に一個あるとする
M[0]+=1
old = 0
for i in range(N):
    new_s = int(S[N-1-i])*pow(10,i,2019)
    new = (new_s + old) % 2019
    M[new] += 1
    old = new
count = 0
for m in M:
    count += int(m*(m-1)/2)
print(count)


Measured memory_bytes: 9352
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
 
#define _USE_MATH_DEFINES
#define mp       make_pair
#define pb       push_back
#define fst      first
#define snd      second
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};


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

    ll A = X;
    int ans = 1;

    while(1) {
        if(A*2 > Y)
            break;
        A = A*2;
        ans++;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
	static int turn(char[][] f,int herew,int hereh,int w,int h){
		int cnt  = 0;
		f[hereh][herew] = '#';
		if(hereh>0)
			if(f[hereh-1][herew]=='.')
				cnt += turn(f,herew,hereh-1,w,h);
		if(hereh<h-1)
			if(f[hereh+1][herew]=='.')
				cnt += turn(f,herew,hereh+1,w,h);
		if(herew>0)
			if(f[hereh][herew-1]=='.')
				cnt += turn(f,herew-1,hereh,w,h);
		if(herew<w-1)
			if(f[hereh][herew+1]=='.')
				cnt += turn(f,herew+1,hereh,w,h);
		return cnt+1;
	}
	
    public static void main(String[] args) {
        try(Scanner sc = new Scanner(System.in)){
        	while(sc.hasNext()) {
        		int w = sc.nextInt();
        		int h = sc.nextInt();
        		if(w+h==0)break;
        		char[][] f = new char[h+1][w+1];
        		int hereh = 0;
        		int herew = 0;
        		for(int i=0;i<h;i++) {
        			String str =sc.next();
        			for(int j=0;j<w;j++) {
        				f[i][j] = str.charAt(j);
        				if(f[i][j]=='@') {
        					hereh =i;
        					herew = j;
        					f[i][j]='#';
        				}
        			}
        		}
        		
        		System.out.println(turn(f,herew,hereh,w,h));
        	}
        }
    }
}





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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init));

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};
const int PrimeMax = 123457 * 2;
int is_prime[PrimeMax];
int sum[PrimeMax];
void Eratosthenes(int N){
  for(int i = 0; i < N; i++){
    is_prime[i] = 1;
  }
  is_prime[0] = 0;
  is_prime[1] = 0;
  for(int i = 2; i*i < N ; i++){
    if(is_prime[i]){
      for(int j = 0; i * (j + 2) < N; j++){
        is_prime[i *(j + 2)] = 0;
      }
    }
  }
  REP(i,1,PrimeMax){
    sum[i] += is_prime[i] + sum[i-1];
  }
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  Eratosthenes(PrimeMax);
  ll n;
  while(cin >> n && n){
    cout << sum[2*n] - sum[n]<<endl;
  }
  return 0;
}

Measured memory_bytes: 5128
#include <stdio.h>
#include <math.h>
 
#define gc() getchar_unlocked()
int in()
{
    int n = 0, c = gc();
    do n = 10*n + (c & 0xf), c = gc();
    while (c >= '0');
    return n;
}
 
int x[102], y[102];
 
int main()
{
    int n, i, t, t2;
    int d, d1, d2;
    long long d3;
     
    n = in();
    for (i = 0; i < n; i++) x[i] = in();
    for (i = 0; i < n; i++) y[i] = in();
    d = 0, d1 = 0, d2 = 0, d3 = 0;
    for (i = 0; i < n; i++) {
        t = x[i] - y[i];
        if (t < 0) t = -t;
        if (t > d) d = t;
        d1 += t;
        t2 = t*t, d2 += t2;
        d3 += t2*t;
    }
    printf("%d\n", d1);
    printf("%.8lf\n", sqrt((double)d2));
    printf("%.8lf\n", pow((double)d3, 1.0/3));
    printf("%d\n", d);
    return 0;
}


Measured memory_bytes: 2132
#include<bits/stdc++.h>
using namespace std;
int main()
{

    int a,b,c,d,e,f;
    while(cin>>a)
    {
        cin>>b>>c;
        e=0;
        for(d=b;d<=c;d++)
        {
            if(d%a==0)
            {
                e=1;
            }
        }
        if(e)cout<<"OK"<<endl;
        else cout<<"NG"<<endl;



    }






    return 0;
}


Measured memory_bytes: 3640
# c = list(map(int, input().split()))
# a, b, c = map(int, input().split())
# a = [list(map(int, list(input()))) for i in range(n)]
n, a, b = map(int, input().split())

m = n % (a + b)

if (m <= a):
    v = m
else:
    v = a

print(int(n / (a + b)) * a + v)


Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;

#define rep(i,beg,end)   for (auto i=(beg);i<(end);i++)
#define all(cont)           begin(cont), end(cont)
#define rall(cont)           rbegin(cont), rend(cont)
using ll = long long;
using vi = vector<ll>;
const ll INFMAX = LLONG_MAX;
const ll INFMIN = LLONG_MIN;
const ll MOD = 1000000007;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	vi b(n - 1);
	rep(i, 0, n - 1)cin >> b[i];
	ll c = b[0] + b[n - 2];
	rep(i, 0, n-2) {
		c += min(b[i], b[i+1]);
	}
	cout << c << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
// constexpr ll MOD = 998244353;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<int> par;
    
//     UnionFind(int N): par(N) {
//         for (int i=0;i<N;i++) par[i] = i;
//     }

//     int root(int x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//     }

//     bool same(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         return rx == ry;
//     }
// };

int main(void) {
    int X, K;
    cin >> K >> X;
    if (500*K >= X) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdint.h>

using namespace std;

int main()
{
	cin.tie(0);ios::sync_with_stdio(false);
	/* ====================================== */
	int K, A, B;
	cin >> K >> A >> B;

	if(B - A < 3){
		cout << (1 + K);
	}else{
		if(K < A){
			cout << (1 + K);
		}else{
			int n = K - A + 1;
			int mult = n / 2;
			int ad = n % 2;
			uint64_t res = (uint64_t) A + ((uint64_t)(B - A)) * mult + ad;
			
			cout << res;
		}
	}

	/* ====================================== */
	return 0;
}

Measured memory_bytes: 256
my ($N, $M, $C) =  split(' ', <>);
my @B =  split(' ', <>);

my $count = 0;
for my $i ( 1 .. $N ) {
    my @A = split(' ', <>);
    my $calc = $C;
    $calc += $A[$_] * $B[$_] for ( 0..$M-1 );
    $count++ if $calc > 0;
}
print $count;

Measured memory_bytes: 512
n = int(raw_input())
inpt = []
for i in range(0, n):
	inpt.append(int(raw_input()))

inpt.sort()
tmp = -1
cnt = 0

for i in range(0, n):
	if inpt[i] != tmp:
		cnt = cnt + 1
		tmp = inpt[i]

print cnt

Measured memory_bytes: 2568
#include<stdio.h>
#include<string.h>
char a[100000],b[100000];
int main(){
    int ans;
    scanf("%s%s",a,b);
    int len1 = strlen(a);
    int len2 = strlen(b);
    int i = -2;
    if(len1>len2) ans = 1;
    else if(len1<len2) ans = -1;
    else{
        for(i = 0; i <len1; i++){
            if(a[i]>b[i]){
                ans = 1;
                break;
            }
            if(a[i]<b[i]){
                ans = -1;
                break;
            }
        }
        if(i == -1) ans = 0;
    }
    if(ans == 1) printf("GREATER");
    else if(ans == -1) printf("LESS");
    else printf("EQUAL");

    return 0;
}


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

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] nk = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var ps = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            Array.Sort(ps);
            int cnt = 0;
            int sum = 0;
            int tmp = 0;
            foreach(int i in ps)
            {
                if(tmp != i)
                {
                    cnt++;
                    sum += i;
                }
                if(cnt >= nk[1])
                {
                    Console.WriteLine(sum);
                    return;
                }
            }
            
        }
    }
}

Measured memory_bytes: 28292
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <queue>
#include <math.h>
#include <assert.h>
#include <set>
#include <map>
#include <bitset>
#include <ctime>
#include <time.h>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <stack>
#include <ctype.h>
#include <numeric>
#include <sstream>
#include <unistd.h>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <random>
#include <chrono>
#include <iomanip>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
#define endl '\n'
#define debug(name) DEBUG(#name, (name))
template<typename T>
void DEBUG(string label, T value) {
    cerr << "[" << label << " = " << value << "]\n";
}

void solve(){
    int n;
    cin >> n;
    map<string, int> mp;
    for(int i = 0; i < n; ++i){
        string s;
        cin >> s;

        mp[s]++;
    }
    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;
}

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

    int t;
    t = 1;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 3624
# -*- coding: utf-8 -*-
n, k = map(int, input().split())
s = input()
nums = []
now = 1

cnt = 0
for i in range(n):
    if s[i] == str(int('0') + now):
        cnt += 1
    else:
        nums.append(cnt)
        now = 1 - now
        cnt = 1

if cnt != 0:
    nums.append(cnt)

t = [0]
for i in range(len(nums)):
    t.append(t[i] + nums[i])

ans = 0
for i in range(0, len(nums), 2):
    left = i
    right = min(i + 2 * k + 1, len(nums))

    ans = max(ans, t[right] - t[left])

print(ans)


Measured memory_bytes: 7932
'use strict'

function Main(input){
	let temp = input.trim().split("\n");
	let NM = temp[0].split(" ").map( (v)=>(parseInt(v)) );
	//let AB = new Array(NM[0]);
	//for(let i=0;i<NM[0];i++){
	//	AB[i] = temp[i+1].split(" ").map( (v)=>(parseInt(v)) );
	//}

	let AB = [];
	for(let i=0;i<NM[0];i++){
		var obj = {
			a : Number(temp[i+1].split(" ")[0]),
			b : Number(temp[i+1].split(" ")[1])
		};
		AB.push(obj);
	}
	AB.sort((x,y)=>(x.a - y.a));

	let money = 0;
	let count = NM[1];
	for(let i=0;count>0;i++){
		var num = Math.min(count,AB[i].b);
		money += num*AB[i].a;
		count -= num;
	}
	console.log(money);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

public class Main {
    // 要素数　最後の位置
    public static int top = 0;
    public static int[] stack = new int[200];

    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        ArrayDeque<Integer> st = new ArrayDeque<>();
        String[] inputStr = sc.nextLine().split(" ");


        // stack を　使うやり方
        for(String str : inputStr){
            if(str.equals("+")){
                int a = st.pop();
                int b = st.pop();
                st.push(a + b);
            }else if(str.equals("-")){
                int a = st.pop();
                int b = st.pop();
                st.push(b - a);
            }else if(str.equals("*")){
                int a = st.pop();
                int b = st.pop();
                st.push(a * b);
            }else{
                st.push(Integer.parseInt(str));
            }
        }
        System.out.println(st.pop());


        // stackを再現するやり方

        /*
        for(String str : inputStr){
            if(str.equals("+")){
                int a = pop();
                int b = pop();
                push(a + b);
            }else if(str.equals("-")){
                int a = pop();
                int b = pop();
                push(b - a);
            }else if(str.equals("*")){
                int a = pop();
                int b = pop();
                push(a * b);
            }else{
                push(Integer.parseInt(str));
            }
        }
        System.out.println(pop());
        
         */



    }
    public static void push(int x){
        top++;
        stack[top] = x;
    }
    public static int pop(){
        top--;
        return stack[top+1];
    }


    static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

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

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

            return tokenizer.nextToken("\n");
        }

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

        public long nextInt() {
            return Integer.parseInt(next());
        }

    }
}


Measured memory_bytes: 24548
n = int(input())
a_list = list(map(int, input().split())) 
x_list = [0 for i in range(n-1)]
a = 0
for i in range(n-1):
	a += a_list[i]
	x_list[i] = a
total = sum(a_list)
r = abs(total - x_list[0]*2)
for x in x_list:
	r = min(r, abs(total - x*2))
print(r)


Measured memory_bytes: 86736
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll=long long;
int main(void){
    vector<vector<ll>> val(4,vector<ll>(1,0));
    ll N,W;
    cin>>N>>W;
    
    ll ans=0;
    ll base,bv;
    cin>>base>>bv;
    val[0].push_back(bv);
    for(int i=1;i<N;i++){
        ll w,v;
        cin>>w>>v;
        val[w-base].push_back(v);
    }
    for(auto &p : val){
        sort(p.rbegin(), p.rend()-1);
        for(int i=1;i<p.size();i++){
            p[i]+=p[i-1];
        }
    }
    for(int i=0;i<val[0].size();i++){
        for(int j=0;j<val[1].size();j++){
            for(int k=0;k<val[2].size();k++){
                for(int l=0;l<val[3].size();l++){
                    if(base*(i+j+k+l)+j+2*k+3*l<=W){
                        ans=max(ans,val[0][i]+val[1][j]+val[2][k]+val[3][l]);
                    }
                }
            }
        }
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
  int i, n, q, q1, q2, arr[100011], num_ap[100011] = {0};
  long sum = 0, ans[100011];
  scanf("%d", &n);
  for(i = 0 ; i < n ; i++)
  {
    scanf("%d", &arr[i]);
    num_ap[arr[i]]++;
    sum += arr[i];
  }
  scanf("%d", &q);
  for(i = 0 ; i < q ; i++)
  {
      scanf("%d %d", &q1, &q2);
      long nums = num_ap[q1];
      num_ap[q1] = 0;
      num_ap[q2] += nums;
      sum += (q2 * nums);
      sum -= (q1 * nums);
    printf("%ld\n",sum);
  }
  return 0;
}


Measured memory_bytes: 4540
# -*- coding: utf-8 -*-
from fractions import Fraction as F

def solve():
    N, K = map(int,input().split())
    P = list(map(int,input().split()))
    q = sum(P[:K])
    res = q
    for i in range(K,N):
        q += P[i]-P[i-K]
        res = max(res, q)
    return str((res+K)/2)

if __name__ == '__main__':
    print(solve())

Measured memory_bytes: 27088
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = 10**6#float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

S = list(input())
T = list(input())

n = len(T)
ans = INF
for i in range(len(S)-n+1):
	s = S[i:i+n]
	tmp = 0
	for j in range(n):
		if s[j] != T[j]:
			tmp += 1
	ans = min(ans, tmp)
print(ans)

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

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

  int w = 0;
  for (int i = 0; i < N; i++){
    if (S[i] == 'W') w++;
  }

  int ans = 0;
  for (int i = 0; i < w; i++){
    if (S[N - 1 - i] == 'R') ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3752
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N, M;
    scan(N, M);
    auto ps = factorize(M);
    long ans = 1;
    foreach (cnt; ps.values())
    {
        // writeln(f(N - 1));
        ans = (ans * ((f(cnt + N - 1) * invmod(f(N - 1) * f(cnt) % MOD)) % MOD)) % MOD;
    }
    writeln(ans);

}

T invmod(T = long)(T x, T m = 10 ^^ 9 + 7)
{
    T powmod(T = long)(T x, T n, T m)
    {
        if (n < 1)
            return 1;
        if (n & 1)
        {
            return x * powmod(x, n - 1, m) % m;
        }
        T tmp = powmod(x, n / 2, m);
        return tmp * tmp % m;
    }

    return powmod(x, m - 2, m);
}

long f(long x)
{
    long ans = 1;
    foreach (i; 2 .. x + 1)
        ans = (ans * i) % MOD;
    return ans;
}

/// 素因数分解
long[long] factorize(long x)
{
    assert(0 < x, "x is negative");
    long[long] ps;
    while ((x & 1) == 0)
    {
        x /= 2;
        ps[2] = (2 in ps) ? ps[2] + 1 : 1;
    }
    for (long i = 3; i * i <= x; i += 2)
        while (x % i == 0)
        {
            x /= i;
            ps[i] = (i in ps) ? ps[i] + 1 : 1;
        }
    if (x != 1)
        ps[x] = (x in ps) ? ps[x] + 1 : 1;
    return ps;
}


Measured memory_bytes: 256