akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		long N = sc.nextLong();
		boolean result = false;

		long ans = N;
		for (int i=1; i<=Math.sqrt(N); i++){
			if (N % i == 0){
				long tmp = (i - 1) + ((N / i) - 1);
				ans = Math.min(ans, tmp);
			}
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 23124
import java.util.*;

public class Main {
	public static void main(String[] args) {
		
		Scanner scin = new Scanner(System.in);
		int num_list_length = Integer.parseInt(scin.nextLine());
		int[] searchable_nums = new int[num_list_length];
		String[] unparsed_nums = scin.nextLine().split(" ");
		for (int i = 0; i < unparsed_nums.length; i++) {
			searchable_nums[i] = Integer.parseInt(unparsed_nums[i]);
		}
		
		num_list_length = Integer.parseInt(scin.nextLine());
		int[] query = new int[num_list_length];
		unparsed_nums = scin.nextLine().split(" ");
		for (int i = 0; i < unparsed_nums.length; i++) {
			query[i] = Integer.parseInt(unparsed_nums[i]);
		}
		
		System.out.println(searchNumsBinary(searchable_nums, query));
	}
	
	public static int searchNumsBinary(int[] nums, int[] query) {
		int output = 0;
		for (int j = 0; j < query.length; j++) {
			int tgtquerynum = query[j];
		    int low = 0, high = nums.length - 1;
		    while (low <= high) {
		        int mid = (low + high) / 2;
		        if (nums[mid] < tgtquerynum) {
		            low = mid + 1;
		        } else if (nums[mid] > tgtquerynum) {
		            high = mid - 1;
		        } else if (nums[mid] == tgtquerynum) {
		            output += 1;
		            break;
		        }
		    }
		}
		return output;
	}
}


Measured memory_bytes: 65392
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    S = iss()
    H = '2019/04/30'
    print('TBD' if S > H else 'Heisei')


if __name__ == '__main__':
    main()


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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
    int N; cin >> N;
    vector<int> a(N), cnt(100000);
    for(int i = 0; i < N; i++) {
        cin >> a[i];
        cnt[a[i]]++;
    }
    int M = 0;
    if(N != 1) {
        for(int i = 0; i < N; i++) {
            int sum;
            if(i != 0 && i != N - 1) {
                sum = cnt[i] + cnt[i - 1] + cnt[i + 1];
            }
            else if(i == 0) {
                sum = cnt[i] + cnt[i + 1];
            }
            else {
                sum = cnt[i] + cnt[i - 1];
            }
            M = max(M, sum);
        }
    }
    else M = 1;
    cout << M << endl;
    return 0;
}

Measured memory_bytes: 4056
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int MOD = 1000000007;
const ll INF = 1LL << 60;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    long double a;
    long double b;
    cin >> a >> b;
    cout << (long)(a * b) << endl;
}

Measured memory_bytes: 3688
#include <iostream>
#include <algorithm>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;
const int mod = (int)1e9 + 7, INF = (int)1e9;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };


ll binary_search(ll x) {
    ll l, r, mid;
    l = 1;
    r = (ll)1e10;
    while (r - l > 1) {
        mid = (l + r) / 2;
        if (x >= mid * (mid + 1) / 2) {
            l = mid;
        }
        else {
            r = mid;
        }
    }
    return l;
}

int main(void) {
    ll n, a, d, ans;

    scanf("%lld", &n);

    ans = 0;
    for (a = 2; a * a <= n; a++) {
        d = 0;
        while (n % a == 0) {
            n /= a;
            d++;
        }
        if (d == 0) {
            continue;
        }
        ans += binary_search(d);
    }

    if (n > 1) {
        ans += 1;
    }

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

    return 0;
}

Measured memory_bytes: 3828
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
data = [0] * (10**5)
for i in range(1,10**5):
  data[i] = data[i-1] + i

def prime_factor(n):
    ass = []
    for i in range(2,int(n**0.5)+1):
        count=0
        while n % i==0:
            count+=1
            n = n//i
        if count!=0:
            ass.append((i,count))
    if n != 1:
        ass.append((n,1))
    return ass
ass = prime_factor(n)
for num,count in ass:
  ans += bisect.bisect_right(data,count)-1
  # print(bisect.bisect_right(data,count),count)
print(ans)
# print(data[:10])

Measured memory_bytes: 69320
n,k = map(int,input().split())
sss = input()

now = 1
cnt = 0
x = []

for i in range(n):
    if sss[i] == str(now):
        cnt += 1
    else:
        x.append(cnt)
        now = 1 - now
        cnt = 1
if cnt != 0:
    x.append(cnt)
if sss[-1] == 0:
    x.append(0)

Add = 2 * k + 1
ans = 0

y = [0]
for i in range(len(x)):
    y.append(y[i] + x[i])

for i in range(len(x))[::2]:
    left = i
    right = min(i + Add, len(x))
    tmp = y[right] - y[left]    
    
    ans = max(tmp, ans)

print(ans)

