akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 2147483647
#include <math.h> /* M_PI */
int main()
{
    ll h, w;
    cin >> h >> w;
    //まだ選んでいないマスを選んで、そこから1枚を隣接するマスに移動する。
    vector<vector<ll>> A(h, vector<ll>(w));
    vector<vector<ll>> B(h, vector<ll>(w)); //偶数かどうかのフラグ。奇数なら1を立てる。
    vector<vector<ll>> C(h, vector<ll>(w)); //訪れたかどうかのflag
    rep(i, h)                               //偶数は偶数のままだが、奇数を動かせば、偶数が二つできるようになる。
    {
        rep(j, w)
        {
            cin >> A[i][j];
            if (A[i][j] % 2 == 1)
            {
                B[i][j] = 1;
                C[i][j] = 1;
            }
        }
    }
    //一番右下に持ってくるようにする？奇数のやつらを集めて、それらを一番右下に持ってくるようなプログラムをかければよくない？
    ll count = 0;
    for (int i = 0; i < h; i++)
    {
        rep(j, w - 1)
        {
            if (B[i][j] == 1)
            {
                count += 1;
                // cout << i << " " << j << " " << i << " " << j + 1 << endl;
                B[i][j] = 0;
                B[i][j + 1] = (B[i][j + 1] + 1) % 2;
            }
        }
    }
    rep(i, h - 1)
    {
        if (B[i][w - 1] == 1)
        {
            count += 1;
            //cout << i << " " << w - 1 << " " << i + 1 << " " << w - 1 << endl;
            B[i][w - 1] = 0;
            B[i + 1][w - 1] = (B[i + 1][w - 1] + 1) % 2;
        }
    }
    cout << count << endl;
    for (int i = 0; i < h; i++)
    {
        rep(j, w - 1)
        {
            if (C[i][j] == 1)
            {

                cout << i + 1 << " " << j + 1 << " " << i + 1 << " " << j + 2 << endl;
                C[i][j] = 0;
                C[i][j + 1] = (C[i][j + 1] + 1) % 2;
            }
        }
    }
    rep(i, h - 1)
    {
        if (C[i][w - 1] == 1)
        {

            cout << i + 1 << " " << w << " " << i + 2 << " " << w << endl;
            C[i][w - 1] = 0;
            C[i + 1][w - 1] = (C[i + 1][w - 1] + 1) % 2;
        }
    }
}

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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<pii, int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;

int pow(int a, int b, int m)
{
    int ans=1;
    while(b)
    {
        if(b&1)
            ans=(ans*a)%m;
        b/=2;
        a=(a*a)%m;
    }
    return ans;
}

int modinv(int k)
{
    return pow(k, MOD-2, MOD);
}

int32_t main() {
    fast;
    int n;

    cin >> n;

    int sum = 0;
    int a[n];
    f(i,0,n)    cin >> a[i], sum += a[i] , sum %= MOD;;


    int ans = 0;

    f(i,0,n){
        int x = ((sum - a[i])%MOD + MOD)%MOD;
        ans = (ans + (x * a[i])%MOD)%MOD;
    }

    ans = (ans * modinv(2))%MOD;

    cout << ans << "\n";
}

Measured memory_bytes: 5164
#include <bits/stdc++.h>
#define maxn 200005
#define MOD 1000000007
#define INF 10000000

using namespace std;

#define ll long long
#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second

void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}


void solve(){
    ll r, c, k;
    cin >> r >> c >> k;
    string a[r];
    for(ll i = 0; i  < r; i++)
        cin >> a[i];
    ll ans = INF;

    for(ll mask = 0; mask < 1<<(r-1); mask++){
        ll sum[r+1], div = __builtin_popcount(mask);
        memset(sum, 0, sizeof(sum));

        for(ll j = 0 ; j < c; j++){
            ll s = 0, f = 0;
            for(ll i = 0; i < r; i++){
                s += a[i][j] - '0';
                if(mask & (1 << i)){
                    if(s > k){
                        div = INF;
                    }
                    else{
                        if(sum[i] + s > k){
                            f = 1; break;
                        }
                        else{
                            sum[i] += s; s = 0;
                        }
                    }
                }
            }
            if(s > 0){
                if(s > k) div = INF;
                else{
                    if(sum[r] + s > k){
                        f = 1;
                    }
                    else{
                        sum[r] += s;
                    }
                }
            }
            if(div == INF) break;
            if(f){
                div++;
                s = 0;
                for(ll i = 0; i < r; i++){
                    s += a[i][j] - '0';
                    if(mask & (1 << i)){
                        sum[i] = s; s = 0;
                    }
                }
                sum[r] = s; s = 0;
            }
            //for(ll i = 0; i <= r; i++)cout << sum[i] << " "; cout << "----" << div << endl;
        }

        //cout << div << "\n";
        ans = min(ans, div);
    }
    cout << ans;


}

int main()
{
    fast(); //power(2, 11);
    int t= 1; //cin >> t;
    while(t--){
//        pre();
        solve();
    }
}

/*
5
1 2
2 3
3 4
3 5
*/


Measured memory_bytes: 256
n,k = [int(x) for x in input().split()]
h = [int(x) for x in input().split()]
dp = [float("inf")]*n
dp[0] = 0
for i in range(1,n):
    for j in range(1,k+1):
        if i>=j:
            dp[i] = min(dp[i],dp[i-j]+abs(h[i]-h[i-j]))

print(dp[n-1])

Measured memory_bytes: 55520
#include <stdio.h>

long long int abscal(long long int a){
    if(a<0) a *= -1;
    return a;
}

int main(void){
    long long int n,k,i,tmp,ans;
    scanf("%lld%lld",&n,&k);

    tmp = n/k;
    ans = (n - tmp*k);

    if(abscal(ans)>abscal(ans-k)){
        ans = abscal(ans - k);
    }

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

    return 0;
}

