akhauriyash/Code-Regression huggingface dataset:
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/
const int MAXN = 2100;

int was[MAXN];

int p[MAXN];
int sz[MAXN];
int cc[MAXN];
vector<pair<int, int>> go[MAXN];
int n;
vector<int> eds[MAXN];
int rm[MAXN];

pair<int, int> get(int v) {
	if (p[v] == v)
		return make_pair(v, 0);
	else {
		auto pr = get(p[v]);
		pr.second ^= cc[v];
		return pr;
	}
}

int ans = 0;

vector<pair<int, int>> dfs1(int v) {
	was[v] = 1;
	vector<pair<int, int>> cur;
	for (auto p: go[v]) {
		if (rm[p.first] != v)
			cur.push_back(p);
	}
	for (int u: eds[v]) {
		if (was[u])
			continue;
		auto tmp = dfs1(u);
		if (tmp.size() == 1) {
			++ans;
		}
		else if (tmp.size() >= 2) {
			ans += 2;
			map<int, int> mm;
			for (auto x: tmp) {
				auto tt = get(x.first);
				int c = tt.second ^ x.second;
				mm[tt.first] |= (1 << c);
			}
			int fl = 0;
			for (auto x: mm) {
				if (x.second == 3) {
					fl = 1;
					break;
				}
			}
			if (!fl) {
				assert(mm.size() >= 2);
				pair<int, int> x = *mm.begin();
				pair<int, int> y = *(next(mm.begin()));
				if (sz[x.first] > sz[y.first])
					swap(x, y);
				if (x.second == y.second) {
					p[x.first] = y.first;
					cc[x.first] = 1;
					sz[y.first] += sz[x.first];
				}
				else {
					p[x.first] = y.first;
					cc[x.first] = 0;
					sz[y.first] += sz[x.first];
				}
			}
		}
		for (auto x: tmp) {
			if (rm[x.first] != v)
				cur.push_back(x);
		}
	}
	return cur;
}

int ga[MAXN];
int tin[MAXN];
int tout[MAXN];
int pr[MAXN];
int gb[MAXN];
int tm1;

int is_p(int a, int b) {
	return tin[a] <= tin[b] && tin[b] < tout[a];
}

int lca(int a, int b) {
	while (!is_p(a, b))
		a = pr[a];
	return a;
}

void dfs0(int v, int p) {
	pr[v] = p;
	tin[v] = tm1++;
	for (int u: eds[v]) {
		if (u == p)
			continue;
		dfs0(u, v);
	}
	tout[v] = tm1;
}

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	int m;
	cin >> n >> m;
	for (int i = 0; i < n - 1; ++i) {
		int a, b;
		cin >> a >> b;
		--a, --b;
		eds[a].push_back(b);
		eds[b].push_back(a);
	}
	dfs0(0, -1);
	for (int i = 0; i < m; ++i) {
		int a, b;
		cin >> a >> b;
		--a, --b;
		ga[i] = a;
		gb[i] = b;
		go[a].push_back(make_pair(i, 0));
		go[b].push_back(make_pair(i, 1));
		rm[i] = lca(a, b);
	}
	for (int i = 0; i < m; ++i)
		p[i] = i, sz[i] = 1;
	dfs1(0);
	cout << ans << "\n";
	for (int i = 0; i < m; ++i) {
		auto t = get(i);
		if (t.second == 0)
			cout << ga[i] + 1 << " " << gb[i] + 1 << "\n";
		else
			cout << gb[i] + 1 << " " << ga[i] + 1 << "\n";
	}
	return 0;
}




Measured memory_bytes: 896
#include<iostream>
using namespace std;
int main(){
     int x,y;

     while(1){
          cin >> x >> y;
          if(x==0 && y==0){
               break;
          }

          if(x>y){
               cout << y << " "<< x <<endl;
          }
          else{
               cout << x << " "<< y << endl;
          }
     }

     return 0;
}

Measured memory_bytes: 3072
#include <stdio.h>
#include <ctype.h>

#define STACK_SIZE 110

int stack[STACK_SIZE];
int stack_pos = 0;

int pop() {
  return stack[--stack_pos];
}

void push(int a) {
  stack[stack_pos++] =a;
}


int main() {
  char str[128];
  int a, b;
  while(scanf("%s", str) != EOF) {
    if(isdigit(str[0])) {
      push(atoi(str));
    } else {
      b = pop();
      a = pop();
      switch(str[0]) {
      case '+':
        push(a+b);
        break;
      case '-':
        push(a-b);
        break;
      case '*':
        push(a*b);
        break;
      }
    }
  }
  printf("%d\n", pop());
  return 0;
}



Measured memory_bytes: 2052
// INCLUDES
#include <bits/stdc++.h>
//DEFINES
#define pii pair<int, int>
#define c1 __builtin_popcount
#define F first
#define S second
#define all(s) begin(s),end(s)
#define MIN3POS(a, b, c) (a) =< (b) ? ((a) =< (c) ? 1 : 3) : ((b) =< (c) ? 2 : 3)
#define MAX3POS(a,b,c) (a) >= (b) ? ((a) >= (c) ? 1 : 3) : ((b) >= (c) ? 2:3)
#define endl '\n'
#define ll long long
#define ui unsigned int
#define FOR(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define IOS   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//NAMESPACES
using namespace std;
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

