akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

struct edge {
    int from, to, cost;
};

vector<edge> es;
vector<ll> d;
int V, E;

void shortest_path(int s) {
    for(int i = 0; i < V; i++) {
        d[i] = INF;
    }
    d[s] = 0;
    for(int i = 0; i < V; i++) {
        bool update = false;
        for(int i = 0; i < E; i++) {
            edge e = es[i];
            if(d[e.from] != INF and d[e.to] > d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
                update = true;
            }
        }
        if(!update) {
            break;
        }
    }
}

// trueなら負の閉路が存在する
bool find_negative_loop() {
    int tmp = 0;
    for(int i = 0; i < V; i++) {
        d[i] = INF;
    }
    d[0] = 0;
    for(int i = 0; i < 2 * V; i++) {
        for(int j = 0; j < E; j++) {
            edge e = es[j];
            if(d[e.to] > d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
            }
        }
        if(i == V) {
            tmp = d[V - 1];
            // cout << tmp << endl;
        }
        if(i == 2 * V - 1) {
            // cout << d[V - 1] << endl;
            if(tmp != d[V - 1]) {
                return true;
            } else {
                return false;
            }
        }
    }
    return false;
}

int main() {
    int N, M, P;
    cin >> N >> M >> P;
    es.resize(M);
    d.resize(N, 0);
    V = N;
    E = M;
    for(int i = 0; i < M; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        c -= P;
        es[i] = {a, b, -c};
    }
    if(find_negative_loop()) {
        cout << "-1" << endl;
        return 0;
    } else {
        // cout << "not ne loop" << endl;
        shortest_path(0);
        cout << max(-d[N - 1], 0LL) << endl;
        return 0;
    }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

vector<bool> MP(string S) { //it doesn't include itself
	int n = (int)S.size();
	vector<int> A(n + 1);
	A[0] = -1;
	rep(i, 0, n) {
		int j = A[i];
		while (j >= 0 && S[i] != S[j]) j = A[j];
		j++;
		A[i + 1] = j;
	}
	vector<bool> B(n, false);
	rep(i, 2, n + 1) {
		int a = A[i];
		if(2 * a >= i && a % (i - a) == 0) {
			B[i - 1] = true;
		}
	}
	return B;
}

int N;
vector<int> vec;
string str;
bool ng[MAX_N];
int cnt[26];

void solve() {
	cin >> str;
	N = sz(str);
	bool found = false;
	rep(i, 1, N) {
		if(str[i] != str[0]) {
			found = true;
			break;
		}
	}
	if(!found) {
		cout << N << "\n1\n"; return;
	}
	vector<bool> ng1 = MP(str);
	reverse(all(str));
	vector<bool> ng2 = MP(str);
	reverse(all(ng2));
	if(!ng1[N - 1]) {
		cout << "1\n1\n";
	}
	else {
		int res = 0;
		rep(i, 0, N - 1) {
			if(!ng1[i] && !ng2[i + 1]) {
				res++;
			}
		}
		cout << "2\n" << res << "\n";
	}
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 3356
#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 INF 999999999
#define SUR 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair

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

using namespace std;

typedef pair<int,int> pii;

bool seikai[100];

int main(){

  vector<int> s, s2;
  while(true){
    int a, b;
    scanf("%d,%d", &a, &b);
    if(a == 0 && b == 0) break;
    s.pb(b);

    if(!seikai[b]){
      s2.pb(b);
      seikai[b] = true;
    }
  }

  sort(ALL(s2), greater<int>());
  
 
  int len = s2.size();
  int q;
  while(scanf("%d", &q) != EOF){
    int score = s[q-1];
    REP(i,len){
      if(s2[i] == score){
        //cout << s2[i] << endl;
        printf("%d\n", i+1);
        break;
      }
    }
  }
  return 0;
}




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


//TEMPLATE
#define pb              push_back
#define mp              make_pair
#define ll              long long
#define ld              long double
//#define pi              3.1415926536
#define pi              acos(-1)
//#define mod             1000000007
#define newline         printf("\n")
#define printminusone   printf("-1\n")
#define scl1(n)         scanf("%lld", &n)
#define scl2(a, b)      scanf("%lld %lld", &a, &b)
#define scl3(a, b, c)   scanf("%lld %lld %lld", &a, &b, &c)
#define printl(n)       printf("%lld\n", n)
#define ssl1(str)       scanf(" %[^\n]", str)
#define scd1(n)         scanf("%lf", &n)
#define scd2(a, b)      scanf("%lf %lf", &a, &b)
#define printd(n)       printf("%lf\n", n)
#define printld(n)      printf("%Lf\n", n)
#define printcase       printf("Case %lld: ", i)
#define reversed(s)     reverse(s.begin(), s.end())
#define asorted(s)      sort(s.begin(), s.end())
#define dsorted(s)      sort(s.begin(), s.end(), cmp)
#define for0(i, n)      for (i = 0; i < n; i++)
#define for1(i, n)      for (i = 1; i <= n; i++)
#define fori(itt, stt)  for(auto itt = stt.begin(); itt != stt.end(); itt++)
#define pii             pair <ll, ll>
#define piii            pair <ll, pii>
//#define SIZE            100005
//#define INF             1000000005
#define F               first
#define S               second
#define FR              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ms(arr, x)      memset(arr, x, sizeof arr)
#define bitcount(n)     __builtin_popcountll(n)

const ll INF = LLONG_MAX;
const ll SIZE = 4e5+5;
const ll mod = 1e9+7;


ll dp[1005][10005];
ll n, a[SIZE], b[SIZE];

ll solve(ll in, ll now) {
    if(now <= 0) return 0;
    if(in == n+1) return 1e16;
    if(dp[in][now] != -1) return dp[in][now];

    ll t1 = solve(in+1, now);
    ll t2 = b[in] + solve(in, now-a[in]);

    return dp[in][now] = min(t1, t2);
}

int main() {
    ll t = 0, x, y, z, i, j, k, g, p, q, ans = 0, sum = 0, c = 1;
    string s, s1, s2;

    scl2(p, n);
    for1(i, n) scl2(a[i], b[i]);

    ms(dp, -1);

    ans = solve(1, p);
    printl(ans);

    return 0;
}



Measured memory_bytes: 81536
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
s=input()
ss="AC"
if s[0]=="A" and s[2:-1].count("C")==1:
   for i in range(len(s)):
     if s[i]=="A" or s[i]=="C" or ord(s[i])>ord("Z"):    
       continue
     ss="WA" 
else:
     ss="WA"
print(ss)

Measured memory_bytes: 38384
#include <iostream>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
using namespace std;

struct ToUpper {
    char operator()(char c) { return toupper(c); }
};

int main() {
	string str;
	getline(cin, str);

	transform(str.begin(), str.end(), str.begin(), ToUpper());

	cout<<str.c_str()<<endl;
	return 0;
}

Measured memory_bytes: 0
import java.util.*;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		while(in.hasNext())
		{
			ArrayList<String>AL=new ArrayList<String>();
			int ans=0;
			for(;;)
			{
				String st=in.next();
				if(st.equals("="))
					break;
				AL.add(st);
			}
			ans=Integer.valueOf(AL.get(0));
			for(int i=1;i<AL.size()-1;i+=2)
			{
				if(AL.get(i).equals("+"))
					ans+=Integer.valueOf(AL.get(i+1));
				else if(AL.get(i).equals("-"))
					ans-=Integer.valueOf(AL.get(i+1));
				else if(AL.get(i).equals("*"))
					ans*=Integer.valueOf(AL.get(i+1));
				else if(AL.get(i).equals("/"))
					ans/=Integer.valueOf(AL.get(i+1));
			}
			System.out.println(ans);	
		}
	}
	
	static public void debug(Object... o)
	{
		System.out.println(Arrays.deepToString(o));
	}
}

