akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

/* DEBUGGING */
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif

/* MACROS */ 
typedef unsigned long long int ll;
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

typedef map<int,int> mii;

#define  ff          first
#define  ss          second
#define  pb          push_back
#define  IOS         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  lb          lower_bound
#define  ub          upper_bound
#define  all(x)      (x).begin(), (x).end()
#define  ps(x,y)     fixed<<setprecision(y)<<x
#define  setbit(x)   __builtin_popcountll(x)
#define  rep(i,a,b)  for(int i=a ; i<b ; ++i)
#define  repr(i,a,b) for(int i=a ; i>=b ; --i)

/* CONSTANTS */ 
#define PI 3.141592653589793
const ll MOD = 1e9 + 7;
const ll INF = 1000000000;
const ll MAX_N = 2e5 + 2;

// #define cerr if(false)cerr
/* CODE STARTS HERE */

void solve(){
    int n,q; cin >> n >> q;
    string s; cin >> s;
    vi pre(n+1,0);
    pre[1] = 0;
    
	rep(i,1,n){
		if(s[i]=='C' && s[i-1]=='A'){
			pre[i+1] += pre[i]+1;
		} else pre[i+1] = pre[i];
	}
	
	while(q--){
		int l,r; cin >> l >> r;
		cout << max(0 , pre[r] - pre[l]) << "\n";
	}
}

int main(){
    IOS;
    solve();
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(20);
  int a, b, v, w, t;
  cin>>a>>v>>b>>w>>t;
  int d = abs(a-b);
  int s = v - w;
  if(s<0) {
    cout<<"NO"<<endl;
    return 0;
  }
  if(s*1LL*t >= d) {
    cout<<"YES"<<endl;
  }
  else cout<<"NO"<<endl;
}



Measured memory_bytes: 3604
# ABC 119: B – Digital Gifts
n = int(input())

x = []
u = []

for i in range(n):
    tmp = [s for s in input().split()]
    x.append(float(tmp[0]))
    u.append(tmp[1])

total_otoshidama = 0

for i in range(n):
    if u[i] == 'BTC':
        total_otoshidama += x[i] * 380000
    else:
        total_otoshidama += x[i]

print(total_otoshidama)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

long long n, k;
long long a[2 * 100000 + 10], aib[2 * 100000 + 10];
long long sum[2 * 100000 + 10];

void read() {
    cin >> n >> k;
    long long s = 0;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        s += a[i];
        sum[i] = s;
    }
}

long long c[2 * 100000 + 10];

void normalize() {
    vector<pair<long long, long long>> v;
    v.push_back(make_pair(0, 1));
    for(long long i = 1; i <= n; i++) {
        v.push_back(make_pair(sum[i] - i * k, i + 1));
    }
    sort(v.begin(), v.end());
    int k = 1;
    for(int i = 0; i < v.size(); i++) {
        if(i && v[i].first != v[i - 1].first) {
            k++;
        }
        c[v[i].second] = k;
    }
}

inline long long zeros(long long x) {
    return (x ^ (x - 1)) & x;

}

void add(long long x, long long up) {
    for(long long i = x; i <= 2 * 100000; i += zeros(i)) {
        aib[i] += up;
    }
}

long long s(long long x) {
    long long res = 0;
    for(long long i = x; i >= 1; i -= zeros(i)) {
        res += aib[i];
    }
    return res;
}

int main()
{
    long long res = 0;
    read();
    normalize();
    
    for(int i = 1; i <= n + 1; i++) {
        res += s(c[i]);
        add(c[i], 1);
    }
    
    cout << res;
    return 0;
}


Measured memory_bytes: 11120
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<unistd.h>
#include <array>
#include <map> 




using namespace std;
typedef long long ll;
struct point{
  int x;
  int y;

};
int gcd(int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}

