akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<cstring>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int           long long
#define umapii        unordered_map<int,int>
#define ps(x,y)       fixed<<setprecision(y)<<x // sets precision upto required digits
#define arr(a,n)      int n;cin>>n;int a[n];for(int i=0;i<n;i++){cin>>a[i];}
#define outarr(a,n)   for(int i=0;i<n;i++){cout<<a[i]<<" ";}
#define mod           1000000007
#define ff            first
#define big           1e15
#define ss            second
#define add           push_back
#define remove        pop_back
#define mapii         map<int,int>
#define large         *max_element
#define small         *min_element
#define float         double
#define pqi           priority_queue<int>
#define mpqi          priority_queue<int,vector<int>,greater<int>>
#define in(n)         int n;cin>>n;
#define w(t)          int t;cin>>t;while(t--)
#define vi            vector<int>
#define vivi          vector<vector<int>>
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>pbds;



int32_t main() {
#ifndef ONLINE_JUDGE
    freopen("input1.txt", "r", stdin);
    freopen("output3.txt", "w", stdout);
#endif

    int x,y;
    cin>>x>>y;
    int i=0,j=x;
    while(true){
        int temp = i*2+j*4;
        if(temp==y){
            cout<<"Yes"<<endl;
            return 0;
        }
        i++;
        j--;
        if(i>x){
            break;
        }
    }
    cout<<"No"<<endl;

}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
int n;
long long x[100100],v[100100],a[100100],b[100100],c,res;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>c;
	for(int i=1;i<=n;i++){
		cin>>x[i]>>v[i];
	}
	x[n+1]=c;
	for(int i=1;i<=n;i++){
		a[i]=a[i-1]-(x[i]-x[i-1])+v[i];
	}
	for(int i=n;i>=1;i--){
		b[i]=b[i+1]-(x[i+1]-x[i])+v[i];
	}
	for(int i=1;i<=n;i++)
		a[i]=max(a[i],a[i-1]);
	for(int i=n;i>=1;i--)
		b[i]=max(b[i],b[i+1]);
	for(int i=1;i<=n;i++){
		res=max(res,a[i]);
		res=max(res,b[i]);
		res=max(res,a[i]-x[i]+b[i+1]);
		res=max(res,b[i]-(c-x[i])+a[i-1]);
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 3456
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <set>
#include <map>
#include <stack>
#include <vector>
#include <cmath>
#include <string>
#include <queue>
#include <cstring>
#include <cstdio>
#define INF 0x3f3f3f3f
typedef long long ll;
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k;
    cin>>n>>k;
    int ans = 1;
    for(int i=1;i<=n;i++)
    {
        ans = min(ans*2,ans+k);
    }
    cout<<ans<<endl;

    return 0;
}



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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define MOD 1000000007
#define el endl
typedef long long ll;

int main() {
    string s, sp = "";
    cin >> s;
    
    for(int i = (int)s.length()-1; i >= 0; i--){
        sp += s[i];
        if(sp == "maerd" || sp == "esare" || sp == "remaerd" || sp == "resare") sp = "";
        if(sp.length() == 7){
            cout << "NO" << endl;
            return 0;
        }
    }
    
    cout << "YES" << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <bitset>
#include <queue>

#define pb push_back
#define ins insert
#define pob pop_back
#define er erase
#define emp empty
#define f first
#define s second
#define ff f.f
#define fs f.s
#define sf s.f
#define ss s.s
#define var auto
#define M int main()
#define For(itr,max) for(int itr = 0;itr <= max;itr++)

using namespace std;
template<typename  T>
using s = set<T>;
template<typename T>
using  v = vector<T>;
template<typename T1, typename  T2>
using p = pair < T1, T2>;
typedef p<int, int> pii;
typedef v<int> vi;
typedef v<pii> vpii;
typedef s<int> si;
typedef s<pii> spii;
typedef long long ll;


//const int Max = 1e8 + 10;
const int Mx = 1e5;
ll n, k;
ll H[Mx];
ll dp[Mx];
int main()
{
	cin >> n >> k;
	for (int i = 0; i < n; i++)
	{
		cin >> H[i];
	}

	dp[n - 1] = 0;
	for (int i = n - 1; i--;)
	{
		dp[i] = 1e18;
		for (int j = 1; j <= k; j++)
		{
			if (i + j == n)
				break;
			dp[i] = min(dp[i], dp[i + j] + abs(H[i] - H[i + j]));
		}
	}

	cout << dp[0];
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


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

	ll x;
	cin >> x;
	for (ll i = -1000; i <= 1000; i++) {
		for (ll j = -1000; j <= 1000; j++) {
			if (i*i*i*i*i - j*j*j*j*j == x) {
				cout << i << ' ' << j << '\n';
				return 0;
			}
		}
	}
}

Measured memory_bytes: 3688
#include  <cstdio>
#include <cstdlib>

using namespace std;

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

	if(a<=c&&c<=b){
		printf("Yes\n");
	}else{
		printf("No\n");
	}

	return 0;
}


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