Measured memory_bytes: 18064
from math import sin, cos, radians
a, b, h, m = map(int, input().split())
x1, y1 = cos(radians(90 - 6*m))*b, sin(radians(90 - 6*m))*b
x2, y2 = cos(radians(90 - 30*h - m/2))*a, sin(radians(90 - 30*h - m/2))*a
print(((x2-x1)**2 + (y2-y1)**2)**0.5)

Measured memory_bytes: 9548
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (A, s, C): (Vec<char>, Vec<char>, Vec<char>) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().chars().collect(),
            iter.next().unwrap().chars().collect(),
            iter.next().unwrap().chars().collect(),
        )
    };

    let ans = format!("A{}C", s[0]);

    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define Phuong_ ios_base::sync_with_stdio(0); cin.tie(0);
#define REP(i,a,b) for(int i=a; i<=b; ++i)

/// easy access -------------
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
typedef pair<int, int> pi;
typedef tuple<bool, int, int> tp;
typedef vector<vector<int> > vv;
///-------------------------


int main()
{
    Phuong_; /// <3333
    int n;
    cin >> n;
    int dem=0;
    bool can= false;
    for(int i=0; i<n; ++i){
        int u,v;
        cin >> u >> v;
        if (u==v) dem++; else dem=0;
        if(dem==3) can=true;
    }
    if (can)
    cout << "Yes"; else cout << "No";
    return 0;
}


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