Measured memory_bytes: 7932
import numpy as np
N,A,B = map(int,input().split())
x=abs(A-B)
    

if x%2==0:
    print(x//2)
else:
    y,z=max(N-A,N-B),max(A-1,B-1)
    a,b=min(A-1,B-1),min(N-A,N-B)
    c,d=max(A-1,B-1)-a,max(N-A,N-B)-b
    e,f=c//2+a+1,d//2+b+1
    if y>z:
        print(min(z,e,f))
    else:
        print(min(y,e,f))

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

int main(){
    string s;
    cin>>s;
    int len = (int)s.size();
    cout <<s[0]<<len-2<<s[len-1]<< endl;
    return 0;
}

Measured memory_bytes: 256
N=int(input())
W=list(map(int,input().split()))
sa=[]
for i in range(N-1):
  S1=sum(W[:i+1])
  S2=sum(W[i+1:])
  #print(S1,S2)
  sa.append(abs(S2-S1))
print(min(sa))

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main() {
	int a,c=0,b[10000];
	cin >> a;
	for (int i = 0; i < a; i++) {
		cin >> b[i];
	}
	for(int i=0;i<a;i++){
		while (1){
			if (b[i] == 0 || b[i] % 2 == 1)break;
			b[i] /= 2; c++;
		}
	}
	cout << c << endl;
	return 0;

}

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

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

int main(int argc, char const *argv[])
{
    string s;
    cin >> s;
    int res(7);
    if (s == "MON")
    {
        res = 6;
    }
    else if (s == "TUE")
    {
        res = 5;
    }
    else if (s == "WED")
    {
        res = 4;
    }
    else if (s == "THU")
    {
        res = 3;
    }
    else if (s == "FRI")
    {
        res = 2;
    }
    else if (s == "SAT")
    {
        res = 1;
    }
    cout << res;
    return 0;
}


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

int main() {
  string a,b;
  cin>>a>>b;
  if(a.size()>b.size())cout<<"GREATER"<<endl;
  if(a.size()<b.size())cout<<"LESS"<<endl;
  if(a.size()==b.size()){
    if(a>b)cout<<"GREATER"<<endl;
    if(a==b)cout<<"EQUAL"<<endl;
    if(a<b)cout<<"LESS"<<endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

int main() {
  int m;
  scanf("%d", &m);
  printf("%d\n", 48-m);
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		String s = sc.next();

		long r = 0;
		long g = 0;
		long b = 0;

		for ( int i=0; i<n; i++ ) {
			if ( s.charAt(i)=='R' ) {
				r++;
			} else if ( s.charAt(i)=='G' ) {
				g++;
			} else {
				b++;
			}
		}

		if ( r*g*b==0 ) {
			System.out.println(0);
			System.exit(0);
		}

		long f = 0;
		for ( int i=0; i<n-2; i++ ) {
			for ( int j=i+1; j<n; j++ ) {
				int k = 2*j-i;
				if ( k < n ) {
					if ( s.charAt(i)!=s.charAt(j) && s.charAt(j)!=s.charAt(k) && s.charAt(k)!=s.charAt(i) ) {
						f++;
					}
				}
			}
		}

		System.out.println(r*g*b-f);
	}

}


Measured memory_bytes: 27700
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
using namespace std;
typedef long long ll;
int main()
{
	int query;
	scanf("%d", &query);
	for (int p = 0; p < query; p++)
	{
		ll a, b;
		scanf("%lld%lld", &a, &b);
		if (a > b)swap(a, b);
		if (a == b || a + 1 == b)printf("%lld\n", a + a - 2);
		else
		{
			ll beg = 0, end = 1010101010LL;
			for (;;)
			{
				if (beg == end)break;
				ll med = (beg + end + 1) / 2;
				if (med*med >= a*b)end = med - 1;
				else beg = med;
			}
			if (beg*(beg + 1) < a*b)printf("%lld\n", beg + beg - 1);
			else printf("%lld\n", beg + beg - 2);
		}
	}
}


Measured memory_bytes: 256
n = int(input())
n_list = [int(i) for i in input().split()] 

minus_count = 0
plus_list = []
for x in n_list:
  if x < 0:
    minus_count += 1
  plus_list.append(abs(x))
    
if minus_count % 2 == 0 or 0 in plus_list: #even
  print(sum(plus_list))
else:
  print(sum(plus_list) - 2 * min(plus_list))


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

 int main(){
   int m1,d1,m2,d2;
   cin>>m1>>d1>>m2>>d2;
   if(m1==m2){
     cout<<0<<endl;
   }else{
     cout<<1<<endl;
   }
}

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

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

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(void) {
    int N;
    string S;
    cin >> N >> S;
    int ans = 0;
    for(int i=0; i<N; i++) {
        vector<char> X(26);
        vector<char> Y(26);
        int ans_tmp = 0;
        for(int j=0; j<N; j++) {
            if(j<i) {
                X[S[j] - 'a']++;
            } else {
                Y[S[j] - 'a']++;
            }
        }
        for(int k=0; k<26; k++) {
            if(X[k] && Y[k]) {
                ans_tmp ++;
            }
        }
        ans = max(ans, ans_tmp);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
/**
 * Created by hiroqn on 13/10/04.
 */
var fs = require('fs'),
    length = fs.fstatSync(process.stdin.fd).size,
    buffer = new Buffer(length),
    bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
    input = buffer.toString('utf8', 0, bytesRead).split('\n');
var e, res;
function solve(e) {
  var res = Infinity;
  for (var z = 0; z * z * z <= e; z++) {
    for (var y = 0; y * y <= e - z * z * z; y++) {
      var x = e - z * z * z - y * y;
      if (res > x + z + y) {
        res = x + y+ z;
      }
    }
  }
  return res;
}
while ((e = +input.shift()) !== 0) {
  console.log(solve(e));
}

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

struct Edge {
    int to;
    long long cost;
};
using Graph = vector<vector<Edge>>;

// 深さ優先探索
vector<long long> dist;  // 既に見たことがある頂点か記録
void dfs(const Graph &G, int v, int p) {
    for (auto e : G[v]) {
        if (e.to != p) {  // 訪問済みでなければ探索
            dist[e.to] = dist[v] + e.cost;
            dfs(G, e.to, v);
        }
    }
}

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

    int V;
    cin >> V;
    int E = V - 1;
    Graph G(V);
    for (int i = 0; i < E; i++) {
        int a, b;
        long long w;
        cin >> a >> b >> w;
        a--, b--;
        G[a].push_back({b, w});
        G[b].push_back({a, w});
    }

    dist.assign(V, 0);  // 初期化
    dfs(G, 0, -1);

    for (int i = 0; i < V; i++) {
        cout << dist[i] % 2 << "\n";
    }

    return 0;
}


Measured memory_bytes: 10752
#pragma GCC optimize("Ofast")
 #pragma GCC optimization ("unroll-loops")
 #include<bits/stdc++.h>
 using namespace std;
 #define gcd(a,b) __gcd(a,b)
 #define pb push_back
 #define DRACO ios_base::sync_with_stdio(false);cin.tie(NULL);
 #define ll long long int
 #define GO ll t; cin>>t; while(t--)
 #define mod  1000000007
 #define vect vector<long long int>
 #define fore(p) for(auto& x:p)
 #define bins binary_search
 #define vecti vector<int>::iterator
 #define bitout __builtin_popcount
 #define all(x) x.begin(),x.end()
 #define allr(x) x.rbegin(), x.rend()
 #define PY 3.141592653589793238
 #define F first
 #define S second
 int main() 
 {   DRACO
     ll i,j,k,l,n,m;
     cout.precision(10);
     //GO
     {   
         cin >> n;
         if(n == 0)
         	cout<<"1";
         else
         	cout<<"0";
         
     }
 return 0;
 }
 //check the corner cases(n==1)
 //try checking in reverse order
 //check your logic again

Measured memory_bytes: 3648
N = int(input())
x = [0] * N
y = [0] * N
for i in range(N):
    x[i],y[i] = map(int,input().split())

if N == 1:
    print(1)
else:
    memo = {}

    for i in range(N-1):
        for j in range(i+1,N):
            dx = x[j] - x[i]
            dy = y[j] - y[i]
            if (dx,dy) in memo:
                memo[(dx,dy)] += 1
            elif (-dx,-dy) in memo:
                memo[(-dx,-dy)] += 1
            else:
               memo[(dx,dy)] = 1
            #print(memo)

    M = max(memo.values())

    print(N-M)


Measured memory_bytes: 3188
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll linf = 1LL << 62;
const int inf = 99999999;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };
const ll atcoder = 1e9 + 7;

#define Endl endl
#define mp make_pair
#define all(v) v.begin(),v.end()
#define pb push_back
#define pr(x) cout << x << endl
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define rep(i,n) for(int i= 0;i<n;i++)
#define FOR(i,a,b) for(int i = a;i<b;i++)

template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

ll gcd(ll a, ll b) {//最大公約数
	if (a < b)swap(a, b);
	if (a%b == 0)return b;
	else gcd(b, a%b);
}

ll lcm(ll a, ll b) {//最小公倍数
	if (a < b)swap(a, b);
	return (a / gcd(a, b))*b;
}

int main() {

	int a, b, k;
	cin >> a >> b >> k;


	for (int i = a; i <= b; i++) {
		if (a + k - 1 >= i || i >= b - k + 1)pr(i);
	}


	//system("pause");
	return 0;
}



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

int main(){
  int N,W;
  cin>>N>>W;
  vector<int> wt(N,0);
  vector<int> val(N,0);
  
  for(int i = 0; i < N; i++)
    cin>>wt[i]>>val[i];
  vector<vector<long long>>dp(N+1,vector<long long>(W+1,0));
  for(int i = 1; i <= N; i ++){
    for(int j = 1; j <= W; j++){
      if(j >= wt[i-1])
        dp[i][j] = max(dp[i-1][j-wt[i-1]] + val[i-1] , dp[i-1][j]);
      else
        dp[i][j] = dp[i-1][j];
    }
  }
  cout<<dp[N][W];
  return 0;
}


Measured memory_bytes: 80256
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <fstream>
#include <map>
#include <string>
#include <sstream>
#include <queue>
#include <iomanip>
#include <set>


using namespace std;

#define ll long long int

ll value(vector<int>& n){
    ll res = 0;
    for(int i=0; i<n.size(); i++){
        res *= 10;
        res += n[i];
    }
    return res;
}

void tree(vector<int>&n, int k, int i0, set<ll>&compt){
    
    int a = n[i0];
    
    if(i0+1 == n.size()){ //c'est fini
        compt.insert( value(n) );
        return;
    }
    
    if(a != 9){
        n[i0 + 1] = a+1;
        tree(n, k, i0+1, compt);
    }
    
    
    n[i0+1] = a;
    tree(n, k, i0+1, compt);
    
    if(a != 0){
        n[i0+1] = a-1;
        tree(n, k, i0+1, compt);
    }
    
}


int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    
    int K;
    cin>>K;
    int k = 1;  //nombre de chiffres
    
    
    if(K < 10){
        cout<<K<<endl;
        return 0;
    }
    k++;
    K-=9;
    
    while(1){
        //cout<<k<<" "<<K<<endl;
        set<ll> compt;
        for(int c = 1; c <= 9; c++){
            vector<int> n(k, 0);
            n[0] = c;
            tree(n, k, 0, compt);
        }
        //cout<<"ici"<<compt.size()<<endl;
        if(compt.size() < K){
            k++;
            K -= compt.size();
        }
        else{
            for(set<ll>::iterator it = compt.begin(); it != compt.end(); it++){
                K--;
                //cout<<K<<" "<<*(it)<<endl;
                if(K == 0){
                    cout<<(*it)<<endl;
                    return 0;
                }
            }
        }
    }
    
    
    return 0;
    
    
    
}


Measured memory_bytes: 6400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 212345
pii a[N];

int main(){
	int n; scanf("%d", &n);
	REP(i, n){
		int b; scanf("%d", &b);
		a[i] = make_pair(b, i);
	}
	sort(a, a+n, greater<pii>());
	REP(i, n){
		if(i==a[0].second) printf("%d\n", a[1].first);
		else printf("%d\n", a[0].first);
	}
}


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

int main() {
  cout<<setprecision(10)<<endl;
  double n;
  cin>>n;
  vector<double> v(n);
  rep(i,n){
    cin>>v[i];
  }
  sort(v.begin(),v.end(),greater<int>());
  double ans=0;
  for(int i=n-2; i>=0; i--){
    v[i]=(v[i+1]+v[i])/2;
    v.pop_back();
  }
  cout<<v[0]<<endl;
}

Measured memory_bytes: 256
n = int(input())
A = list(set(list(map(int, input().split()))))
A.sort()

while not len(A) == 1:
    div = A[0]
    A = A[1:]
    A = list(map(lambda x:x%div, A))
    A.append(div)
    A = list(set([x for x in A if x != 0]))
    A.sort()

print(A[0])

Measured memory_bytes: 113436
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

int N, M;

int K = 1;
ll dat[200010 * 4], lz[200010 * 4];

void prop(int k, int l, int r) {
    dat[k] += lz[k];
    if (r - l > 1) {
        int kl = 2 * k, kr = kl + 1;
        lz[kl] += lz[k];
        lz[kr] += lz[k];
    }
    lz[k] = 0;
}

void upd(int k, int l, int r, int L, int R, ll x) {
    prop(k, l, r);
    if (r <= L || R <= l)return;

    if (L <= l && r <= R) {
        lz[k] += x;
        prop(k, l, r);
    } else {
        int m = (l + r) / 2, kl = 2 * k, kr = kl + 1;
        upd(kl, l, m, L, R, x);
        upd(kr, m, r, L, R, x);
        ll yl = dat[kl], yr = dat[kr];
        dat[k] = max(yl, yr);
    }
}

ll qry(int k, int l, int r, int L, int R) {
    if (r <= L || R <= l)return 0;
    prop(k, l, r);
    if (L <= l&&r <= R) {
        return dat[k];
    } else {
        int m = (l + r) / 2, kl = 2 * k, kr = kl + 1;
        ll yl = qry(kl, l, m, L, R);
        ll yr = qry(kr, m, r, L, R);
        return max(yl, yr);
    }
}

vi S[200003];

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

    cin >> N >> M;

    vi L(N), R(N);
    rep(i, N) {
        cin >> L[i] >> R[i];
        if (L[i] + 1 < R[i])S[L[i]].push_back(R[i]);
    }

    while (K < M + 2)K *= 2;
    ll ans = max(0, N - M);

    for (int r = 1; r <= M; ++r) {
        upd(1, 0, K, 1, r + 1, -1);
    }
    for (int l = 0; l <= M; ++l) {
        each(r, S[l]) {
            upd(1, 0, K, 1, r + 1, 1);
        }
        ll z = qry(1, 0, K, 1, M + 2) - l;
        smax(ans, z);
    }
    cout << ans << endl;
}