int main() {
  int N,A,B;
  cin >> N >> A >> B;
  int sum=0;
  for(int i=1;i<N+1;i++){
    int su=i%10+(i/10)%10+(i/100)%10+(i/1000)%10+(i/10000)%10+(i/100000)%10;
    if(su>=A && su<=B)sum+=i;
  }
  cout << sum;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fill fill_n
#define pb push_back
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string x,y,s="",t="";
	cin>>x>>y;
	int a=x.length();
	int b=y.length();
	s+='2';t+='2';
	s.append(x);
	t.append(y);
	ll dp[a+2][b+2];
	memset(dp,0,sizeof(dp));
	for(int i=1;i<=a;i++){
	    for(int j=1;j<=b;j++){
	        
	        if(s[i]==t[j]) dp[i][j]= 1+dp[i-1][j-1];
	        else{
	            dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
	        }
	    }
	}
	if(dp[a][b]==0) cout<<" ";
	else{
	int i=a,j=b;
	vector<char> v;
	while(i>0&&j>0){
	    if(s[i]==t[j]){
	        v.pb(s[i]);
	        i--;j--;
	    }
	    else if(dp[i-1][j]>dp[i][j-1]){
	        i--;
	    }
	    else j--;
	}
	
	reverse(v.begin(),v.end());
	for(auto i:v){
	    cout<<i;
	}
	
	    
	}
	
	
	
	
	return 0;
}


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

#define mod 1000000007
typedef int integer;
#define int long long
using namespace std;

const int N = 100005;


int n;
int ar[100][2];

double dist(double x1, double y1, double x2, double y2) {
    return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}

integer main() {
    ios_base::sync_with_stdio(false);

    cin >> n;
    int x1 = 10000, x2 = -1, y1 = 10000, y2 = -1;
    for (int i = 0; i < n; i++) {
        cin >> ar[i][0] >> ar[i][1];
        x1 = min(x1, ar[i][0]);
        x2 = max(x2, ar[i][0]);
        y1 = min(y1, ar[i][1]);
        y2 = max(y2, ar[i][1]);
    }
    double ans = 1e15;
    if (n == 2) {
        ans = dist(ar[0][0], ar[0][1], ar[1][0], ar[1][1]) / 2.0;
    }
//
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            for (int l = j + 1; l < n; l++) {
                double x1 = ar[i][0], y1 = ar[i][1], x2 = ar[j][0], y2 = ar[j][1], x3 = ar[l][0], y3 = ar[l][1];

                double a = x1 * (y2 - y3) - y1 * (x2 - x3) + x2 * y3 - x3 * y2;
                double b = (x1 * x1 + y1 * y1) * (y3 - y2) + (x2 * x2 + y2 * y2) * (y1 - y3) +
                           (x3 * x3 + y3 * y3) * (y2 - y1);
                double c = (x1 * x1 + y1 * y1) * (x2 - x3) + (x2 * x2 + y2 * y2) * (x3 - x1) +
                           (x3 * x3 + y3 * y3) * (x1 - x2);
                double d = (x1 * x1 + y1 * y1) * (x3 * y2 - x2 * y3) + (x2 * x2 + y2 * y2) * (x1 * y3 - x3 * y1) +
                           (x3 * x3 + y3 * y3) * (x2 * y1 - x1 * y2);
                double mx = -1 * b / (2 * a);
                double my = -1 * c / (2 * a);
                double r = sqrt((b * b + c * c - 4 * a * d) / (4 * a * a));

                bool f = true;
                for (int k = 0; k < n; k++) {
                    if (k == i || k == j || k == l) continue;
                    if (dist(mx, my, ar[k][0], ar[k][1]) > r) {
                        f = false;
                        break;
                    }
                }
                if (f) {
                    ans = min(ans, r);
                }
            }
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            double x1 = ar[i][0], y1 = ar[i][1], x2 = ar[j][0], y2 = ar[j][1];

            double mx = fabs(x1 + x2) / 2.0;
            double my = fabs(y1 + y2) / 2.0;
            double r = dist(x1, y1, x2, y2) / 2.0;
//            cout << mx << ' ' << my << ' ' << r << endl;

            bool f = true;
            for (int k = 0; k < n; k++) {
                if (k == i || k == j) continue;
                if (dist(mx, my, ar[k][0], ar[k][1]) > r) {
                    f = false;
                    break;
                }
            }
            if (f) {
                ans = min(ans, r);
            }
//            cout << ans << endl;
        }
    }
    cout << fixed << setprecision(10) << ans << endl;

}



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

const int Maxn = 1005;

int my[Maxn];
int a, b;