void solve(){
int n,k;
cin>>n>>k;
vector<int> v(n),prod(n);
FOR(i,0,n) cin>>v[i];
int flag = 1;
// cout<<"Yes"<<endl;
for(int i=k;i<n;i++) {
    if(v[i] > v[i-k]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}
}
int32_t main()
{
IOS
int t=1;
// cin>>t;
while(t--) {
    solve();
}

return 0;
}
// Use emplace back in place of pushback
// Use tie function , for object destructuring

Measured memory_bytes: 4792
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
#define int ll
#define fi first
#define se second
#define Sort(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/4
#define INTINF INT_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T &a, T b){if(a < b){a = b;return true;}return false;}
template<class T> inline bool chmin(T &a, T b){if(a > b){a = b;return true;}return false;}
/*----------------------------------------------------------------*/
const int MOD = 998244353;
// const int MOD = 1000000007;

int ans[1000100] = {};
/*----------------------------------------------------------------*/
signed main(){

	int n;
	cin >> n;

	vll a(n);
	rep(i,n){
		cin >> a[i];
		ans[a[i]]++;
	}
	Sort(a);

	int anscnt = 0;
	for(auto b:a){
		// cerr << b << endl;
		if(ans[b] == 0)continue;
		else{
			for(int c = 2*b;c <= 1000000;c += b){
				ans[c] = 0;
			}
		}
		if(ans[b] == 1){
			anscnt++;
		}else{
			ans[b] = 0;
		}
	}
	cout << anscnt << endl;

	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=gnu++17 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://pakencamp-2019-day3.contest.atcoder.jp/tasks/pakencamp_2019_day3_c
// rm -r -f test;oj dl https://atcoder.jp/contests/abc170/tasks/abc170_a


Measured memory_bytes: 12708
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define ll long long int
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int a,b,c,d; cin>>a>>b>>c>>d;
    int a1=ceil((double)a/d); int a2=ceil((double)c/b);
    if(a1>=a2)
        cout<<"Yes\n";
    else
        cout<<"No\n";
    return 0;
}

Measured memory_bytes: 3612
using System;
using System.Text.RegularExpressions;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using System.Numerics;

namespace ConsoleApplication1
{
    class Program
    {
        static long[] dx = new long[] { -1, 0, 1, 0 };
        static long[] dy = new long[] { 0, 1, 0, -1 };

        static void Main(string[] args)
        {
            var str = Console.ReadLine().Split();
            var n = Int32.Parse(str[0]);
            var m = Int32.Parse(str[1]);
            var num = new int[n + 1];
            for (int i = 1; i < n + 1; i++) num[i] = 1;

            var ret = new HashSet<int>() { 1 };
            for (int i = 0; i < m; i++)
            {
                str = Console.ReadLine().Split();
                var x = Int32.Parse(str[0]);
                var y = Int32.Parse(str[1]);

                if (ret.Contains(x)) ret.Add(y);

                num[x]--;
                num[y]++;

                if (num[x] == 0) ret.Remove(x);

            }
            Console.WriteLine(ret.Count());
        }
    }
}

Measured memory_bytes: 11696
#include <iostream>
#include <vector>
using namespace std;
int main() {
int N, cnt = 0, p = 0, sn = 1;
cin >> N;
vector<long long> A(N);
for (int i = 0; i < N; ++i) cin >> A[i];
sort(A.begin(), A.end());

while (p < N - 1) {
        if (A[p] != A[p+1]) {
                cnt++;
        } else {
                sn = 1;
                while (p < N - 1 and A[p] == A[p + 1]) {
                        sn++;
                        p++;
                }   
                if (sn % 2 != 0) cnt++;
        }   
        p++;
}

if (A[N - 2] != A[N - 1]) cnt++;
cout << cnt << endl;
}

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

int main(){
	int a, b, c, i;
	cin>>a>>b>>c;
	for(i=0; i<b; i++){
		if((i+1)*a%b==c){
			cout<<"YES"<<endl;
			return 0;
		}
	}
	cout<<"NO"<<endl;
	return 0;
}


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

using namespace std;

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

	vector<pair<int,int>> arr(n);
	for (int i = 0; i < n; i++)
	{
		int c, t;
		cin >> c >> t;

		arr[i] = make_pair(c,t);
	}

	sort(arr.begin(), arr.end());

	for (int i = 0; i < n; i++)
	{
		if (arr[i].second <= t)
		{
			cout << arr[i].first;
			return 0;
		}
	}

	cout << "TLE" << endl;
}

Measured memory_bytes: 256
use std::io;


fn read_line() -> String {
    let mut in_str = String::new();
    io::stdin().read_line(&mut in_str).unwrap();
    return in_str
}


fn main(){

    let mut ln1 = read_line();
    ln1.pop();
    
    let m = ln1.parse::<i32>().unwrap();
    println!("{}", 24 - m + 24);

    
}


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

Measured memory_bytes: 128
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
ctr = Counter(A)
MOD = 10**9+7