Measured memory_bytes: 21760
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

ll cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    int n, q;
    cin >> n >> q;

    vector<pair<pair<int,int>,int>> vec;
    rep(i, n){
        int s, t, x;
        cin >> s >> t >> x;

        vec.push_back({{max(0,s - x), x}, 0});
        vec.push_back({{max(0,t - x), x}, 1});
    }

    sort(all(vec));
    vector<int> d(q);

    rep(i, q){
        cin >> d[i];
    }

    int now = 0;
    multiset<int> st;
    rep(i, q){
        while(d[i] >= vec[now].first.first && now < vec.size()){
            //cout << now << " " << vec[now].first.first << " " << vec[now].first.second <<" "<< vec[now].second << endl;
            if(!vec[now].second){
                st.insert(vec[now].first.second);
            } else {
                auto itr = st.find(vec[now].first.second);
                st.erase(itr);
            }
            now++;
        }

        cout << (*st.begin()==0?-1:*st.begin()) << endl;

    }
}

Measured memory_bytes: 16108
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

ans = sum(B)
for i in range(N - 1):
    if A[i + 1] - A[i] == 1:
        ans += C[A[i] - 1]
print(ans)


Measured memory_bytes: 3060
#define errOut(s) \
  { std::cerr << __LINE__ << ":" << #s << ":" << (s) << std::endl; }

#include <bits/stdc++.h>
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Weverything"
//#include <boost/multi_array.hpp>
//#include <boost/optional.hpp>
//#include <boost/range/adaptors.hpp>
//#include <boost/range/algorithm.hpp>
//#include <boost/range/irange.hpp>
#pragma clang diagnostic pop

using namespace std;

struct UnionFind {
  std::vector<int64_t> par;

  explicit UnionFind(int64_t N) : par(N) {
    for (int64_t i = 0; i < N; i++) {
      par[i] = i;
    }
  }

  int64_t root(int64_t x) {
    if (par[x] == x) {
      return x;
    }
    return par[x] = root(par[x]);
  }

  void unite(int64_t x, int64_t y) {
    int64_t const rx = root(x);
    int64_t const ry = root(y);
    if (rx == ry) {
      return;
    }
    par[rx] = ry;
  }

  bool same(int64_t x, int64_t y) {
    int64_t const rx = root(x);
    int64_t const ry = root(y);
    return rx == ry;
  }
};

int64_t solve(int64_t n, int64_t m, std::vector<int64_t> as,
              std::vector<int64_t> bs) {
  auto uf = UnionFind(n);
  for (auto i = 0; i < m; i++) {
    auto const a = as[i];
    auto const b = bs[i];
    uf.unite(a, b);
  }

  int64_t ret = 0;
  std::vector<int64_t> counts(n, 0);
  for (auto i = 0; i < n; i++) {
    auto const r = uf.root(i);
    counts[r]++;
    ret = std::max(counts[r], ret);
  }
  return ret;
}

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int64_t n;
  std::cin >> n;
  int64_t m;
  std::cin >> m;
  std::vector<int64_t> as(m);
  std::vector<int64_t> bs(m);
  for (int i = 0; i < m; i++) {
    std::cin >> as[i];
    as[i]--;
    std::cin >> bs[i];
    bs[i]--;
  }
  auto const res = solve(n, m, std::move(as), std::move(bs));
  std::cout << res << std::endl;
  return 0;
}


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