int main(){
    ll N;
    cin >> N;
    map<ll, ll> mp;
    char can[5] = {'M', 'A', 'R', 'C', 'H'};
    rep(i, 0, N){
        string s;
        cin >> s;
        for(auto c : can){
            if(c == s[0]) mp[s[0]]++;
        }
    }
    ll ans = 1;
    if(mp.size() < 3){
        cout << 0 << endl;
    }else{
        if(mp.size() == 3){
            for(auto p : mp){
                ans *= p.second;
            }
            cout << ans << endl;
        }else if(mp.size() > 3){
            vector<ll> tmp;
            for(auto p : mp) tmp.push_back(p.second);
            if(mp.size() == 4){
                ans = 0;
                ans += tmp[0] * tmp[1] * tmp[2];
                ans += tmp[0] * tmp[2] * tmp[3];
                ans += tmp[0] * tmp[1] * tmp[3];
                ans += tmp[1] * tmp[2] * tmp[3];
            }
            if(mp.size() == 5){
                ans = 0; 
                ans += tmp[0] * tmp[1] * tmp[2];
                ans += tmp[0] * tmp[1] * tmp[3];
                ans += tmp[0] * tmp[1] * tmp[4];
                ans += tmp[0] * tmp[2] * tmp[3];
                ans += tmp[0] * tmp[2] * tmp[4];
                ans += tmp[0] * tmp[3] * tmp[4];
                ans += tmp[1] * tmp[2] * tmp[3];
                ans += tmp[1] * tmp[2] * tmp[4];
                ans += tmp[1] * tmp[3] * tmp[4];
                ans += tmp[2] * tmp[3] * tmp[4];
            }
            cout << ans << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <string>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
using namespace std;
int main(void){
    int n,m;
    cin >> n >> m;
    int s[5] = {};
    int c[5] = {};
    int ans[3] = {1,0,0};
    if(m == 0){
        if(n == 1){
            cout << 0 << endl;return 0;
        }
        rep(i,n){
        cout << ans[i];
        }
        return 0;
    }
    rep(i,m){
        cin >> s[i] >> c[i];
        if(n < s[i]){
            cout << -1 << endl;return 0;
        }
    }
    if(n != 1){
        rep(i,m){
            if(s[i] == 1 && c[i] == 0){
                cout << -1 << endl;return 0;
            }
        }
    }
    rep(i,m-1){
        REP(j,i,m){
            if(s[i] == s[j] && c[i] != c[j]){
                cout << -1 << endl;return 0;
            }
        }
    }
    rep(i,m){
        ans[s[i]-1] = c[i];
    }
    rep(i,n){
        cout << ans[i];
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n,i,k,a[200000];
	while((scanf("%d",&n)!=EOF)&&(n!=0))
	{
		for(i=0;i<n;i++)
		{
			scanf("%d",&a[i]);
		}
		if(n%2==0)
		{
			for(i=n-1;i>0;i-=2)
			{
				printf("%d ",a[i]);
			}
			for(i=0;i<n-1;i+=2)
			{
				printf("%d ",a[i]);
			}
		}else
		{
			for(i=n-1;i>=0;i-=2)
			{
				printf("%d ",a[i]);
			}
			for(i=1;i<n-1;i+=2)
			{
				printf("%d ",a[i]);
			}
		}
	}
	return 0;
}

Measured memory_bytes: 2816
#encoding: utf-8
import os, sys
import math

def read_items_in_line(cast=int):
    return [cast(x) for x in sys.stdin.readline().strip(' \n').split(' ')]

items = ["dream", "dreamer", "erase", "eraser"]
rev_items = [x[::-1] for x in items]

S = read_items_in_line(cast=str)[0]
rev_S = S[::-1]

while(True):
    found = False
    for x in rev_items:
        # print((rev_S, x))
        if rev_S.startswith(x):
            rev_S = rev_S[len(x):]
            found = True
            break
    if not found:
        break

if len(rev_S) == 0:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3316
n,m = map(int,input().split())
s = [list(map(int,input().split())) for i in range(m)]
t = list(map(int,input().split()))
ans = 0
for i in range(2**n):
  bit = [i>>j & 1 for j in range(n)]
  for k,x in enumerate(s):
    if t[k] != sum([bit[y-1] for y in x[1:]])%2:
      break
  else:
    ans += 1
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main() {
    ios::sync_with_stdio(false);cin.tie(0);
    int n,x[3];
    cin>>n;
    int dpp[3],dpc[3];
    memset(dpp,0,sizeof(dpp));
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            cin>>x[j];
            dpc[j] = 0;
            for(int k=0;k<3;k++)
            {
                if(j==k) continue;
                dpc[j] = max(dpc[j],dpp[k]+x[j]);
            }
        }
        swap(dpc,dpp);
    }
    cout<<max({dpp[0],dpp[1],dpp[2]});
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//







int main(void) {
    
    string s; cin >> s;
    int n = s.size();
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        int len = s.size() - i;
        bool OK = true;
        if (len % 2 == 0) {
            for (int j = 0; j < len / 2; ++j) {
                if (s[j] != s[len/2+j]) OK = false;
            }
        } 
        else {
            OK = false;
        }
        if (OK) ans = max(ans, len);
    }
    out(ans);

    
    return 0;
}









Measured memory_bytes: 256
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
        checked {
#if DEBUG
            MyDebugger.Test(process, "../TextFile1.txt");
            //TestCaseMaker.MakeTestCase1("../TextFile2.txt");
            //MyDebugger.Test(process, "../TextFile2.txt");
#else
            object ret = process(new StreamReader(Console.OpenStandardInput()));
            Console.WriteLine(ret);
#endif
        }
    }

    static object process(TextReader input) {
        var s = input.ReadLine();

        long x = 0;
        foreach(var c in s) {
            x += (c - '0');
        }

        return x % 9 == 0 ? Yes : No;
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 26504
import bisect
n = int(input())
li = list(map(int,input().split()))
ans = 0
li.sort()
for k in range(0,n-2):
  for i in range(k+1,n-1):
    ans += bisect.bisect_left(li,li[k]+li[i])-i-1
print(ans)
      

Measured memory_bytes: 3188
n,k = map(int,input().split())
d = [0] * n

for i in range(0,k):
  tmp = int(input().rstrip())
  a = list(map(int,input().split()))
  for j in a:
    d[j-1] += 1

s = 0
for i in d:
  if i == 0:
    s += 1

print(s)


Measured memory_bytes: 9200
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;

public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		BigInteger n = new BigInteger(br.readLine());
		System.out.println(n.multiply(n.subtract(BigInteger.ONE)).divide(new BigInteger("2")));
	}
}