Measured memory_bytes: 1704
#include <bits/stdc++.h>
#define ull unsigned long long
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ull n;
    cin>>n;
    unordered_map<int,int> factors;
    ull i = 2;
    while(i*i <= n) {
        if(n%i) {
            i++;
        } else {
            n/=i;
            factors[i]++;
        }
    }
    if(n > 1)
        factors[n]++;
    ull ans = 0;
    for(auto& p : factors) {
        ull s = p.second;
        ans += (ull)(floor(sqrt(1+(s<<3)))-1)>>1;
    }
    cout<<ans<<"\n";
}

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

int main(){
    int N;
    cin >> N;
    int sum = 0;
    int dd = 0;
    for(int i = 0;i < N;++i){
        int d;
        cin >> d;
        sum += d;
        dd += d*d;
    }
    cout << (sum*sum -dd)/2 << endl;
}

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

using namespace std;
typedef long long ll;

bool f(vector<int> &a, vector<int> &b) {
  for (int i = 0; i < a.size(); ++i) {
    if (a[i] != b[i]) return false;
  }
  return true;
}

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  vector<int> q(n);
  for (int i = 0; i < n; ++i) cin >> p[i];
  for (int i = 0; i < n; ++i) cin >> q[i];

  vector<int> x(n);
  iota(x.begin(), x.end(), 1);
  int a;
  int b;
  int cnt = 1;
  do {
    if (f(x, p)) a = cnt;
    if (f(x, q)) b = cnt;
    cnt++;
  } while(next_permutation(x.begin(), x.end()));
  cout << abs(a - b) << endl;
  return 0;
  
}


Measured memory_bytes: 256
#include <chrono>

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << " ";
    return a;
}

#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
    const int INF = 1e18;
//    const int mod = 2600000069;
//    const int p = 10;
//    const ld PI = 3.1415926535;
#else
    #define dbg(x)
    const int INF = 1e18;
//    const int mod = 2600000069;
//    const int p = 179;
//    const ld PI = 3.1415926535;
#endif

//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,sse3,sse4")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("fast-math")
//#pragma GCC target("avx2")
//#pragma GCC optimize("section-anchors")
//#pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
//#pragma GCC optimize("vpt")
//#pragma GCC optimize("rename-registers")
//#pragma GCC optimize("move-loop-invariants")
//#pragma GCC optimize("unswitch-loops")
//#pragma GCC optimize("function-sections")
//#pragma GCC optimize("data-sections")

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifdef LOCAL
    #else
//        freopen("capitals.in", "r", stdin);
//        freopen("capitals.out", "w", stdout);
    #endif
    int n, k;
    cin >> n >> k;
    vector<pii> edges;
    for (int i = 1; i < n; i++) edges.pb({0, i});
    int lft = (n - 1) * (n - 2) / 2 - k;
    if (lft < 0) {
        cout << -1;
        return 0;
    }
    for (int i = 1; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (lft) {
                lft--;
                edges.pb({i, j});
            }
        }
    }
    cout << edges.size() << "\n";
    for (auto k : edges) {
        cout << k.first + 1 << " " << k.second + 1 << "\n";
    }
}
/*

*/


Measured memory_bytes: 512
//  ▓█████▄  ▄████▄  ▓██   ██▓ ██▓███   ██░ ██ ▓█████  ██▀███
// ▒██▀ ██▌▒██▀ ▀█   ▒██  ██▒▓██░  ██▒▓██░ ██▒▓█   ▀ ▓██ ▒ ██▒
//  ░██   █▌▒▓█    ▄   ▒██ ██░▓██░ ██▓▒▒██▀▀██░▒███   ▓██ ░▄█ ▒
//  ░▓█▄   ▌▒▓▓▄ ▄██▒  ░ ▐██▓░▒██▄█▓▒ ▒░▓█ ░██ ▒▓█  ▄ ▒██▀▀█▄
//  ░▒████▓ ▒ ▓███▀ ░  ░ ██▒▓░▒██▒ ░  ░░▓█▒░██▓░▒████▒░██▓ ▒██▒
//   ▒▒▓  ▒ ░ ░▒ ▒  ░   ██▒▒▒ ▒▓▒░ ░  ░ ▒ ░░▒░▒░░ ▒░ ░░ ▒▓ ░▒▓░
//   ░ ▒  ▒   ░  ▒    ▓██ ░▒░ ░▒ ░      ▒ ░▒░ ░ ░ ░  ░  ░▒ ░ ▒░
//   ░ ░  ░ ░         ▒ ▒ ░░  ░░        ░  ░░ ░   ░     ░░   ░
//     ░    ░ ░       ░ ░               ░  ░  ░   ░  ░   ░
//   ░      ░         ░ ░

#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define fr(i,a,b) for(ll i=a; i<b; i++)
#define fr1(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vii vector <pair<ll,ll> >
#define pb push_back
#define md 1000000007
#define umap unordered_map<ll, ll>
int main()
{
	fast;
	ll n, w;
	cin >> n >> w;
	vi wt;
	vi cost;
	ll dp[n + 1][w + 1];
	for (ll i = 0; i < n; ++i)
	{
		ll a, b;
		cin >> a >> b;
		wt.pb(a);
		cost.pb(b);
	}
	for (ll i = 0; i <= n; ++i)
	{
		/* code */
		for (ll j = 0; j <= w; ++j)
		{
			/* code */
			if (i == 0 or j == 0)
			{
				dp[i][j] = 0;
			}
			else if (wt[i - 1] <= j)
			{
				dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - wt[i - 1]] + cost[i - 1]);
			}
			else
			{
				dp[i][j] = dp[i - 1][j];
			}
		}
	}

	cout << dp[n][w] << endl;
	return 0;
}

Measured memory_bytes: 79232
#include <iostream>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

