akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define mp make_pair
#define mt make_tuple
#define DESYNC                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector<ii>
#define all(x) x.begin(), x.end()
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define M 1000000007
#define curtime chrono::steady_clock::now().time_since_epoch().count
#define rep(i, beg, n, s) for (int i = beg; i < n; i += s)
const double PI = acos(-1);

using namespace std;

inline int mod(int n, int m) {
  int ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}

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

void solution() {
  int n;
  cin >> n;
  vector<int> cnt(1123456, 0);
  vector<int> v;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    v.pb(x);
  }
  sort(all(v));
  vector<ii> bk;
  for (int x : v) {
    if (bk.size() == 0 || bk.back().ff != x) {
      bk.pb(ii(x, 1));
    } else
      bk.back().ss++;
  }
  for (ii x : bk) {
    for (int j = x.ff; j <= 1000000; j += x.ff) cnt[j] += x.ss;
  }
  int ans = 0;
  for (int x : v)
    if (cnt[x] == 1) ans++;
  cout << ans << endl;
}

int32_t main() {
  DESYNC;
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  int t = 1;
#ifdef MULTIPLE_TEST_CASE
  cin >> t;
#endif
  while (t--) solution();
}


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

typedef long long int ll;
ll powk(ll a, ll n = 2){
    ll r = 1;
    for(ll i = 0;i < n;i++){
        r *= a;
    }

    return r;
}


int main()
{
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for(ll i = 0;i < n;i++){
        cin >> a[i];
    }
    
    ll t = 0, ans = 1, bans = 0;
    for(ll i = 0;i < n;i++){
        if(k <= i){
            if(a[i] > a[t]){
                cout << "Yes\n";
            }
            else{
                cout << "No\n";
            }
            t++;
        }
    }

    return 0;
}