int main()
{
	int cur = 0;
	for (int i = 1; i < Maxn; i++) {
		cur += i;
		my[i] = cur;
	}
	scanf("%d %d", &a, &b);
	for (int i = 1; i + 1 < Maxn; i++)
		if (my[i] > a && my[i + 1] > b && my[i] - a == my[i + 1] - b) {
			printf("%d\n", my[i] - a);
			return 0;
		}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lst long long
#define ldb double
#define N 100050
#define M 100000
using namespace std;
const int Inf=1e9;
int read()
{
	int s=0,m=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')m=1;ch=getchar();}
	while( isdigit(ch))s=(s<<3)+(s<<1)+(ch^48),ch=getchar();
	return m?-s:s;
}

int n;
int v[N],p1[N],p2[N],Ans;
struct POT{int num,id;}mx1,mx2,mx3,mx4;

int main()
{
	n=read();
	for(int i=1;i<=n;++i)
	{
		v[i]=read();
		if(i&1)p1[v[i]]++;
		else   p2[v[i]]++;
	}
	for(int i=1;i<=M;++i)
	{
		if(p1[i]>mx1.num)mx2=mx1,mx1=(POT){p1[i],i};
		else if(p1[i]>mx2.num)mx2=(POT){p1[i],i};
		if(p2[i]>mx3.num)mx4=mx3,mx3=(POT){p2[i],i};
		else if(p2[i]>mx4.num)mx4=(POT){p2[i],i};
	}
	if(mx1.id!=mx3.id)Ans=mx1.num+mx3.num;
	else Ans=max(mx1.num+mx4.num,mx2.num+mx3.num);
	printf("%d\n",n-Ans);
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll h, w, k;
    cin >> h >> w >> k;

    vvll a(h, vll(w));
    char c;
    vll zero(h);
    REP(i, h) {
        REP(j, w) {
            cin >> c;
            if (c == '#') {
                a[i][j] = 1;
                zero[i] = 1;
            }
        }
    }
    
    vvll used(h, vll(w));
    ll col = 1;
    REP(i, h) {
        REP(j, w) {
            if (a[i][j]) { // イチゴを発見
                ll cw = j, left, right;
                // 左に行けるとこまで左へ
                while (cw - 1 >= 0) {
                    if (a[i][cw - 1] || used[i][cw - 1]) break;
                    cw--;
                }
                left = cw;
                cw = j;
                // 右に行けるとこまで右へ
                while (cw + 1 < w) {
                    if (a[i][cw + 1] || used[i][cw + 1]) break;
                    cw++;
                }
                right = cw;
                ll ch = i;
                // 左右に行けるとこまで今見ているイチゴぶんの領域として塗る
                // 上の列が塗られていなければ塗る
                while (ch >= 0) {
                    if (ch != i && zero[ch]) break;
                    for (int p = left; p <= right; p++) {
                        used[ch][p] = col;
                    }
                    ch--;
                }
                ch = i;
                while (ch < h) {
                    if (ch != i && zero[ch]) break;
                    for (int p = left; p <= right; p++) {
                        used[ch][p] = col;
                    }
                    ch++;
                }
                // cout << col << " " << left << " " << right << endl;
                col++;
            }
        }
    }
    REP(i, h) {
        REP(j, w) cout << used[i][j] << " ";
        cout << endl;
    }
    return 0;
}

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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1LL<<60;
const int MINF = 1e9;
const int MOD = 1e9+7;

using vi = vector<int>;
using vii = vector<vi>;

template<typename T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

int main(){
    int n;cin >> n;
    map<string,int> mp;
    rep(i,n){
        string s;cin >> s;
        mp[s]++;
    }

    auto max_itr = max_element(ALL(mp), [](auto a,auto b){
        if(a.second < b.second)return true;
        else return false;
    });
    int Max = max_itr->second;

    for(auto itr = mp.begin(); itr != mp.end(); itr++){
        if(Max == itr->second)cout << itr->first << endl;
    }
    return 0;
}

Measured memory_bytes: 25216
#!/usr/bin/env python3
import sys
from collections.abc import Iterable
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int, W: "List[int]"):
    acc = list(accumulate(W))
    ret = float('inf')
    for i in range(N-1):
        s1 = acc[i]
        s2 = acc[-1] - acc[i]
        ret = min(ret, abs(s1 -s2))
    return ret


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    W = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    result = solve(N, W)
    if isinstance(result, Iterable) and not isinstance(result, str):
        result = '\n'.join([str(v) for v in result])
    print(result)

if __name__ == '__main__':
    main()


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

int main() {
 string s; cin >> s;
 string out;
 for(auto &c : s) {
  switch(c) {
   case '0':
    out += "0"; break;
   case '1':
    out += "1"; break;
   case 'B':
    if(out.size() > 0) out.pop_back(); break;
  }
 }
 cout << out << endl;
}

