akhauriyash/Code-Regression huggingface dataset:
/***
        ***Fresher***
    Md Mahfujur Rahman Khan
    Dept. of CSE
    CSE-28 Batch
    JU-48 Batch
    Jahangirnagar University

***/
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<queue>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<functional>
#include<set>
#include<map>
#include<climits>
#include<numeric>
#include<utility>
using namespace std;
#define V_ vector
#define Q_ queue
#define S_ set
#define ST_ stack
#define M_ map
#define DQ_ deque
/***PAIR***/
#define pii pair<ll,ll>
#define pci pair<char,ll>
#define psi pair<string, ll>
#define pis pair<ll,string>
#define pic pair<ll, char>
/***MAP***/
#define mii map<ll,ll>
#define msi map<string, ll>
#define mis map<ll, string>
#define mib map<ll,bool>
#define msb map<string,bool>
#define mci map<char, ll>
/***VECTOR***/
#define vi vector<ll>
#define vs vector<string>
/***ITERASTORS***/
#define ivi vector<ll> :: iterator
#define ivs vector<string> :: iterator
#define imii map<ll,ll> :: iterator
#define imsi map<string,ll> :: iterator
#define imis map<ll, string> :: iterator
#define imib map<ll, bool> :: iterator
#define imsb map<string, bool> :: iterator
#define imci map<char, ll> :: iterator
/*** FAST ***/
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
/***FUNCTIONS AND MACROS***/
#define F first
#define S second
#define M_P(x, y) make_pair(x, y)
#define PB(x) push_back(x)
#define PP(x) push(x)
#define RSZ(n) resize(n)
#define POB pop_back()
#define P_ pop()
#define CL_ clear()
#define LEN_ length()
#define SZ_ size()
#define CNT(x) count(x)
#define FF first.first
#define FS first.second
#define SF second.first
#define SS second.second
#define B_ begin()
#define E_ end()
#define F_ front()
#define t_ top()
#define IN_ insert
#define ER_  erase
#define GT(x) getline(cin , x)
#define NL_   "\n"
#define SP_ " "
#define R_0 return 0
#define R_ return

#define ul unsigned long long int
#define ll long long int
/***
//prime fact
#define most_prime_loop 1001
#define most_prime_number 2000010
#define prime_MAX_arr 2000010/2
ll PRIME[2000010];
void seive()
{
    PRIME[0] = 0;
    for(auto &x: PRIME )
        x = 1;
    for(ll i= 3; i <= most_prime_loop; i+=2)
    {
        for(ll j = i*i; j <= most_prime_number; j+=2*i)
            PRIME[j/2] = 0;
    }
}
***/

#define fr(i, n) for( ll i = 0; i < n; i++)
#define fe(x, n) for( ll i = x; i <= n; i++)
#define fa(x,a)    for(auto &x : a)

#define pi acos(-1)

#define SR(x) sqrt(x)
#define IC   (ll)

const ll  inf = 2000000;
ll i=0, T=0, N=0, tc =0, t= 0;
ll n=0, k=0;
string s;
bool palin(ll a, ll b)
{
    a--;
    b--;
    while(a<=b)
    {
        if(s[a++]!=s[b--]) return 0;
    }
    return 1;
}
int main()
{
       cin >> s;
       if(palin(1LL,(ll)s.LEN_)&& palin(1, (ll)s.LEN_/2) && palin((ll)(s.LEN_+3)/2, s.LEN_)) cout <<"Yes";
       else cout <<"No";
}



Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
   int a, b, s;

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

   s = a + b;
   
   if(s < (a-b)) s=a-b;

   if(s<(a*b)) s=a*b;
   
   printf("%d\n", s);
   
   return 0;
}