void make_pattern(string X, unordered_map<char, vector<int>>& pattern)
{
  for (int ii=0; ii<X.size(); ++ii) {
    char c = X[ii];
    if (pattern.count(c)==0) {
      pattern[c] = {ii};
    } else {
      pattern.at(c).push_back(ii);
    }
  }
}

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

  unordered_map<char, vector<int>> patternS, patternT;

  make_pattern(S, patternS);
  make_pattern(T, patternT);

  for (auto& kvS : patternS) {
    vector<int>& placesS = kvS.second;
    for (auto& kvT : patternT) {
      char keyT = kvT.first;
      vector<int>& placesT = kvT.second;
      if (placesS==placesT) {
	patternT.erase(keyT);
	break;
      }
    }
  }

  cout << ( patternT.size()==0 ? "Yes" : "No" ) << endl;
  
  return 0;
}

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

int main(void){
int H, W;
   while(true){
   cin >> H >> W;
   if(H == 0 && W == 0) break;
       for ( int i = 0; i < H; i++ ){
           for ( int j = 0; j < W; j++ ){
               if( (i+j)%2 == 0 ){
                   cout << "#";
               }
               else{
               cout << ".";
               }
           }
       cout << endl;
       }
   cout << endl;
   }
}


Measured memory_bytes: 3068
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	string a,b;
	cin>>a>>b;
	for(int i=0;i<a.size();i++)
	{
		cout<<a[i]<<b[i];
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int h, w;
int Sx, Sy, Ex, Ey;
char Map[1005][1005];
int fx[4] = {1, 0, -1, 0};
int fy[4] = {0, 1, 0, -1};
int dis[1005][1005];

struct node{
	int x, y;
};

void BFS01(){
	deque<node>Q;
	memset(dis, 0x3f, sizeof(dis));
	dis[Sx][Sy] = 0;
	node now;
	Q.push_front({Sx,Sy});
	
	while(!Q.empty()){
		now = Q.front();
		Q.pop_front();
		for(int i = 0; i < 4; i++){
			int nx = now.x + fx[i];
			int ny = now.y + fy[i];
			if(nx > h || ny > w || nx < 1 || ny < 1 || Map[nx][ny] == '#') continue;
			if(dis[now.x][now.y] < dis[nx][ny]){
				dis[nx][ny] = dis[now.x][now.y];
				Q.push_front({nx, ny});
			}
		}
		for(int i = -2; i <= 2; i++){
			for(int j = -2; j <= 2; j++){
				int nx = now.x + i;
				int ny = now.y + j;
				if(nx > h || ny > w || nx < 1 || ny < 1 || Map[nx][ny] == '#') continue;
				if(dis[now.x][now.y] + 1 < dis[nx][ny]){
					dis[nx][ny] = dis[now.x][now.y] + 1;
					Q.push_back({nx, ny});
				}
			}
		}
	}
}

int main(){
	scanf("%d%d", &h, &w);
	scanf("%d%d%d%d", &Sx, &Sy, &Ex, &Ey);
	for(int i = 1; i <= h; i++) scanf("%s", Map[i] + 1);
	
	BFS01();
	if(dis[Ex][Ey] <= h * w)  printf("%d\n", dis[Ex][Ey]);
	else printf("-1");
	return 0;
}


Measured memory_bytes: 8728
/*  -*- coding: utf-8 -*-
 *
 * 2875.cc: Mapping
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;

/* typedef */

typedef vector<int> vi;
typedef queue<int> qi;
typedef pair<int,int> pii;

/* global variables */

int as[MAX_N], bs[MAX_N];
bool used[MAX_N];

/* subroutines */

void printfunc(int n, int v) {
  for (int i = 0; i < n; i++) {
    if (i) putchar(' ');
    printf("%d", used[as[i]] ? as[i] + 1 : v);
  }
  putchar('\n');
}

/* main */

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

  for (int i = 0; i < n; i++) scanf("%d", as + i), as[i]--;
  for (int i = 0; i < n; i++) scanf("%d", bs + i), bs[i]--, used[bs[i]] = true;

  int un = 0;
  for (int i = 0; i < n; i++) un += used[i];

  if (un == n) puts("Yes");
  else {
    puts("No");
    printfunc(n, 1);
    printfunc(n, 2);
  }
  return 0;
}



Measured memory_bytes: 4088
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	public static void main(String[] args) {

		Scanner scanner=new Scanner(System.in);

		int w=scanner.nextInt();
		int h=scanner.nextInt();
		int n=scanner.nextInt();

		Map<Integer,Integer> data=new TreeMap<Integer,Integer>();


			data.put(1,0);
			data.put(2,w);
			data.put(3,0);
			data.put(4,h);


		for(int i=0;i<n;i++) {
			int bufx=scanner.nextInt();
			int bufy=scanner.nextInt();
			int bufa=scanner.nextInt();

			if(bufa==1) {

				if(data.get(1)==0) {
					data.put(1,bufx);
				}else {
					if(bufx>data.get(1)) {
						data.put(1,bufx);
					}
				}
			}else if(bufa==2) {

				if(data.get(2)==w) {
					data.put(2,bufx);
				}else {
					if(bufx<data.get(2)) {
						data.put(2,bufx);
					}
				}


			}else if(bufa==3) {

				if(data.get(3)==0) {
					data.put(3,bufy);
				}else {

				if(bufy>data.get(3)) {
					data.put(3,bufy);
				}

				}
			}else {

				if(data.get(4)==h) {
					data.put(4,bufy);
				}else {
					if(bufy<data.get(4)) {
						data.put(4,bufy);
					}
				}
			}

		}

		int retwidth=data.get(2)-data.get(1);
		int retheight=data.get(4)-data.get(3);

		int result=retwidth*retheight;

		if(retwidth>0 && retheight>0) {
			System.out.println(result);
		}else {
			System.out.println("0");
		}

		scanner.close();

	}

	public static int getsumofkakuketa(int n) {

		int result=0;

		while(true) {

			result+=n%10;

			if(n/10!=0) {
				n/=10;
			}else {
				return result;
			}
		}



	}

	public static boolean isMacthed(int a,int b,int sum) {

		if(sum>=a && sum<=b) {
			return true;
		}else {
			return false;
		}

	}



}