Measured memory_bytes: 256
import sys
import math
import bisect
import heapq
from collections import Counter


def input():
    return sys.stdin.readline().rstrip()


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    AS = [0]

    it = 0
    for i in range(0, N):
        it += A[i]
        it %= K
        sj = (it - i - 1) % K
        AS.append(sj)
    # 最初だけ作る

    C = dict()
    C[0] = 1
    current = 0
    for j in range(1, N + 1):
        if j > K-1:
            C[AS[j - K]] -= 1
        if AS[j] in C:
            current += C[AS[j]]
            C[AS[j]] += 1
        else:
            C[AS[j]] = 1

    print(current)


if __name__ == "__main__":
    main()


Measured memory_bytes: 142408
import scala.io.StdIn.readLine

object Main extends App {
  val n = readLine.split(" ").map(_.toInt).sorted
  if(n(0)==n(1) && n(1) == n(2) && n(2)==n(3) &&
     n(4)==n(5) && n(5) == n(6) && n(6)==n(7) &&
     n(8)==n(9) && n(9) == n(10) && n(10)==n(11)) println("yes")
  else println("no")
}

Measured memory_bytes: 43960
#include<iostream>
#include<cstdio>

using namespace std;

int main()
{   
    char op = '+';
    int a , b ;
    scanf("%d %c %d",&a,&op,&b);

    if(op == '+')
        printf("%d\n",a + b);
    else
        printf("%d\n",a - b);

    return 0;
}

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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

vector<int> prime;
bool is_prime[1000010];
int sieve(int n) {
  fill(is_prime + 2, is_prime + 1000010, true);
  for (int i = 2; i <= n; i++) {
    if (is_prime[i]) {
      prime.emplace_back(i);
      for (int j = 2 * i; j <= n; j += i) is_prime[j] = false;
    }
  }
  return prime.size();
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  sieve(1000000);
  int n;
  while (cin >> n) {
    cout << upper_bound(prime.begin(), prime.end(), n) - prime.begin() << endl;
  }

  return 0;
}


Measured memory_bytes: 4272
#include <stdio.h>

inline int min(int a, int b)
{
    if (a<b)    return a;
    else        return b;
}