Measured memory_bytes: 128
/*
[agc028] A - Two Abbreviations
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

int gcd(int a, int b) {
    while (b > 0) {
        swap(b, a %= b);
    }
    return a;
}

int N, M;
string S, T;

ll solve() {
    int d = gcd(N, M);

    for (int i = 0, j = 0; i < N && j < M; i += N / d, j += M / d) {
        if (S[i] != T[j]) {
            return -1;
        }
    }

    return 1LL * N * M / d;
}

int main() {
    cin >> N >> M;
    cin >> S;
    cin >> T;

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 512
N,x = [int(i) for i in input().split()]
alist = [int(i) for i in input().split()]

ct = 0
for i in range(len(alist)-1):
    extra = alist[i]+alist[i+1]-x
    if extra <= 0:
        continue
    ct += extra
    if extra <= alist[i+1]-1:
        alist[i+1] -= extra
    else:
        alist[i] -= (extra-alist[i+1])
        alist[i+1] = 0

print(ct)

Measured memory_bytes: 14548
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define nn '\n'
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) cout << n << '\n';
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int64_t, int >prime_factor(int64_t n){map< int64_t, int > ret;for(int64_t i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int n,k; cin >> n >> k;
    int ans = 0;
    while(n--){int x; cin >> x; if(x>=k)ans++;}
    out(ans);

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

typedef unsigned long ul;
typedef pair<ul, ul> P;
map<int, int> dp;
#define REP(i, n) for (int i = 0; i < n; i++)
ul H, W;
int X, Y, Z, K;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> X >> Y >> Z >> K;
  vector<ul> A(X, 0);
  vector<ul> B(Y, 0);
  vector<ul> C(Z, 0);
  vector<ul> AB(X * Y, 0);

  REP(i, X) cin >> A[i];
  REP(i, Y) cin >> B[i];

  REP(i, X) {
    REP(j, Y) { AB[i * Y + j] = A[i] + B[j]; }
  }
  REP(i, Z) { cin >> C[i]; }
  sort(AB.rbegin(), AB.rend());
  sort(C.rbegin(), C.rend());
  vector<ul> ABC(K * K, 0);
  const int calc_num_XY = min(K, X * Y);
  const int calc_num_Z = min(K, Z);
  REP(ii, min(K, calc_num_XY)) {
    REP(jj, min(K, calc_num_Z)) { ABC[calc_num_Z * ii + jj] = AB[ii] + C[jj]; }
  }
  sort(ABC.rbegin(), ABC.rend());
  REP(ii, K) { cout << ABC[ii] << endl; }

  return 0;
}


Measured memory_bytes: 78464
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
using namespace std;

const int INT__MAX = 2147483647;
const int MOD = 1000000007;

int main() {

	string s;

	cin >> s;

	cout << s[0] << s.length() - 2 << s[s.length()-1] << endl;

	return 0;
}

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

int main(){
    cin >> n;
    vector<string> s(n);
    rep(i,n)cin >> s[i];
    int mi = inf;
    rep(i,n){
        vector<string> t = s;
        bool a = 0;
        rep(j,n){
            if(t[i][j]=='#'){
                a = 1;
            }
        }
        bool b = 0;
        int k = -1;
        rep(j,n){
            if(t[j][i]=='#'){
                b = 1;
                k = j;
            }
        }
        int c = 0;
        if(b){
            rep(j,n){
                if(t[i][j]=='.'){
                    op(t,k,j);
                    c++;
                }
            }
            rep(j,n){
                rep(k,n){
                    if(t[k][j]=='.'){
                        op(t,i,j);
                        c++;
                        break;
                    }
                }
            }
            mi = min(mi,c);
        }else{
            if(!a){
                continue;
            }else{
                c++;
                op(t,i,i);
                rep(j,n){
                    if(t[j][i]=='#'){
                        b = 1;
                        k = j;
                    }
                }
                rep(j,n){
                    if(t[i][j]=='.'){
                        op(t,k,j);
                        c++;
                    }
                }
                rep(j,n){
                    rep(k,n){
                        if(t[k][j]=='.'){
                            op(t,i,j);
                            c++;
                            break;
                        }
                    }
                }
                mi = min(mi,c);
            }
        }

    }
    if(mi==inf){
        cout << -1 << endl;
    }else{
        cout << mi << endl;
    }
    return 0;
}

Measured memory_bytes: 976
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define uset unordered_set
#define umap unordered_map
#define db(x) cout << #x << " == " << x << ";\n"
#define a(x) x.begin(),x.end()
#define input(v,n) for(int i=0;i<n;i++)cin>>v[i]
typedef vector<int> vi;
typedef pair<int,int> pi;

const int inf = 1e5+7;
// ===================== MANASH =================== //

void test() {

	string s,t;
	cin >> s >> t;
	t.pop_back();
	
	s == t ? cout << "Yes" : cout << "No";

}

int32_t main() {

	ios_base :: sync_with_stdio(false);
	cin.tie(NULL);

	#ifdef LOCAL
	freopen("input.txt","r",stdin);
	#endif

	int T = 1;
	while(T--) {
		test();
		//cout << "\n";
	}
	return 0;

}


Measured memory_bytes: 3612
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<tuple>
#include<string>
typedef unsigned long long ll;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define repm(i,a,b) for(int i=(a);i>(b);i--)
#define F first
#define S second
using namespace std;
const ll INF = 1e12;
const int i_INF = 2147483647;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
	int a, b;
	cin >> a >> b;
	if (a > 9 || b > 9)cout << -1 << endl;
	else cout << a * b << endl;
	return 0;
}

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

#define INF 10000000

using namespace std;

class State{
public:
  int x, y;
  int t;
  int f;
};

int dx[2][9]={1, 1, 2, 1, 2, 3, 1, 2, 1, -1, -1, -2, -1, -2, -3, -1, -2, -1};
int dy[9]={-2, -1, -1, 0, 0, 0, 1, 1, 2};
char in[60][30];
int  w, h;
int bfs(int);
main(){
  while(1){
    cin >> w >> h;
    if(w==0 && h==0) break;

    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin >> in[i][j];
      }
    }
    int ans=INF;
    int tmp;
    tmp=bfs(0);
    if(ans>tmp) ans=tmp;
    tmp=bfs(1);
    if(ans>tmp) ans=tmp;
    if(ans==INF) ans=-1;
    cout << ans << endl;
  }
  return 0;
}

int bfs(int sf){
  queue<State> Q;
  int tmp;
  int cost[2][60][30];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cost[0][i][j]=cost[1][i][j]=INF;
    }
  }
  State u;
  int ans=INF;
  for(int i=0;i<w;i++){
    if(in[h-1][i]=='S'){
      u.x=i;
      u.y=h-1;
      u.t=0;
      u.f=sf;
      Q.push(u);
      cost[u.f][u.y][u.x]=0;
      bool end=false;
      while(!Q.empty()){
	u=Q.front(), Q.pop();
	int tx, ty;
	for(int j=0;j<9;j++){
	  tx=u.x+dx[u.f][j];
	  ty=u.y+dy[j];
	  if(ty>=0 && ty<h){
	    if(tx>=0 && tx<w){
	      if(in[ty][tx]!='X'){
		int num;
		if(in[ty][tx]=='T'){
		  if(cost[(u.f+1)%2][ty][tx]>u.t) cost[(u.f+1)%2][ty][tx]=u.t;
		  break;
		}else if(in[ty][tx]=='S') num=0;
		else num=in[ty][tx]-'0';
		if(cost[(u.f+1)%2][ty][tx]>u.t+num){
		  State v;
		  v.x=tx;
		  v.y=ty;
		  v.t=u.t+num;
		  v.f=(u.f+1)%2;
		  cost[v.f][ty][tx]=v.t;
		  Q.push(v);
		}
	      }
	    }
	  }
	}
	tmp=INF;
	for(int i=0;i<w;i++){
	  if(in[0][i]=='T'){
	    if(tmp>cost[0][0][i]){
	      tmp=cost[0][0][i];
	    }
	    if(tmp>cost[1][0][i]){
	      tmp=cost[1][0][i];
	    }
	  }
	}
      }
      if(ans>tmp) ans=tmp;
    }
  }
  return ans;
}

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

int main() {
  int n;
  int res = -2000000000;
  cin >> n;
  int a[200005];
  cin >> a[0];
  int minv = a[0];
  for (int i = 1; i < n; ++i) {
    cin >> a[i];
    res = max(res, a[i] - minv);
    minv = min(minv, a[i]);
  }
  cout << res << endl;
}


Measured memory_bytes: 3876
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
using ll = long long;

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	ll answer = 0;
	vector<int> last;
	for(int i = 0; i < n; ++i){
		ll d, c;
		cin >> d >> c;
		while(c > 0){
			if(c % 2 != 0){
				last.push_back(d);
				--c;
			}
			if(d < 5){
				d = d * 2;
				answer += c / 2;
				c /= 2;
			}else{
				d = d * 2 - 9;
				answer += c;
				c /= 2;
			}
		}
	}
	while(last.size() > 1){
		const ll x = last.back();
		last.pop_back();
		const ll y = last.back();
		last.pop_back();
		if(x + y >= 10){
			last.push_back(x + y - 9);
			answer += 2;
		}else{
			last.push_back(x + y);
			answer += 1;
		}
	}
	cout << answer << endl;
	return 0;
}



Measured memory_bytes: 18664
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename x>
using ordered_set = tree<x,null_type,less<x>,rb_tree_tag,tree_order_statistics_node_update>;
#define sorta(a,n) sort(a,a+n)
#define sortad(a,n) sort(a,a+n,greater<__typeof(a[0])>())
#define all(x) (x).begin(),(x).end()
#define ms0(x) memset((x),0,sizeof((x)))
#define ms1(x) memset((x),-1,sizeof((x)))
typedef pair<long long,long long> pi;
#define inarr(arr,n) for(long long i=0;i<n;i++)cin>>arr[i];
#define prinarr(arr) {for(long long x:arr)cout<<x<<" ";} cout<<"\n";
#define cout1(a) cout<<a<<"\n";
#define cout2(a,b) cout<<a<<" "<<b<<"\n";
#define cout3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n";
#define setpre(n) cout<<fixed<<setprecision(8)<<n<<"\n";
#define filldp(arr,n,m,k) for(long long i=0;i<n;i++){for(long long j=0;j<m;j++) arr[i][j]=k;}

#define mod 1000000007
#define mod1 998244353

const long long N=5;

vector<vector<long long>> adj;
bool visited[N];
long long dis[N];
//long long parent[N];

void newgr(){
    adj= vector<vector<long long>>(N);
    for(long long i=0;i<N;i++){
        dis[i]=0;
        visited[i]=false;
       // parent[i]=-1;
    }
}

long long power(long long x,long long y){  
    long long ans=1;
    x%=mod;
    while(y>0){
        if(y&1) ans=(ans*x)%mod;
        y>>=1;
        x=(x*x)%mod;
    }
    return ans;
}

long long modinv(long long b){ 
    return power(b,mod-2);
}

void dfs(long long s){
    visited[s]=true;
    for(long long u:adj[s]){
        if(!visited[u]){
       // parent[u]=s;
        dis[u]=dis[s]+1;
        dfs(u);
    }}
}
queue<long long> qu;
void bfs(long long x){
    visited[x] = true;
    dis[x] = 0;
    qu.push(x);
    while (!qu.empty()) {
    long long s = qu.front();
     qu.pop();
    for (auto u : adj[s]) {
    if (visited[u]) continue;
    visited[u] = true;
    dis[u] = dis[s]+1;
    qu.push(u);
    }
    }
}


int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    long long n;
    cin>>n;
    long long arr[n];
    long long flag=1;
    for(long long i=0;i<n;i++){
        cin>>arr[i];
        if(arr[i]==0){
            flag=0;
            break;
        }
    }
    if(!flag){
        cout1(0);
    }
    else{
        long long co=1,p=1e18;
        for(long long x:arr){
            if(x>(p/co)){
                flag=0;
                break;
            }
            co*=x;
        }
        if(!flag or co>p){
            cout1(-1);
        }
        else{
            cout1(co);
        }
    }

    return 0;
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b;
	cin >> a >> b;
	cout << a + b / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
def ceil(x):
    ans = x
    while ans % 10 != 0:
        ans += 1
    return ans

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

time_list = [a, b, c, d, e]
time_list.sort(key=lambda x: ceil(x) - x)

ans = 0
for i in range(len(time_list)-1):
    ans += ceil(time_list[i])
ans += time_list[-1]
print(ans)



Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define sz(x) (int((x).size()))
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
template<typename T> bool domax(T &a, T b) { return (b > a ? (a = b, true) : false); }
template<typename T> bool domin(T &a, T b) { return (b < a ? (a = b, true) : false); }
typedef long long ll;

const int maxn = 2005;

int n, k, ans = 1e9;
std::vector<int> e[maxn];

void go(int i, int f, int d, std::pair<int, int> &p) {
    if (d == k/2+1) p.second++;
    if (d > k/2) p.first++;
    for (int j : e[i]) if (j != f) {
        go(j, i, d+1, p);
    }
}

int main() {
    scanf("%d%d", &n, &k);
    for (int i = 0; i < n-1; i++) {
        int a, b;
        scanf("%d%d", &a, &b);
        a--; b--;
        e[a].pb(b);
        e[b].pb(a);
    }

    for (int i = 0; i < n-1; i++) {
        int best = 0, sum = 0;
        for (int j : e[i]) {
            std::pair<int, int> p = {0, 0};
            go(j, i, 1, p);
            domax(best, p.second);
            sum += p.first;
        }
        if (k%2) sum -= best;
        domin(ans, sum);
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
bool zs(int n)
{
	for(int i=2;i*i<=n;++i)
		if(n%i==0)
			return false;
	return true;
}
bool hw(int n)
{
	int m=0,k=n;
	while(k!=0)
	{
		m=m*10+k%10;
		k/=10;
	}
	if(m==n)
		return true;
	return false;
}
int main()
{
	long long n,m,cnt=0;
	cin>>n>>m;
	if(n==m/2)
	{
		cnt+=n;
		cout<<cnt<<endl;
	}
	else
	{
		if(n<m/2)
		{
			cnt+=n,m-=2*n,cnt+=m/4;
			cout<<cnt<<endl;
		}
		else
		{
			if(n>m/2)
			{
				cnt+=m/2;
				cout<<cnt<<endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
n,k=gets.split.map(&:to_i)
x=gets.split.map(&:to_i)
r=1<<30
(n-k+1).times{|i|
	a,b=x[i],x[i+k-1]
	s,l=[a.abs,b.abs].sort
	r=[r,a*b<0 ? s*2+l : l].min
}
p r

Measured memory_bytes: 11012
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();

		int B = sc.nextInt();

		int ans = 0;

		for(int i=A;i<=B;i++) {

			int s = i/10000;

			int t = i/1000 - s*10;

			int u = i%10;

			int v = (i%100 - u)/10;

			if(s==u && t==v)ans++;
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 24020
// Last Update:2017-11-30 22:18:48
// author:sjy
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
LL w[100005],d[100005];
LL c[100005];
int main(void)
{
    int n,p;
    while(scanf("%d %d",&n,&p)!=EOF)
    {  LL sum = 0;
       for(int i = 0;i < n;i++)
           scanf("%lld %lld",&w[i],&d[i]),sum += w[i];
       LL k = p,kk = 100-p;
       sum = kk*sum;
       for(int i = 0;i < n;i++)
           c[i] = k*d[i] + kk*w[i];
       sort(c,c+n);
       int m = 0;
       for(int i = 0;i < n;i++)
       {
         if(sum >= c[i])
             sum -= c[i],m++;
         else break;
       }
       printf("%d\n",n - m);
    }
    return 0;
}

Measured memory_bytes: 2688
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  string a,b;
  cin>>a>>b;
  if(a.size()<b.size())
    cout<<"LESS"<<endl;
  else if(a.size()>b.size())
    cout<<"GREATER"<<endl;
  else{
    rep(i,a.size()){
      if(a[i]==b[i])continue;
      if(a[i]<b[i])cout<<"LESS"<<endl;
      else cout<<"GREATER"<<endl;
      return 0;
    }
    cout<<"EQUAL"<<endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
string s;
int l;
int main()
{
	cin>>s;
	l=s.size();
	for(register int i=0;i<l;i++)
	{
		if(s[i]=='C')
		{
			for(register int j=i+1;j<l;j++)
			{
				if(s[j]=='F')
				{
					cout<<"Yes";
					return 0;
				}
			}
		}
	}
	cout<<"No";
	return 0;
}

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

int main(){
  int N, count=0;
  cin >> N;
  int H[N+1];
  H[0]= 0;
  for(int i=0;i<N;i++){
    cin >> H[i+1];
  }

  for(int i=1;i<=N;i++){
    bool flag = true;
    for(int j=0;j<i;j++){
      if(H[j]>H[i]){
        flag = false;
        break;
      }
    }
    if(flag) count++;
  }

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

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

int bit[234567];
int siz;
void init(int n)
{
    siz = 1;
    while(siz < n)siz *= 2;
    for(int i = 0;i <= siz;++i)
        bit[i] = 0;
}
void add(int i,int x)
{
    ++i;
    while(i <= siz)
    {
        bit[i] += x;
        i += (i & -i);
        //cerr << i << " " << bit[i] << endl;
    }
}
int sum(int i)
{
    int ans = 0;
    while(i > 0)
    {
        ans += bit[i];
        i -= (i & -i);
    }
    return ans;
}

int main()
{
    int n,q;
    cin >> n >> q;
    init(n);
    for(int i = 0;i < q;++i)
    {
        int a,b,c;
        cin >> a >> b >> c;
        if(a == 0)
        {
            --b;
            add(b,c);
        }
        else
        {
            --b;--c;
            cout << sum(c + 1) - sum(b) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
int main(){
  while (1){
    int N;
    cin >> N;
    if (N == 0){
      break;
    }
    int W, H;
    cin >> W >> H;
    vector<int> x(N), y(N);
    for (int i = 0; i < N; i++){
      cin >> x[i] >> y[i];
    }
    int S, T;
    cin >> S >> T;
    int ans = 0;
    for (int i = 1; i <= W - S + 1; i++){
      for (int j = 1; j <= H - T + 1; j++){
        int cnt = 0;
        for (int k = 0; k < N; k++){
          if (i <= x[k] && x[k] <= i + S - 1 && j <= y[k] && y[k] <= j + T - 1){
            cnt++;
          }
        }
        ans = max(ans, cnt);
      }
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 3004
function main()
  
  (x1,y1,x2,y2) = map(x -> parse(Int,x), split(readline()))
  
  c1 = [x1;y1]
  c2 = [x2;y2]
  
  c3 = [0 1;-1 0]*(c1-c2) + c2
  c4 = [0 1;-1 0]*(c2-c3) + c3
  
  println(c3[1,1]," ",c3[2,1]," ",c4[1,1]," ",c4[2,1])
  
end

main()

Measured memory_bytes: 168876
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int n,m;
  cin >> n >> m;
  string s[n];
  rep(i,n) R s[i];
  int x=0,y=0;
  bool u[n][m];mem(u);
  u[x][y]=1;
  while(1) {
    if(x==n-1&&y==m-1) break;
    rep(i,2) {
      int xx=x+dx[i],yy=y+dy[i];
      if(!check(n,m,xx,yy)) continue;
      if(s[xx][yy]=='#') {
        x=xx,y=yy;
        u[x][y]=1;
        goto next;
      }
    }
    pr("Impossible");
    return;
  next:;
  }
  rep(i,n)rep(j,m) {
    if(s[i][j]=='#'&&u[i][j]==0) {
      pr("Impossible");
      return;
    }
    if(s[i][j]!='#'&&u[i][j]!=0) {
      pr("Impossible");
      return;
    }
  }
  pr("Possible");
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
  ll n, k, cnt = 0;
  cin >> n >> k;
  
  for (ll i = k; i <= n+1; i++) {
    ll ans = i*n - i*(i-1) + 1;
    cnt += ans;
  }
  
  cout << cnt % 1000000007 << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long int64;
int main(){
  int N, M;
  cin >> N >> M;
  vector< int > P(M);
  for(int i = 0; i < M; i++){
    cin >> P[i];
    --P[i];
  }
  vector< int > A(N - 1), B(N - 1), C(N - 1);
  for(int i = 0; i < N - 1; i++){
    cin >> A[i] >> B[i] >> C[i];
  }
  vector< int64 > Imos( N + 1, 0);
  for(int i = 1; i < M; i++){
    int u = P[i - 1], v = P[i];
    if(u > v) swap( u, v);
    ++Imos[u];
    --Imos[v];
  }
  for(int i = 1; i < N - 1; i++){
    Imos[i] += Imos[i - 1];
  }
 
  int64 ret = 0;
  for(int i = 0; i < N - 1; i++){
    ret += min( A[i] * Imos[i], C[i] + B[i] * Imos[i]);
  }
  cout << ret << endl;
}

Measured memory_bytes: 3384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if (b/a >= c) {
			System.out.println(c);
		} else {
			System.out.println(b/a);
		}

	}

}


Measured memory_bytes: 23508
#include <iostream>

using namespace std;

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

    for (int i=0; i<=n; i++) {
        for (int j=0; j+i<=n; j++) {
            int k = n - j - i;
            if (10000*i + 5000*j + 1000*k == y) {
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
}

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

void swap(std::vector<int> &target,int i,int j)
{
    int temp = target.at(i);
    target.at(i) = target.at(j);
    target.at(j) = temp;
    return;
}

int main(int argc, char const *argv[])
{
    int num = 0;
    std::cin >> num ;
    std::vector<int> array;
    int temp;
    for(int i = 0 ; i < num ; i ++){
        std::cin >> temp;
        array.push_back(temp);
    }
    int count = 0;
    for(int i = 0 ; i < num ; i ++){
        for(int j = num-1 ; j >i ; j --){
            if(array.at(j-1) > array.at(j)){
                swap(array,j,j-1);
                count ++;
            }
        }
    }
    
    for(int i = 0 ; i < num -1 ; i ++){
        std::cout << array.at(i) << " ";
    }
    std::cout << array.at(num-1) << std::endl;
    std::cout << count << std::endl;
    return 0;
}

Measured memory_bytes: 3156
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    int n,k; cin >> n >> k;
    string s; cin >> s;
    int st = 1;
    if(s[0] == '0')st = 0;

//群数列化
    vector <int> sec; int p = 0;
    rep(i,n){
        sec.push_back(1);
        while(s[i] == s[i+1]){ ++i; ++sec[p]; }
        ++p;
    }

//累積和
    vector <int> sum(sec.size()+3,0);
    rep(i,sec.size()) sum[i+2] = sum[i+1] + sec[i]; 
    sum[sum.size()-1] = sum[sum.size()-2];
    //for(auto x:sum)cout << x << endl; cout << "----------" << endl;

//処理
    int ans = -INF; k = k*2+1;
    for(int i = 0; i+k < sum.size(); ++i){
        //cout << i << endl;
        if(i%2 == st){
            int tmp = sum[i+k] - sum[i];
            //cout << tmp << endl;
            ans = max(ans, abs(tmp));
        }
    }
    if(ans == -INF)ans = n;
    cout << ans << endl; return 0;
}


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

/*#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;*/