Measured memory_bytes: 4836
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024
var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	k, n := nextInt(), nextInt()
	a := make([]int, n)

	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}

	res := 1 << 63 - 1
	for i := 0; i < n; i++ {
		res = min(res, min((a[(i-1+n)%n]-a[i]+k)%k, (k-(a[(i+1+n)%n]-a[i])+k)%k))
	}
	fmt.Println(res)
}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  a+b >= 10 ? cout << "error" << endl : cout << a+b << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>
#include <unordered_map>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

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

  int N;
  cin >> N;

  vector<int> v(N+1);

  v[N] = -2;

  REP(i,N){
    cin >> v[i];
  }

  int sum = 0;
  int color = -1;
  int num = 0;
  REP(i, N + 1)
  {
    if(v[i]==color){
      num++;
    }
    else
    {
      sum += num / 2;
      color = v[i];
      num = 1;
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
"use strict";

function compareFunc(a, b) {
  return a - b;
}
const main = arg => {
  const input = arg.trim().split("\n");
  const T = input[0].split(" ").map(x => parseInt(x)).reduce((a, v) => a + v);
  if (T >= 22) {
    console.log("bust");
  } else {
    console.log("win");
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29612
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
ll n,m,cur;
int main(){
  vector<ll> ans;
  string s;
  cin>>n>>m>>s;
  cur=n;
  while(cur)
  {
  	 bool check=true;
  	 for(int i=max(0ll,cur-m);i<cur;i++)
  	    if(s[i]=='0'){
  	    	check=false;
  	    	ans.push_back(cur-i);
  	    	cur=i;
  	    	break;
  	    }
  	  if(check){
  	  	cout<<-1<<endl;return 0;
  	  }
  }
  reverse(ans.begin(),ans.end());
  for(int i=0;i<ans.size();i++){
  	  cout<<ans[i];
  	  if(i==ans.size()-1)cout<<endl;
  	  else cout<<" ";
  }



	return 0;
}


Measured memory_bytes: 1528
#include<bits/stdc++.h>
using namespace std;
const int inf=1e9;
const int N=1e3;
int vis[12],d,g,p[12],c[12],ex;
int dp[12][10002];
int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  cin>>d>>g;
  for(int i=1;i<=d;i++)
    cin>>p[i]>>c[i];

  for(int i=1;i<=d;i++)
  {
    for(int j=0;j<=10000;j++)
    {
      for(int k=0;k<=p[i];k++)
      {
        dp[i][j]=max(dp[i][j],dp[i-1][j]);
        if(k>j)continue;
        if(k==p[i])ex=c[i];
        else ex=0;
        dp[i][j]=max(dp[i][j],k*i*100+ex+dp[i-1][j-k]);
      }
    }
  }
  int ans=inf;
  for(int i=1;i<=d;i++)
  {
    for(int j=1;j<=10000;j++)
    {
      if(dp[i][j]>=g)ans=min(ans,j);
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 640
#include<stdio.h>

int n, A[50];

int solve(int i, int m) {
	if (m == 0) return 1;
	if (i >= n) return 0;
	int res = solve(i + 1, m) || solve(i + 1, m - A[i]);
	return res;
}

int main() {
	int q, M, i;

	scanf("%d", &n);
	for (i = 0; i < n; i++) scanf("%d", &A[i]);
	scanf("%d", &q);
	for (i = 0; i < q; i++) {
		scanf("%d", &M);
		if (solve(0, M)) printf("yes\n");
		else printf("no\n");
	}
	return 0;
}

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

int main(){
  char c;
  cin>>c; 

  if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'){
    cout<<"vowel"<<endl;
  }
  else{
    cout<<"consonant"<<endl;
  }
}

Measured memory_bytes: 256
// Learn more about F# at http://fsharp.org

open System

let Input f =
    stdin.ReadLine() |> f

let InputArray f =
    stdin.ReadLine().Split(' ') |> Array.map f

[<EntryPoint>]  
let main argv =

    let in1 = InputArray int
    let a = in1.[0]
    let b = in1.[1]

    if a % 2 = 0 || b % 2 = 0 then
        printfn "Even"
    else
        printfn "Odd"

    0 // return an integer exit code


Measured memory_bytes: 11484
#include <stdio.h>
#include <string.h>
#include <math.h>

int main(void)
{
	int tate,yoko,takasa,i;
	int enter,enterH[10000];
	char enterOK[10000][3];
	double taikaku1,taikaku2,taikaku3;
	
	
	while(scanf("%d %d %d",&tate,&yoko,&takasa),(tate || yoko || takasa))
	{
		taikaku1=sqrt(tate*tate+yoko*yoko);
		taikaku2=sqrt(takasa*takasa+yoko*yoko);
		taikaku3=sqrt(tate*tate+takasa*takasa);
		
		scanf("%d",&enter);
		for(i=0;i<enter;i++)
		{
			scanf("%d",&enterH[i]);
			
			
			
			if(taikaku1<enterH[i]*2 || taikaku2<enterH[i]*2 || taikaku3<enterH[i]*2)
				strcpy(enterOK[i],"OK");
			else
				strcpy(enterOK[i],"NA");
		}
		
		for(i=0;i<enter;i++)
			printf("%s\n",enterOK[i]);
	}
	
	return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,s,f) for(i=s;i<f;i++)
#define print(v) for(auto &z:v) cout<<z<<' ';cout<<'\n'
#define db cout<<"db: "
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define B begin()
#define E end()
#define all(v) v.B,v.E
#define sz(v) (int)((v).size())
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define clk1 clock_t start_time=clock()
#define clk2 cout<<(clock()-start_time)/(double)CLOCKS_PER_SEC
#define clean(arr) memset(arr,0,sizeof(arr))
#define mod 1000000007
#define mod2 998244353
#define space 100005
//<<fixed << setprecision(9)

int main()
{
    int n,i,j,t;
    boost;

    cin>>n;
    ll ans=0;
    rep(i,1,n+1)
    {
        int m=(n-1)/i;
        ans+=m;
    }
    cout<<ans;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  for (int i = 1; i < N; i++) {
    if (A.at(i) == A.at(i-1)) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}

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

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

  int cnt = 0;
  int max = 0;

  for(int i = 0; i < s.size(); i++){
    if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T'){
      cnt++;
    }

    else{
      if(cnt > max) max = cnt;
      cnt = 0;
    }
  }

  if(cnt > max) max = cnt;

  cout << max << endl;

  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 K = sc.nextInt();
		int X = sc.nextInt();

		if(X <= K * 500)
		System.out.println("Yes");
		else
		System.out.println("No");

	}
}

Measured memory_bytes: 35828
import java.util.Scanner;

class Main{
	static boolean check(String[] A, String[] B) {
		for(int i = 0; i + B.length <= A.length; i++) {
			for(int j = 0; j + B.length <= A.length; j++) {
				//matching
				int matchedline = 0;
				for(int k = 0; k < B.length; k++) {
					if(B[k].equals(A[k + i].substring(j, j + B.length))) {
						matchedline++;
					}
				}
				if(matchedline == B.length) return true;;
			}
		}
		return false;
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), M = sc.nextInt();
		String[] A = new String[N];
		String[] B = new String[M];
		for(int i = 0; i < N; i++) A[i] = sc.next();
		for(int i = 0; i < M; i++) B[i] = sc.next();
		System.out.println(check(A, B) ? "Yes" : "No");
	}
}

Measured memory_bytes: 21844
n = int(input())
total = 0
for i in range(2, int(n**(1/2)+2)):
    acc = 0
    while n % i == 0:
        acc += 1
        n //= i
    total += (-1 + (1 + 8 * acc)**(1/2)) // 2;
if n != 1:
    total += 1
print(int(total))


Measured memory_bytes: 68124
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdio>
using namespace std;

int main () {
    int n;
    while (cin >> n, n) {
        vector<vector<int> > d(n, vector<int>(n, 0));
        int x = n / 2 + 1, y = n / 2;
        d[x][y] = 1;
        int m = 1;
        while (m < n * n) {
            m++;
            int dx = (x + 1) % n, dy = (y + 1) % n;
            while (d[dx][dy] != 0) {
                dx = (dx + 1) % n;
                dy = (dy + n - 1) % n;
            }
            d[dx][dy] = m;
            x = dx;
            y = dy;
        }
        for (auto i : d) {
            for (auto &j : i) {
                cout << setw(4) << j;
            }
            cout << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1228
#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 n, m;
    cin >> n >> m;

    vector<int> X(m);
    rep(i,m) cin >> X[i];
    sort(X.begin(), X.end());

    vector<int> D;
    for(int i=1; i<m; i++) D.push_back(X[i]-X[i-1]);
    sort(D.rbegin(), D.rend()); 

    if (n-1 >= D.size()) {
        cout << 0 << endl;
        return 0;
    }

    int ans = 0;
    for(int i= n-1; i<D.size(); i++) ans += D[i];

    cout << ans << endl; 

    return 0;
}


Measured memory_bytes: 1276
import java.util.Scanner;

/**
 * B - 81
 * 入力された数字が九九として表現できる場合はYes,できない場合はNoを出力する
 */
public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner( System.in );
        // 確認する数値
        int n = sc.nextInt();
        String result = "No";

        // 81以下であること
        if( n <= 81 ) {
            for( int i = 1; i <= 9; i++ ) {
                if( n % i == 0 && n / i <= 9 ) {
                    result = "Yes";
                    break;
                }
            }
        }
        System.out.println( result );

        sc.close();
    }
}

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

using namespace std;


const int MAX = 1000010;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

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

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

    int cnt = (x + y) / 3;
    COMinit();
    int x_cnt = x - cnt;
    int y_cnt = y - cnt;

    if ((x+y)%3 || x_cnt > cnt || y_cnt > cnt) {
        cout << 0 << endl;
        return 0;
    }

    cout << COM(cnt, x_cnt) << endl;
}

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

int m,n,A,B,f[505][505];

int main()
{
    cin>>m>>n>>A>>B;
    if(m%A==0&&n%B==0)
    {
        cout<<"No";
        return 0;
    }
    for(int i=1;i<=m;i++)
        for(int j=1;j<=n;j++)
            if(i%A==0&&j%B==0)
                f[i][j]=-(1000*(A*B-1)+1);
            else
                f[i][j]=1000;
    cout<<"Yes\n";
    for(int i=1;i<=m;i++)
    {
        for(int j=1;j<=n;j++)
            cout<<f[i][j]<<' ';
        cout<<"\n";
    }
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
#define ll int
#define pp pair<ll,ll>
#define ppp pair<ll,pp >
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
typedef tree<pp,null_type,less<pp>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rep(i,a,b) for(ll i=a;i<b;i+=1)
#define sz(v) (ll)(v.size())
#define hell (ll)998244353
#define slld(x) scanf("%lld",&x)
ll t=1, tt;
const ll nax=3005, N=nax;
ll dp[3005][3005];
ll fact[N], invFact[N];
ll add(ll x,ll y){x+=y;return x%hell;}
ll mult(ll x,ll y){return (1LL*x*y)%hell;}
ll powMod(ll base,ll expo){
	ll ans=1;
	while(expo){
		if(expo&1)ans=mult(ans,base);
		base=mult(base,base);
		expo>>=1;
	}
	return ans;
}
ll C(ll x,ll y){
	if(x<0 || y<0 || x<y)return 0;
	return mult(fact[x],mult(invFact[y],invFact[x-y]));
}
ll get(ll x){
	return powMod(powMod(2,x),hell-2);
}
void solve(){
	ll n, s;
	cin>>n>>s;
	vector<ll> v(n), cnt(nax,0);
	rep(i,1,n+1){
		cin>>v[i-1];
		cnt[v[i-1]]++;
	}
	dp[0][0]=powMod(2,n);
	rep(i,1,n+1){
		rep(j,0,nax){
			dp[i][j]=add(dp[i-1][j],dp[i][j]);
			if(j+v[i-1]<nax)dp[i][j+v[i-1]]=add(dp[i][j+v[i-1]],mult(dp[i-1][j],get(1)));
		}
	}
	cout<<dp[n][s];
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    fact[0]=1;
    rep(i,1,N)fact[i]=mult(fact[i-1],i);
    invFact[N-1]=powMod(fact[N-1],hell-2);
    for(ll i=N-2;i>=0;i--)invFact[i]=mult(invFact[i+1],i+1);
   	//cin>>t;
   	tt=t;
    while(t--){
        solve();
        if(t)cout<<"\n";
    }
    return 0 ;
}


Measured memory_bytes: 38928
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
// const ll MOD=998244353;

int N,Q;
int cnt[202020];
vector<vector<int>> G(202020);

void dfs(int v,int p){
  for(int u:G[v]){
    if(p==u) continue;
    cnt[u]+=cnt[v];
    dfs(u,v);
  }
}

int main(){
  cin>>N>>Q;
  rep(i,N-1){
    int A,B; cin>>A>>B; A--,B--;
    G[A].push_back(B);
    G[B].push_back(A);
  }
  rep(i,Q){
    int P,X; cin>>P>>X; P--;
    cnt[P]+=X;
  }
  dfs(0,-1);
  rep(i,N-1) cout<<cnt[i]<<" ";
  cout<<cnt[N-1]<<endl;
  return 0;
}


Measured memory_bytes: 23552
import sys
readline = sys.stdin.readline
write = sys.stdout.write

N, Q = map(int, readline().split())
*p, = range(N)
data = [0]*N
def root(x):
    if x == p[x]:
        return x
    r = p[x]
    p[x] = y = root(r)
    data[x] += data[r]

    return y
def unite(x, y, z):
    px = root(x); py = root(y)
    if px == py:
        return 0
    if px < py:
        p[py] = px
        data[py] = data[x] - data[y] - z
    else:
        p[px] = py
        data[px] = data[y] - data[x] + z
    return 1


ans = []
for q in range(Q):
    t, *cmd = map(int, readline().split())
    if t:
        x, y = cmd
        px = root(x); py = root(y)
        if px == py:
            ans.append(str(data[x] - data[y]))
        else:
            ans.append("?")
    else:
        x, y, z = cmd
        unite(x, y, z)
write("\n".join(ans))
write("\n")



Measured memory_bytes: 18092
#include <iostream>

// CREATED BY AHNAF SHAHRAER

using namespace std ;

int main ( )

{
               int TOTAL1 , TOTAL2 ;
               cin >> TOTAL1 >> TOTAL2 ;
               if ( TOTAL1 < 9 && TOTAL2 < 9 )
               {
                              cout << "Yay!\n" ;
               }
               else cout << ":(\n" ;
               return 0 ;
}


Measured memory_bytes: 256
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define ll long long
#define mod (1000000007)
#define C 0.5772156649
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#define pil pair<int,ll>
#define pii pair<int,int>
#define ull unsigned long long
#define base 1000000000000000000
#define fio ios::sync_with_stdio(false);cin.tie(0)

using namespace std;

const double g=10.0,eps=1e-12;
const int N=100000+10,maxn=100000+10,inf=0x3f3f3f3f,INF=0x3f3f3f3f3f3f3f3f;

int a[N];
int main()
{
    int n;ll ans=0;
    scanf("%d",&n);
    a[0]=0,a[n+1]=0;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        ans+=abs(a[i]-a[i-1]);
    }
    ans+=abs(a[n]);
    for(int i=1;i<=n;i++)
        printf("%lld\n",ans-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1]));
    return 0;
}
/********************

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


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL dp[10][20]; //dp[i][j]代表以i开头的j位数有多少个lun number 
LL sum[20], pos;
LL k;

void dfs(LL num, LL lst) {
	if(num > pos) return ;
	if(num == 1) {
		for(LL i = 1; i < 10; i++) {
			if(k > dp[i][pos - num + 1]) k -= dp[i][pos - num + 1];
			else {
				cout << i;
				dfs(num + 1, i);
				break;
			}
		}
	}
	else {
		for(LL i = lst - 1; i <= lst + 1; i++) {
			if(i < 0 || i > 9) continue; //记住特判 
			if(k > dp[i][pos - num + 1]) k -= dp[i][pos - num + 1];
			else {
				cout << i;
				dfs(num + 1, i);
				break;
			}
		}
	}
}

int main() {
	cin >> k;
	for (LL i = 0; i < 10; i++) dp[i][1] = 1;
	sum[1] = 9;
	for(LL j = 2; j <= 10; j++) {
		for(LL i = 0; i < 10; i++) {
			if(i != 0 && i != 9) dp[i][j] = dp[i - 1][j - 1] + dp[i][j - 1] + dp[i + 1][j - 1];
			else if(i != 0) dp[i][j] = dp[i - 1][j - 1] + dp[i][j - 1];
			else if(i != 9) dp[i][j] = dp[i][j - 1] + dp[i + 1][j - 1];
			if(i != 0) sum[j] += dp[i][j];
		}
	}
	for(LL i = 1; i <= 20; i++) {
		if (k > sum[i]) k -= sum[i];
		else {
			pos = i;
			break;
		}
	}
	dfs(1, 0);
	return 0;
}

/*
dp + 构造
设dp[i][j]代表以i开头, 有j位的lun number有多少个
根据样例的提示, j最大就能到10, i在[0,9]
首先初始化所有dp[i][1] = 1
然后不难想到转移方程dp[i][j] = dp[i - 1][j - 1] + dp[i][j - 1] + dp[i + 1][j - 1]
当然如果i = 0或i = 9时要特殊处理(具体见代码)
接下来开始构造:
首先算出第k个数的位数
我们只需统计每个位数有多少lun number, 然后做一遍前缀和,
从小到大遍历, 找到第一个大于等于k的位数即为k的位数
确定好位数之后我们就可以开始枚举每一位是什么了
当然不是暴力枚举
如果是第一位, 我们暴力枚举1 ~ 9, 
用找位数同样的方法, 我们可一个确定第一个位置的数(我们记录了以i开头, 有j位的lun number有多少个)
然后后面的位置的数只有最多三种选择: 上次减一; 上次同样; 上次加一 (记住不能小于0或大于9)
然后再用相同的方法即可
*/