int main(void)
{
    int c[10][10];
    int i, j, k, h, w, d, s=0;

    scanf("%d%d", &h, &w);

    // 魔力表
    for (i=0; i<10; i++) {
        for (j=0; j<10; j++) {
            scanf("%d", &c[i][j]);
        }
    }

    // 1に変換する最少魔力
    for (k=0; k<=9; k++) {
        for (i=0; i<=9; i++) {
            for (j=0; j<=9; j++) {
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
            }
        }
    }

    for (i=0; i<h; i++) {
        for (j=0; j<w; j++) {
            scanf("%d", &d);
            if (d!=-1) {
                s += c[d][1];
            }
        }
    }
    printf("%d\n", s);

    return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  int i,j;
  if(C%B==0)i=C/B;
  else i=C/B+1;
  if(A%D==0)j=A/D;
  else j=A/D+1;
  if(i<=j) cout << "Yes" << endl;
  if(i>j) cout << "No" << endl;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <fstream>
#include <sstream>
#include <math.h>

using namespace std;



int n;

int main(){
    while(cin>>n){
        int s[12]={0};
        int c[12]={0};
        if(n==0)break;
        for(int i=0; i<n; i++){
            cin>>s[i];
        }
        
        int count=0;
        while(1){
            count++;
            
            
            for(int i=0; i<n; i++){
                for(int j=0; j<n; j++){
                    if(s[i]==s[j]){
                        c[i]++;
                    }
                }
            }
            
            bool flag=true;
            for(int i=0; i<n; i++){
                if(s[i]!=c[i])flag=false;
            }
            if(flag)break;
            
            for(int i=0; i<n; i++){
                s[i]=c[i];
                c[i]=0;
            }
        }
        
        cout<<count-1<<endl;
        cout<<c[0];
        for(int i=1; i<n; i++){
            cout<<" "<<c[i];
        }
        cout<<endl;
    }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define all(uiet) uiet.begin(),uiet.end()
#define read(UIET) for(int i = 0; i < n; ++i) cin >> UIET[i]
#define out(UIET) for(int i = 0; i < n; ++i) cout << UIET[i] << " "
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >
#define pll pair<int , int >
#define ppll pair < pll , pll >
#define debug(n1) cout << n1 << endl
#define len(a) ((int) (a).size())
#define endl "\n"
#define mod 1000000007
const int INF=(1LL<<60)-1;
bool isPerfectSquare(long double x) {   
    long double sr = sqrt(x); 
    return ((sr - floor(sr)) == 0); 
} 
bool isPrime(int x){
    for(int i = 2; i * i <= x; ++i){
        if(x % i == 0) return 0;
    }
    return 1;
}
int fun(int n){
    if(n & 1) return 3 * n + 1;
    else return n/2;
}
int32_t main(){
    SPEED;
    string s;
    cin >> s;
    set<char> su;
    for(char c: s){
        su.insert(c);
    }
    if(len(s) == len(su)) cout << "yes" ;
    else cout << "no" ;
}


Measured memory_bytes: 3624
package main

import (
	"bufio"
	"container/list"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	iv, _ := strconv.Atoi(scanString())
	return iv
}
func scanString() string {
	sc.Scan()
	return sc.Text()
}

func init() {
	sc.Split(bufio.ScanWords)
	buf := make([]byte, 10000)
	sc.Buffer(buf, 200000)
}

func main() {
	s := scanString()
	ls := list.New()
	for _, r := range s {
		ls.PushBack(string(r))
	}
	rv := false
	q := scanInt()
	for i := 0; i < q; i++ {
		t := scanInt()
		switch t {
		case 1:
			rv = !rv
		case 2:
			f, c := scanInt(), scanString()
			if rv {
				f = 3 - f
			}
			if f == 1 {
				ls.PushFront(c)
			} else {
				ls.PushBack(c)
			}
		}
	}

	var wr = bufio.NewWriter(os.Stdout)
	if rv {
		for e := ls.Back(); e != nil; e = e.Prev() {
			wr.WriteString(e.Value.(string))
		}
	} else {

		for e := ls.Front(); e != nil; e = e.Next() {
			wr.WriteString(e.Value.(string))
		}
	}
	wr.WriteString("\n")
	wr.Flush()
}


Measured memory_bytes: 22016
n = int(input())
q = input().split()
w = []
for i in range(n):
    w.append(int(q[i]))
c = 10000
for i in range(n):
    a = 0
    b = 0
    for j in range(i):
        a += w[j]
    #print(a)

    for j in range(i,n):
        b += w[j]
    #print(b)


    if abs(a - b) < c:
       c =  abs(a - b)
    #print(c)

print(c)

Measured memory_bytes: 3060
#include <iostream>
#include <map>

using namespace std;

int cnt;
map<string, bool> mp;

int main() {
	int n;
	cin >> n;
	while(n--) {
		string s;
		cin >> s;
		if(!mp[s]) {
			cnt++;
			mp[s] = true;
		}
	}	
	cout << cnt << endl;
	return 0;
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <ll,int> ii;
typedef pair <ii,int> iii;

const int mod = 1e9 + 7;
const ll INF = (1LL<<50);
const int N = 100005;

//dp[i] = TRUE if the first player wins with i stones remaining playing optmally

int main(){
	fastio;
	int n, k;
	cin >> n >> k;
	vi v(n);
	vector<bool> dp(k+1);
	for(auto &i:v)
		cin >> i;
		for(int stone = 0; stone <= k; stone++){
			for(auto x:v){
				if(stone >= x and !dp[stone-x])
					dp[stone] = true;
			}
		}
	cout << (dp[k] ?"First" : "Second") << '\n';
	return 0;
}


Measured memory_bytes: 3576
/*input
7
1
3
1
2
3
3
2
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long 
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back

#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)

#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int raise(int a,int n,int m = MOD){
  if(n == 0)return 1;
  if(n == 1)return a;
  int x = 1;
    x *= raise(a,n/2,m);
    x %= m;
    x *= x;
    x %= m;
    if(n%2)x*= a;
    x %= m;
    return x;
}

int floor1(int n,int k){
    if(n%k == 0 || n >= 0)return n/k;
    return (n/k)-1;
}

int ceil1(int n,int k){
    return floor1(n+k-1,k);
}

const int N = 2e5+1;
int dp[N];
int a[N];
vi b;
int pref[N];
int n;
int pref_col[N];

void solve(){
     cin >> n;
     RE(i,n){
     	cin >> a[i];
     	if(i == 1 or a[i] != a[i-1])b.pb(a[i]);
     	pref_col[a[i]] = 0;
     }
     n = b.size();
     dp[0] = 1;
     pref[0] = 1;
     int ans = 0;
     RE(i,n){
     	dp[i] = pref_col[b[i-1]];
        /*for(int j = 1;j < i;j++){
        	if(b[i-1] == b[j-1])dp[i] += pref[j-1];
        }*/
        pref_col[b[i-1]] += pref[i-1];
        pref_col[b[i-1]] %= MOD;
        pref[i] = pref[i-1]+dp[i];
        pref[i] %= MOD;
        ans += dp[i];
        ans %= MOD;
     }
     ans++;
     ans %= MOD;
     if(ans < 0)ans += MOD;
     debug(ans);
}

signed main(){
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  //freopen(".in","r",stdin);freopen(".out","w",stdout);
  int t = 1;
  //cin >> t;
  while(t--){
    solve();
  }
  return 0;
}

Measured memory_bytes: 8176
from copy import deepcopy
from functools import reduce


class Divisor:
    def __init__(self, n):
        """ make divisors list and prime factorization list of n
            complexity: O(n^(1/2))
            used in ProjectEuler No.12, yukicoder No.36
        """
        assert(n >= 1)
        number = n
        if number == 1:
            self.primeFactorization = {1: 1}
        else:
            self.primeFactorization = {}
            for i in range(2, int(n**0.5)+1):
                cnt = 0
                while number % i == 0:
                    cnt += 1
                    number //= i
                if cnt > 0:
                    self.primeFactorization[i] = cnt
            if number > 1:
                self.primeFactorization[number] = 1

    def primeFactors(self):
        return deepcopy(self.primeFactorization)

    def numDivisors(self):
        """ the number of divisors """
        if self.primeFactorization.get(1, 0) == 1:
            return 1
        numDiv = 1
        for _, cnt in self.primeFactorization.items():
            numDiv *= cnt+1
        return numDiv

    def sumDivisors(self):
        return reduce(lambda x, y: x * y, [sum(p**i for i in range(n+1)) for p, n in self.primeFactorization.items()])


def main() -> None:
    N, P = map(int, input().split())
    d = Divisor(P)
    ans = 1
    for key, value in d.primeFactorization.items():
        ans *= key ** (value // N)
    print(ans)


if __name__ == '__main__':
    main()


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

int main() {
  int N;
  cin >> N;
  string s = "No";
  for (int i = 0; i <= N / 4; i++) {
    for (int j = 0; j <= N / 7; j++) {
      int t = 4 * i + 7 * j;
      if (t == N) s = "Yes";
    }
  }
  cout << s << endl;
}


Measured memory_bytes: 3596
#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 <iostream>
#include <utility>
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 
 
using namespace std;
using ll = long long;
using ld = long double;
using Vl = vector<ll>;
using pll = pair<ll, ll>;
using vb = vector<bool>;
using vs = vector<string>;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, m, n) for(int i = m; i < (n); i++)

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

    if(S=="Sunny"){
        cout << "Cloudy" << endl;
    }
    if(S=="Cloudy"){
        cout << "Rainy" << endl;
    }
    if(S=="Rainy"){
        cout << "Sunny" << endl;
    }

    return 0;
}

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