Measured memory_bytes: 21972
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


public class Main {
    public static void main(String[] args) throws IOException {
        new Main().run();
    }

    private void run() throws IOException {
        boolean b = true;
        final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        while (b) {
            b = runOnce(reader);
        }

        reader.close();
    }

    private boolean runOnce(BufferedReader reader) throws IOException {
        final String[] params = reader.readLine().split(" ");
        int count = Integer.parseInt(params[0]);
        int length = Integer.parseInt(params[1]);
        if (count == 0 && length == 0) return false;
        final List<Ant> list = new ArrayList<>(count);
        for (int i = 0; i < count; i++) {
            final Ant a = new Ant(reader.readLine().split(" "), i + 1);
            list.add(a);
        }
        exec(list, length);
        return true;
    }

    private void exec(List<Ant> ants, int length) {
        List<Ant> deleted = new ArrayList<>();
        int count;
        for (count = 0; !ants.isEmpty(); count++) {
            deleted = update(ants, length);
        }

        int index = (deleted.size() == 2) ? (deleted.get(0).left ? deleted.get(0).index : deleted.get(1).index) : deleted.get(0).index;
        System.out.println(count + " " + index);
    }

    private List<Ant> update(List<Ant> ants, int length) {
        final Map<Integer, Ant> map = new HashMap<>();
        final ArrayList<Ant> outList = new ArrayList<>();
        for (final Ant ant : ants) {
            ant.position = ant.left ? ant.position - 1 : ant.position + 1;
            if (map.containsKey(ant.position)) {
                final Ant ant1 = map.get(ant.position);
                ant1.left = !ant1.left;
                ant.left = !ant.left;
            }
            map.put(ant.position, ant);
            if (ant.position == 0 || ant.position == length) {
                outList.add(ant);
            }
        }
        ants.removeAll(outList);
        return outList;
    }

    class Ant {
        int position;
        int index;
        boolean left;

        Ant(final String[] params, int index) {
            this.position = Integer.parseInt(params[1]);
            this.left = params[0].equals("L");
            this.index = index;
        }
    }
}

Measured memory_bytes: 29348
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  int count =0;
  for(int i=0;i<S.size();i++){
    if(S.at(i)=='x'){
      count++;
    }
  }
  
  
  if(count >= 8){
   cout << "NO" << endl;
  }else{
    cout << "YES" << endl;
  }

}


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

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

const long long INF = 1LL << 60;

int main() {
	int N;

	long long int dp_h[100010];
	int cost[100010];

	cin >> N;

	for (int i = 0; i < N; i++) {
		cin >> cost[i];
	}

	for (int i = 0; i < 100010; i++) {
		dp_h[i] = INF;
	}

	dp_h[0] = 0;
	dp_h[1] = abs(cost[1] - cost[0]);
	for (int i = 2; i < N; i++) {
		chmin(dp_h[i], dp_h[i-1] + abs(cost[i] - cost[i - 1]));

		chmin(dp_h[i], dp_h[i-2] + abs(cost[i] - cost[i - 2]));
	}

	cout << dp_h[N-1] << endl;

}