Measured memory_bytes: 256
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val s = sc.next()
  val n = s.length
  val s1 = s.take(n/2).reverse
  val s2 = s.takeRight(n/2)
  if (n % 2 == 0) {
    if (s1.head == s2.head) {
      val idx1 = s1.indexWhere(_ != s1.head)
      val t1 = if (idx1 == -1) n/2 else idx1
      val idx2 = s2.indexWhere(_ != s2.head)
      val t2 = if (idx2 == -1) n/2 else idx2
      println(n/2 + t1.min(t2))
    } else {
      println(n/2)
    }
  } else {
    val t = s(n/2)
    val idx1 = s1.indexWhere(_ != t)
    val t1 = if (idx1 == -1) n/2 else idx1
    val idx2 = s2.indexWhere(_ != t)
    val t2 = if (idx2 == -1) n/2 else idx2
    println(n/2 + 1 + t1.min(t2))
  }
}


Measured memory_bytes: 55460
#include "bits/stdc++.h"
#define ll long long
#define PI 3.1415926535897932384626433832795l
#define MAX_NUM 1000000000
using namespace std;
template <typename T> inline T __lcm(T a,T b)
{
    return (a*b)/__gcd(a,b);
}

ll h[1000000];
ll dp[1000000];
ll n;
ll fun(ll i)
{
    if(i>=n)
    {
        return MAX_NUM;
    }
    if(i==n-1)
    {
        return 0;
    }
    if(dp[i]!=-1)
    {
        return dp[i];
    }
    return dp[i]=min(fabs(h[i]-h[i+1])+fun(i+1),fabs(h[i]-h[i+2])+fun(i+2));
}