/*#include <ext/pb_ds/assoc_container.hpp>   // Policy_based_Data_Structure 
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define fbo find_by_order
#define ook order_of_key*/


#define ll long long int
#define bigint int64_t
#define pll pair<ll, ll>
#define vll vector<ll>
#define vpll vector<pll>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define MOD 1000000007
#define w(t) cin >> t;while(t--)
#define bitcount __builtin_popcount
#define endl "\n"
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define deb(x) cout << #x << " " << x << endl;
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(ll i = a; i <= b; i++)
#define ffo(i, a, b) for(ll i = a; i >= b; i--)
#define ffi(i,a,b,c) for(ll i = a ; i <= b ; i += c)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
void io_set() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

int main(){
    IOS;
    //io_set();
    string s, a;
    cin >> s >> a;
    cout << a << s << endl;
    return 0;
} 

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

const int N = 5001;
int n, mo;
int C[N][N], S[N][N];

int qp(int x, int y, int mod) {
	int res = 1;
	while (y) {
		if (y & 1) (res *= x) %= mod;
		y >>= 1;
		(x *= x) %= mod;
	}
	return res;
}

signed main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0), std::cout.tie(0);
	std::cin >> n >> mo;
	for (int i = 0; i <= n; ++ i) {
		C[i][0] = 1, S[i][0] = 1;
		for (int j = 1; j <= i; ++ j) {
			C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % mo;
			S[i][j] = (S[i - 1][j - 1] + (j + 1) * (S[i - 1][j]) % mo) % mo;
		}
	}