Measured memory_bytes: 1408
/*
  kadai4_1 golden_apple
  unomi
*/
#include <stdio.h>
#include <math.h>
int main(void){
    float n_woods=0,monitoring_range=0;
    // n_woods(N),monitoring_range(D) の入力を取得
    scanf("%f %f",&n_woods, &monitoring_range);
    // 一人の監視員は(2*monitoring_range + 1)本分を監視できる
    // -> n_woods / (2*monitoring_range + 1)　の切り上げが答え
    printf("%d\n",(int)ceil(n_woods/(2*monitoring_range+1)));

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(ll (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(ll (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
#define Rall(a) (a).rbegin(), (a).rend()
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>
#define mp make_pair
#define pb push_back
const ll MOD=1e9+7;
using namespace std;

signed main(){
  ll N;
  cin >> N;
  ll x=0,y=0,z=0;
  rep(i,N){
    ll a;
    cin >> a;
    if(a%4==0) x++;
    else if(a%2==0) y++;
    else z++;
  }

  if((y>=1 && x>=z) || (y==0 && x+1>=z)) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vector<int>> vvi;
typedef unordered_map<int,int> uoii;
typedef unordered_map<string,int> uosi;

const int MOD = 1e9+7;

const int INF = 1e10;
int n;
void dfs(string s, char mx){
    if(s.length()==n){
        cout<<s<<"\n";
    }else{
        for(char i='a';i<=mx;i++){
            dfs(s+i,(i==mx)?(char)(mx+1):mx);
        }
    }
}


int32_t main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    IOS
    cin>>n;
    dfs("",'a');

    return 0;
}


Measured memory_bytes: 1536
#include <iostream>
int main() {

int a,b,c;

std::cin >>a>>b>>c;

if(a<b){
 if(b<c){
 std::cout << a<<" "<<b<<" "<<c<<"\n";
 }else if(a<c){
 std::cout << a<<" "<<c<<" "<<b<<"\n";
 }else{std::cout << c<<" "<<a<<" "<<b<<"\n";}
}else{
if(b>c)
{std::cout << c<<" "<<b<<" "<<a<<"\n";}
else if(a<c){std::cout << b<<" "<<a<<" "<<c<<"\n";}
else{std::cout << b<<" "<<c<<" "<<a<<"\n";}}
return 0;
}

Measured memory_bytes: 3100
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);

		while (sc.hasNext()) {
			String[] inputData = sc.next().split(",");

			double[] l = new double[10];
			double length = 0;

			for (int i = 0; i < 10; i++) {
				l[i] = Integer.parseInt(inputData[i]);
				length = length + l[i];
			}

			double v1 = Integer.parseInt(inputData[10]);
			double v2 = Integer.parseInt(inputData[11]);
			double cross = v1 * (length / (v1 + v2));
			int stationNum = 0;
			length = 0;

			for (int i = 0; i < 10; i++) {
				length = length + l[i];
				stationNum++;

				if (length >= cross) {
					break;
				}
			}
			System.out.println(stationNum);
		}
	}
}

Measured memory_bytes: 26240
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mpair make_pair
#define pm(first, second) pb(mpair(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()
#define reall(X) (X).rbegin(), (X).rend()
#define divcel(a, b) (((a) + ((b) - 1)) / (b))

int main(){

	int a, b;
	cin >> a >> b;
	cout << max(0, a-b-b) << endl;

	return 0;
}


Measured memory_bytes: 3604
#include <stdio.h>
 int num=0;
 double xa,ya,xb,yb,xc,yc,xd,yd;int main(){
 while(scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",&xa,&ya,&xb,&yb,&xc,&yc,&xd,&yd) != EOF){
double x1=xc-xa,x2=xd-xb,y1=yc-ya,y2=yd-yb,xy1=xc*ya-xa*yc,xy2=xd*yb-xb*yd;
 double x=(xy2*x1-xy1*x2)/(y1*x2-y2*x1);
if(xa<=xc){if(xa>x || x>xc){num=1;}}else{if(xa<x || x<xc){num=1;}}
 if(xb<=xd){if(xb>x || x>xd){num=1;}}else{if(xb<x || x<xd){num=1;}}
 if(num==0){printf("YES\n");}else{printf("NO\n");}}
return 0;
}

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

vector<pair<ll,ll>> prime_factorize(ll N){
    vector<pair<ll,ll>> ret;
    for(ll a = 2; a * a <= N; a++){
        if(N % a != 0) continue;
        ll ex = 0;
        while(N % a == 0){
            ex++;
            N /= a;
        }
        ret.push_back({a, ex});
    }
    if(N != 1) ret.push_back({N, 1});
    return ret;
}

int main(){
    ll N;
    cin >> N;
    map<ll,ll> mp;
    rep(i, 2, N+1){
        auto v = prime_factorize(i);
        for(auto e : v){
            mp[e.first] += e.second;
        }
    }
    ll ans = 0;
    ll c2 = 0, c4 = 0, c14 = 0, c24 = 0, c74 = 0;
    for(auto p : mp){
        if(p.second >= 2) c2++;
        if(p.second >= 4) c4++;
        if(p.second >= 14) c14++;
        if(p.second >= 24) c24++;
        if(p.second >= 74) c74++;
    }
    for(auto p : mp){
        if(p.second >= 2){
            if(p.second >= 4) ans += (c4 - 1) * (c4 - 2) / 2;
            else ans += c4 * (c4 - 1) / 2;
            if(p.second >= 24) ans += (c24 - 1);
            else ans += c24; 
        }
        if(p.second >= 4){
            if(p.second >= 14) ans += (c14 - 1);
            else ans += c14;
        }
    }
    ans += c74;
    cout << ans << endl;
    return 0;
}

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

struct card {
	char suit, value;
};

void bubble(struct card a[], int n) {
	for (int i = 0; i < n; i++) {
		for (int j = n - 1; j >= i; j--) {
			if (a[j].value < a[j - 1].value) swap(a[j], a[j - 1]);
		}
	}
}

void selection(struct card a[], int n) {
	for (int i = 0; i < n; i++) {
		int minj = i;
		for (int j = i; j < n; j++) {
			if (a[j].value < a[minj].value) minj = j;
		}
		swap(a[i], a[minj]);
	}
}

bool isStable(struct card c1[], struct card c2[], int n) {
	for (int i = 0; i < n; i++) {
		if (c1[i].suit != c2[i].suit) return false;
	}
	return true;
}

void print(struct card a[], int n) {
	for (int i = 0; i < n; i++) {
		if (i > 0) cout << " ";
		cout << a[i].suit << a[i].value;
	}
	cout << endl;
}

int main(){
	card c1[110], c2[110];
	int n;
	char ch;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> c1[i].suit >> c1[i].value;

	for (int i = 0; i < n; i++) c2[i] = c1[i];

	bubble(c1, n);
	selection(c2, n);

	print(c1, n);
	cout << "Stable" << endl;
	print(c2, n);
	if (isStable(c1, c2, n)) {
		cout << "Stable" << endl;
	}
	else
		cout << "Not stable" << endl;

	return 0;
}

Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 1e5 + 5;

priority_queue<int> L;
priority_queue<int, vector<int>, greater<int> > R;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int Q;
    cin >> Q;
    int n = 0, opt, x, y, cntL = 0, cntR = 0;
    LL sumL = 0, sumR = 0, sum = 0;

    while(Q--)
    {
        cin >> opt;
        if(opt== 1)
        {
            cin >> x >> y;
            ++n;
            if(n & 1)
            {
                R.push(x), sumR += x, x = R.top(), R.pop(), sumR -= x;
                L.push(x);
                sumL += x;
                ++cntL;
            }
            else
            {
                L.push(x), sumL += x, x = L.top(), L.pop(), sumL -= x;
                // R.push(x), sumR += x, ++cntR;
                R.push(x);
                sumR += x;
                ++cntR;
            }
            sum += y;
        }
        else
        {
            x = L.top();
            cout << x << " "<<sum + 1LL * x *  cntL - sumL + sumR - 1LL * x * cntR<<endl;
        }
    }
    return 0;
}


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


using ull = unsigned long long;


using namespace std;


void dump(vector<ull> &apples) {
    for (auto e : apples) {
        cout << e << " ";
    }
    cout << endl;
}


int main() {
    ull X, Y, A, B, C;

    cin >> X >> Y >> A >> B >> C;

    ull p;
    vector<ull> apples;
    vector<ull> red;
    vector<ull> green;
    vector<ull> none;

    for (ull i = 0; i < A; i++) {
        cin >> p;
        red.push_back(p);
    }

    for (ull i = 0; i < B; i++) {
        cin >> p;
        green.push_back(p);
    }

    for (ull i = 0; i < C; i++) {
        cin >> p;
        none.push_back(p);
    }

    sort(red.rbegin(), red.rend());
    sort(green.rbegin(), green.rend());
    sort(none.rbegin(), none.rend());

    for (ull i = 0; i < X; i++) {
        apples.push_back(red[i]);
    }
    for (ull i = 0; i < Y; i++) {
        apples.push_back(green[i]);
    }
    for (ull i = 0;i < C; i++) {
        apples.push_back(none[i]);
    }
    sort(apples.rbegin(), apples.rend());
    ull ans = 0;
    for (ull i = 0; i < X + Y; i++) {
        ans += apples[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 8688
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
template<typename T> inline void debug(const vector<T> &xs){
#ifdef DEBUG
	pr(xs);
#endif
}

int main(){
	int N, M, Q;
	cin >> N >> M >> Q;

	vector<int> L(M), R(M);
	for(int i=0; i<M; i++) cin >> L[i] >> R[i];

	vector<vector<int>> cnt(N+1, vector<int>(N+1));
	for(int i=0; i<M; i++){
		cnt[L[i]][R[i]]++;
	}

	vector<vector<int>> cumsum(N+1, vector<int>(N+1));
	for(int i=1; i<=N; i++){
		for(int j=1; j<=N; j++){
			cumsum[i][j] = cnt[i][j]+cumsum[i][j-1]+cumsum[i-1][j]-cumsum[i-1][j-1];
		}
	}

	for(int i=0; i<Q; i++){
		int p, q;
		cin >> p >> q;
		cout << cumsum[N][q] - cumsum[p-1][q] << endl;
	}

	return 0;
}


Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}



long mod = 998244353;
/* C++の構造体 メンバがpublicなclass */
typedef struct mint
{
    ll x;
    mint(ll x = 0) : x(x % mod) {} //コンストラクタ
    /* 演算子オーバーロード */
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += mod - a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const
    {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const
    {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const
    {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const
    {
        if (!t)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1)
            a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const
    {
        return pow(mod - 2);
    }
    mint &operator/=(const mint a)
    {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const
    {
        mint res(*this);
        return res /= a;
    }
} mint_t;

ll intpow(mint_t m, int n)
{
    if (n == 0) return 1;
    mint_t ans(1);
    while (n >= 1)
    {
        if ((n % 2) == 0){
            m *= m.x;
            n /= 2;
        }else {
            ans *= m.x;
            n -= 1;
        }
    }
    return ans.x;
}


const int n_max = 100050;
mint table[n_max] = {0};


int main()
{
    int n;
    cin >> n;
    int max_node = 0;
    vector<int> d(n, 0);
    rep(i, n){cin >> d[i];}
    rep(i, n) {table[d[i]]+=1; max_node = max(max_node, d[i]);}

    mint ans = 1; 
    rep1(i, max_node){
        mint mut = intpow(table[i-1], table[i].x)%mod;
        ans *= mut;
    }
    if (table[0].x != 1 || d[0] != 0) cout << "0" << endl;
    else cout << ans.x << endl;
}



Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <sstream>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <numeric>
#include <bitset>
#include <ext/algorithm>
#include <ext/numeric>
#define ffor(_a,_f,_t) for(int _a=(_f),__t=(_t);_a<__t;_a++)
#define all(_v) (_v).begin() , (_v).end()
#define sz size()
#define pb push_back
#define SET(__set, val) memset(__set, val, sizeof(__set))
#define FOR(__i, __n) ffor (__i, 0, __n)
typedef long long LL; using namespace std;

int t[300000];

int main() {
	int N, T;
	scanf("%d %d", &N, &T);
	FOR (i, N)
		scanf("%d", &t[i]);
	LL ret = 0LL;
	LL last = -1;
	FOR (i, N) {
		if (last < t[i])
			ret += T;
		else
			ret += t[i] + T - last;
		last = t[i] + T;
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 1024
<?php
fscanf(STDIN, "%d", $n);
$a = explode(" ", fgets(STDIN));

sort($a, SORT_NUMERIC);
if (count($a) %2 === 0) {
    $alice = 0;
    $bob = 0;
    foreach ($a as $key => $item) {
        $alice += $key%2 === 1 ? $item : 0;
        $bob += $key%2 === 0 ? $item : 0;
    }
    echo $alice - $bob;
    return;
}
$alice = 0;
$bob = 0;
foreach ($a as $key => $item) {
    $alice += $key%2 === 0 ? $item : 0;
    $bob += $key%2 === 1 ? $item : 0;
}
echo $alice - $bob;
return;


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

int n;
double p[3005];
double dp[3005][3005];
int main()
{
	std::cin >> n;
	for (int i = 0; i < n; ++i)
		std::cin >> p[i];

	dp[0][0] = 1.0;
	for (int i = 0; i < n; ++i)
		for (int j = 0; j <= i; ++j) {
			dp[i + 1][j + 1] += dp[i][j] * p[i];
			dp[i + 1][j] += dp[i][j] * (1 - p[i]);
		}

	double ans = 0;
	for (int i = (n + 2 - 1) / 2; i <= n; ++i)
		ans += dp[n][i];

	std::cout << std::setprecision(10) << std::fixed << ans << std::endl;
	return 0;
}


Measured memory_bytes: 68992
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n = readline() |> parseInt
	h = readline() |> split |> parseMap
	dp = Array{Int}(n)
	dp[1] = 0
	dp[2] = abs(h[2]-h[1])
	for i in 3:n
		dp[i] = min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]))
	end
	println(dp[n])
end

main()


Measured memory_bytes: 124716
#include <iostream>
# include <cstring>
# include <math.h>
using namespace std; 
const int N =2e5 + 5;
int n,m;
int ton[N];
int fol[N];
int a,b;
   
int main()
{  
  cin>>n>>m;
  for (int i = 0; i < m; ++i)
  {
  	cin>>a; cin>>b; if(a==1){ton[b]=1;}
  	else if(b==n) {fol[a]=1;}

  }
  for (int i = 2; i < n; ++i)
  {
    if(ton[i] && fol[i]) {cout<<"POSSIBLE"; return 0;}
  }
    cout<<"IMPOSSIBLE";
     	 
  
    return 0;
  
}

Measured memory_bytes: 1920
#include <stdio.h>

int main(){

  int x,y,tmp,r;

  scanf("%d%d",&x,&y);

  if(x<y){
    tmp = x;
    x = y;
    y = tmp;
  }

  r = x % y;
  while(r!=0){
    x = y;
    y = r;
    r = x % y;
  }

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

  return 0;
}



Measured memory_bytes: 2124
//#if !defined(YCM) && 1
//#define _FORTIFY_SOURCE 0
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC target("avx")
////#pragma GCC optimize ("O3")
////#pragma GCC target ("sse4")
//#include <stdio.h>
//#endif

#include <bits/stdc++.h>
#include <unistd.h>
//#pragma GCC diagnostic ignored "-Wunused-result"
//#pragma GCC diagnostic ignored "-Wunused-function"
using namespace std;
#define ll int64_t
#define ull unsigned long long int
#define clr(a) memset(a,0,sizeof(a))
#define clr_(a) memset(a,-1,sizeof(a))
#define pb(a) push_back(a)
#define pii pair<int,int>

#define eps 1e-9
#define inf INT_MAX
#define pi acos(-1.0)
#define ff first
#define ss second
#define INF (ll)1e18
#define m_p make_pair
#define vsort(v) sort(v.begin(),v.end())
#define all(v) v.begin(),v.end()
int fx[]={0,0,-1,1,-1,1,1,-1};
int fy[]={1,-1,0,0,1,1,-1,-1};
ll lcm(ll a,ll b){return (a/__gcd(a,b))*b;}
ll bigmod(ll a,ll p,ll mod){ll ans=1;while(p){if(p&1)ans=ans*a%mod;a=a*a%mod;p>>=1;}return ans;}
ll power(ll x,ll n){if(n==0)return 1;else if(n%2==0){ll y=power(x,n/2);return y*y;}else return x*power(x,n-1);}

#ifdef shaft
     #define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template < typename Arg1 >
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " is " << arg1 << std::endl;
    }
    template < typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names+1, ',');
        cerr.write(names, comma - names) << " is " << arg1 <<endl;
        __f(comma+1, args...);
    }
#else
    #define debug(...)
#endif
const int N=(int)1e6+5;
const int mod=(int)1e9+7;

int main()
{
    ios_base::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(100); cout.tie(nullptr); cin.tie(nullptr);
    #ifdef shaft
        //freopen("in.txt","r",stdin);
        //freopen("out.txt","w",stdout);
    #endif ///shaft
    ll a , b;
    cin >> a >> b;
    vector<int>v;
    while(b > 0){
        v.pb(b%10);
        b/=10;
    }
    reverse(all(v));
    for(int i : v)
        a *= 10, a+=i;
    ll k = sqrt(a);
    if(k*k == a)
        cout <<"Yes"<<endl;
    else
        cout <<"No"<<endl;
    return 0;
}




Measured memory_bytes: 256
package main

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

// go run ./main.go < in

func main() {
	var inputs []string
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	inputs = strings.Split(sc.Text(), "")
	a, _ := strconv.Atoi(inputs[0])
	b, _ := strconv.Atoi(inputs[1])
	c, _ := strconv.Atoi(inputs[2])
	fmt.Println(a + b + c)
}

Measured memory_bytes: 640
(let* ((s (read-line))
    (tt (read-line))
    (ans (length tt)))

    (loop for i to (- (length s) (length tt)) do
        (let ((tmp 0))
            (loop for j below (length tt) do
                (if (not (char= (char s (+ i j)) (char tt j)))
                    (incf tmp)
                )
            )
            (if (< tmp ans)
                (setq ans tmp)
            )
        )
    )

    (format t "~D~%" ans)
)

Measured memory_bytes: 24332
#![allow(unused_imports)]
#![allow(dead_code)]
use datastructure::*;
use grapth::*;
use input_scanner::*;
use math::*;
use string_algorithm::*;
use util::*;

use std::cmp;
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque};

fn main() {
    let mut scan = Scanner::new();
    let x: i32 = scan.next();
    let y: i32 = scan.next();

    if x*2 <= y && y <= x*4 && y%2==0 {
        println!("Yes");
    }else{
        println!("No");
    }

}

mod datastructure {}
mod grapth {}
mod math {}
mod string_algorithm {}
mod util {}
mod input_scanner {
    pub struct Scanner {
        bytes: Vec<u8>,
        begin: usize,
        end: usize,
    }

    impl Scanner {
        pub fn new() -> Self {
            use std::io::Read;
            let mut buffer: Vec<u8> = Vec::new();
            std::io::stdin().read_to_end(&mut buffer).unwrap();
            let end = (0..buffer.len())
                .find(|i| buffer[*i].is_ascii_whitespace())
                .unwrap_or(buffer.len());
            Scanner {
                bytes: buffer,
                begin: 0,
                end: end,
            }
        }
        pub fn next<T: std::str::FromStr>(&mut self) -> T {
            let s: &str =
                unsafe { std::str::from_utf8_unchecked(&self.bytes[self.begin..self.end]) };
            let ret: T = s.parse::<T>().ok().expect("Parse error.");
            self.skip();
            ret
        }
        pub fn next_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
        pub fn next_word(&mut self) -> Vec<u8> {
            let r = Vec::from(&self.bytes[self.begin..self.end]);
            self.skip();
            r
        }
        fn skip(&mut self) {
            self.begin = (self.end..self.bytes.len())
                .find(|i| !self.bytes[*i].is_ascii_whitespace())
                .unwrap_or(self.bytes.len());
            self.end = (self.begin..self.bytes.len())
                .find(|i| self.bytes[*i].is_ascii_whitespace())
                .unwrap_or(self.bytes.len());
        }
    }
}


Measured memory_bytes: 2128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) (V).begin(),(V).end()
#define MOD 1000000007
#define mod 998244353

int rw[100010];
vector<int> W[100010];

int main(){
	for (int i = 0;i < 100010;i++)rw[i] = -1;
	ll N, L;
	cin >> N;
	vector<ll> X(N);
	for (int i = 0;i < N;i++)
		cin >> X[i];
	cin >> L;
	for (int j = 0;j < N;j++) {
		if (rw[j] >= 0)continue;
		for (int i = j;i < N;) {
			W[j].push_back(i);
			if (rw[i] >= 0)break;
			rw[i] = j;
			auto it = upper_bound(all(X), X[i] + L);
			it--;
			i = it - X.begin();
		}
	}

	//for (int i = 0;i < N;i++)cout << rw[i] << " ";

	ll Q, a, b, c, d, ans = 0;
	cin >> Q;
	for (int i = 0;i < Q;i++) {
		ans = 0;
		cin >> a >> b;
		if (a > b)swap(a, b);
		a--;b--;
		c = rw[a];
		while (1) {
			auto it = W[c].end();
			it--;
			d = *it;
			if (d >= b)break;
			ans += it - find(all(W[c]), a);
			//cout << ans << endl;
			a = d;
			c = rw[a];
		}
		auto it1 = find(all(W[c]), a);
		auto it2 = lower_bound(all(W[c]), b);
		ans += it2 - it1;
		cout << ans << endl;
	}
}

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

typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e9;

void solve()
{
  int n,X; cin>>n>>X;
  vector<int> x(n, 0);
  for (int i=0; i<n; i++) {
    cin >> x[i];
  }

  sort(x.begin(),x.end());
  int g=abs(X-x[0]);
  for (int i=1; i<n; i++) {
    g = __gcd(g, x[i]-x[i-1]);
  }
  cout << g << endl;
}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 640
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define ll long long
#define endl "\n"

using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
const int N = 2e5 + 10;
const ll inf = 1e18 + 10, mod = 1e9 + 7;

int main()
{
    //ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("lca_rmq.in", "r", stdin);
    //freopen("lca_rmq.out", "w", stdout);
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5])cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
void Digvijay()
{
    int l,r,d;
    cin>>l>>r>>d;
    int val1=l/d;
    if(l%d==0)val1--;
    int ans = r/d-val1;
    cout<<ans<<"\n";
}
signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int _=1;
    //cin>>_;
    for(int __=1;__<=_;__++)
    {
        Digvijay();
    }
}