int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>h[i];
    }
    memset(dp,-1,sizeof(dp[0])*1000000);
    ll ans=fun(0);
    printf("%lld\n",ans);
}


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

using namespace std;
typedef long long ll;

#define rep(i , j , n) for(long long i = j ; i <= n ; i++)
const ll N = 123456;

pair < ll , ll > a[N];

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

    ll h , w , n;

    cin >> h >> w >> n;

    rep(i , 1 , n) cin >> a[i].first >> a[i].second;

    map < pair < ll , ll > , ll > res;

    rep(p , 1 , n) {
        pair < ll , ll > k = a[p];
        for(ll i = k.first - 2 ; i <= k.first; i++) {
            for(ll j = k.second - 2 ; j <= k.second ; j++) {
                if(i >= 1 && j >= 1 && i + 2 <= h && j + 2 <= w) {
                    if(res.find({i , j}) == res.end()) {
                        res[make_pair(i , j)] = 1;
                    }
                    else {
                        res[make_pair(i , j)]++;
                    }
                }
            }
        }
    }

//    cout << endl;
//
//    for(auto j : res) {
//        cout << j.first.first << " " << j.first.second << "      " << j.second << endl;
//    }

    ll total = (h - 2) * (w - 2);

    vector < ll > ans;
    ans.resize(10);

    for(ll i = 0 ; i < 10 ; i++) {
        ans[i] = 0;
    }

    for(auto j : res) {
        if(j.second <= 9) {
            ans[j.second]++;
        }
    }

    ll sum = 0;

    for(auto j : ans) sum += j;

    ans[0] = total - sum;

    for(auto j : ans) cout << j << endl;
    return 0;
}