//	std::cerr << "Yuno" << '\n';
	int ans = 0;
	for (int i = 0; i <= n; ++ i) {
		int A = qp(2, qp(2, n - i, mo - 1), mo);
//		std::cerr << "Yuno\n";
		int B = C[n][i];
		int res = 1, base = qp(2, n - i, mo), sum = 0;
		for (int j = 0; j <= i; ++ j) {
//			std::cerr << j << '\n';
			(sum += S[i][j] * res % mo) %= mo;
			(res *= base) %= mo;
		}
		if (!(i & 1)) (ans += A * B % mo * sum % mo) %= mo;
		else ans = (ans - A * B % mo * sum % mo + mo) % mo;
//		std::cerr << i << ' ' << ans << '\n';
	}
	std::cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 97936
//#define DEBUG
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define MAX_T 200002
#define MAX_N 100000

int main() {
#ifdef DEBUG

#endif
	int N, C;
	int s[MAX_N], t[MAX_N], c[MAX_N];
	int tt[MAX_T] = { 0 };
	scanf("%d %d", &N, &C);
	int i,j;
	for (i = 0; i < N; i++) {
		scanf("%d %d %d", &s[i], &t[i], &c[i]);
	}
	int cnt[MAX_T] = { 0 };
	int tmp;
	for (i = 1; i <= C; i++) {
		/*for (j = MAX_T / 2; j < MAX_T; j++)tt[j] = 0;
		for (j = 0; j < N; j++)if (c[j] == i) {
			tt[s[j] + MAX_T / 2]++;
			if (t[j] != MAX_T / 2 - 1)tt[t[j] + MAX_T / 2+1]--;
			if (tt[s[j] + MAX_T / 2+1]<0) {
				tt[s[j] + MAX_T / 2]--;
				tt[s[j] + MAX_T / 2+1]++;
			}
			if (t[j] != MAX_T / 2 - 1) {
				if (tt[t[j] + MAX_T / 2] > 0) {
					tt[t[j] + MAX_T / 2 + 1]++;
					tt[t[j] + MAX_T / 2]--;
				}
			}
		}
		for (j = 0; j < MAX_T/2; j++) {
			tt[j] += tt[j + MAX_T/2];
		}//printf("%d", i);*/
		for (j = 0; j < MAX_T; j++)tt[j] = 0;
		for (j = 0; j < N; j++)if (c[j] == i) {
			tt[s[j]]++;
			if (t[j] != MAX_T - 1)tt[t[j]+1]--;
			if (tt[s[j]+1]<0) {
				tt[s[j]]--;
				tt[s[j]+1]++;
			}
			if (t[j] != MAX_T - 1) {
				if (tt[t[j]] > 0) {
					tt[t[j] + 1]++;
					tt[t[j]]--;
				}
			}
		}
		tmp = 0;
		for (j = 0; j < MAX_T; j++) {
			tmp += tt[j];
			if (tmp > 0)cnt[j]++;
			//printf("%d", cnt[j]);
		}//printf("\n");
	}
	int max=0;
	for (i = 0; i < MAX_T; i++) {
		/*
		printf("%d", tt[i]);
		if (i % 20 == 19)printf("\n");
		//*/
		if (max < cnt[i])max = cnt[i];
	}
	printf("%d\n", max);
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
// #define int ll
using namespace std;
const int INF (1 << 30);
const ll LLINF (1LL << 55LL);
const int MOD = 1000000007;
const int MAX = 510000;
const double pi=3.14159265358979;

ll fac[MAX], finv[MAX], inv[MAX];
ll POW[MAX];

void POWinit(){
    POW[0]=0;
    POW[1]=1;
    for(ll i=2;i<MAX;i++){
        POW[i]=POW[i-1]*i;
        POW[i]%=MOD;
    }
}


// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (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);
    ll n,k;
    cin>>n>>k;
    COMinit();
    POWinit();
    cout<<COM(n+k-1,k-1)<<endl;
    return 0;
}