int main() {
  int r;
  cin >> r;
  if (r < 1200) {
    cout << "ABC" << endl;
  } else if (r < 2800) {
    cout << "ARC" << endl;
  } else {
    cout << "AGC" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.List

main :: IO ()
main = do
  [m, n] <- f
  unless (m == 0 && n == 0) $ do
    putStrLn $ solve m n
    main
  where
    f = map read <$> words <$> getLine

solve :: Integer -> Integer -> String
solve m n = concat $ reverse $ zipWith (\x s -> if x == 0 then "" else show x ++ s) ls us
  where
    us = ["", "Man", "Oku", "Cho", "Kei", "Gai", "Jo", "Jou", "Ko",
          "Kan", "Sei", "Sai", "Gok", "Ggs", "Asg", "Nyt", "Fks", "Mts"]
    ls = unfoldr (\x -> if x == 0 then Nothing else let (q, r) = divMod x 10000 in Just (r, q)) $ expt m n

expt :: Integer -> Integer -> Integer
expt m n
  | n == 1 = m
  | even n = x * x
  | otherwise = x * x * m
  where
    x = expt m (n `div` 2)



Measured memory_bytes: 4312
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;

        int n = Integer.parseInt(br.readLine());
        st = new StringTokenizer(br.readLine());

        int prev = Integer.parseInt(st.nextToken());
        int len = 1;
        int max = 1;
        for(int i=1 ; i<n ; i++) {
            int curr = Integer.parseInt(st.nextToken());
            if(curr <= prev) {
                len++;
            }
            else {
                if(len > max) {
                    max = len;
                }
                len = 1;
            }
            prev = curr;
        }

        if(len > max) {
            max = len;
        }

        System.out.println(max-1);
    }
}