if all(a%2 for a in A):
    for i in range(1,N,2):
        if ctr[i] != 2:
            print(0)
            exit()
    else:
        print(pow(2,N//2,MOD))
elif all(a%2==0 for a in A):
    if ctr[0] != 1:
        print(0)
        exit()
    for i in range(2,N,2):
        if ctr[i] != 2:
            print(0)
            exit()
    else:
        print(pow(2,N//2,MOD))
else:
    print(0)

Measured memory_bytes: 14820
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P>IP;
typedef vector<ll> V;
typedef vector<V> V2;
typedef vector<vector<P> > G;
void g_dir(G &graph, ll a, ll b, ll w = 1){graph[a].push_back(P(b, w));}
void g_undir(G &graph, ll a, ll b, ll w = 1){g_dir(graph, a, b, w);g_dir(graph, b, a, w);}
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}
const ll INF = 1145141919;
const ll MOD = 1000000007;
const ll NUM = 101010;

int main(){

    ll K;
    cin >> K;
    V v(K, INF);
    queue<ll>Q[50];
    Q[1].push(1);
    v[1] = 1;
    rep1(i, 45){
        while(!Q[i].empty()){
            ll x = Q[i].front();
            Q[i].pop();
            if(i > v[x])continue;
            if(x == 0){
                cout << v[0] << endl;
                return 0;
            }
            if(v[(x * 10) % K] > i){
                v[(x * 10) % K] = i;
                Q[i].push((x * 10) % K);
            }
            if(x % 10 < 9 && v[(x + 1) % K] == INF){
                v[(x + 1) % K] = i + 1;
                Q[i + 1].push((x + 1) % K);
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 1408
N, L = map(int, input().split())

total = N * (L - 1) + N * (N + 1) / 2
lowest = 10 ** 10
for i in range(1, N + 1):
    y = L + i - 1
    lowest = min(lowest, abs(y))
print(int(total) - lowest) if total >= 0 else print(int(total) + lowest)

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

int main(){
  int N;
  string S;
  cin>>N>>S;
  char C='A';
  int i=0;
  for(char c:S){
    if(c!=C){
      i++;
      C=c;
    }
  }
  cout<<i<<endl;
}

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

#define all(container) container.begin(), container.end()
#define sortall(container) (sort(container.begin(), container.end()))
#define yn(cond) ((cond) ? (cout << "yes" << endl) : (cout << "no" << endl))
#define Yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))

typedef long long       ll;

typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<char>    vc;
typedef vector<string>  vs;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<vi>		vvi;
typedef vector<vll>		vvll;
typedef vector<vd>		vvd;
typedef vector<vb>		vvb;
typedef vector<vc>		vvc;
typedef vector<vs>		vvs;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;

typedef struct edge_ {
	ll to;
	ll cost;
} edge;

typedef struct point_ {
	ll x, y;
	point_(ll x = 0, ll y = 0) : x(x), y(y) {}
} point;

template <typename T>
using mat2d = vector<vector<T>>;

constexpr double	PI = 3.14159265358979323846;
constexpr ll		INF = 1 << 15;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
	for (const T& x : vec) os << x << " ";
	return os;
}

template<typename S, typename T>
istream& operator >> (istream& is, pair<S, T>& p) {
	is >> p.first >> p.second;
	return is;
}

istream& operator >> (istream& is, point& p) {
	is >> p.x >> p.y;
	return is;
}

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

template<typename T>
ostream& operator << (ostream& os, const set<T>& s) {
	for (const T& x : s) os << x << " ";
	return os;
}

ostream& operator << (ostream& os, const edge e) {
	os << "{to: " << e.to << ", cost: " << e.cost << "}";
	return os;
}

ostream& operator << (ostream& os, const point& p) {
	os << "(" << p.x << " " << p.y << ")";
	return os;
}

/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/

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

	int ans = 0;
	int p = 0;
	for (int i = 1; p < X; i++) {
		p += i;
		ans++;
	}

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

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

using namespace std;

const int root = 1;
const long long MOD = 1e9+7;

vector<int> AdjList[100005];

int dist[100005];
int p[100005];

int main(){
	int N, K;
	scanf("%d%d", &N, &K);
	
	for(int i = 0; i < N-1; i ++){
		int a, b;
		scanf("%d%d", &a, &b);
		AdjList[a].push_back(b);
		AdjList[b].push_back(a);
	}
	
	memset(p, -1, sizeof(p));
	memset(dist, -1, sizeof(dist));
	
	queue<int> q;
	q.push(root);
	dist[root] = K;
	while(!q.empty()){
		int u = q.front(); q.pop();
		
		int begin1 = K-1;
		if(u != root){
			begin1 --;
		}
		for(int v: AdjList[u]){
			if(dist[v] == -1){
				dist[v] = begin1;
				begin1 --;
				q.push(v);
			}
		}
	}
	
	long long ans = 1;
	for(int i = 1; i <= N; i ++){
		ans = ans*dist[i]%MOD;
	}
	printf("%lld", ans);
	return 0;
}


Measured memory_bytes: 7288
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
    double n,k,ar[5000009];
int main()
{
    cout << fixed << setprecision(15);
    map<int,int>mp;
    cin >> n >> k;
    for(ll i=1;i<=n;i++)
    {
        cin >> ar[i];
        //mp[ar[i]]++;
    }
    //sort(ar+1,ar+1+n);
    double sum=0.0;
    ll ck=0;
    for(ll i=1;i<=k;i++)
    {
        sum+=(ar[i]*(ar[i]+1))/(2*ar[i]);
    }
    double max1 =0.0;
    ll f=k;
    max1=max(max1,sum);
    for(ll i=2;i<=n;i++)
    {
        ck++;
        f=k+ck;
        //cout << ck << " " << f << endl;
        if(f>n)break;
//        cout << sum << " ";
        double v=(ar[f]*(ar[f]+1.0))/(2.0*ar[f]);
        double v0=(ar[ck]*(ar[ck]+1.0))/(2.0*ar[ck]);
        sum-=v0;
        sum+=v;
//        cout << sum << endl;
        max1=max(max1,sum);
    }
    cout << max1 << endl;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()


int main(){
    int k,x;
    scanf("%d%d",&k,&x);
    for(int i = k-1; i>=1; --i){
         printf("%d ", x-i);
    }
    printf("%d ",x);
    for(int i = 1; i<k; ++i){
        printf("%d ",x+i);
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
using ll = long long;
using namespace std;

int main(){
	ll k,t;
	cin>>k>>t;
	ll a[110];
	rep(i,0,t)cin>>a[i];
	ll m=0;
	rep(i,0,t) m=max(m,a[i]);
	cout<<max((ll)0,2*m-k-1);
}

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

int main(){
	char ch;
	int count[26] = {};
	while (cin >> ch){
		int num = -1;

		if (ch >= 'a'&&ch <= 'z'){
			num = ch - 'a';
			count[num]++;
		}
		if (ch >= 'A'&&ch <= 'Z'){
			num = ch - 'A';
			count[num]++;
		}
	}
	for (int i = 0; i < 26; i++){
		cout << (char)('a' + i) << " : " << count[i] << endl;
	}
	return 0;
}

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

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

  int X = 1;
  for (int i = 0; i < N; i++) {
    if (X * 2 < X + K) {
      X *= 2;
      //cout << "A" << endl; 
    }
    else {
      X += K;
    }
    //cout << "B" << endl;
  }
  cout << X << endl;
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e2 + 5;

int dp[MAXN][MAXN];

void solve(){
	/*int lim = 50;
	REP(s, 2, lim) {
		REPN(x, 0, s) {
			int y = s - x;
			REPN(k, 1, x / 2) {
				if (!dp[x - 2 * k][y + k]) {
					dp[x][y] = 1;
					break;
				}
			}
			REPN(k, 1, y / 2) {
				if (!dp[x + k][y - 2 * k]) {
					dp[x][y] = 1;
					break;
				}
			}
		}
	}
	
	REP(i, 0, lim) {
		REP(j, 0, lim) {
			printf("%d", dp[i][j]);
		}
		putchar('\n');
	}*/
	ll x, y;
	cin >> x >> y;
	if (abs(x - y) <= 1) {
		printf("Brown\n");
	} else {
		printf("Alice\n");
	}
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
static const double pi = 3.141592653589793;



int main(){
    ll N, D, X;
    cin>>N>>D>>X;
    vector<ll> A(N);
    ll Ans=X;
    rep(i, N){
        cin>>A[i];
        Ans+=D/A[i]+1;
      	if(D%A[i]==0)Ans--;
    }
    cout<<Ans<<endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String args[]){
		ArrayList[] a;
		a=new ArrayList[10];
		a[1]=new ArrayList<Integer>();
		//a[1].add(3);
		for(int i=1;i<=9;i++){
			for(int j=1;j<=9;j++){
				System.out.printf("%dx%d=%d\n",i,j,i*j);
			}
		}
		
	}
}

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

int main() {
    int h, w, n;
    cin >> h >> w >> n;
    int big = max(h, w);
    int ans = (n+big-1)/big;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3596
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a += b;
	if(a>MOD){
		a -= MOD;
	}
}

ll f(ll a, ll b){
	if(a<b){
		swap(a,b);
	}
	return ((b)?(a-(a%b))*2+f(b,a%b):(-a));
}

int main(void){
	ll n,x;
	cin >> n >> x;
	cout << (n+f(x,n-x)) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int main(){
  const char *str[4]={"NA", "YYMM", "MMYY", "AMBIGUOUS"};
  int YYMM, res=0;
  rd(YYMM);
  if(1 <= YYMM/100  &&  YYMM/100 <= 12){
    res += 2;
  }
  if(1 <= YYMM%100  &&  YYMM%100 <= 12){
    res += 1;
  }
  wt_L(str[res]);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190526-1

// --- original code ---
// {
//   int YYMM;
//   const char *str[4] = {"NA", "YYMM", "MMYY", "AMBIGUOUS"};
//   int res = 0;
// 
//   rd(YYMM);
//   if(1 <= YYMM/100 <= 12) res += 2;
//   if(1 <= YYMM%100 <= 12) res += 1;
//   wt(str[res]);
// }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    int N,K;cin >> N >> K;
    vector<ll> A(N);
    REP(i,N){
        cin >> A[i];A[i]--;
        if(i > 0) A[i] += A[i-1];
    }
    A.pb(0);
    sort ALL(A);
    ll ans = 0,cnt = 1;
    map<ll,int> V;
    REP(i,N+1){
        ans += V[A[i]%K];
        V[A[i]%K]++;
        int t = i - K + 1;
        if(t >= 0) V[A[t]%K]--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 15588
a, b, c, d = map(int, input().split())

# print(a)
# print(b)
# print(c)
# print(d)

area1 = a * b
area2 = c * d

# print(area1)
# print(area2)

if area1 == area2:
    print(area1)
elif area1 > area2:
    print(area1)
else:
    print(area2)

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

using namespace std;

string a[51];
string b[51];

int main()
{
    #ifdef DEBUG
    freopen("input.txt", "r", stdin);
    #endif
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }
    for (int i = 0; i < m; i++){
        cin >> b[i];
    }
    for (int i = 0; i + m <= n; i++){
        for (int j = 0; j + m <= n; j++){
            bool b1 = true;
            for (int di = 0; di < m; di++){
                for (int dj = 0; dj < m; dj++){
                    if (a[i + di][j + dj] != b[di][dj]){
                        b1 = false;
                        break;
                    }
                }
                if (!b1) break;
            }
            if (b1){
                cout << "Yes";
                return 0;
            }
        }
    }
    cout << "No";
    return 0;
}


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

using namespace std;


int main()
{
    int n, m;
    unsigned long long k;
    unsigned long long a[200001], b[200001];
    
    cin >> n >> m >> k;
    for (int i = 1; i <=n ; i++) {
        cin >> a[i];
        a[i] += a[i-1];
    }
    for (int i = 1; i <= m ; i++) {
        cin >> b[i];
        b[i] += b[i-1];
    }
    int mm = 0;
    for (int i = 0; i <= n; i++) {
        for (int j = mm - i; j <= m; j++) {
            if (a[i] + b[j] <= k) {
                mm = max(mm, i+j);
            } else {
                break;
            }
        }
    }
    cout << mm << endl;
    return 0;
}

Measured memory_bytes: 6720
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define upperlimit 1000100
#define INF 1000000100
#define INFL 1000000000000000100
#define eps 1e-8
#define endl '\n'
#define sd(n) scanf("%d",&n)
#define slld(n) scanf("%lld",&n)
#define pd(n) printf("%d",n)
#define plld(n) printf("%lld",n)
#define pds(n) printf("%d ",n)
#define pllds(n) printf("%lld ",n)
#define pdn(n) printf("%d\n",n)
#define plldn(n) printf("%lld\n",n)
#define REP(i,a,b) for(i=a;i<=b;i++)
#define mp make_pair
#define pb push_back
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define F first
#define S second
#define clr(a) memset(a,0,sizeof(a))
using namespace std;

ll gcd(ll n1,ll n2){
	if(!n1)return n2;
	if(!n2)return n1;
	if(n1%n2==0)return n2;
	return gcd(n2,n1%n2);
}
ll powmod(ll base,ll exponent){
	base%=mod;
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	ans%=mod;
	return ans;
}
int main()
{
	int n,a,b,c;
	sd(n);
	for(a=1;a<=3500;a++)for(b=1;b<=3500;b++){
		ll temp1=(1LL*n*a*b);
		ll temp2=(4*a*b-a*n-b*n);
		if(temp2>0)if(temp1%temp2==0){
			cout<<a<<" "<<b<<" "<<(temp1/temp2)<<endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

res = []
res.append(abs(a - b))
res.append(abs(a - c))
res.append(abs(a - d))
res.append(abs(a - e))
res.append(abs(b - c))
res.append(abs(b - d))
res.append(abs(b - e))
res.append(abs(c - d))
res.append(abs(c - e))
res.append(abs(d - e))

res = sorted(res)
if res[-1] > k:
    print(':(')
else:
    print('Yay!')

Measured memory_bytes: 3064
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Maybe

readInt = fromIntegral . fst . fromJust . BS.readInteger

readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine

getIntList = readIntList <$> BS.getLine

getNum :: [Int] -> Int
getNum xs
  | l > h = l - h
  | l == h = 0
  | l < h = l
  where
    h = head xs
    l = length xs

elemCountOrd :: [Int] -> Int
elemCountOrd = sum . map (\xs -> getNum xs) . group . sort

main = do
  n <- getInt
  as <- getIntList
  print $ elemCountOrd as


Measured memory_bytes: 20000
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iomanip>
#include <map>
#include <queue>

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
//#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define INF 1e9

using namespace std;
typedef long long  ll;

const long long MOD = 1e9+7;

int main(){
    int x;
    cin >> x;
    int coin_500 = 0;
    int coin_5 = 0;
    coin_500 = x / 500;
    coin_5 = (x % 500) / 5;
    p(coin_500 * 1000 + coin_5 * 5);
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i,j,n) for (int i=(j); i < (n); i++)
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 n; cin >> n;
    vector<int> A(n), B(n), C(n-1);
    rep(i, n) cin >> A[i], A[i]--;
    rep(i, n) cin >> B[i];
    rep(i, n-1) cin >> C[i];

    int res = 0;
    rep(i, n){
        res += B[A[i]];
        if(i<n-1 && A[i]+1==A[i+1]){
            res += C[A[i]];
        }
    }    
    cout << res << ln;
}

Measured memory_bytes: 3624
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;


typedef long long i64;
const int inf = (int)1.05e9;

int waf(char x, char a, char b, char c)
{
	int t = 0;
	if(x != a) t += 1;
	if(x != b) t += 1;
	if(x != c) t += 1;
	return t;
}

int main()
{
	char a[1024], b[1024], c[1024];
	int n;

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

	int ans = 0;

	for(int i = 0; i < n; ++i) {
		int p = 3;
		p = min(p, waf(a[i], a[i], b[i], c[i]));
		p = min(p, waf(b[i], a[i], b[i], c[i]));
		p = min(p, waf(c[i], a[i], b[i], c[i]));
		ans += p;
	}

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

	return 0;
}

/* waffle */


Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner scn = new Scanner(System.in);
        int a = scn.nextInt();
        int b = scn.nextInt();

        int s = a*b;
        int r = (a+b)*2;
        System.out.println(s+" "+r);
    }
}


Measured memory_bytes: 26408
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;

int main() {

    int n, m;

    cin >> n >> m;
    auto pf = [&](const pair<int, int> &a, const pair<int, int> &b) { return a.first > b.first; };

    priority_queue<pair<int, int>, vector<pair<int, int>>, decltype(pf)> works(pf);


    for(int i = 0; i < n; ++i) {
        pair<int, int> w;
        cin >> w.first >> w.second;
        works.push(w);
    }


    auto ps = [&](const pair<int, int> &a, const pair<int, int> &b) { return a.second < b.second; };
    priority_queue<pair<int, int>, vector<pair<int, int>>, decltype(ps)> works_Value(ps);

    int day = 1;
    int sum = 0;

    while(day <= m) {
     
        while(!works.empty() && works.top().first <= day) {
            works_Value.push(works.top());
            works.pop();
        }

        if(!works_Value.empty()) {
            sum += works_Value.top().second;
            works_Value.pop();
        }
        day++;

    }

    cout << sum << endl;
    return 0;

}

Measured memory_bytes: 2548
function Main(input){
	input = input.split(" ").map(a=>~~a);
  if(input[0]>8)return ":(";
  if(input[1]>8)return ":(";
  
  return "Yay!"
}

// If you are interested in the algorithms I used, 
// there is no need to read down from this line.

((b,c,d)=>"undefined"!=typeof require?console.log(Main(require("fs").readFileSync("/dev/stdin","utf8"))):[b=b.split("\n").slice(1,-1).join("\n"),c=function(){try{return Main(b)}catch(f){return f.stack||f.message}}(),d=typeof c,"string"==d||(c=JSON.stringify(c)),$("<form>").append([[10,b],0,[1,d],0,[10,c]].map(f=>$(f?"<textarea>":"<br>",f&&{rows:f[0],cols:40,text:f[1]}))).appendTo("body")])(`
8 8
`);

Measured memory_bytes: 7372
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

struct BIT{
    int n;
    VL bit;

    BIT(){}
    BIT(int x){
        n = x;
        bit.assign(n+1, 0);
    }

    void init(int x){
        n = x;
        bit.assign(n+1, 0);
    }

    void add(int i, ll x){
        i++;
        while (i <= n){
            bit[i] += x;
            i += i & -i;
        }
    }

    // [0, i]
    ll sum(int i){
        i++;
        ll ret = 0;
        while (i > 0){
            ret += bit[i];
            i -= i & -i;
        }
        return ret;
    }

    // [l, r)
    ll sum(int l, int r){
        if (l >= r) return 0;
        return sum(r-1) - sum(l-1);
    }
};

int main() {
    ll n, d, a;
    cin >> n >> d >> a;
    vector<PL> p(n);
    REP(i,n){
        p[i].first = in();
        p[i].second = in();
    }
    sort(ALL(p));
    VL x(n), h(n);
    REP(i,n){
        x[i] = p[i].first;
        h[i] = p[i].second;
    }
    BIT bit(n + 1);
    bit.add(0, h[0]);
    FOR(i,1,n-1) bit.add(i, h[i] - h[i - 1]);
    ll ans = 0;
    int j = 0;
    REP(i,n){
        while (j < n && x[j] <= x[i] + 2 * d) j++;
        ll s = bit.sum(i);
        if (s <= 0) continue;
        ll c = (s + a - 1) / a;
        ans += c;
        bit.add(i, -c * a);
        bit.add(j, c * a);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8064
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>

using namespace std;

int main(){

  string s;
  cin >> s;

  int flag = 0;
  if (s[0] != 'A'){
    flag = 1;
  }

  int flag2 = 0;
  for (int i = 2; i < s.size() - 1; i++){
    if (s[i] == 'C'){
      flag2 += 1;
    }
  }
  if (flag2 == 1){
    flag2 = 0;
  }else {
    flag2 = 1;
  }

  int flag3 = 0;
  for (int i = 0; i < s.size(); i++){
    if ((s[i] == 'C') || (s[i] == 'A')){
      continue;
    }
    else {
      if ((s[i] >= 'A') && (s[i] <= 'Z')){
        flag3 = 1;
      }
    }
  }

  if ((flag + flag2 + flag3) == 0) {
    cout << "AC" << endl;
  }
  else {
    cout << "WA" << endl;
  }

  return 0;
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M;
    cin >> N;
    map<string,int> counter;
    REP(i,N){
        string N;
        cin >> N;
        if(counter.count(N)){
            counter.at(N)++;
        }else{
            counter.emplace(N,1);
        }
    }
    cin >> M;
    REP(i,M){
        string N;
        cin >> N;
        if(counter.count(N)){
            counter.at(N)--;
        }else{
            counter.emplace(N,-1);
        }
    }
    int ans = 0;
    for(auto i = counter.begin();i != counter.end();i++){
        ans = max(ans,(*i).second);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

const INF: i64 = 1 << 50;

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize, t: usize,
        ab: [(usize, i64); n],
    }
    let mut ab = ab;
    ab.sort();
    let mut dp = vec![vec![-INF; t + 1]; n + 1];
    dp[0][0] = 0;
    for i in 0..n {
        for j in 0..t + 1 { dp[i + 1][j] = dp[i][j]; }
        for j in 0..t {
            let toj = min(j + ab[i].0, t);
            dp[i + 1][toj] = max(dp[i + 1][toj], dp[i][j] + ab[i].1);
        }
    }
    let &ma: &i64 = dp[n].iter().max().unwrap();
    puts!("{}\n", ma);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 94460
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<ll,int> p;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;
const int INF = 1001001001;

int main() {
  ll n, c;
  cin >> n >> c;
  vector<ll> x(n), v(n);
  rep(i, n) {
    cin >> x[i] >> v[i];
  }
  vector<ll> s1(n), s2(n);
  ll cur = 0;
  ll maxv = 0;
  rep(i, n) {
    cur += v[i];
    maxv = max(maxv, cur - x[i]);
    s1[i] = max(0LL, maxv);
  }
  cur = 0;
  maxv = 0;
  for (int i = n - 1; i >= 0; --i) {
    cur += v[i];
    maxv = max(maxv, cur - (c - x[i])); 
    s2[i] = max(maxv, 0LL);
  }

  ll ans = 0;
  rep(i, n) {
    ll xx = s1[i];
    ll yy = 0;
    if(i != n - 1) yy = max(0LL, s2[i + 1] - x[i]);
    ans = max(ans, xx + yy);
  }

  for(int i = n - 1; i >= 0; --i) {
    ll xx = s2[i];
    ll yy = 0;
    if(i != 0) yy = max(0LL, s1[i - 1] - (c - x[i]));
    ans = max(ans, xx + yy);
  }
  cout << ans << endl;

}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int a,b,c,x,y;
int main()
{
	scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
	if(a+b>c*2)
		if(x>y)
		{
			if(a<c*2)
				printf("%d",2*c*y+(x-y)*a);
			else
				printf("%d",2*c*x);
		}
		else
		{
			if(b<c*2)
				printf("%d",2*c*x+(y-x)*b);
			else
				printf("%d",c*2*y);
		}
	else
		printf("%d",a*x+b*y);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"-----------------"#x"-----------------\n"
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
                    For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int,int> pii;
LL read(){
    LL x=0,f=0;
    char ch=getchar();
    while (!isdigit(ch))
        f=ch=='-',ch=getchar();
    while (isdigit(ch))
        x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
    return f?-x:x;
}
const int N=1000005*3;
int k,n,m;
int _a[N],_b[N],*a=_a,*b=_b;
void IN(){
	static char s[N],t[N];
	n=read(),m=read(),k=read();
	cin>>(s+1)>>(t+1);
	For(i,1,n)
		a[i]=s[n-i+1]-'0';
	For(i,1,m)
		b[i]=t[m-i+1]-'0';
}
int p[N];
typedef pair <int,pair <int,int> > Node;
struct cmp{
	bool operator () (Node a,Node b){
		if (a.fi!=b.fi)
			return a.fi>b.fi;
		return a.fi>b.fi;
	}
};
priority_queue <Node,vector <Node>,cmp> Q;
int main(){
	IN();
	n=m=max(n,m)*2;
	For(i,1,n)
		if (a[i]&&b[i])
			p[i]=1,a[i]=b[i]=0;
//	outarr(p,1,n);
//	outarr(a,1,n);
//	outarr(b,1,n);
	int las=0;
	For(i,1,n)
		if (a[i]||b[i]||p[i]){
			if (p[las]&&!p[i]){
				Q.push(mp(i-las,mp(las,i)));
//				printf("push(%d,%d,%d)\n",i-las,las,i);
				las=0;
			}
			if (p[i])
				las=i;
		}
	int rev=0;
//	outtag(START);
	while (!Q.empty()){
		Node tmp=Q.top();
		Q.pop();
		if (tmp.fi>k)
			break;
		int now=tmp.fi,x=tmp.se.fi,y=tmp.se.se;
		if (!p[x]||(!a[y]&&!b[y]))
			continue;
//		outval(now),outval(x),outval(y);
//		outtag(ROUND_START);
		if (!a[y])
			rev^=1,swap(a,b);
		int yp=y;
		while (a[yp])
			a[yp++]=0;
//		outtag(PART1_END);
		a[yp]=1;
		b[y]=1;
		p[x]=0;
//		For(i,1,now*2)putchar(' ');outarr(p,1,n);
//		outarr(a,1,n);
//		outarr(b,1,n);
		int yq=y-1;
		while (yq-now>0&&!p[max(yq-now,0)]&&!a[yq]&&!b[yq])
			yq--;
//		assert(yq-now>=0);
//		outtag(MID);
		if (p[yq-now])
//			printf("push1(%d,%d,%d)\n",y-yq+now,yq-now,y),
			Q.push(mp(y-yq+now,mp(yq-now,y)));
		if (a[yp]&&b[yp]){
			p[yp-now]=1;
			a[yp]=b[yp]=0;
			int zp=yp+1;
			while (zp<=n+now&&!p[zp-now]&&!a[zp]&&!b[zp])
				zp++;
			if (a[zp]^b[zp])
//				printf("push2(%d,%d,%d)\n",zp-yp+now,yp-now,zp),
				Q.push(mp(zp-yp+now,mp(yp-now,zp)));
		}
//		outval(now);
//		For(i,1,now*2)putchar(' ');outarr(p,1,n);
//		outarr(a,1,n);
//		outarr(b,1,n);
//		outtag(NEXTROUND);
	}
//	outtag(FINAL);
	if (rev)
		swap(a,b);
	For(i,1,n)
		if (p[i])
			a[i+k]=b[i+k]=1;
	n=m=2e6+3;
	while (!a[n])
		n--;
	while (!b[m])
		m--;
	Fod(i,n,1)
		putchar('0'+a[i]);
	puts("");
	Fod(i,m,1)
		putchar('0'+b[i]);
	puts("");
	return 0;
}

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

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

signed main() {
	int n, ans = 0;
	cin >> n;
	int cnt = 0;
	rep(i, n) {
		int a;
		cin >> a;
		if (a == i + 1) cnt++;
		else {
			ans += (cnt + 1) / 2;
			cnt = 0;
		}
	}
	ans += (cnt + 1) / 2;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
<?php

fscanf(STDIN,"%d %d",$A,$B);

$koubaisu_ab = $A*$B;

$koubaisu_ab_before = 0;

while($koubaisu_ab != $koubaisu_ab_before){
  $koubaisu_ab_before = $koubaisu_ab;
  for($i=2;$i<1000000;$i++){
     if($koubaisu_ab%$i==0 && $koubaisu_ab != $i 
     && $A<=$koubaisu_ab/$i && $B<=$koubaisu_ab/$i
     && ($koubaisu_ab/$i)%$A==0 && ($koubaisu_ab/$i)%$B==0){
      $koubaisu_ab /= $i;
      break;
    }
  }
}


echo $koubaisu_ab."\n";


Measured memory_bytes: 4728
from fractions import*
N,*A=map(int,open(0).read().split())
B=[0]
a=range(N)
for x in a:B+=[gcd(B[-1],A[x])]
w=M=0
for x in a[::-1]:M=max(M,gcd(w,B[x]));w=gcd(w,A[x])
print(M)

Measured memory_bytes: 16148
a = input()
word = "keyence"
if a[:7] == word or a[-7:]==word:
    print("YES")
elif (a[0]=="k" and a[-6:]=="eyence") or \
        (a[:2]=="ke" and a[-5:]=="yence") or \
        (a[:3]=="key" and a[-4:]=="ence") or \
        (a[:4]=="keye" and a[-3:]=="nce") or \
        (a[:5]=="keyen" and a[-2:]=="ce") or \
        (a[:6]=="keyenc" and a[-1]=="e"):
        print("YES")

else:
    print("NO")



Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define f first
#define s second
#define fastio ios_base::sync_with_stdio(false); cin.tie(0)
#define loop(i, a, b) for(lli i=a; i<b; i++)
#define loopb(i, a, b) for(lli i=a; i>=b; i--)
#define pb push_back
typedef long long int lli;
typedef pair<lli, lli> pii;
typedef vector<lli> vll;
// use to avoid collision
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// for pair in unordered_map
struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
lli power(lli x, lli y){
    lli res = 1;
    x = x ;
    while (y > 0) {
        if (y & 1)
            res = (res*x) ;
        y = y>>1;
        x = (x*x);
    }
    return res;
}
lli solve(){
	lli n, k;
	cin>>n>>k;
	vll a(n);
	loop(i, 0, n)	cin>>a[i];
	vector<bool> dp(k+1, false);
	loop(i, 1, k+1){
		bool flag = false;
		loop(j, 0, n){
			if(a[j] > i)
				break;
			lli temp = i - a[j];
			if(dp[temp] == false){
				flag = true;
				break;
			}
		}
		dp[i] = flag;
	}
	if(dp[k])
		cout<<"First\n";
	else
		cout<<"Second\n";
	
}
int main(){
	fastio;
	lli t;
//	cin>>t;
	t = 1;
	while(t>0){
		t--;
		solve();
	}
}

Measured memory_bytes: 256
def check_num(n):
	a=list(n)
	b=list(n)
	a.reverse()
	if a==b:
		return True
	else:
		return False
num=[x for x in input().split()]
A=int(num[0])
B=int(num[1])
cnt=0
for i in range(A,B+1):
	if check_num(str(i)):
		cnt+=1
	else:
		continue
print(cnt)

Measured memory_bytes: 3064