int keta(int n) {
    int res;
    for(int i = 0; i < 100; i++) {
        n = n / 10;

        if(n == 0) {
            res = i + 1;
            break;
        }
    }
    return res;
}

int main() {
    int n;
  cin>>n;
  if(n%1000!=0){

  cout<<1000-n%1000<<endl;
  }
  else {
  cout<<0<<endl;
}
}



Measured memory_bytes: 3636
N, x = map(int, input().split())
a = list(map(int, input().split()))
ans = 0

left = a[0]
for right in a[1:]:
    s = left + right
    if s > x:
        if left > x:
            right = 0
            left = x
        else:
            right -= s - x
        ans += s - x
    left = right

print(ans)


Measured memory_bytes: 14252
s = gets.chomp
gets.to_i.times{
    x = gets.split
    a = x[1].to_i
    b = x[2].to_i
    case x[0]
    when "print" then
        puts s[a, b - a + 1]
    when "reverse" then
        s[a, b - a + 1] = s[a, b - a + 1].reverse
    when "replace" then
        s[a, b - a + 1] = x[3]
    end
}


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

using namespace std;

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

int main(){
  
  int a,b;
  cin >> a >> b;
  long long c=a/gcd(a,b);
  cout << setprecision(20);
  cout << c*b << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	long long n,k,cnt;
	cin>>n>>k;
	long long a[n]; cnt=0;
	for (int i=1;i<=n;i++)
	{
		cin>>a[i];
		if (a[i]>=k) cnt++;
	}
	cout<<cnt;
	return 0;
}

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

//#pragma gcc optimize("O3,unroll-loop")
//#pragma gcc target("sse,sse2,sse3,ssse3,sse4,avx,avx2,fma,abm,mmx,popcnt,tune=native")
//#define int long long
//#define double long double

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

    int n;
    cin >> n;
    cout << 8 - (n - 400) / 200 << '\n';

    return 0;
}

//      *   *  *****  *   *  *   *   ****  ****    ****     **    **
//     *   *  *      **  *  *   *  *      *   *  *        * *   * *
//    *****  *****  * * *  *   *  *      ****   *       *  *     *
//   *   *      *  *  **  *   *  *      *  *   *       *****    *
//  *   *  *****  *   *   ***    ****  *   *    ****     *   *****

//      *****  *****  *   *  *      *****  *   *  *****  *****
//        *   *   *  *   *  *        *    **  *    *    *   *
//       *   *   *  *****  *        *    * * *    *    *****
//   *  *   *   *    *    *        *    *  **    *    *
//  ****   *****    *    *****  *****  *   *    *    *


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