Measured memory_bytes: 37972
import Data.Char
import Control.Monad

op "+" = (+)
op "-" = (-)

main = do
  [a,b,c,d] <- map digitToInt <$> getLine
  putStrLn $ head $ solve a b c d

solve a b c d = do
  let opss = ["+","-"]
  ops1 <- opss
  ops2 <- opss
  ops3 <- opss
  let op1 = op ops1
  let op2 = op ops2
  let op3 = op ops3
  guard (a `op1` b `op2` c `op3` d == 7)
  return (show a ++ ops1 ++ show b ++ ops2 ++ show c ++ ops3 ++ show d ++ "=7")


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;



int n, m;
int a[maxn];
vector<int> g[maxn];
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
    cin>>n>>m;
    for (int i=1; i<=n; i++) {
	cin>>a[i];
    }

    for (int i=0; i<m; i++) {
	int u,v; cin>>u>>v;
	g[u].push_back(v);
	g[v].push_back(u);
    }

    int ans = 0;
    for (int i=1; i<=n; i++) {
	bool ok = true;
	for (int to: g[i]) {
	    if (a[i]>a[to]) continue;
	    ok = false;
	}
	ans += ok;
    }
    out(ans);
  

    return 0;
}


Measured memory_bytes: 30208
while s = gets do
  26.times do
    break if s.include?("the") || s.include?("this") || s.include?("that")
    s.length.times do |i|
      s[i] = (s[i].ord + 1).chr if 'a' <= s[i] && s[i] <= 'z'
      s[i] = 'a' if s[i].ord == 'z'.ord + 1
    end
  end
  puts s