Measured memory_bytes: 19092
import std.stdio;
import std.algorithm;
import std.string;
import std.range;
import std.array;
import std.conv;
import std.complex;
import std.math;
import std.ascii;
import std.bigint;
import std.container;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

const real eps = 1e-10;

void main(){
	while(true) {
		auto n = readInt();
		if(n == 0) {
			return;
		}
		int ans[7];
		for(int i; i < n; ++i) {
			auto c = min(readInt()/10, 6);
			ans[c]++;
		}
		foreach(int a; ans) {
			writeln(a);
		}
	}
}

Measured memory_bytes: 3192
#include <iostream>
#include <math.h>
using namespace std;
int main(){
	while(1){
		int i;
		cin >> i;
		if (i==0) {break;}
		int count = 0;
		for(int j=1;j<i;j++){
			
			for(int k=1;k<i;k++){
				int sum =0;
				for(int l=0;l<k;l++){
					sum +=j+l;
				}
				if (sum == i) {
					count +=1;
					break;
				}
			}
		}
		cout << count <<endl;
	}



	return 0;
}

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

int v[100002] = {};

int main()
{
    int n;
    cin>>n;
    int k = 0, p =0;
    for(int i=1;i<=n;i++)
    {
        cin>>v[i];
        if(v[i] > p)
        {
            k += v[i]-p;
        }
        else k+=p-v[i];
        p = v[i];
    }
    k += abs(v[n]);
    for(int i=1;i<=n;i++)
    {
        int tp = k;
        int start = v[i-1];
        int end = v[i+1];
        if(i==1)
        {
            start = 0;
        }
        else if(i==n)
        {
            end = 0;
        }
        tp -= abs(v[i]-start) + abs(end - v[i]);
        tp += abs(start - end);
        cout<<tp<<'\n';
    }
    return 0;
}