Measured memory_bytes: 58112
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
#include <assert.h>
#include <deque>
using namespace std;
typedef long long ll;

#define fi first
#define se second
#define rep(i, n) for (ll i = 0; i < n; i++)
#define debugA cerr << "AAAAA" << endl
#define debug_ cerr << "-------------" << endl
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v)                   \
    cout << #v << endl;                \
    for (int i = 0; i < v.size(); i++) \
    {                                  \
        cout << v[i] << " ";           \
    }                                  \
    cout << endl;
#define debug_vec2(v)                         \
    cout << #v << endl;                       \
    for (int i = 0; i < v.size(); i++)        \
    {                                         \
        for (int j = 0; j < v[i].size(); j++) \
        {                                     \
            cout << v[i][j] << " ";           \
        }                                     \
        cout << endl;                         \
    }

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

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

using Graph = vector<vector<int>>;
using P = pair<int, int>;
using P1 = pair<int, pair<int, int>>; // クラスカル法とかで、{cost, {from, to}}的に使う。
const ll INF = 1001001001001001001;
const double pi = acos(-1);

int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<int>> a(m);
    for (int i = 0; i < m; i++)
    {
        int k;
        cin >> k;
        vector<int> v(k);
        for (int j = 0; j < k; j++)
        {
            cin >> v[j];
        }
        a[i] = v;
    }
    vector<int> p(m);
    for (int i = 0; i < m; i++)
    {
        cin >> p[i];
    }

    int ans = 0;
    for (int bit = 0; bit < (1 << n); bit++)
    { //スイッチについてbit全探索
        bool flag = true;
        // debug(bit);
        for (int i = 0; i < m; i++)
        {
            int tmp = 0;
            for (int j = 0; j < a[i].size(); j++)
            {
                if (bit & (1 << (a[i][j] - 1)))
                {
                    tmp++;
                }
            }
            // debug(tmp);
            if (tmp % 2 != p[i])
            {
                flag = false;
                break;
            }
        }
        if (flag)
        {
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;
using ll = long long;
vector<ll> seis;
vector<ll> dp(1000000+1,190);
vector<ll> odp(1000000+1,190);

bool solve(){
    ll n;
    cin>>n;
    if(n==0)return false;

    cout<<dp[n]<<" "<<odp[n]<<"\n";
    return true;
}

int main() {
    ll t=1;
    ll n=1;
    while(t<=1000000) {
        t=n*(n+1)*(n+2)/6;
        seis.emplace_back(t);
        ++n;
    }

    dp[0]=0;
    for(int i = 1;i <= 1000000;++i) {
        dp[i]=i;
        for(int j = 0;j < 181;++j) {
            if(i<seis[j])break;

            dp[i]=min(dp[i],dp[i-seis[j]]+1);
        }
        //cerr<<dp[i]<<endl;
    }

    odp[0]=0;
    for(int i = 1;i <= 1000000;++i) {
        odp[i]=i;
        for(int j = 0;j < 181;++j) {
            if(i<seis[j])break;
            if(seis[j]%2==0)continue;

            odp[i]=min(odp[i],odp[i-seis[j]]+1);
        }
    }



    while(solve());
    return 0;
}



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

typedef pair<int, ll> p;

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

    int N, K;
    cin >> N >> K;

    vector<vector<int> > w(K * 4 + 1, vector<int>(K * 4 + 1));
    vector<vector<int> > b(K * 4 + 1, vector<int>(K * 4 + 1));
    vector<vector<int> > ws(K * 4 + 1, vector<int>(K * 4 + 1));
    vector<vector<int> > bs(K * 4 + 1, vector<int>(K * 4 + 1));

    for(int i = 0; i < N; i++) {
        int x, y;
        char c;
        cin >> x >> y >> c;
        x %= K * 2;
        y %= K * 2;
        if(c == 'W') {
            w[y + 1][x + 1]++;
            w[y + 1][2 * K + x + 1]++;
            w[2 * K + y + 1][x + 1]++;
            w[2 * K + y + 1][2 * K + x + 1]++;
        } else {
            b[y + 1][x + 1]++;
            b[y + 1][2 * K + x + 1]++;
            b[2 * K + y + 1][x + 1]++;
            b[2 * K + y + 1][2 * K + x + 1]++;
        }
    }

    for(int i = 1; i < K * 4 + 1; i++) {
        int count_w = 0;
        int count_b = 0;
        for(int j = 1; j < K * 4 + 1; j++) {
            count_w += w[i][j];
            count_b += b[i][j];
            ws[i][j] = count_w + ws[i - 1][j];
            bs[i][j] = count_b + bs[i - 1][j];
        }
    }
/*
    for(int i = 0; i < K * 4 + 1; i++) {
        for(int j = 0; j < K * 4 + 1; j++) {
            cout << ws[i][j] << " ";
        }
        cout << endl;
    }*/

    int ans = 0;

    for(int i = 0; i < K * 2; i++) {
        for(int j = 0; j < K * 2; j++) {
            int count = 0;
            count += ws[i + K][j + K] + ws[i][j] - ws[i + K][j] - ws[i][j + K];
            count += ws[i + 2 * K][j + 2 * K] + ws[i + K][j + K] - ws[i + 2 * K][j + K] - ws[i + K][j + 2 * K];
            count += bs[i + 2 * K][j + K] + bs[i + K][j] - bs[i + 2 * K][j] - bs[i + K][j + K];
            count += bs[i + K][j + 2 * K] + bs[i][j + K] - bs[i + K][j + K] - bs[i][j + 2 * K];
            ans = max(ans, count);
        }
    }

    cout << ans << endl;
}

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

int main() {
	string s;
	cin>>s;
	int a = s[0]-'0',b=s[1]-'0',c = s[2]-'0',d=s[3]-'0';
	int op[] = {-1,-1,-1}, flag = 0;
	for(int i=1;i<=8;++i) {
		int w = a,x=b,y=c,z=d;
		int sum = a;
		sum = sum + op[0]*x + op[1]*y + op[2]*z;
		if(sum == 7) {
			flag = 1;
			break;
		}
		for(int j=2;j>=0;--j) {
			if(op[j] == -1) {
				op[j] = 1;
				break;
			} else op[j] = -1;
		}
	}
	if(flag) {
		cout<<a;
		if(op[0] == 1)
		cout<<"+";
		else cout<<"-";
		cout<<b;
		if(op[1] == 1)
		cout<<"+";
		else cout<<"-";
		cout<<c;
		if(op[2] == 1)
		cout<<"+";
		else cout<<"-";
		cout<<d<<"=7";
	}
	return 0;
}

Measured memory_bytes: 256
s = input()
a = int(s[0] + s[1])
b = int(s[2] + s[3])
if a >= 1 and a <= 12 and b >= 1 and b <= 12:
    print("AMBIGUOUS")
elif a >= 1 and a <= 12:
    print("MMYY")
elif b >= 1 and b <= 12:
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef long long ll;
const long long MOD=1e09+7;



#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define vi vector<int>

int main(){
  

  int n;
  cin>>n;
  vector<ll> height(n);
  rep(i,n){
     ll tmp;
    cin>>tmp;
    height.at(i)=tmp;
  }
  
  reverse(height.begin(),height.end());
  
  vi answer(n);
  
  answer.at(0)=0;
  
  rep2(i,1,n){
    if (height.at(i)<height.at(i-1)){
      answer.at(i)=0;
    }
    
    else {
      answer.at(i)=answer.at(i-1)+1;
    }
  }
  
  sort(answer.begin(),answer.end());
  
  cout<<answer.at(n-1)<<endl;
  
    

  


  
}



Measured memory_bytes: 1408
#include<stdio.h>
#include<string.h>
int main(void){
	int num,i,count,sum;
	char number[1001];
	char* str;
	while(1){
		scanf("%s",number);
		i = 0;
		sum = 0;
		str = &number;
		count = (int)strlen(str);
		if(number[0] == '0'){
			if(count == 1){
				break;
			}
		}
		while(i < count){
			num = number[i] - '0';
			sum = sum + num ;
			i++;
		}
		printf("%d\n",sum);
	}
	return 0;
}
				

Measured memory_bytes: 536
#include<iostream>
#include<algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main()
{
    string s;cin >> s;
    int fee = 700;
    rep(i,3)
    {
        if(s[i] == 'o')
        {
            fee += 100;
        }
    }
    cout << fee;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <stack>
#include <unordered_map>
#include <utility>
#include <vector>

// Aliases
using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ll = long long;
using ull = unsigned long long;

using std::cout;
using std::cerr;
using std::cin;
using std::endl;
using std::string;
using std::vector;
using std::array;
template <class T>
using matrix = vector<vector<T>>;
template <class T>
constexpr T inf = std::numeric_limits<T>::max();
template <class T>
constexpr T neg_inf = -std::numeric_limits<T>::max();
template <class T>
constexpr T pi = static_cast<T>(3.141592653589793);

template <class T = i64>
vector<T> read_vector(const u64 n)
{
    vector<T> vec;
    vec.reserve(n);
    for (u64 i = 0; i < n; i++)
    {
        T v;
        cin >> v;
        vec.emplace_back(v);
    }

    return vec;
}

template <class T>
void print(const vector<T>& vec, const bool new_line = false)
{
    const u64 n = vec.size(); 
    if (new_line)
    {
        for (u64 i = 0; i < n; i++)
        {
            cout << vec[i];
            if (i != n - 1) { cout << '\n'; }
        }
    }
    else
    {
        for (u64 i = 0; i < n; i++)
        {
            cout << vec[i];
            if (i != n - 1) { cout << ' '; }
        }
    }

    cout << endl;
}

int main()
{
    f64 a, b, x;
    cin >> a >> b >> x;

    f64 rad = 0;
    if (a * a * b <= x * 2.0)
    {
        rad = atan(2.0 * (a * a * b - x) / (a * a * a));
    }
    else
    {
        rad = atan(a * b * b / (2.0 * x));
    }

    printf("%.10f\n", 180.0 * rad / pi<f64>);

    return 0;
}


Measured memory_bytes: 256
/**
 * Author: PraveenKumarRana
**/

#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
using namespace std;

bool comp(pair<int,int> a, pair<int,int> b){
    return ((double)a.second/(double)a.first)>((double)b.second/(double)b.first);
}

void solve(){
    ll n,w; cin>>n>>w;
    vector<ll> dp(w+1);
    for(ll i=0; i<n; i++){
        ll weight,value; cin>>weight>>value;
        for(ll already_weight=w-weight; already_weight>=0; --already_weight){
            dp[already_weight+weight]=max(dp[already_weight+weight],dp[already_weight]+value);
        }
    }
    ll ans=0;
    for(ll i=0; i<=w; i++) ans=max(ans,dp[i]);
    cout<<ans<<"\n";
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}



Measured memory_bytes: 1024
//file_name:ABC75_B.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);

    int mm[x+2][y+2];
    rep(i,x+2){
        rep(j,y+2){
            mm[i][j]=0;
        }
    }
    srep(i,1,x+1){
        string s;
        cin >> s;
        srep(j,1,y+1){
            if(s[j-1]=='#'){
                mm[i][j] = 10;
                srep(k,i-1,i+2){
                    srep(l,j-1,j+2){
                        mm[k][l]++;
                    }
                }
            }
        }
    }
    srep(i,1,x+1){
        srep(j,1,y+1){
            if(mm[i][j]>9){
                cout << '#';
            }else{
                cout << mm[i][j];
            }
        }
        cout << endl;
    }


    return 0;
}



Measured memory_bytes: 256
n=int(input())
#a,b=map(int,input().split())
pl=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
#sortedl=sorted(pl)
flag=False
if pl==sorted(pl):
    flag=True
else:
    for i in range(n):
        for j in range(n):
            templ=pl[:]
            templ[i]=pl[j]
            templ[j]=pl[i]
            if templ==(sorted(pl)):
                flag=True
                break
if flag:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String s = in.readLine();
    int n = s.length();
    String s_bf = s.substring(0,n/2);
    String s_af = s.substring(n/2,n);
    StringBuffer s_af_sb = new StringBuffer(s_af);
    String s_af_rev = s_af_sb.reverse().toString();
    int cnt = 0;
    for(int i = 0; i<n/2; i++) {
      if(s_bf.charAt(i) != s_af_rev.charAt(i)){
        cnt += 1;
      }
    }
    System.out.println(cnt);
  }
}