end

Measured memory_bytes: 6104
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

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

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    int h,w,a,b;cin>>h>>w>>a>>b;

    REP(i,h){
        REP(j,w){
            if(i<b && j<a){
                cout<<1;
            }
            else if(i<b){
                cout<<0;
            }
            else if(j<a){
                cout<<0;
            }
            else{
                cout<<1;
            }

        }
        cout<<endl;
    }

	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 1280
//优先取出最大键值的队列称为最大优先级队列，利用最大堆实现;


#include <iostream>
#include<string>
using namespace std;
#define NIL  -(1 << 30)//左移符号，将1的二进制所有符号向左移动30位
#define MAX  2000000
int Total = 0, Tree[MAX];
void includeSwitchKey(int &parent, int &son)//交换位置
{
	int change;
	change = parent, parent = son;
	son = change;
}
void includeFindMaximum(int num)//找子结点最大值
{
	int leftnumber, rightnumber, largestnumber, change;
	leftnumber = num * 2;
	rightnumber = num * 2 + 1;
	if (leftnumber <= Total && Tree[leftnumber] > Tree[num])//左节点值大于父节点
		largestnumber = leftnumber;
	else
		largestnumber = num;
	if (rightnumber <= Total && Tree[rightnumber] > Tree[largestnumber])//右子结点最大
		largestnumber = rightnumber;
	if (largestnumber != num)//当父节点小于任意的节点的时候
	{
		change = Tree[largestnumber];//交换数据应单独做成一个函数
		Tree[largestnumber] = Tree[num];
		Tree[num] = change;
		includeFindMaximum(largestnumber);
	}
}
void includeFindSuitablePosition(int total,int key)
{
	if (Tree[total] > key)
	{
		cout << "不能低于此值" << endl;
		return;
	}
	Tree[total] = key;
	while (total > 1 && Tree[total / 2] < Tree[total])//大于父节点
	{
		includeSwitchKey(Tree[total / 2], Tree[total]);
		total = total / 2;
	}
}
void includeInsertData(int key)//插入
{
	Total++;
	Tree[Total] = NIL;//防止输入的值比此值更小
	includeFindSuitablePosition(Total,key);

}
int  includeDeleteAndExtractData()//提取根值，即最大值，同时删除根值
{
	int max;
	if (Total < 1)
		return NIL;
	max = Tree[1];//最大堆根值最大
	Tree[1] = Tree[Total--];//将最后结点移上去
	includeFindMaximum(1);//将最后节点移上去相当于在已经排好序的最大堆放入一个新的元素，将其放入应在的位置
	return max;
}
int main()
{	
	string order;
	int key,count=0;
	while (1)
	{
		cin >> order;
		if ("insert" == order)
		{
			cin >> key;
			includeInsertData(key);
		}
		else if ("extract" == order)
		{
			cout<<includeDeleteAndExtractData()<<endl;
		}
		else if ("end" == order)
			break;
	}
	
	return 0;
	
}


Measured memory_bytes: 7072
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;