Measured memory_bytes: 3608
#include <iostream>

using namespace std;

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

    long long res = 0;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0 && n / i - 1 > 0 && n / (n / i - 1) == i) {
            res += n / i - 1;
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 384
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int appart[][][] = new int[4][3][10];
		
		for(int i = 0; i < 4; i++)
			for(int j = 0; j < 3; j++)
				for(int k = 0; k < 10; k++)
					appart[i][j][k] = 0;
		
		int n = sc.nextInt();
		
		for(int i = 0; i < n; i++){
			int b = sc.nextInt();
			int f = sc.nextInt();
			int r = sc.nextInt();
			int v = sc.nextInt();
			
			appart[b-1][f-1][r-1] += v;
		}
		
		for(int i = 0; i < 4; i++){
			for(int j = 0; j < 3; j++){
				for(int k = 0; k < 10; k++){
					System.out.print(" " + appart[i][j][k]);
				}
				System.out.println("");
			}
			if(i < 3)
				System.out.println("####################");
		}
	}
}

Measured memory_bytes: 29196
N = input()
S = input()
count = 0
result = ''

for s in S:
    # if result:
    count += 1

    if result == '':
        result += s
    else:
        if result[-1] != s:
            result += s
    if count >= int(N):
        # print('break')
        break


print(len(result))