int main(){
  int a,b,c;
  int result=0;

  cin >> a >> b >> c;

  result++;

  if(b != a){
    result++;
  }

  if(c != a && c!=b){
    result++;
  }
  
  cout << result << endl;
  
  return 0;
}


Measured memory_bytes: 256
base = ord("a")
alst = [i for i in range(3, 26, 2) if i % 13]
def restore(s):
  for a in range(1,26):
    for b in range(26):
      new = "".join([chr((a * (ord(x) - base) + b) % 26 + base) if x != " " else " " for x in s])
      if "that" in new or "this" in new:
        return new

n = int(input())

for _ in range(n):
  print(restore(input()))


Measured memory_bytes: 5600
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n;
  cin >> n;
  vector<string> W;
  rep(i,n){
    string w;
    cin >> w;
    W.push_back(w);
  }
  srep(i,1,n){
    string w = W[i];
    string last = W[i-1];
    if(last[sz(last)-1] != w[0]){
      cout<<"No"<<endl;
      return 0;
    }
    rep(j,i){
      if(W[j] == w){
        cout<<"No"<<endl;
        return 0;        
      }
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}

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

public class Main{
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int x = sc.nextInt();
		int hasu = x % 100;
		int five = hasu / 5;
		hasu %= 5;
		int four = hasu / 4;
		hasu %= 4;
		int three = hasu / 3;
		hasu %= 3;
		int two = hasu / 2;
		hasu %= 2;
		int one = hasu;
		if (x - hasu >= 100 * (five + four + three + two + one)) {
			System.out.println(1);
		} else {
			System.out.println(0);
		}
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}
	public String next() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || Integer.MAX_VALUE < nl) {
			throw new NumberFormatException();
		}
		return (int) nl;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 22996
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
 
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

int main() {

    ll X,Y;
    cin >> X >> Y;

    if (X % Y == 0) {
        cout << -1 << endl;
    } else {
        ll ans = X;
        while (ans % Y == 0) ans++;
        cout << ans << endl;
    }

    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  string s, s3, s2;
  cin >> s;
  int len = s.size();
  bool flg = true;

  for (int i = 0; i < len / 2; ++i) {
    if (s[i] == s[len - 1 - i]) continue;
    flg = false;
    // cout << "hoge1" << endl;
  }
  s2 = s.substr(0, (len - 1) / 2 );
  s3 = s.substr((len + 3) / 2 - 1, len - 1);

  int len2 = s2.size();
  int len3 = s3.size();

  for (int i = 0; i < len2 / 2; ++i) {
    if (s2[i] == s2[len2 - 1 - i]) continue;
    flg = false;
    // cout << "hoge2" << endl;
  }
  for (int i = 0; i < len3 / 2; ++i) {
    if (s3[i] == s3[len3 - 1 - i]) continue;
    flg = false;
    // cout << "hoge3Z" << endl;
  }

  cout << (flg ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(pair<int,int> a, pair<int,int> b) {
	return a < b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= 1000000007;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, 1000000007);
		ans %= 1000000007;
	}
	return ans;
}

int main() {
	int a, b;
	cin >> a >> b;
	b = b * 2 + 1;
	a += b - 1;
	cout << a / b << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  llong n, c;
  scanf("%lld %lld", &n, &c);

  vector<llong> x(n), v(n), xr(n);
  REP(i,n){
    scanf("%lld %lld", &x[i], &v[i]);
    xr[i] = c - x[i];
  }

  llong ans = 0;
  llong sum = 0, cur = 0;
  vector<llong> mx1(n), mx2(n), st1(n), st2(n);
  REP(i,n){
    sum += v[i] - (x[i] - cur);
    cur = x[i];
    if(ans < sum){
      ans = sum;
      st1[i] = x[i];
    }else{
      if(i == 0){
        st1[i] = 0;
      }else{
        st1[i] = st1[i - 1];
      }
    }

    mx1[i] = ans;
    //cout << sum << endl;
  }

  llong ans2 = 0;
  sum = 0, cur = 0;
  for(int i = n - 1; i >= 0; --i){
    sum += v[i] - (xr[i] - cur);
    cur = xr[i];
    if(ans2 < sum){
      ans2 = sum;
      st2[i] = xr[i];
    }else{
      if(i == n - 1){
        st2[i] = 0;
      }else{
        st2[i] = st2[i + 1];
      }
    }

    mx2[i] = ans2;
    //cout << mx2[i] << endl;
  }
  ans = max(ans, ans2);
  
  sum = 0;
  for(int i = 0; i < n - 1; ++i){
    //cout << mx1[i] + mx2[i + 1] << " " << st1[i] << " " << st2[i + 1] << endl;
    sum = mx1[i] + mx2[i + 1] - min(st1[i], st2[i + 1]);
    ans = max(sum, ans);
  }

  printf("%lld\n", ans);
  return 0;
}