Measured memory_bytes: 1664
#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;

int main()
{
	cin >> N;
	vector<string> S(N);
	FOR(i,0,N){
		cin >> S [i];
	}

	string ans;
	for(char c = 'a';c <= 'z';c++){
		int mn = 1e9;
		FOR(i,0,N){
			chmin(mn,(int) count(ALL(S [i]),c));
		}
		ans += string(mn,c);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextLine();

		String[] ss = new String[n];

		for (int i = 0; i < n; i++) {
			char[] cs = sc.nextLine().toCharArray();
			Arrays.sort(cs);
			ss[i] = new String(cs);
		}

		Arrays.sort(ss);
		List<Long> same = new ArrayList<>();
		for (int i = 1; i < n; i++) {
			long count = 1;
			while (i < n && ss[i].equals(ss[i - 1])) {
				i++;
				count++;
			}
			if (count > 1) same.add(count);
		}
		long answer = 0;
		for (Long m : same) answer += m * (m - 1) / 2;
		System.out.println(answer);
	}
}


Measured memory_bytes: 97412
import sys
from sys import stdin, stdout
import math
from copy import deepcopy
rem=10**9+7
sys.setrecursionlimit(10 ** 6)
take = lambda: map(int, stdin.readline().split())



n,c=take()
ans=[]
ans2=[]
ans1=[]
ans3=[]
u=[0]
f=[0]
all=[[0,0]]
rev=[[0,0]]
for i in range(n):
    a,b=take()
    all.append([a,b])
    rev.append([c-a,b])