Measured memory_bytes: 21460
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
typedef pair<int,int> P;
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define rep(i, n) for (lint i = 0; i < (n); i++)
#define INF LLONG_MAX
#define all(x) (x).begin(),(x).end()
#define pb push_back
int main(){
    int x,t;
    cin>>x>>t;
    cout<<max(0,(x-t))<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <array>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <random>
#include <limits>
#include <string>
#include <sstream>
#include <iomanip>

#include <cassert>
#include <cmath>
#include <ctime>

#pragma comment(linker, "/STACK:200000000")

using namespace std;

mt19937 mt (736);

void solve (istream &cin = std::cin, ostream &cout = std::cout)
{
    int n;
    long long c;

    cin >> n >> c;

    vector<pair<long long, int>> sushi (n);

    for (auto &it : sushi)
        cin >> it.first >> it.second;

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

    auto rev = sushi;

    for (auto &it : rev)
        it.first = c - it.first;

    reverse (rev.begin (), rev.end ());

    vector<pair<long long, long long>> ps (sushi.size () + 1), rs (rev.size () + 1);

    for (int i = 1; i < ps.size (); i++)
    {
        ps[i] = {sushi[i - 1].first, sushi[i - 1].second + ps[i - 1].second};
        rs[i] = {rev[i - 1].first, rev[i - 1].second + rs[i - 1].second};
    }

    for (auto &it : ps)
        it.second -= it.first;
    for (auto &it : rs)
        it.second -= it.first;

    vector<long long> pm (ps.size ()), rm (rs.size ());

    for (int i = 1; i < pm.size (); i++)
    {
        pm[i] = max (pm[i - 1], ps[i].second);
        rm[i] = max (rm[i - 1], rs[i].second);
    }

    long long ans = 0;

    for (int i = 0; i < ps.size (); i++)
    {
        ans = max (ans, ps[i].second - ps[i].first + rm[n - i]);
        ans = max (ans, rs[i].second - rs[i].first + pm[n - i]);
    }

    cout << ans << endl;
}

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

#ifdef LOCAL
    solve ();

    cout << "clock: " << clock () << endl;
#else
    solve ();
#endif // LOCAL

    return 0;
}


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

int main() {
  int n;
  cin >> n;
  
  int ans;
  if(n==2) ans = 2; 
  
  else {
    if(n%2==0) n++;
    for(int i=n; i<100004; i+=2) {
      bool prime = true;
      double x = sqrt(i);
      for (int j=3; j<=x; j+=2) {
        if(i%j==0) {
          prime = false;
          break;
        }
      }
    
      if(prime) {
        ans = i;
        break;
      }
    }
  }
  
  cout << ans << endl;
  return 0;
}

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

struct Node{
    int key;
    Node *parent;
    Node *left;
    Node *right;
};

Node *root, *NIL;

void inorder(Node *T){
    if (T == NIL) return;
    inorder(T->left);
    cout << ' ' << T->key;
    inorder(T->right);
}

void preorder(Node *T){
    if (T == NIL) return;
    cout << ' ' << T->key;
    preorder(T->left);
    preorder(T->right);
}

void infree(Node *T){
    if (T == NIL) return;
    infree(T->left);
    delete T;
    infree(T->right);
}

void insert(int k){
    Node *y = NIL;
    Node *x = root;
    Node *z;
    z = new Node;
    z->key = k;
    z->left = NIL;
    z->right = NIL;
    while (x != NIL){
        y = x;
        if (x->key < z->key) x = x->right;
        else x = x->left;
    }
    z->parent = y;
    if (y == NIL) root = z;
    else if (z->key > y->key) y->right = z;
    else y->left = z;
    return;
}

Node* find(int k){
    Node *a = root;
    while (a != NIL){
        if (a->key == k){
            //cout << "yes" << endl;
            //return;
            return a;
        }
        else if (a->key < k) a = a->right;
        else if (a->key > k) a = a->left;
    }
    //cout << "no" << endl;
    return NIL;
}

int main(){
    int m;
    cin >> m;
    string s;
    int k;
    for (int i = 0; i < m; i++){
        cin >> s;
        if (s == "insert"){
            cin >> k;
            insert(k);
        }
        else if (s == "print"){
            inorder(root);
            cout << endl;
            preorder(root);
            cout << endl;
        }
        else if (s == "find"){
            cin >> k;
            //find(k);
            if (find(k) != NIL) cout << "yes" << endl;
            else cout << "no" << endl;
        }
        else if (s == "delete")
            cin >> k;
    }
    infree(root);
    return 0;
}


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