Measured memory_bytes: 5760
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline int read()
{
	int f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
const int MAXN=105;
const int mod=1e9+7;
void ad(int &x,int y){x+=y;if(x>=mod)x-=mod;}
int n,m,a[MAXN],f[MAXN][MAXN][MAXN];
int main()
{
	n=read();m=2*n-1;
	for(int i=1;i<=m;i++)a[i]=read();
	sort(a+1,a+1+m);
	f[n][1][0]=1;
	for(int i=n-1;i>=1;i--)
	{
		int al=(a[i]!=a[i+1]),ar=(a[2*n-i]!=a[2*n-i-1]);
		for(int l=1;l<=2*n-i;l++)
			for(int r=0;r+l<=2*n-i;r++)if(f[i+1][l][r])
			{
				for(int fl=1;fl<=l+al;fl++)ad(f[i][l+al-fl+1][r+ar+(fl>1)],f[i+1][l][r]);
				for(int fr=1;fr<=r+ar;fr++)ad(f[i][l+al+1][r+ar-fr],f[i+1][l][r]);
			}
	}
	int ans=0;
	for(int l=0;l<=2*n-1;l++)for(int r=0;r+l<=2*n-1;r++)ad(ans,f[1][l][r]);
	pr2(ans);
	return 0;
}


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

int main(){
    int N, Q;
    std::cin >> N >> Q;
    std::vector< std::vector< int > > AB(N);
    for(int i=0; i<N-1; i++){
        int tmp1, tmp2;
        std::cin >> tmp1 >> tmp2;
        AB[tmp1 - 1].push_back(tmp2 - 1);
        AB[tmp2 - 1].push_back(tmp1 - 1);
    }
    std::vector< int > X(N, 0);
    for(int i=0; i<Q; i++){
        int tmp1, tmp2;
        std::cin >> tmp1 >> tmp2;
        X[tmp1 - 1] += tmp2;
    }
    
    std::deque< int > deq_No;
    std::deque< int > deq_preNo;
    std::deque< int > deq_X;
    deq_No.push_back(0);
    deq_preNo.push_back(-1);
    deq_X.push_back(0);
    
    std::vector< int > ans(N);
    while(!deq_No.empty()){
        int cur_No = deq_No[0];
        int cur_preNo = deq_preNo[0];
        int cur_X = deq_X[0];
        deq_No.pop_front();
        deq_preNo.pop_front();
        deq_X.pop_front();
        cur_X += X[cur_No];
        ans[cur_No] = cur_X;
        
        for(int i=0; i<AB[cur_No].size(); i++){
            if(AB[cur_No][i] != cur_preNo){
                deq_No.push_back(AB[cur_No][i]);
                deq_preNo.push_back(cur_No);
                deq_X.push_back(cur_X);
            }
        }
    }
    for(int i=0; i<N; i++){
        std::cout << ans[i] << std::endl;
    }
    
    return 0;
}



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

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

    long long longer=0;

    vector<long long> a(n);
    for (int i=0; i<n; i++) {
        cin >> a.at(i);
    }

    longer = k + a.at(0) - a.at(n-1);

    for (int i=1; i<n; i++) {
        if (a.at(i) - a.at(i-1) > longer) {
            longer = a.at(i) - a.at(i-1);
        }
    }

    long long ans = k - longer;

    cout << ans << endl;
}

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

int main(){
  int N;
  cin>>N;
  vector<int64_t> T(N+1),A(N+1);
  for(int i=0;i<N;++i) cin>>T[i+1]>>A[i+1];
  T[0]=1,A[0]=1;


  int64_t x=1;
  for(int i=1;i<=N;++i){
    x=max((T[i-1]*x+T[i]-1)/T[i],(A[i-1]*x+A[i]-1)/A[i]);
  }
  cout<<(A[N]+T[N])*x<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int n;
  scanf("%d", &n);
  long long int in[n], ai = 1e18, x= 1, y = 0, z= 0;
  for (int i = 0; i < n; i++) {
    scanf("%lld", &in[i]);
    y = (in[i] > ai) ? 1 : y;
    x *= in[i];
    (in[i]) ? ai /= in [i] : z = 1;
  }
  (z) ? puts("0") : ((y) ? puts("-1") : printf("%lld\n", x));
  return 0;
}


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

bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

ll ans[100005];
ll q;

int main(){
    cin >> q;
    ans[0]=0;
    ans[1]=0;
    ans[2]=0;
    for(ll i=3;i<=100000;i++){
        if(is_prime(i)&&is_prime((i+1)/2)) ans[i]=ans[i-1]+1;
        else ans[i]=ans[i-1];
    }
    for(ll i=0;i<q;i++){
        ll l,r;
        cin >> l >> r;
        cout << ans[r]-ans[l-1] << endl;
    }
}


Measured memory_bytes: 4356