all.sort()
rev.sort()
#print all,rev
tot=0
en=0
for i in all:
    a,b=i
    tot+=b
    en=tot
    ans.append(en-a)
    ans1.append(en-2*a)

tot=0
en=0
for i in rev:
    a,b=i
    tot += b
    en = tot
    ans2.append(en - a)
    ans3.append(en-2*a)

fin=0
#print all,rev
#print ans,ans2
t=0
k=0
for i in range(len(ans)):
    t=max(t,ans[i])
    u.append(t)
    k=max(k,ans2[i])
    f.append(k)

#print ans,ans1,ans2,ans3,f
for i in range(n+1):
    fin=max(fin,ans1[i]+f[n-i+1])
    fin=max(fin,ans3[i]+u[n-i+1])
print fin









Measured memory_bytes: 50668
#include <cstdio>
#include <iostream>
#include <unordered_set>

int main() {
    int n;
    std::scanf("%d", &n);
    std::string a, b;
    std::unordered_set<std::string> us;
    while (n--) {
        std::cin >> a >> b;
        if (a.at(0) == 'i') us.insert(b);
        else std::cout << (us.find(b) != us.end() ? "yes" : "no") << std::endl;
    }
}


Measured memory_bytes: 32328
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main(){
	char a[1000000];
	while(~scanf("%s",a)){
		int t=strlen(a);
		char k,h;
		int sum=0;
		if(a[t-1]=='B')
		{
			k='W';
			h='B';
		}
		else
		{
			k='B';
			h='W';
		}
		char l;
		for(int i=t-1;i>=0;i--){
			if(a[i]==k)
				{
					sum++;
					l=h;
					h=k;
					k=l;
				}
		}
		printf("%d\n",sum);	
	}
	return 0;
}

Measured memory_bytes: 256
//region #include <cp_helper>
#include <algorithm>
#include <array>
#include <bitset>
#include <cstring>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <array>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
#define io() ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define ll long long
#define ull unsigned long long
#define ii pair<int, int>
#define vi vector<int>
#define vvi vector<vi>
#define vll vector<ll>
#define vii vector<ii>
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define pin(n) in(n.first) >> n.second
#define vin(a, n) for (ll i=0; i<n; ++i) in(a[i])
#define viin(a, n) for (ll i=0; i<n; ++i) in2(a[i].first, a[i].second);
#define out(n) cout << n
#define outs(n) out(n) << ' '
#define outn(n) out(n) << '\n'
#define out2(n, m) cout << n << ' ' << m
#define out2s(n, m) out2(n, m) << ' '
#define out2n(n, m) out2(n, m) << '\n'
#define pout(n) out2(n.first, n.second)
#define pouts(n) pout(n) << ' '
#define poutn(n) pout(n) << '\n'
#define vout(a) for (auto i : a) outs(i)
#define viout(a) for (auto i : a) out2n(i.first, i.second)
#define all(a) a.begin(), a.end()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define pp(a, b) emplace_back(make_pair(a, b))
#define fori(i, n) for (ll i=0; i<n; ++i)
#define foris(i, a, b) for (ll i=a; i<b; ++i)
#define ford(i, n) for (ll i=n-1; i>=0; --i)
#define fords(i, a, b) for (ll i=a; i>=b; --i)
#define forr(i, a) for (auto &i : a)
#define umap unordered_map
#define fileio(in, out) freopen("in", "r", stdin); freopen("out", "w", stdout)
const int mod = (int)(1e9) + 7;
//endregion