using namespace std;

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

#define get_bit(n, i) (((n) >> (i)) & 1)
#define set_bit(n, i) ((n = ((1 << i) | n))))
#define del_bit(n, i) ((n) &= (~((1) << (i))))
#define flip_bit(n, i) ((n) ^= ((1) << (i)))

#define fast_io ios_base::sync_with_stdio(true);cin.tie(nullptr);cout.tie(nullptr);
#define sqr(x) (x) * (x)
#define sz(n) (n.size())

const int uinf = INT_MIN;
const int inf  = INT_MAX;

inline int bitscnt(int src) { int ans = 0; while(src <<= 1) ans++; return ans; }
inline bool ifpow2(int src) { return !(src & (src - 1)); }
inline int log2(int src) { int ans = 0; while (src >>= 1) ans++; return ans; }
inline void fast_swap(ll &a, ll &b) { a = a ^ b; b = b ^ a; a = a ^ b; }
inline void fast_swap(int &a, int &b) { a = a ^ b; b = b ^ a; a = a ^ b; }
inline int bin_pow(int a, int n) { int res = 1; while (n) { if (n & 1) res = res * a; a *= a; n >>= 1;} return res; }

//
const int arr = 7000;
/*

int  dp[1 + arr];
bool good[1 + arr][1 + arr];

int kek(string str, int n) {
  for (int i = 0; i < n; ++i) {
    good[i][i] = true;
  }
  for (int len = 2; len <= n; ++len) {
    for (int i = 0; i < n - len + 1; ++i) {
      int j = i + len - 1;
      if (len == 2)
        good[i][j] = bool(str[i] == str[j]);
      else good[i][j] = bool((str[i] == str[j]) && good[i + 1][j - 1]);
}
  }
  for (int i = 0; i < n; ++i) {
    if (good[0][i])
      dp[i] = 0;
    else {
      dp[i] = inf;
      for (int j = 0; j < i; ++j) {
        if (good[j + 1][i] == true && dp[j] + 1 < dp[i])
          dp[i] = dp[j] + 1;
      }
    }
  }
  return dp[n - 1];
}

*/