int main(){
    fast_io

    string s;
	cin>>s;
	
	if(s[2]==s[3] && s[4]==s[5]){
		cout<<"Yes"<<endl;
	}else cout<<"No"<<endl;
    
    return 0;
}


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

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int main(){
    ll h,w;
    while(true){
        cin>>h>>w;
        if(h==0&&w==0)return 0;
        REP(i,h){
            REP(j,w){
                if(i==0||i==h-1||j==0||j==w-1)cout<<"#";
                else cout<<".";
            }
            cout<<endl;
        }
        cout<<endl;
    }
}


Measured memory_bytes: 3068
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
// const int mod=998244353;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n;
    cin>>n;
    switch(n%10){
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:cout<<"hon"<<endl;break;
        case 0:
        case 1:
        case 6:
        case 8:cout<<"pon"<<endl;break;
        case 3:cout<<"bon"<<endl;break;
    }
}

Measured memory_bytes: 3640
# coding: utf-8

import math

#整数a,bを読み込む
a, b = map(float, input().split())

#範囲チェック→今回はエラー処理がないため実装せず

#平均を出して切り上げ
val_ave = math.ceil((a+b)/2)

#表示
print(val_ave)

Measured memory_bytes: 2940
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	public static void main(String args[]) throws Exception {

		MyScanner sc = new MyScanner();
		PrintWriter pr = new PrintWriter(System.out);
		
		String s = sc.next();
		long sum = 0;
		
		for(char ch : s.toCharArray())
			sum += Integer.parseInt(ch + "");
		
		pr.print((sum % 9 == 0) ? "Yes" : "No");
		pr.close();
	}

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
}


Measured memory_bytes: 46632
#define DEBUG 0
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll LLINF = 1e16;
const int MOD = 1000000007;
const int MOD2 = 998244353;
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#if DEBUG
#define debug(...)\
    do {\
        std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        std::cerr << std::noboolalpha;\
    } while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
    { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
os << "{";
    for (auto it = v.begin(); it != v.end(); it++)
        {os << (it != v.begin() ? "," : "") << *it;}
    return os << "}";
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<char> c(n);
    vector<char> d(n);
    for(int i =0;i<n;i++){
        char x;
        cin >> x;
        c[i] = x;
        d[i] = x;
    }
    sort(all(c));
    int cnt = 0;
    for(int i =0;i<c.size();i++){
        if(c[i] != d[i]) cnt++;
    }
    cout << cnt/2 << endl;

}

Measured memory_bytes: 3696
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>

using namespace std;

int main() {
  string S;
  cin >> S;
  sort(S.begin(), S.end());
  if (S[0] == S[1] and S[1] != S[2] and S[2] == S[3]) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int card[10];
	int c1, c2, c3;
	int need, cnt;

	while(scanf("%d %d %d", &c1, &c2, &c3) != EOF){
		cnt = 0;

		for(int i=0; i<10; i++){
			card[i] = 1;
		}

		card[c1-1] = 0;
		card[c2-1] = 0;
		card[c3-1] = 0;

		need = 20 - (c1+c2);
		for(int i=0; i<10; i++){
			if(i+1 <= need && card[i] == 1){
				cnt++;
			}
		}
		if(cnt / 7.0 >= 0.5){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ld double
#define ull unsigned long long 
#define ll long long 
#define pii pair<int,int >
#define iiii pair<int,pii >
#define mp make_pair 
#define INF 1000000000
#define MOD 1000000007 
#define rep(i,x) for(int (i)=0;(i)<(x);(i)++)
inline int getint()
{
	int x=0,p=1;char c;
	c=getchar();
	while (c<=32)c=getchar();
	if(c==45)p=-p,c=getchar();
	while (c>32)x=x*10+c-48,c=getchar();
	return x*p;
}
using namespace std;

const int maxn=1e5+5;
ll a[maxn],pre[maxn];
int n;
int main()
{
	n=getint();
	a[0]=0;
	pre[0]=0;
	for(int i=1;i<=n;i++)
	{
		int x=getint();
		a[i]=x;
		pre[i]=pre[i-1]+1ll*abs(a[i]-a[i-1]);
	}
	a[n+1]=0;
	pre[n+1]=pre[n]+1ll*abs(a[n+1]-a[n]);
	for(int i=1;i<=n;i++)
	{
		ll ra=pre[i-1]+pre[n+1]-pre[i+1]+abs(1ll*a[i+1]-a[i-1]);
		printf("%lld\n",ra);
	}
	return 0;	
} 


Measured memory_bytes: 2816
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};
vector< ll > divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

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

    ll  a,b,c,d,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,stra,straa;
    ll x,y,z;
    char ca,cb,cc;
    cin>>n;
    vector<ll> v(n);
    vector<ll> w(n);

    rep(i,n) cin>>v[i];
    rep(i,n) cin>>w[i];

    rep(i,n){
        sum=max(sum,sum+v[i]-w[i]);
    }
    cout<<sum<<endl;


    

    return 0;
}


Measured memory_bytes: 3664
s = input()
t = ''
result = 'NO'

scripts = ['dream', 'dreamer', 'erase', 'eraser']

for i in range(len(scripts)):
    script = scripts[i]
    script = script[::-1]
    scripts[i] = script

s_rev = s[::-1]

while len(s) > 0:
    for script in scripts:
        if s_rev[:len(script)] == script:
            s_rev = s_rev[len(script):]
            break
    else:
        break

if s_rev == '':
    result = 'YES'
print(result)


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define Would
#define you
#define please

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


	int suuretu[2002][2001] = {};
	rep(i, N + 1) suuretu[1][i] = 1;
	for (int i = 2; i <= K; i++) {
		suuretu[i][0] = 1;
		rep1(ii, N) suuretu[i][ii] = (suuretu[i][ii - 1] + suuretu[i - 1][ii]) % 998244353;
	}

	int output;
	int kotae[2001];
	rep(i, K / 2 + K % 2) {
		output = suuretu[K][N];
		rep(ii, i + 1) { 
			if (N - 2 * (ii + 1) >= 0) output -= (long long)(pow(-1, ii) * (1ll * suuretu[i - ii + 1][ii + 1] * suuretu[K][N - 2 * (ii + 1)] % 998244353));
			output %= 998244353;
		}
		if (output < 0) {
			output += 998244353;
		}
		kotae[i] = output;
		cout << output << "\n";
		if (i + 1 != K / 2 + K % 2 || K % 2 == 0) cout << output << "\n";
	}
	if (K % 2 == 0)	cout << output << "\n";
	rep(i, K / 2 + K % 2 - 1) {
		cout << kotae[K / 2 + K % 2 - 2 - i] << "\n";
		cout << kotae[K / 2 + K % 2 - 2 - i] << "\n";
	}
	Would you please return 0;
}