int main() {
    io();
    int n;
    in(n);
    if (!(n%2)) out(0.5);
    else {
        out((n/2+1)/double(n));
    }
}


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

int N;
int a[200000];

int main() {
    cin >> N;
    rep(i, N) {
        int tmp; 
        cin >> tmp;
        a[i] = tmp;
    }

    int target_idx = 0;
    int target_value = 1;
    int prev_idx = -1;
    int ans = 0;
    bool found = false;
    while (target_idx <= N - 1) {
        found = false;

        // cout << target_idx << endl;
        // printf("target_idx: %d target_value: %d prev_idx %d\n", target_idx, target_value, prev_idx);
        if (target_value == a[target_idx]) {
            // printf("diff %d\n", target_idx - prev_idx);
            ans += target_idx - prev_idx - 1;

            prev_idx = target_idx;
            target_value++;
            found = true;
        }

        target_idx++;
    }
    if (!found) {
        ans += (N - 1) - prev_idx;
    }
    // printf("%d ddd\n", found);

    if (prev_idx == -1) cout << -1 << endl; 
    else cout << ans << endl; 
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;
const int M=1e5+10,MOD=1e9+7;
int n,m,x,f[M],a[M];
bool vis[M];
int dfs(int step)
{
    if(!step) return 1;
    if(vis[step])
        return f[step];
    vis[step]=1;
    int re=0;
    if(step>=2 && !a[step-2])
        re=((ll)re+dfs(step-2))%MOD;
    if(step>=1 && !a[step-1])
        re=((ll)re+dfs(step-1))%MOD;
    return f[step]=re;
}
int main()
{
    cin>>n>>m;
    for(int i=0;i<m;i++)
        scanf("%d",&x),a[x]=1;
    printf("%d",dfs(n));
    return 0;
}


Measured memory_bytes: 2816
N = int(input())
line = list(map(int, input().split()))
countList = [0] * ((10 ** 5) + 1)

ansSum = sum(line)
for i in line:
    countList[i] += 1
Q = int(input())
for i in range(Q):
    B, C = map(int, input().split())
    ansSum += (C - B) * countList[B]
    countList[C] += countList[B]
    countList[B] = 0
    print(ansSum)


Measured memory_bytes: 21152
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, n) for(int i = 1; i <= (int)(n); i++)
const long long INF = 1LL << 60;
int main() 
{
    int n,maxv=-2000000000;
    cin >> n;

    int A[n+100];
    rep(i,n){
        cin >> A[i];
    }
    int minv = A[0];

    for(int i=1; i<n; i++){
        maxv=max(maxv,A[i]-minv);
        minv=min(minv,A[i]);
        }
 

    cout << maxv << endl;

 	return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

typedef pair<pdd, ll> plll;
map<char, ll> di;
const double INF = (1ll << 58);

double evaluate(ll N, vector<plll> &points, double delta){
    double maxx = -INF, may = -INF, mix = INF, miy = INF;
        REP(i, N){
        double nx = points[i].first.first;
        double ny = points[i].first.second;
        ll dd = points[i].second;
        if(dd == 0) nx += delta;
        if(dd == 1) nx -= delta;
        if(dd == 2) ny += delta;
        if(dd == 3) ny -= delta;
        maxx = max(nx, maxx);
        mix = min(nx, mix);
        may = max(ny, may);
        miy = min(ny, miy);
    }
    double res = (maxx - mix) * (may - miy);
    return res;
}

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

    di['R'] = 0;
	di['L'] = 1;
	di['U'] = 2;
	di['D'] = 3;

    ll N;
    cin >> N;
    vector<plll> points;
    REP(i, N){
    	ll x, y;
    	cin >> x >> y;
    	char d;
    	cin >> d;
    	points.push_back({{x, y}, di[d]});
    }

    ll lb = 0;
    ll ub = 101010101010;

    for(;ub-lb>1;){
        ll mid = (lb+ub)/2;
        double val = 1.0*mid/2;
        if(evaluate(N, points, val) - evaluate(N, points, val-0.5) < 0){
            lb = mid;
        }else{
            ub = mid;
        }
    }
    printf("%.10f\n", min(evaluate(N, points, 1.0*ub/2-0.5), evaluate(N, points, 0.0)));
    //cout << evaluate(N, points, 0.5) << endl;


    return 0;
}

Measured memory_bytes: 4852
#include <iostream>
using namespace std;
void drawFlame(int w,int h);
int main(int argc, const char * argv[]) {
    int w,h;
    while (1) {
        cin >> w >> h;
        if (w==0&&h==0) {
            break;
        }
        drawFlame(w, h);
    }
    return 0;
}
void drawFlame(int w ,int h){
    for (int i=1; i<=w; i++) {
        for (int j=1; j<=h; j++) {
            if (i==1||j==1||i==w||j==h) {
                cout <<'#';
            }else{
                 cout <<'.';
            }
        }
        cout<<endl; //改行
    }
    cout<<endl; //改行
}


Measured memory_bytes: 3080