main () {
  #ifdef MartinLeshko
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif
  fast_io;
  int x, y;
  cin >> x >> y;
  int ans = x + y / 2;
  cout << ans;
  exit(0);
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($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:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        s: String,
        t: String,
    }

    println!("{}{}", t, s);
}



Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
typedef long long ll;
int main(){
ll c[3][3];
for(ll i=0;i<3;i++){
for(ll j=0;j<3;j++){
cin >>c[i][j];
}
}
if(c[0][0]-c[0][1]==c[1][0]-c[1][1]&&c[0][0]-c[0][1]==c[2][0]-c[2][1]&&c[0][0]-c[0][2]==c[1][0]-c[1][2]&&c[0][0]-c[0][2]==c[2][0]-c[2][2]&&c[0][2]-c[0][1]==c[1][2]-c[1][1]&&c[0][2]-c[0][1]==c[2][2]-c[2][1]&&c[1][0]-c[0][0]==c[1][1]-c[0][1]&&c[1][0]-c[0][0]==c[1][2]-c[0][2]&&c[2][0]-c[0][0]==c[2][1]-c[0][1]&&c[2][0]-c[0][0]==c[2][2]-c[0][2]&&c[1][0]-c[2][0]==c[1][1]-c[2][1]&&c[1][0]-c[2][0]==c[1][2]-c[2][2])
cout<<"Yes";
else
cout<<"No";
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int n;

int main() {
	cin >> n;
	
	int ans = 0;
	inc1(i, n) {
		if(inII(i, 1, 9)) { ans++; }
		if(inII(i, 100, 999)) { ans++; }
		if(inII(i, 10000, 99999)) { ans++; }
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
N=int(input())
xl=[list(map(int,input().split()))for _ in range(N)]
arms={}
for x,l in xl:
    arms[x-l]=0
    arms[x+l]=0
for x,l in xl:
    arms[x-l]+=1
    arms[x+l]-=1
point={}
for x,l in xl:
    point[x-l]=[]
    point[x+l]=[]
for x,l in xl:
    point[x-l].append(x+l)

ans=N
K=sorted(arms.keys())
now=0
count=[]
for k in K:
    now+=arms[k]
    for kk in point[k]:
        count.append(kk)
    for i in range(count.count(k)):
        count.remove(k)
    if now>=2:
        ans-=now-1
        now=1
        C=sorted(count)[::-1]
        for c in C[:-1]:
            arms[c]+=1
            count.remove(c)

print(ans)

Measured memory_bytes: 89468
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back


int n;


bool solve(int in[3],int a){
    rep(i,n){
        if(in[i]%a!=0)return false;
    }
    return true;
}


int main() {
    cin>>n;
    int in[3]={};
    
    int ma=-1;
    rep(i,n){
        cin>>in[i];
        ma=max(ma,in[i]);
    }
    
    for(int i=1;i<=ma;i++){
        if( solve(in,i) ){
            cout<<i<<endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
char st[100009];
int main()
{
    scanf("%s",st+1);
      int len=strlen(st+1);

       for(int i=1;i<=len;i++)
       {
           if(i+1<=len&&st[i+1]==st[i])
           {
               cout<<i<<" "<<i+1<<endl;
               return 0;
           }
           if(i+2<=len&&st[i+2]==st[i])
           {
               cout<<i<<" "<<i+2<<endl;
               return 0;
           }
       }
       cout<<"-1 -1"<<endl;
}


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

int main(){
	int W, H, x, y, r;
	int tmp;
	cin >> W >> H >> x >> y >> r;
	
	if(x - r < 0 || x + r > W || y - r < 0 || y + r > H){
		cout << "No" << endl;		
	}else{
		cout << "Yes" << endl;
	}
    return 0;
}

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

using namespace std;

int main(void){
    int N,M,C;
    cin>>N>>M>>C;
    vector<int> B(M);
    vector<vector<int>>A(N,vector<int>(M));
    for(int i=0;i<M;i++){
        cin>>B[i];
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<M;j++){
            cin>>A[i][j];
        }
    }
    int count=0;
    for(int i=0;i<N;i++){
        int result=0;
        for(int j=0;j<M;j++){
            result+=A[i][j]*B[j];
        }
        if(result+C>0) count++;
    }
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 256
s = input()
n = len(s)
s1 = s[:int((n-1)/2)]
s2 = s[int((n+1)/2):]
def is_kaibun(ss):
    for i in range(int((len(ss)+1)/2)):
        if ss[i]!=ss[-(i+1)]:
            return False
    return True
if is_kaibun(s1) and is_kaibun(s2) and is_kaibun(s):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#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 endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 2e5 + 10;

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

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

	int h, w;
	cin >> h >> w;
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	x1--; x2--; y1--; y2--;
	string s[h];
	for(int i = 0; i < h; i++) {
		cin >> s[i];
	}
	int d[h][w];
	for(int i = 0; i < h; i++) {
		for(int j = 0; j < w; j++) {
			d[i][j] = inf;
		}
	}
	bool vis[h][w];
	memset(vis, 0, sizeof(vis));
	queue<pii> q;
	d[x1][y1] = 0;
	vis[x1][y1] = 1;
	vector<pii> have;
	have.pb({x1, y1});
	while(!have.empty()) {
		vector<pii> vv;
		for(auto it : have) {
			q.push(it);
		}
		have.clear();
		while(!q.empty()) {
			pii cur = q.front();
			vv.pb(cur);
			q.pop();
			for(int i = 0; i < 4; i++) {
				int tx = cur.fi + dx[i];
				int ty = cur.se + dy[i];
				if(tx >= 0 && tx < h && ty >= 0 && ty < w && !vis[tx][ty] && s[tx][ty] == '.') {
					d[tx][ty] = min(d[tx][ty], d[cur.fi][cur.se]);
					q.push({tx, ty});
					vis[tx][ty] = 1;
				}
			}
		}
		for(auto cur : vv) {
			for(int i = -2; i <= 2; i++) {
				for(int j = -2; j <= 2; j++) {
					int tx = cur.fi + i;
					int ty = cur.se + j;
					if(tx >= 0 && tx < h && ty >= 0 && ty < w && !vis[tx][ty] && s[tx][ty] == '.') {
						d[tx][ty] = min(d[tx][ty], d[cur.fi][cur.se] + 1);
						vis[tx][ty] = 1;
						have.pb({tx, ty});
					}
				}
			}
		}
	}
	if(d[x2][y2] == inf) {
		d[x2][y2] = -1;
	}
	cout << d[x2][y2];

	return 0;
}

Measured memory_bytes: 13824
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bitset>
#include<iomanip>
#include<numeric>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

const double pi = 3.141592653589793;


//最大公約数
template<class T> T gcd(T a, T b)
{
	while (true)
	{
		T r;
		if (a%b == 0) return b;
		else
		{
			r = a % b;
			a = b;
			b = r;
		}
	}
}
//最小公倍数
template<class T> T lcm(T a, T b)
{
	return a / gcd(a, b)*b;
}
//文字0~9をint型0~9に変換
int char_to_int(char c)
{
	if (c == '0') return 0;
	if (c == '1') return 1;
	if (c == '2') return 2;
	if (c == '3') return 3;
	if (c == '4') return 4;
	if (c == '5') return 5;
	if (c == '6') return 6;
	if (c == '7') return 7;
	if (c == '8') return 8;
	if (c == '9') return 9;
	else return -1;
}
//int型0~9を文字0~9に変換
char int_to_char(int c) {
	if (c == 0) return '0';
	if (c == 1) return '1';
	if (c == 2) return '2';
	if (c == 3) return '3';
	if (c == 4) return '4';
	if (c == 5) return '5';
	if (c == 6) return '6';
	if (c == 7) return '7';
	if (c == 8) return '8';
	if (c == 9) return '9';
	else return'x';
}
//a^b mod MODを計算
long long int ModPower(long long int a, long long int b, long long int MOD)
{
	if (b == 0) return 1;
	else if (b % 2 == 0)
	{
		long long int d = ModPower(a, b / 2, MOD);
		return (d*d) % MOD;
	}
	else
	{
		return (a*ModPower(a, b - 1, MOD)) % MOD;
	}
}
//nCr mod MODを計算
long long int ModCombi(long long int n, long long int r, long long int MOD)
{
	if (n == 0 || r == 0) return 1;

	long long int Kn = 1, Kr = 1, Knr = 1;

	long long int temp = 1;
	for (long long int i = 1; i <= n; i++)
	{
		temp *= i;
		temp %= MOD;
		if (i == n) Kn = temp;
		if (i == r) Kr = temp;
		if (i == n - r) Knr = temp;
	}

	long long int x = ModPower(Kr, MOD - 2, MOD);
	long long int y = ModPower(Knr, MOD - 2, MOD);

	long long int ans;
	ans = Kn * x;
	ans %= MOD;
	ans *= y;
	ans %= MOD;

	return ans;
}
//int型10進数をord桁のstring型2進数に変換する
string binary(int x, int ord)
{
	int y;
	string ans = "";
	for (int i = 0; i < ord; i++)
	{
		y = x / (int)pow(2, ord - 1 - i);
		y %= 2;
		if (y == 0) ans += "0";
		else ans += "1";
	}

	return ans;
}
//ord桁のstring型2進数をint型10進数に変換する
int rep_binary(string x, int ord)
{
	int res = 0;
	for (int i = 0; i < ord; i++)
	{
		if (x[i] == '1') res += (int)pow(2, ord - 1 - i);
	}
	return res;
}


/*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*/



int main()
{
	int N, A[105];
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
	}

	for (int i = 0; i < N; i++)
	{
		cout << A[i];
		if (i != N - 1) cout << " ";
	}
	cout << endl;

	int v, j;
	for (int i = 1; i < N; i++)
	{
		v = A[i];
		j = i - 1;

		while (j>=0&&A[j]>v)
		{
			A[j + 1] = A[j];
			j--;
		}

		A[j + 1] = v;

		for (int k = 0; k < N; k++)
		{
			cout << A[k];
			if (k != N - 1) cout << " ";
		}
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 3080
' Imports System.Collections.Generic
' Imports System.Linq
' Imports System.Text
' Imports System.Text.RegularExpressions

Class Main
    Public Shared Sub Main()
        Dim S As String = Console.ReadLine()
        Dim T As String = Console.ReadLine()
        Dim z = S.Zip(T, Function(first, second) New Char() { first, second })
        Dim ans = 0
        For Each v in z
            If v(0) <> v(1) Then
                ans += 1
            End If
        Next
        Console.WriteLine(ans)
        Return
    End Sub
End Class

Measured memory_bytes: 33932
#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm> 
#include <math.h>
#include <queue>
#include <functional>
#include <map>
#include <vector>
#include <string>
#include <set> 
using namespace std;

typedef long long ll;
typedef pair<ll, int> P;
typedef pair<pair<int, int>, int> PP;

const ll INF = 1e15;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

const int MAX = 510000;
const int MOD = 1000000007;


ll A[100010];

int main(void) {
	int N; cin >> N;
	for (int i = 0; i < N; i++) {
	    cin >> A[i]; A[i] *= 2;
	}
	ll d = A[0];
	for (int i = 0; i < N - 1; i++) {
		d = A[i + 1] - d;
	}
	ll pre = d/2; cout << pre << endl;
	for (int i = 0; i < N - 1; i++) {
	    pre = A[i] - pre;
		cout << pre << endl;
	}

}


Measured memory_bytes: 2048
x = int(input())

# def is_prime(n):
#     for i in range(2, n + 1):
#         if i * i > n:
#             break
#         if n % i == 0:
#             return False
#     return n != 1


# A = []
# for i in range(1, x+1):
#     if is_prime(i):
#         A.append(i)
# # print(A)
# B = [0] * 1000
# for i in range(1, x+1):
#     for j in A:
#         if i % j == 0:
#             B[j] += 1
#         for k in range(2, 15):
#             if j**k == i:
#                 B[j] += k -1
#     print(B[2:x])
# t = 1
# for i in B:
#     t *= (i+1)
#     t %= 1000000007
# # print(B)
# print(t)

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

A = [0] * 1000
for i in range(1, x+1):
    B = factorization(i)
    for j in B:
        a, b = j
        A[a] += b

t = 1
for i in A[2:]:
    t *= (i+1)
    t %= 1000000007
print(t)

Measured memory_bytes: 42220
a,b,c = gets.split.map(&:to_i)
# a + b + 2 * ((a*b)**0.5) < c
# 2 * ((a*b)**0.5) < c-a-b
f = 4 * (a*b)
g = (c-a-b)**2

if c - a - b <= 0
    puts "No"
    exit
end
# p [f,g]
puts 4 * (a*b) < (c-a-b)**2 ? "Yes" : "No"

Measured memory_bytes: 1788
fun main(args: Array<String>) {
    val s = readLine()!!
    val keyence = "keyence"

    if (s.startsWith(keyence) || s.endsWith(keyence)) {
        println("YES")
        return
    }

    for (i in (1..6)) {
        val head = keyence.substring(0, i)
        val tail = keyence.subSequence(i, keyence.length)

        if (s.startsWith(head) && s.endsWith(tail)) {
            println("YES")
            return
        }
    }

    println("NO")
}

Measured memory_bytes: 33608
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()

    val sn = IntArray(n) { readLine()!!.toInt() }

    if (sn.all { it % 10 == 0 }) {
        println(0)
        return
    }

    val sum = sn.sum()
    if (sum % 10 != 0) {
        println(sum)
        return
    }

    (sum - sn.filter { it % 10 != 0 }.min()!!).let(::println)
}


Measured memory_bytes: 35772
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
 
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
 
const ll MOD = 1000000007;

int main() {
   int n, k; scanf("%d%d", &n, &k);
   char temp[n]; scanf("%s", temp); string s = temp;
   int run = 1;
   for (int i = 0; i < n - 1; ++i) {
      if (temp[i] != temp[i + 1]) ++run;
   }
   int ans = n - run;
   for (int i = 0; i < k; ++i) {
      if (run > 2) {
         ans += 2;
         run -= 2;
      } else if (run == 2) {
         ans += 1;
         break;
      } else {
         break;
      }
   }
   printf("%d", ans);
   return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
#define INF 1e9
char v[32][62][2];
char map[32][62];
int dp[32][62][2];
int w,h;
struct {int x,y;} d[9]={
{1,-2},
{1,-1},
{1,0},
{1,1},
{1,2},
{2,-1},
{2,0},
{2,1},
{3,0}
};


class State{
public:
	int cost;
	int x,y,d;
	
	State(){}
	State(int c, int a, int b, int e)
	:cost(c),x(a),y(b),d(e)
	{}
	bool operator < (const State &opp) const{
		return cost > opp.cost;
	}
};

main(){
	int i,j,k;
	while(cin>>w>>h,w){
		priority_queue<State> S;
		for(i=1;i<=h;i++) 
			for(j=1;j<=w;j++){
				cin>>map[j][i];
				for(k=0;k<2;k++){
					if(map[j][i]=='S'){
						S.push(State(0,j,i,k));
						dp[j][i][k] = 0;
					}else{
						dp[j][i][k] = INF;
					}
					v[j][i][k] = 0;
				}
			}
		
		State t;
		while(!S.empty()){
			t = S.top();S.pop();
			if(map[t.x][t.y]=='T') break;
			if(v[t.x][t.y][t.d]) continue;
			v[t.x][t.y][t.d] = 1;

			for(i=0;i<9;i++){
				int tx=t.x+d[i].x*(!t.d?1:-1);
				int ty=t.y+d[i].y;
				int td=(t.d+1)%2;
				if(tx<1 || ty<1 || w<tx || h<ty || map[tx][ty]=='X') continue;
				int tc=('0'<=map[tx][ty] && map[tx][ty]<='9')?map[tx][ty]-'0':0;
				if(t.cost+tc < dp[tx][ty][td]){
					dp[tx][ty][td] = t.cost+tc;
					S.push(State(dp[tx][ty][td], tx, ty, td));
				}
			}
		}
		cout << (map[t.x][t.y]=='T'?dp[t.x][t.y][t.d]:-1) << endl;
	}
	return 0;
}

Measured memory_bytes: 944
#include<stdio.h>
int main(void){
	int s,i=1;
	scanf("%d",&s);
	while(1){
		if(s==1||s==2||s==4){
			printf("%d",i+3);
			return 0;
		}
		s=s%2?3*s+1:s/2;
		i++;
	}
}

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

using namespace std;

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

    int N;
    cin >> N;
    vector<pair<int, int>> BA(N);
    for (int i = 0; i < N; ++i) {
        cin >> BA[i].second >> BA[i].first;
    }
    sort(begin(BA), end(BA));
    int t = 0;
    for (int i = 0; i < N; ++i) {
        t += BA[i].second;
        if (t > BA[i].first) {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int M,d;

void solve(){
    cin >> M >> d;
    int ans=0;
    Rep(m,1,M+1){
    Rep(i,2,min(m,10)){
        if (m%i!=0) continue;
        if (10*i+(m/i)<=d && i<=9 && m/i<=9) {
            ans+=1;
            //cout << m << " " << 10*i+(m/i) << endl;
        }
    }
    }

    cout << ans << endl;
}

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

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

int N;
int a[100010], b[100010];
int cum[100010];

void _main() {
    cin >> N;
    REP (i, N) {
        cin >> a[i] >> b[i];
        cum[a[i]]++;
        cum[b[i] + 1]--;
    }
    FOR (i, 1, 100010) cum[i] += cum[i - 1];
    int ans = 0;
    FOR (i, 2, N + 2) if (cum[i] + 1 >= i) {
        ans = i - 1;
    }
    cout << ans << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}


Measured memory_bytes: 5580