Measured memory_bytes: 23380
a=input().split()
N=int(a[0])
A=int(a[1])
B=int(a[2])

cnt = 0
for i in range(N+1):
  j = str(i)
  x = [int(k) for k in j]
  s = sum(x)
  if s >= A and s <= B:
    cnt += i
print(cnt)

Measured memory_bytes: 3064
from pprint import pprint


n = int(input())

xl = [list(map(int,input().split())) for _ in range(n)]

#2次元配列リストのソートでは0番目の要素が比較されるとのこと。
#https://note.nkmk.me/python-list-2d-sort/
#xl.sort()

robot_area = []

for i in range(n):
    startpoint = xl[i][0] - xl[i][1]
    endpoint = xl[i][0] + xl[i][1]
    #この後のsortのことを考えて、endpointを0番目の要素とする。
    robot_area.append([endpoint,startpoint])

robot_area.sort()

counter = 0

#初期値は負の無限大とする。
before_point = -float('inf')

for j in range(n):
    #開始エリアが前回の終了エリアより大きければOK
    if robot_area[j][1] >= before_point:
        counter += 1
        before_point = robot_area[j][0]
    else:
        pass

print(counter)

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

#define dbg(x) cout << #x"=" << x << endl;
typedef long long LL;
LL R,S,P;
int N,K;
const int MAX_K = 1e6+100;
int cnt[MAX_K];
char lstc[MAX_K];
char T[MAX_K];