Measured memory_bytes: 16000
#include <stdio.h>
#include <math.h>
#include <cstring>

bool nArray[999999];

int main() {
    int n = 0;
    for (int cou = 0; ((scanf("%d", &n) != EOF) && (cou < 30)); ++cou) {
        for (int i = 0; i < 999999; ++i) {
            nArray[i] = (i <= 1) ? false : true;
        }

        int maxValue = sqrt(n);
        for (int i = 2; i <= n + 1; ++i) {
            if (!nArray[i]) {
                continue;
            }

            for (int j = 2; (i * j) <= n; ++j) {
                nArray[i * j] = false;
            }
        }

        int result = 0;
        for (int i = 0; i <= n; ++i) {
            if (nArray[i]) {
                result++;

            }
        }

        printf("%d\n", result);
    }

    return 0;
}

Measured memory_bytes: 2000
//g++ -std=gnu++14 a.cpp

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
#include <stdio.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;
ll MODP = 998244353;

ll kai(ll x,ll y){
  if(y == 0)return 1;
  if(y == 1)return x;
  if(y&1){
    return (x*kai(x,y-1))%MOD;
  }else{
    ll t = kai(x,y/2);
    return (t*t)%MOD;
  }
}

ll comb(ll a,ll b,vector<ll> &p){
  if(a == 0)return 1;
  if(b == 0)return 1;
  ll ans = p[a+b];
  ans = (ans*kai(p[a],MOD-2))%MOD;
  ans = (ans*kai(p[b],MOD-2))%MOD;
  return ans;
}

int main(){
  ll N;
  cin >> N;
  vector<ll> A(N);
  rep(i,N)cin >> A[i];
  vector<ll> resA(N+1,0);
  for(int i = N-1;i >= 0;i--){
    resA[i] = resA[i+1] + A[i];
  }
  ll ans = 0;
  for(int i = 0;i <= N-2;i++){
    ans = (ans%MOD + ((A[i]%MOD)*(resA[i+1]%MOD))%MOD)%MOD;
  }
  cout << ans << endl;


  return 0;
}


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

namespace _0184
{
    public class Program

    {
        public static void Main(string[] args)
        {
            while (true)
            {
                int n = RInt();
                if (n == 0) break;

                int[] Cnt = new int[7];
                for (int i = 0 ; i < n ; i++)
                {
                    int ageClass = (RInt() / 10);
                    if (ageClass <= 5) Cnt[ageClass]++; else Cnt[6]++;
                }

                for (int i = 0 ; i < Cnt.Length ; i++)
                {
                    Console.WriteLine(Cnt[i]);
                }
            }
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}



Measured memory_bytes: 20060
#include <stdio.h>
#include <string.h>
#include <math.h>
int main()
{
    int n, k ,q, i, m;
    scanf("%d %d %d",&n,&k,&q);
    int scores[n];
    for(i=0;i<n;i++)
    {
        scores[i] = k - q; 
    }
    for(i=0;i<q;i++)
    {
        scanf("%d",&m);
        scores[m-1]++;
    }
    for(i=0;i<n;i++)
    {
        if(scores[i]>0)
        {
            printf("Yes\n");
        }
        else
        {
            printf("No\n");
        }
    }
    return 0;
}

Measured memory_bytes: 896