Measured memory_bytes: 3316
#include <stdio.h>
#include <string.h>
char t1[1510];
char t2[1510];
char t3[1510];
int main(){
    int n;
    int a,b;
    int i,j;
    char t;
    scanf("%s",&t1);
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%s",&t3);
        if(strcmp(t3,"replace")==0){
            scanf("%d %d %s",&a,&b,&t2);
            for(j=0;j<b-a+1;j++){
                t1[a+j]=t2[j];
            }
        }
        else if(strcmp(t3,"reverse")==0){
            scanf("%d %d",&a,&b);
            for(;a<b;){
                t=t1[a];
                t1[a]=t1[b];
                t1[b]=t;
                a++;
                b--;
            }
        }
        else if(strcmp(t3,"print")==0){
            scanf("%d %d",&a,&b);
            for(j=a;j<b+1;j++){
                printf("%c",t1[j]);
            }
             printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 2104
using System;
using System.Collections.Generic;

namespace Volume0_0001_ListOfTop3Hills
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int> list = new List<int>(10);

            for(int i = 0; i < 10; i++)
            {
                int height = Convert.ToInt32( Console.ReadLine());
                list.Add(height);
            }

            list.Sort();
            list.Reverse();

            for (int i = 0; i < 3; i++) Console.WriteLine(list[i]);
        }
    }
}

Measured memory_bytes: 5820
#include <iostream>

using namespace std;
using ll = long long;

int main() {
    ll K, A, B;
    cin >> K >> A >> B;

    if (K + 1 <= A || B - A <= 2) {
        cout << K + 1 << endl;
        return 0;
    }

    K -= A - 1;
    cout << A + (B - A) * (K / 2) + K % 2 << endl;
    return 0;
}


Measured memory_bytes: 256