int moji(char in)
{
    int ans = (int)in-(int)'a';
    if((ans < 0) || (ans > 25)){
        ans = 26;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}

int binary_searchh(long long x,long long k[],int n){
  int l=0;
  int r=n;
  while(r-l>=1){
    int i=(l+r)/2;
    if(k[i]==x)return i;
    else if(k[i]<x)l=i+1;
    else r=i;
  }
  return -1;
}

struct File {
    int aa;
    int bb;

    File(const int& aa, const int& bb)
        : aa(aa), bb(bb) {}
};

bool operator<(const File& a, const File& b)
{
    // ファイル種別、ファイル名の順番で優先順位を付けて比較
    return std::tie(a.aa, a.bb) < std::tie(b.aa, b.bb);
}




int main(){
  long long N;
  cin>>N;
  long long A[N];
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  long long B[N];
  for(int i=0;i<N;i++){
    B[i]=A[i]-i-1;
  }
  
  sort(B,B+N);
  long long sum=0;
  if(N%2==0){
    long long x=B[N/2];
    for(int i=0;i<N;i++){
      sum+=abs(B[i]-x);

    }
  }else{
    long long x=B[N/2];
    long long y=B[N/2+1];
    long long tmp=0;
    long long tmpp=0;
    for(int i=0;i<N;i++){
      tmp+=abs(B[i]-x);
      tmpp+=abs(B[i]-y);
    }
    sum=min(tmp,tmpp);
  }
  cout<<sum<<endl;



  


}


  

Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define ll long long int
#define vec vector<ll>
#define mat vector<vec>

using namespace std;

const ll mod=1000000007;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

int main(){

  ll d,t,s;
  cin >> d >> t >> s;
  if(t*s>=d)cout << "Yes" << endl;
  else cout << "No" << endl;

}

Measured memory_bytes: 3636
from collections import deque
N = int(input())


# 最大公約数
def gcd(a, b):
    while b > 0:
        a, b = b, a%b
    return a


# 最小公倍数
def lcm(a, b):
    return a*b//gcd(a, b)


array = []
for _ in range(N):
    array.append(int(input()))

ans = array[0]
for x in array[1:]:
    ans = lcm(ans, x)


print(ans)

Measured memory_bytes: 3316
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>

 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define LLIandI pair<long long int , int>
#define ll long long
int main(void){
    int N;
    long long int C;
    scanf("%d %lld",&N,&C);
    long long int x[100004];
    long long int v[100004];
    long long int v_inc[100004];
    long long int v_inc_max[100004];
    long long int v_dec[100004];
    long long int v_dec_max[100004];
    rep(i,N){
        scanf("%lld %lld",&x[i],&v[i]);
        i==0 ? (v_inc[i]=v[i]-x[i]) : (v_inc[i]=v_inc[i-1]+v[i]-(x[i]-x[i-1]) );
        i==0 ? (v_inc_max[i]= v_inc[i]) : (v_inc_max[i]=max(v_inc[i],v_inc_max[i-1]));
    }
    rep(i,N){
        int j=N-1-i;
        i==0?(v_dec[j]=v[j]-(C-x[j])) : (v_dec[j]=v_dec[j+1]+v[j]-(x[j+1]-x[j]) );
        i==0?(v_dec_max[j]= v_dec[j]) : (v_dec_max[j]=max(v_dec[j],v_dec_max[j+1]));
    }
    
    long long int ans=0;//動かないという選択肢
    rep(i,N){
        if(i==N-1 || v_dec_max[i+1]<=x[i]){ans=max(ans,v_inc[i]);continue;}//方向転換しないのがベスト
        else{ans=max(ans,v_inc[i]-x[i]+v_dec_max[i+1]);continue;}//方向転換するのがベスト
    }
    //from decriment
    rep(i,N){
        int j=N-1-i;
        if(j==0||v_inc_max[j-1]<=C-x[j]){ans=max(ans,v_dec[j]);continue;}
        else{ans=max(ans,v_dec[j]-(C-x[j])+v_inc_max[j-1]);continue;}//方向転換するのがベスト
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 4864
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <climits>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

#define ll long long

using namespace std;

const ll INF = LLONG_MAX / 2 - 1;


struct Edge {
	ll t;
	ll c;
	Edge(ll to, ll cost):t(to),c(cost){}
	Edge(){}
};

vector<ll> weigh;
ll R, C;
ll xmin, ymin;

bool DFS(ll node, vector<vector<Edge> >& edge) {
	if (node < R) xmin = min(xmin, weigh[node]);
	else ymin = min(ymin, weigh[node]);
	for (auto &to : edge[node]) {
		if (weigh[to.t] == INF) {
			weigh[to.t] = to.c - weigh[node];
			if (not DFS(to.t, edge)) return false;
		}
		else {
			if (weigh[to.t] + weigh[node] != to.c) return false;
		}
	}
	return true;
}
int main() {
	cin >> R >> C;
	ll N;
	cin >> N;
	weigh.resize(R + C, INF);
	vector<vector<Edge> > edge(R+C);
	for(int i = 0; i < N; i++){
		ll r, c, a; cin >> r >> c >> a;
		--r; --c;
		edge[r].push_back(Edge(R+c,a));
		edge[R+c].push_back(Edge(r, a));
	}

	bool res = true;
	for(int i = 0; i < R + C; i++){
		xmin = ymin = INT_MAX;
		if(weigh[i] == INF and edge[i].size() > 0) {
			weigh[i] = 0;
			if (not DFS(i,edge) or xmin+ymin < 0) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 16384
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <iomanip>
using namespace std;

const int LIMIT = 101;

int main()
{
	int n, m;
	double g[ LIMIT ][ LIMIT ];
	double dp[ LIMIT ][ LIMIT ];

	while( cin >> n >> m && ( n || m ) ){
		memset( g, 0, sizeof(g) );
		memset( dp, 0, sizeof(dp) );
		for( int i = 0; i < n; ++i ){
			for( int j = 0; j < n; ++j ){
				cin >> g[ i ][ j ];
			}
		}
		for( int i = 0; i < n; ++i ){
			dp[ 1 ][ i ] = 1.0;
		}
		for( int i = 2; i <= m; ++i ){
			for( int j = 0; j < n; ++j ){
				for( int k = 0; k < n; ++k ){
					dp[ i ][ j ] = max( dp[ i ][ j ], dp[ i - 1 ][ k ] * g[ k ][ j ] );
				}
			}
		}
		double result = 0.0;
		for( int i = 0; i < n; ++i ){
			result = max( result, dp[ m ][ i ] );
		}
		cout << fixed << setprecision( 2 ) << result << endl;
	}

	return 0;
}

Measured memory_bytes: 1452
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;

template <typename X>
struct RMQ{
  vector<X> dat;
  int n;
  X init;
  
  RMQ(int _n,X _init)
  {
    n = 1;
    init = _init;
    while(n < _n) n *= 2;
    dat.resize(2*n-1);
    rep(i,2*n-1){
      dat[i] = init;
    }
  }
  
  void update(int k,X a)
  {
    k += n - 1;
    dat[k] = a;
    while(k > 0){
      k = (k - 1)/2;
      dat[k] = min(dat[2*k+1],dat[2*k+2]);
    }
  }
  
  X query(int a,int b,int k,int l,int r)
  {
    if(r<=a||b<=l) return init;

    if(a<=l&&r<=b) return dat[k];
    else{
      X vl = query(a,b,2*k+1,l,(l+r)/2);
      X vr = query(a,b,2*k+2,(l+r)/2,r);
      return min(vl,vr);
    }
  }
};

int main()
{
  int n,m;
  cin >> n >> m;
  string s;
  cin >> s;
  const int inf=1e+9;
  
  RMQ<int> rmq(n+1,inf);

  rmq.update(0,0);

  rep1(i,n){
    if(s[i]=='1'){
      continue;
    }
    int l=max(0,i-m);
    int d=rmq.query(l,i,0,0,rmq.n)+1;
    rmq.update(i,d);
  }

  vector<int> dp(n+1);
  rep(i,n+1){
    dp[i]=rmq.dat[i+rmq.n-1];
  }

  if(dp[n]>=inf){
    cout << -1 << "\n";
    return 0;
  }
  
  vector<int> res(0);
  int l = dp[n];
  int i=n;
  while(i>0){
    int x;
    rep1(j,m){
      if(i-j<0) break;
      if(dp[i-j]==l-1){
  	x = j;
      }
      else if(dp[i-j]==l-2){
  	break;
      }
    }
    res.push_back(x);
    i = i-x;
    l--;
  }

  reverse(res.begin(), res.end());
  rep(i,res.size()){
    cout << res[i] << " ";
  }
  cout  << "\n";
  
  return 0;
}


Measured memory_bytes: 2552
while True:
    n = int(raw_input())
    if n == 0:
        break
    d = dict([raw_input().split() for _ in range(n)])
    m = int(raw_input())
    s = ''
    for _ in range(m):
        b = raw_input().split()
        if b[0] in d:
            s += d[b[0]]
        else:
            s += b[0]
    print s

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define POINT_MAX 50
#define ll long long

int main(void) {
    int n, k;
    ll x[POINT_MAX], y[POINT_MAX];
    ll ans=LONG_LONG_MAX;
    cin >> n >> k;
    rep(i, n) cin >> x[i] >> y[i];
    rep(l, n) {
        rep(r, n) {
            if (x[l] >= x[r]) continue;
            rep(b, n) {
                rep(t, n) {
                    if (y[b] >= y[t]) continue;
                    int cnt = 0;
                    rep(i, n) {
                        if (x[i]>=x[l] and x[i]<=x[r] and y[i]>=y[b] and y[i]<=y[t]) cnt++;
                    }
                    if (cnt>=k) ans=min(ans, (x[r]-x[l])*(y[t]-y[b]));
                }
            }
        }
    }
    cout << ans << endl;
    return 0; 
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  int wa = 0;
  int n = N;
  while(n){
    wa += n % 10;
    n /= 10;
  }
  cout<<(N%wa==0?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
S=str(input())

count=0
maxcount=0
flg=True
for i in range(3):
  ##print(i)
  ##print(S[i:i+1])
  ##print(count)
  if S[i:i+1]=='R':
    if i>0 and S[i-1:i]=='R':
      count+=1
    else:
      count=1
print(str(count))    

Measured memory_bytes: 61636
#include<stdio.h>
#include<math.h>
#define RADIAN1 3.141592654/180.0
double area(int,int,double);
double circum(int,int,double);
double height(int,double);

int main(){
  int a,b,angle;
  double s,l,h;

  scanf("%d%d%d",&a,&b,&angle);
  printf("%.5f\n%.5f\n%.5f\n",area(a,b,RADIAN1*angle),circum(a,b,RADIAN1*angle),height(b,RADIAN1*angle));

 
  
  return 0;
}

double area(int a,int b,double angle){
  return a*b*sin(angle)/2.0;
}

double circum(int a,int b,double angle){
  return a+b+sqrt(a*a+b*b-2*a*b*cos(angle));
}
double height(int b,double angle){
  return b*sin(angle);
}

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

ll k, mod=1e9+7, fac[2000010], pa[2][2000010];
string s;

ll p(ll a, ll b) {
	if (b==0) return 1;
	ll ans=p(a, b/2);
	ans*=ans;
	ans%=mod;
	if (b%2==1) ans*=a;
	ans%=mod;
	return ans;
}

ll comb(ll a, ll b) {
	if (a==b||b==0) return 1;
	ll ans=fac[a];
	ans*=p(fac[b], mod-2);
	ans%=mod;
	ans*=p(fac[a-b], mod-2);
	ans%=mod;
	return ans;
}

int main() {
	cin>>k;
	cin>>s;
	pa[0][0]=1, pa[1][0]=1;
	for (int i=0; i<2000010; i++) {
		if (i<2) fac[i]=1;
		else fac[i]=fac[i-1]*i;
		fac[i]%=mod;
		if (i>0) {
			pa[0][i]=pa[0][i-1]*25;
			pa[0][i]%=mod;
			pa[1][i]=pa[1][i-1]*26;
			pa[1][i]%=mod;
		}
	}
	ll len=s.size(), n=len+k, ans=0;
	for (int i=len-1; i<n; i++) {
		//cout<<"i: "<<i<<endl;
		ll tambah=comb(i, len-1)*pa[0][i-len+1];
		tambah%=mod;
		//cout<<"test"<<endl;
		tambah*=pa[1][n-i-1];
		tambah%=mod;
		ans+=tambah;
		ans%=mod;
	}
	cout<<ans<<endl;
}



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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int n; std::cin >> n;
  vi a(n); rep(i, n) std::cin >> a[i];
  int MAX = 2*1e5+5;
  map<int, int> r;
  rep(i, n) {
    int x = i-a[i];
    r[x]++;
  }
  ll ans = 0;
  rep(i, n) {
    int l = i+a[i];
    ans += r[l];
  }
  std::cout << ans << "\n";
}


Measured memory_bytes: 21084
import java.util.*;


public class Main {

	// test 2 B - String Palindrome
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		int amount = sc.nextInt();

		// 500
		int c500=0;
		c500 = amount/500;
		
		// 5
		int c5 = (amount - (c500 * 500)) / 5;

		// calc 嬉しさ
		log( c500 * 1000 + c5 * 5 );
		
		sc.close();
	}

	static void log(int i) {
		System.out.println(i);
	}
	
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main() {
  int64_t n,m,a,b,i,ans=0,c=0;
  map<int64_t,int64_t> mp;
  cin>>n>>m;
  for(i=0;i<n;i++){
    cin>>a>>b;
    if(mp.count(a)) mp.at(a)+=b;
    else mp[a]=b;
  }
  for(auto z:mp){
    ans+=z.first*z.second;
    c+=z.second;
    if(c>=m){
      ans-=z.first*(c-m);
      break;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 9800
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    long long N, X; cin >> N >>X;
    vector<long long> x(N);
    for (long long i = 0; i < N; i++)
        cin >> x[i];
    x.push_back(X);

    sort(x.begin(), x.end());
    vector<long long> dist;
    for (long long i = 1; i < x.size(); i++)
        dist.push_back(x[i] - x[i-1]);

    long long ans = dist[0];
    for (long long i = 1; i < dist.size(); i++)
        ans = __gcd(ans, dist[i]);

    cout << ans << endl;
}

Measured memory_bytes: 2800
#include <stdio.h>

void BubSort(int x[ ], int n) {
    int i, j, temp;
    
    for (i = 0; i < n - 1; i++) {
        for (j = n - 1; j > i; j--) {
            if (x[j - 1] > x[j]) {
                temp = x[j];
                x[j] = x[j - 1];
                x[j - 1]= temp;
            }
        }
    }
}


int main(int argc, const char * argv[])
{
    int i, tmp;
    int height[10];
    
    for (i = 0; i < 10; i++) {
        scanf("%d", &tmp);
        height[i] = tmp;
    }
    BubSort(height, 10);

    for (i = 9; i >= 7; i--) {
        printf("%d\n", height[i]);
    }
    return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;

public class Main {

    public static void main(final String[] args) {

        try (final Scanner sc = new Scanner(System.in)) {
            final int H = sc.nextInt();
            final int W = sc.nextInt();
            final int h = sc.nextInt();
            final int w = sc.nextInt();
            final int total = H * W;
            System.out.println(total - (h * W + (H - h) * w));
        }
    }
}


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

int main(){
  string s;
  cin >> s;
  int counter = 0;
  if(s[0] == 'o') ++counter;
  if(s[1] == 'o') ++counter;
  if(s[2] == 'o') ++counter;
  cout << 700 + 100 * counter << endl;
}

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

int main() {
    int a, b, d, r;
    double f;
    cin >> a >> b;
    d = a / b;
    r = a % b;
    f = (double) a / b;
    cout << d << " " << r << " " << fixed << setprecision(10) << f << endl;
    return 0;
}




Measured memory_bytes: 3284
#include<stdio.h>
int main(void){
	int a[102][102],b,i,j,k,m,n,l,x,r,f;
	char d;

	scanf("%d %d",&m,&n );
	for(i=0;i<m;++i){
		a[i][n]=0;
		for(j=0;j<n;++j){
			scanf("%*c%d",&a[i][j] );
			a[i][n]=a[i][n]+a[i][j];
		}
	}
	for(i=0;i<n+1;++i){
		a[m][i]=0;
		for(j=0;j<m;++j){
			a[m][i]=a[m][i]+a[j][i];
		}
	}
	for(i=0;i<m+1;++i){
		for(j=0;j<n+1;++j){
			if(j==n){
				printf("%d",a[i][j] );
			}
			else printf("%d ",a[i][j]);
		}
		printf("\n" );
	}
	return 0;
}

Measured memory_bytes: 644
### constant

#     (+x,+y,+z)
DICE = [1, 2, 3]

### subroutines

def rot_x(dc0, n = 1)
  dc = dc0.clone
  n.times.each{tmp = dc[1]; dc[1] = 7 - dc[2]; dc[2] = tmp}
  dc
end

def rot_y(dc0, n = 1)
  dc = dc0.clone
  n.times.each{tmp = dc[2]; dc[2] = 7 - dc[0]; dc[0] = tmp}
  dc
end

def rot_z(dc0, n = 1)
  dc = dc0.clone
  n.times.each{tmp = dc[0]; dc[0] = 7 - dc[1]; dc[1] = tmp}
  dc
end

def right_sum()
  rsum = 0
  for x in (0...3)
    for y in (0...3)
      posz = x * 9 + y * 3
      d = $cbs[posz][2] | $cbs[posz + 1][2] | $cbs[posz + 2][2]
      rsum += d
    end
  end
  rsum
end

def rec(k)
  if k >= 27
    $rsums[right_sum()] = true
    return
  end

  x = k / 9
  y = (k / 3) % 3
  z = k % 3

  posx = k - x * 9
  posy = k - y * 3
  posz = k - z
  xd = $cbs[0 * 9 + posx][0] | $cbs[1 * 9 + posx][0] | $cbs[2 * 9 + posx][0]
  yd = $cbs[0 * 3 + posy][1] | $cbs[1 * 3 + posy][1] | $cbs[2 * 3 + posy][1]
  zd = $cbs[0 * 1 + posz][2] | $cbs[1 * 1 + posz][2] | $cbs[2 * 1 + posz][2]

  cbsk = $cbs[k]

  $alldcs.each do |dc|
    if (xd != 0 && xd != dc[0]) ||
       (yd != 0 && yd != dc[1]) ||
       (zd != 0 && zd != dc[2])
      next
    end

    $cbs[k] = dc
    rec(k + 1)
    $cbs[k] = cbsk
  end
end

### main

$alldcs = []

for zr in (0...4)
  for yr in (0...4)
    for xr in (0...4)
      $alldcs << rot_z(rot_y(rot_x(DICE, xr), yr), zr)
    end
  end
end
$alldcs.sort!.uniq!
$nalldcs = $alldcs.length
#p $alldcs

n = gets.to_i

n.times do
  $cbs = 27.times.map{[0] * 3}

  for y in (0...3)
    tys = gets.split.map(&:to_i)
    for z in (0...3)
      tyz = tys[z]
      next if tyz == 0
      for x in (0...3)
        pos = x * 9 + y * 3 + z
        $cbs[pos][0] = tyz
      end
    end
  end

  for x in (0...3)
    fxs = gets.split.map(&:to_i)
    for z in (0...3)
      fxz = fxs[z]
      next if fxz == 0
      for y in (0...3)
        pos = x * 9 + y * 3 + z
        $cbs[pos][1] = fxz
      end
    end
  end
  #p $cbs; exit

  $rsums = {}

  rec(0)

  rs = $rsums.keys.sort
  puts rs.empty? ? 0 : rs.join(' ')
end

Measured memory_bytes: 6132
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
typedef long long ll;
ll ans;int len;char num[15];
void DFS(int x,ll sum)
{
	if(x==len)
	{
		ans+=sum;
		return ;
	}
	ll tot=0;
	for(int i=x;i<len;i++)
	{
		tot=tot*10ll+num[i]-'0';
		DFS(i+1,sum+tot);
	}
}
int main()
{
	scanf("%s",num);
	len=strlen(num);
	DFS(0,0);
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl

using namespace std;
using lli = long long int;

lli mod197 = 1000000007LL;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

lli memoT['z' - 'a' + 1] = {};
lli memoS['z' - 'a' + 1] = {};

int main(void) {

	string s, t;
	cin >> s >> t;

	int N = s.size();

	int countT = 1, countS = 1;

	for (int i = 0; i < N; i++) {
		if(memoT[t[i] - 'a'] == 0)
			memoT[t[i] - 'a'] = countT++;

		t[i] = memoT[t[i] - 'a'];

		if (memoS[s[i] - 'a'] == 0)
			memoS[s[i] - 'a'] = countS++;

		s[i] = memoS[s[i] - 'a'];
	}


	for (int i = 0; i < N; i++) {
		if (s[i] != t[i]) {
			COUT("No");
			return 0;
		}
	}

	COUT("Yes");

	return 0;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
int N, Q;
string S;
vector<int> l(100010);
vector<int> r(100010);
vector<int> num(100010, 0);

int main() {
    cin >> N >> Q;
    cin >> S;
    for(int i = 0; i < Q; ++i) {
        cin >> l.at(i) >> r.at(i);
    }

    for(int i = 0; i < N-1; ++i) {
        if(S.at(i) == 'A' && S.at(i+1) == 'C') {
            num.at(i+1) = num.at(i) + 1;
        }else {
            num.at(i+1) = num.at(i);
        }
    }

    for(int i = 0; i < Q; ++i) {
        cout << num.at(r.at(i) - 1) - num.at(l.at(i) - 1) << endl;
    }
}

Measured memory_bytes: 2176
# coding: utf-8
# Your code here!
def main():
    while True:
        sum_a = 0
        sum_b = 0
        n = input()
        if n == '0':
            return 
        for i in range(int(n)):
            a,b = list(map(int, input().split()))
            if a > b:
                sum_a += a+b
            elif a < b:
                sum_b += a+b
            else:
                sum_a += a
                sum_b += b
        print(sum_a, sum_b)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5616
def Base_10_to_n(X, K):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%K)+out
        X_dumy = int(X_dumy/K)
    return out
n, k = map(int, input().split())
print(len(Base_10_to_n(n, k)))

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> auto compare = [](T x, T y) -> bool{return (x < y);};
const int MOD = 1000000007;

signed main(){
    char c;
    cin >> c;
    if('a' <= c && c <= 'z') PRINT("a");
    else PRINT("A");
    return 0;
}

Measured memory_bytes: 3628
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;

#define erep(i, x, n) for (auto i = x; i<=(ll)(n); i++)
#define rep(i, x, n) for(auto i = x; i<(ll)(n); i++)
#define all(v) ((v).begin()), ((v).end())
#define sz(v) ((int)((v).size()))
#define mod(n, m) ((n%m + m) % m)
#define reset(n, m) memset(n, m, sizeof n)
#define endl '\n'

const int N = 2e5 + 5;
ll sum[N], xorr[N];

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

	int n;
	cin >> n;
	erep(i, 1, n)
	{
		int x;
		cin >> x;
		xorr[i] = x ^ xorr[i - 1];
		sum[i] = x + sum[i - 1];
	}
	ll ans = 0;
	erep(i, 1, n)
	{
		int st = i, en = n, mid, ret = -1;

		while (st <= en)
		{
			mid = (st + en) / 2;

			if ((sum[mid] - sum[i - 1]) != (xorr[mid] ^ xorr[i - 1]))
				en = mid - 1;
			else
				st = mid + 1, ret = mid;
		}

		if (ret != -1)
			ans += (ret - i + 1);
	}
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 3328
struct Read<R: std::io::BufRead> {
    stdin: R,
    v: Vec<String>,
    i: usize,
}
impl<R:std::io::BufRead> Read<R> {
    pub fn new(stdin: R) -> Self {
        Read{
            stdin: stdin,
            v: Vec::new(),
            i: 0,
        }
    }
    pub fn read_line(&mut self) {
        self.i = 0; self.v.clear();
        let mut buf = String::new();
        self.stdin.read_line(&mut buf).unwrap();
        let buf = buf.trim().to_owned();
        let mut ws = buf.split_whitespace();
        loop {
            let x = ws.next();
            if x.is_none() {break;}
            let x = x.unwrap().to_owned();
            self.v.push(x);
        }
    }
    #[allow(dead_code)]
    pub fn read_t<T: std::str::FromStr>(&mut self) -> T {
        if self.i == self.v.len() {self.read_line();}
        let elem = &self.v[self.i];
        self.i += 1;
        elem.parse().unwrap_or_else(|_| panic!())
    }
    
    #[allow(dead_code)]
    pub fn read_i32(&mut self) -> i32 {
        if self.i == self.v.len() {self.read_line();}
        let elem = self.v[self.i].parse().unwrap();
        self.i += 1;
        elem
    }
    #[allow(dead_code)]
    pub fn read_usize(&mut self) -> usize {
        if self.i == self.v.len() {self.read_line();}
        let elem = self.v[self.i].parse().unwrap();
        self.i += 1;
        elem
    }
    #[allow(dead_code)]
    pub fn read_u64(&mut self) -> u64 {
        if self.i == self.v.len() {self.read_line();}
        let elem = self.v[self.i].parse().unwrap();
        self.i += 1;
        elem
    }
    #[allow(dead_code)]
    pub fn read_string(&mut self) -> String {
        if self.i == self.v.len() {self.read_line();}
        let elem = &self.v[self.i];
        self.i += 1;
        elem.to_owned()
    }
}

fn main() {
    use std::io;
    let stdin = io::stdin();
    let stdin = io::BufReader::new(stdin.lock());
    let read = Read::new(stdin);
    solve(read);
}


fn solve<R: std::io::BufRead>(mut r: Read<R>) {
    let n = r.read_i32();
    let k = r.read_i32();
    
    let mut d:Vec<i32> = Vec::new();
    let mut a:Vec<Vec<i32>> = Vec::new();
    for i in 0..k {
        d.push(r.read_i32());
        a.push(Vec::new());
        for j in 0..d[i as usize] {
            a[i as usize].push(r.read_i32());
        }
    }
    let mut list:Vec<i32> = vec![0;101];
    for i in 0..k as usize{
        for j in &a[i] {
            list[*j as usize]+=1;
        }
    }
    let mut ans:i32 = 0;
    for i in 1..n+1 {
        if list[i as usize] == 0 {
            ans+=1;
        } 
    }
    println!("{}",ans);
}


Measured memory_bytes: 2156
#include <iostream>
#include <string>
#include <vector>
#include <cmath>

#define MAX_LENGTH 3000

using namespace std;

int main()
{

    string s, t;
    cin >> s >> t;

    size_t sln = s.length();
    size_t tln = t.length();

    // LCSを計算
    vector<vector<int>> dp(MAX_LENGTH + 1, vector<int>(MAX_LENGTH + 1, 0));
    for (int i = 1; i <= sln; i++)
    {
        for (int j = 1; j <= tln; j++)
        {
            if (s[i - 1] == t[j - 1])
            {
                dp[i][j] = dp[i - 1][j - 1] + 1;
            }
            else
            {
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            }
        }
    }

    // 復元
    int l = dp[sln][tln];
    int x = sln;
    int y = tln;
    string ans = "";
    while (true)
    {

        if (l == 0)
            break;
        if (dp[x - 1][y] == l)
            x -= 1;
        else if (dp[x][y - 1] == l)
            y -= 1;
        else
        {
            ans = s[x - 1] + ans;
            l -= 1;
            x -= 1;
            y -= 1;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 35584
# coding: utf-8

n, m, x, y = map(int, input().split())
Xs = list(map(int, input().split()))
Ys = list(map(int, input().split()))

Xs.append(x)
Ys.append(y)

x_min = min(Xs)
x_max = max(Xs)
y_min = min(Ys)
y_max = max(Ys)

if x_max < y_min or y_max < x_min:
	print("No War")
else:
	print("War")


Measured memory_bytes: 3064
"use strict";
function Main(input) {
    let lines = input.split("\n");
    let N = lines.shift() - 0;
    let V = lines.shift().split(/\s/).map((v) => v - 0);
    let O = V.filter((v, i) => i < N && i % 2 != 0);
    let E = V.filter((v, i) => i < N && i % 2 == 0);
    const same = (v) => v.every((v, i, a) => v == a[0]);
    if (same(O) && same(E) && O[0] != E[0]) {
        console.log(0);
        return;
    }
    let Ev = new Array(1e5 + 1);
    let Ov = new Array(1e5 + 1);
    E.forEach((v) => { Ev[v] = Ev[v] || [v, 0]; Ev[v] = [v, Ev[v][1] + 1]; });
    O.forEach((v) => { Ov[v] = Ov[v] || [v, 0]; Ov[v] = [v, Ov[v][1] + 1]; });
    Ev.sort((a, b) => b[1] - a[1]);
    Ov.sort((a, b) => b[1] - a[1]);
    if (Ov[1] == undefined) Ov[1] = [1, 0];
    if (Ev[1] == undefined) Ev[1] = [1, 0];
    let ans = 0;
    let e0 = E.length - Ev[0][1];
    let e1 = E.length - Ev[1][1];
    let o0 = O.length - Ov[0][1];
    let o1 = O.length - Ov[1][1];
    if (Ev[0][0] != Ov[0][0]) {
        ans = e0+o0;
    } else {
        ans = Math.min(...[e0+o1, e1+o0]);
    }

    console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int count(int x) {
    if(x==0) return 0;
    return count(x>>1) + (x%2);
}

int main() 
{ 
    int n;
    cin >> n;
    int a[n+1];
    int x[n+1][n+1],y[n+1][n+1];
    
    for(int i=1;i<=n;i++){
        cin >> a[i];
        
        for(int j=1;j<=a[i];j++){
            cin >> x[i][j] >> y[i][j];
        }
    }
    
    int ans = 0;
    
    for(int mask=1;mask < (1 << n);mask++){
        bool ok = true;
        for(int i=1;i<=n;i++){
            if( !(mask & (1<<(i-1))) ) continue;
            
            for(int j=1;j<=a[i];j++){
                if(( (mask >> (x[i][j]-1)) & 1) ^ y[i][j]) ok=false;
            }
        }
        if(ok) {
            ans=max(ans, count(mask));
        }
    }
    
    cout<<ans<<endl;
    return 0;
} 

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

int main() {
  long long a, b, x;
  long long c = 0;
  cin >> a >> b >> x;
  if(a == 0) {
    cout << b/x + 1;
  }
  else {
    cout << b/x - (a-1)/x;
  }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define REP3(i,x,n) for(int i=x; i>(n); i--)
#define zero_pad(num) setfill('0') << std::right << setw(num)
#define space_pad(num) setfill(' ') << std::right << setw(num)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    ll N,M;
    cin >> N >> M;
    if(N==M)cout << "Yes" << endl;
    else cout << "No" << endl; 
    return 0;
}

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

int main(){
    vector<int> A = vector<int>(9, 0);
    vector<bool> flag = vector<bool>(9, false);
    int N, x;
    for (int i = 0; i < 9; i++) {
        cin >> A[i];
    }
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> x;
        for (int j = 0; j < 9; j++) {
            if (A[j] == x) {
                flag[j] = true;
            }
        }
    }
    
    bool isBingo =
       (flag[0] && flag[1] && flag[2])
    || (flag[3] && flag[4] && flag[5])
    || (flag[6] && flag[7] && flag[8])
    || (flag[0] && flag[3] && flag[6])
    || (flag[1] && flag[4] && flag[7])
    || (flag[2] && flag[5] && flag[8])
    || (flag[0] && flag[4] && flag[8])
    || (flag[2] && flag[4] && flag[6]);

    cout << (isBingo ? "Yes" : "No");
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
  string s;
  ll k;
  cin >> s;
  cin >> k;
  vector<ll> v(s.size(), 0);
  for(int i=0;i<s.size();i++) {
    v[i] = (s[i] - 'a');
  }

  for(int i=0;i<v.size();i++) {
    if(v[i] != 0 && (26-v[i]) <= k) {
      k -= (26 - v[i]);
      v[i] = 0;
    }
  }

  for(int i=0;i<v.size();i++) {
    if(i<v.size()-1) {
      cout << (char) (v[i] + 'a');
    } else {
      cout << (char) ((v[i] + k)%26 + 'a') << endl;
    }
  }

}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <cmath>
#include <typeinfo>
#include <set>
#include <bitset>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;

int f(int n){
    if(n%6==2){return 10;}
    else if(n%6==3){return 9;}
    else if(n%6==4){return 12;}
    else if(n%6==5){return 3;}
    else if(n%6==0){return 4;}
    else{
        return 1;
    }
}

int main(){
    string s;
    cin >> s;
    int n;
    n = s.length();
    vector<vector<ll>> dp(n,vector<ll>(13,0));
    for(int i = n-1; i>-1; i--){
        if(i==n-1){
            if(s[i]=='?'){
                for(int j=0;j<10;j++){
                    dp[i][j] = 1;
                }
            }else{
                dp[i][(int)s[i]-(int)'0'] = 1;
            }
        }
        else{
            if(s[i]=='?'){
                for(int j=0;j<13;j++){
                    for(int k=0; k<10; k++){
                        dp[i][(j+f(n-i)*k)%13] += dp[i+1][j];
                        dp[i][(j+f(n-i)*k)%13] = dp[i][(j+f(n-i)*k)%13]%(1000000007);
                    }
                }
            }else{
                for(int j=0; j<13; j++){
                    dp[i][(j+f(n-i)*((int)s[i]-(int)'0'))%13] += dp[i+1][j];
                    dp[i][(j+f(n-i)*((int)s[i]-(int)'0'))%13] = dp[i][(j+f(n-i)*((int)s[i]-(int)'0'))%13]%(1000000007);
                }
            }
        }
    }
    
    cout << dp[0][5] << endl;
}

Measured memory_bytes: 13696
#include <iostream>

int main(){
    int x, y, W, H, r;
    std::cin >> W >> H >> x >> y >> r;
    if((x<=W-r)&&(x>=r)&&(y<=H-r)&&(y>=r)) std::cout << "Yes" << std::endl;
    else std::cout << "No" << std::endl;
    return 0;
}


Measured memory_bytes: 3120
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < (n); ++(i))
#define repeat_from(i, m, n) for (int i = (m); (i) < (n); ++(i))
using namespace std;
template <class T>
void setmax(T &a, T const &b) {
    if (a < b) a = b;
}

template <class T>
void setmin(T &a, T const &b) {
    if (a > b) a = b;
}

template <typename T, typename X>
auto vectors(T a, X x) { return vector<T>(x, a); }

template <typename T, typename X, typename Y, typename... Zs>
auto vectors(T a, X x, Y y, Zs... zs) {
    auto cont = vectors(a, y, zs...);
    return vector<decltype(cont)>(x, cont);
}

int main() {
    int N;
    long long T;
    cin >> N >> T;
    vector<int> A(N);
    repeat(i, N) cin >> A[i];
    vector<int> minA(N + 1, 1e9 + 7);
    repeat(i, N) {
        minA[i + 1] = min(minA[i], A[i]);
    }

    vector<int> B(N);
    repeat(i, N) {
        B[i] = A[i] - minA[i];
        //cout << B[i] << " ";
    }
    //cout << endl;

    int P = *max_element(B.begin(), B.end());
    int x = 0;
    for (int bi : B) {
        if (P == bi) ++x;
    }
    cout << x << endl;
    return 0;
}

Measured memory_bytes: 4556
#include<iostream>
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a+b==c+d){
		cout<<"Balanced";
    }
    if(a+b<c+d){
    	cout<<"Right";
    }
    if(a+b>c+d){
    	cout<<"Left";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;

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

int main(){
    int n, m; cin>>n>>m;
    vector<ll> sum(n+10, 0);
    for(int i=1; i<n; i++){
        ll d; cin>>d;
        sum[i+1]+=sum[i]+d;
    }

    ll cp=1, ans=0;
    for(int i=0; i<m; i++){
        ll d; cin>>d;
        if(d>0){
            ans+=sum[cp+d]-sum[cp];
        }
        else{
            ans+=sum[cp]-sum[cp+d];
        }
        cp+=d;
        ans%=100000;
    }
    cout << ans%100000 << endl;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
// #define lli long long int
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
#define endl '\n'
#define all(x) x.begin(),x.end()
#define f(i,j,l) for(i=j;i<l;i++)
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int const mod = 1e9+7;
int power(int a,int b,int m){
    int res = 1;
    while(b){
        if(b&1){
            res = res*a;
            res %= m;
        }
        a=a*a;
        a%=m;
        b=b/2;
    }
    return res;
}
 
// int inverse_mod(int x){
//     return power(x,mod-2);
// }

int const N = 1e5+5;
int const inf = 1e10;

void solve(){
    int i,j,l;
    int n,m,k;
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b+c >= 22) cout<<"bust"<<endl;
    else cout<<"win"<<endl;
}

int32_t main(){
    IOS;
    int t;
    t = 1;
    // cin>>t;
    for(int tt=1;tt<=t;tt++){
        solve();
    }
    return 0;
}

/*

0111110000000
1000010000000

01101101
10010101


*/

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

typedef pair<int, int> P;

using Weight = int;
struct Edge {
	int src, dst; Weight weight;
	Edge() {}
	Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = vector<Edge>;

struct UnionFind {
	vector<int> par;
	int cnt;
	UnionFind(int size_) : par(size_, -1), cnt(size_) {}
	void unite(int x, int y) {
		if((x = find(x)) != (y = find(y))) {
			if(par[y] < par[x]) swap(x, y);
			par[x] += par[y]; par[y] = x; cnt--;
		}
	}
	bool same(int x, int y) { return find(x) == find(y); }
	int find(int x) { return par[x] < 0 ? x : par[x] = find(par[x]); }
	int size(int x) { return -par[find(x)]; }
	int size() { return cnt; }
};

bool operator < (const Edge &e, const Edge &f) { return e.weight < f.weight; }

const int MAX = (int)1e6 + 10;
vector<int> x[MAX];
int alive[200];

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

	int N, M;
	while(cin >> N >> M, N) {
		for(int i = 0; i < MAX; i++) {
			x[i].clear();
		}

		for(int i = 0; i < N; i++) {
			int t;
			cin >> t;
			x[t].push_back(i);
		}

		vector<Edge> es;
		for(int i = 0; i < M; i++) {
			int a, b, c;
			cin >> a >> b >> c;
			a--, b--;
			es.push_back({ a, b ,c });
		}
		sort(es.begin(), es.end());

		{
			UnionFind uf(N);
			for(auto e : es) {
				uf.unite(e.src, e.dst);
			}
			if(uf.size(0) != N) {
				cout << 0 << endl;
				continue;
			}
		}

		int last = -1;
		for(int i = 0; i < N; i++) {
			alive[i] = 1;
		}
		for(int t = 0; t < MAX; t++) {
			if(x[t].size() == 0) continue;
			for(auto v : x[t]) {
				alive[v] = 0;
			}
			UnionFind uf(N);
			for(auto e : es) {
				if(alive[e.src] && alive[e.dst]) uf.unite(e.src, e.dst);
			}
			int sz = 1;
			for(int j = 0; j < N; j++) {
				if(!alive[j]) sz++;
			}
			if(uf.size() != sz) {
				last = t;
				break;
			}
		}

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

		UnionFind uf(N);
		int ans = 0;
		for(int t = last; t < MAX; t++) {
			if(x[t].size() == 0) continue;

			for(auto v : x[t]) {
				alive[v] = 1;
			}
		}
		for(auto e : es) {
			if(alive[e.src] && alive[e.dst] && !uf.same(e.src, e.dst)) {
				uf.unite(e.src, e.dst);
				ans += e.weight;
			}
		}
		for(int t = last - 1; t >= 0; t--) {
			if(x[t].size() == 0) continue;

			for(auto v : x[t]) {
				alive[v] = 1;
			}
			for(auto e : es) {
				if(alive[e.src] && alive[e.dst] && !uf.same(e.src, e.dst)) {
					uf.unite(e.src, e.dst);
					ans += e.weight;
				}
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 27032
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int main(void){
  /*cout << std::fixed << std::setprecision(16);
  cin.tie(0);
  std::ios::sync_with_stdio(false);*/

  char S[99][99];

  for(;;){
    int h,w;
    scanf("%d %d",&h,&w);
    if(h==0 && w==0) break;

    for(int i = 0; i < h; ++i)
      scanf("%s",S[i]);

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

    std::vector<std::string> spells;

    for(int i = 10000*w; i < 10001*w; ++i){
      for(int j = 10000*h; j < 10001*h; ++j){
        for(int k = 0; k < dn; ++k){
          std::string sub;
          int u = i,v = j;
          do{
            sub += S[v%h][u%w];
            v += dx[k];
            u += dy[k];
          }while(u % w != i % w || v % h != j % h);
          spells.push_back(sub);
        }
      }
    }

    /*bool f = true;
    std::string ans;
    int anslength = 0;
    for(auto c:Counts){
      if(c.second == 2){
        if(c.first.size() > anslength){
          anslength = c.first.size();
          ans = c.first;
        }
        f = false;
      }
    }
    if(f) printf("0\n");
    else printf("%s\n",ans.c_str());
     */
    sort(spells.begin(), spells.end());

    int ansl = -1;
    std::string ans;
    for(int i = 0 ; i+1 < spells.size();++i){
      int c = 0;
      for(int j = 0; spells[i][j] == spells[i+1][j]&& spells[i][j]; ++j, c = j);
      if(c > ansl){
        ansl = c;
        ans  = spells[i].substr(0, c);
      }
    }

    if(ans.size() > 1)
    printf("%s\n", ans.c_str());
else printf("0\n");

  }


  return 0;
}



Measured memory_bytes: 3480
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		var S = rs();
		Console.WriteLine(S == "ABC" ? "ARC" : "ABC");
	}

	public Sol(){
		
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 25640