int main(){
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> N >> K;
    cin >> R >> S >> P;
    cin >> T;
    int orN = N;
    N += K-N%K;
    N += K;
    for(int i = orN; i < N; ++i) {
        T[i] = '#';
    }
    T[N] = 0;
    memset(cnt, 0, sizeof cnt);
    for(int i = 0; i < K; ++i) {
        lstc[i] = '#';
    }
    lstc[K] = 0;
    LL ans = 0;
    for(int i = 0; i < N; ++i){
        int now = i%K;
        if(T[i] == lstc[now]){
            cnt[now]++;
        } else {
            // 计算分数
            char c = lstc[now];
            int x = cnt[now];
            if(c != '#'){
                LL sc = 0;
                if(c == 'r'){
                    sc = P;
                } else if(c == 's'){
                    sc = R;
                } else if(c == 'p'){
                    sc = S;
                }
                if(x&1) ++x;
                x >>= 1;
                ans += sc * x;
            }
            cnt[now] = 1;
            lstc[now] = T[i];
        }
    } 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4480
#include <bits/stdc++.h> //全てのヘッダファイルをインクルード
 
//ループ
#define rep(i, n) for(int i = 0; i < (n); i++) //普通のループ
#define repr(i, n) for(int i = n; i >= 0; i--) //逆ループ
 
//型名省略
typedef long long ll;
//値
static const ll MX = 100005;
static const ll MX_ll = 1e18;
const double PI = acos(-1); //π
 
using namespace std;
 
//ソート
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
 
//#include "./lib/generic/search.h"

//文字列入力した小数値を小数点なくして返す
int changeDoubleToInt(string decimal){ 
    decimal.erase(1, 1); //小数点削除
    int n_decimal = atoi(decimal.c_str()); //c_strでchar*に変換後、atoiでintに変換
    return n_decimal;
}

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

//素数判定(True/Falseを返却)
int IsPrime_tf(ll num){
    if (num < 2) return false; //0、1は素数でない
    else if (num == 2) return true; //2は素数
    else if (num%2==0) return false; // 偶数はあらかじめ除く
    for (ll i = 3; i*i <= num; i += 2){ //チェックは2～√nで十分
        if (num % i == 0) return false; //素数でない
    }
    return true; //素数である
}

//素数判定(割れる値を返却)
ll IsPrime_value(ll num){
    if (num < 2) return -1; //0、1は素数でない
    else if (num == 2) return 2; //2は素数
    for (ll i = 2; i*i <= num; i += 1){ //チェックは2～√nで十分
        if (num % i == 0) return i; //素数でない
    }
    return num; //素数である
}

int main(){
   int x;
   cin >> x;
   cout << x*x*x << endl;
   return 0;
}


Measured memory_bytes: 3108
from collections import Counter

h,w,N=map(int,input().split())
rec=[]
for i in range(N):
    a,b=map(int,input().split())
    a-=1
    b-=1
    for i in range(-2,1):
        for j in range(-2,1):
           if 0<=a+i<h-2 and 0<=b+j<w-2:
               rec.append((a+i,b+j))

ans=[0]*10
ans[0]=(h-2)*(w-2)
c=Counter(rec)
for i in c.values():
    ans[i]+=1
    ans[0]-=1
for i in range(10):
    print(ans[i])

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

using namespace std;
using ll = long long;
using ii = pair<ll, ll>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

ll solve(int N, const vector<ll>& xs)
{
    return 0;
}

int main()
{
    ios::sync_with_stdio(false);

    int ans = 0, x;

    for (int i = 1; i <= 5; ++i)
    {
        cin >> x;

        if (x == 0)
        {
            ans = i;
            break;
        }
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,A,B; cin >> N >> A >> B;
    if ((B-A)%2==0){
        cout << (B-A)/2 << endl;
        return 0;
    }
    cout << min(A-1,N-B)+(B-A+1)/2 << endl;
}

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

typedef long long ll;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) {
    return arg1.first > arg2.first;
}

int main(void) {
    ll x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;

    vector<int> p(a);
    vector<int> q(b);
    vector<int> r(c);
    for(int i=0;i<a;i++) {
        cin>>p.at(i);
    }
    for(int i=0;i<b;i++) {
        cin>>q.at(i);
    }
    for(int i=0;i<c;i++) {
        cin>>r.at(i);
    }
    sort(p.begin(),p.end(),greater<int>());
    sort(q.begin(),q.end(),greater<int>());

    vector<int> pqr(x+y+c);
    for(int i=0;i<x+y+c;i++) {
        if(i<x) pqr.at(i)=p.at(i);
        else if(x<=i&&i<x+y) pqr.at(i)=q.at(i-x);
        else pqr.at(i)=r.at(i-x-y);
    }
    sort(pqr.begin(),pqr.end(),greater<int>());

    ll ans = 0;
    for(ll i=0;i<x+y;i++) {
        ans += pqr.at(i);
    }

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


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=1e9+7;
int main(){
    int n;cin>>n;
    vector<string>s(2);
    cin>>s[0]>>s[1];
    ll cnt;
    bool f;
    if(s[0][0]==s[1][0]){
        f=1;
        cnt=3;
    }
    else{
        f=0;
        cnt=6;
    }
    for(int i=(f?1:2);i<s[0].size();i++){
        if(f){
            if(s[0][i]==s[1][i])cnt=cnt*2%inf;
            else{
                cnt=cnt*2%inf;
                i++;
                f=0;
            }
        }else{
            if(s[0][i]==s[1][i])f=1;
            else{
                cnt=cnt*3%inf;
                i++;
            }
        }
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    int a[3] = { 1, 0, 0 };
    char x, y;
    while (scanf(" %c,%c", &x, &y) != EOF) swap(a[x-'A'], a[y-'A']);
    rep (i, 3) if (a[i]) putchar('A'+i);
    putchar('\n');
    return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define fi first
#define vi vector<int>
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long 
using namespace std;
const int mod = 1e9+7;
main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int a,b,c,k;
	cin >> a >> b >> c>>k;
	while(b <= a) b*=2,k--;
	while(c<=b) c*=2,k--;
	if (k>=0) cout <<"Yes";
	else cout <<"No";
	
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    double A = sc.nextDouble();
    double B = sc.nextDouble();
    double H = sc.nextDouble();
    double M = sc.nextDouble();
    double xShort;
    double yShort;
    double degreeShort = 90 - (30 * H) - (30 * M / 60); // 時針は分針のぶんもちょっぴり動く
    double xLong;
    double yLong;
    double degreeLong = 90 - (6 * M);

    double radianShort = degreeShort * Math.PI / 180;
    yShort = Math.sin(radianShort) * A;
    xShort = Math.cos(radianShort) * A;

    double radianLong = degreeLong * Math.PI / 180;
    yLong = Math.sin(radianLong) * B;
    xLong = Math.cos(radianLong) * B;

    double distance =
        Math.sqrt((xLong - xShort) * (xLong - xShort) + (yLong - yShort) * (yLong - yShort));
    System.out.println(distance);
  }
}


Measured memory_bytes: 37604
#include<cstdio>
using namespace std;
int a,b,k;
int main(){
	scanf("%d%d",&k,&a);
	scanf("%d",&b);
	for(int i=a;i<=b;i++){
		if(i%k==0){
			puts("OK");
			return 0;
		}
	}
	puts("NG");
	return 0;
}

Measured memory_bytes: 1664