akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
#include<ctype.h>
int main(){
  char W[10];
  char memw[10];
  char c[1000];
  char memc[1000];
  int ans=0;
  int n,m;
  int i;
  int h;
  scanf("%s",&W);
  n = strlen(W);
  for(i=0;i<n;i++){
    memw[i] = tolower(W[i]);
    //printf("%c\n",memw[i]);
  }
  while(scanf("%s",&c)){
    h = 0;
    if(c[0]=='E'&&c[1]=='N'&&c[2]=='D'&&c[3]=='_'&&c[4]=='O'&&c[5]=='F'&&c[6]=='_'&&c[7]=='T'&&c[8]=='E'&&c[9]=='X'&&c[10]=='T') break;
    m = strlen(c);
    for(i=0;i<m;i++) memc[i] = tolower(c[i]);
    if(n!=m) h = 1; 
    else if(memc[0]==W[0]){
      for(i=1;i<n;i++){
	if(W[i]!=memc[i]){
	  h = 1;
	  break;
	}
      }
      if(h==0) ans++;
    }
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 976
#include <bits/stdc++.h>
#define ll long long
#define io ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define fi first
#define se second

using namespace std;

int main() 
{
//	freopen("test.inp","r",stdin);
//	freopen("BAILAM.OUT","w",stdout);	
	io;
	int n;
	cin >> n;	
	int cur = 1000;
	while (cur < n) cur += 1000;
	cout << cur - n;
    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
const int N=2e5+2;
int main()
{
    ft
    ll t,i,j,n,m,l,r,x,y,c=0;
    cin>>n>>m;
    if(n==1 || m==1)
    {
        if(n==1 && m==1)
        {
            cout<<"1\n";
        }
        else
        {
            cout<<(max(n,m)-2)<<"\n";
        }
    }
    else
    {
        c=n*m-(n+m+n+m-4);
        cout<<c<<"\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	unsigned long long a, b, c, d, e, f, count, tmp, r, x;

	scanf("%lld%lld%lld%lld", &a, &b, &c, &d);

	e = c, f = d;

	if (e < f) {
		tmp = e;
		e = f;
		f = tmp;
	}

	x = e * f;

	r = e % f;
	while (r != 0) {
		e = f;
		f = r;
		r = e % f;
	}

	x = x / f; // 最小公倍数

	count = b - a + 1;

	if (a % c == 0)
		count -= b / c - a / c + 1;
	else
		count -= b / c - a / c;

	if (a % d == 0)
		count -= b / d - a / d + 1;
	else
		count -= b / d - a / d;

	if (a % x == 0)
		count += b / x - a / x + 1;
	else
		count += b / x - a / x;

	if (a <= b)
		printf("%lld\n", count);
	else
		printf("%d\n", 0);
	return 0;
}

	


Measured memory_bytes: 128
#include "bits/stdc++.h"
#define YES "YES"
#define NO "NO"
#define YESNO OUT(three(solve(),YES,NO))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(b);i>=(LL)(a);i--)
#define REP(i,b) FOR(i,zero,b)
#define rep REP
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define zero 0LL
#define all ALL
#define pb emplace_back
#define eb pb
#define int long long
using namespace std;
template<typename T> inline void maximize(T &a, T b) { a = max(a, b); }
template<typename T> inline void minimize(T &a, T b) { a = min(a, b); }
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef int LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef tuple<int, int, int, int> tapu;
typedef vector<tapu> Vtapu;
typedef priority_queue<pr, Vpr, greater<pr> > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
const int SIZE1 = 3e5 + 1000;
const int SIZE2 = 2010;
const int SIZE3 = 430;
const int SIZE = SIZE1;
const int MAPSIZE = 40;
const LL p = 7 + 1e9;
const LL INF = 1LL << 60;
const long double EPS = 1e-7;
typedef pair<ld, ut> pld;
//#define endl "\n" //インタラクティブでは消す
//ut A,B,C,D,E,F,G,H,I,J,O,P,Q,R,T,U;
ut N, M, K, L, Q, D, H, W,R;
VI edges[SIZE];
LL vals[SIZE], answer = zero;
LL maps[SIZE2][SIZE2];
pr A[SIZE];
LL reached[SIZE];
LL parent[SIZE];
LL solve() {
	cin >> N >> M;
	REP(i, N + M - 1) {
		int a, b;
		cin >> a >> b;
		edges[a].pb(b);
		reached[b]++;
	}
	queue<LL> qu;
	int root = 0;
	EFOR(i,1, N) {
		if (reached[i] == 0) {
			root = i;
			qu.push(i);
		}
	}
	while (!qu.empty()) {
		int now = qu.front();
		qu.pop();
		for(auto next : edges[now]) {
			reached[next]--;
			if (reached[next] == 0) qu.push(next);
			parent[next] = now;
		}
	}
	EFOR(i,1, N) {
		cout << parent[i] << endl;
	}
	return 0;
}




//!!!!!!!!!!!!!!!!!!!実装を詰める!!!!!!!!!!!!!!!!!!!!!!!!!
signed main() {

	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	string s;
	solve();
		
	
	//cin >> N;
	return 0;

}


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

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i,n) cin >> p[i];
  int ans = 0;
  for(int i = 1; i < n-1;i++){
    if(p[i+1] > p[i] && p[i] > p[i-1]) ans++;
    if(p[i-1] > p[i] && p[i] > p[i+1]) ans++;
  }
  cout << ans << endl;
}

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




int main(){
    ll N, W; cin >> N >> W;
    vector<ll> W_(N), V_(N); for(int i = 0; i < N; i++) cin >> W_[i] >> V_[i];
    vector<vector<ll>> DP(N+1, vector<ll>(W+1, 0));
    for(int i = 1; i <= N; i++){
        ll v = V_[i-1], w = W_[i-1];
        for(int j = 1; j <= W; j++){
            if(j < w) DP[i][j] = max(DP[i-1][j], DP[i][j-1]);
            else DP[i][j] = max(DP[i-1][j-w]+v, DP[i-1][j]);
        }
    }
    cout << DP[N][W] << endl;

    
}

Measured memory_bytes: 80256
let last_i = ref 0

let parent i = int_of_float (floor (float_of_int i) /. 2.)

let left i = 2*i

let right i = 2*i + 1

let extract (t : int array) =
  let rec max_heapify i =
    let l = left i in
    let r = right i in
    let m = if l <= !last_i && t.(l) > t.(i) then l else i in
    let m = if r <= !last_i && t.(r) > t.(m) then r else m in
    if i = m then ()
    else begin
      let tmp = t.(i) in
      t.(i) <- t.(m);
      t.(m) <- tmp;
      max_heapify m
    end in
  let ret = t.(1) in
  t.(1) <- t.(!last_i);
  decr last_i;
  max_heapify 1;
  ret

let insert x (t : int array) =
  let rec doit i =
    let p = parent i in
    if i <= 1 || t.(p) >= t.(i) then ()
    else begin
      let tmp = t.(i) in
      t.(i) <- t.(p);
      t.(p) <- tmp;
      doit p
    end in
  incr last_i;
  t.(!last_i) <- x;
  doit !last_i

let () =
  let t = Array.make 2000001 0 in
  while true do
    let op = Scanf.scanf "%s " (fun i -> i) in
    if op = "end" then exit 0
    else if op = "extract" then extract t |> Printf.printf "%d\n"
    else insert (Scanf.scanf "%d " (fun i -> i)) t
  done

Measured memory_bytes: 20448
module app;

import core.bitop;

import std.algorithm;
import std.array;
import std.bigint;
import std.conv;
import std.stdio;
import std.string;

struct Input
{
	int n, k;
	int[] p;
}

void parseInput(T)(out Input input, T file)
{
	with (file) with (input)
	{
		auto array = readln().strip().split();
		n = array[0].to!int;
		k = array[1].to!int;
        p = readln().strip().split().map!(to!int).array();
	}
}

struct Output
{
}

auto main2(Input* input)
{
    int max = sum(input.p[0..input.k]);
    int prev = max;
    int i = input.k;
    while (i < input.n)
    {
        int current = prev - input.p[i - input.k] + input.p[i];
        if (current > max)
            max = current;
        prev = current;
        i++;
    }

	return (cast(real)(max + input.k)) / 2.0;
}

void main()
{
	Input input = void;
	parseInput(input, stdin);
	auto result = main2(&input);
	writefln("%f", result);
}


Measured memory_bytes: 11304
#include<bits/stdc++.h>
#include <numeric>
// #define int long long
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
#define MOD 1000000007
using namespace std;
using ll = long long;
typedef vector<int> vi;

signed main() {
    ll n;
    cin >> n;
    ll ans = 1;
    rep(i, n){
        if(ans * (i+1) > MOD){
            ans = (ans * (i+1)) % MOD;
        }else{
            ans *= i+1;
        }
    }


    cout << ans % MOD << endl;
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

using namespace std;

static const ll INF = 1e15;

template<typename T>
static inline void chmin(T & ref, const T  value) {
	if (ref > value) ref = value;
}

template<typename T>
static inline void chmax(T& ref, const T value) {
	if (ref < value) ref = value;
}

int main() {
	ll n, d;
	cin >> n >> d;
	d = d * d;
	ll sum = 0;
	rep(i, n) {
		ll x, y;
		cin >> x >> y;
		ll a = x * x + y * y;
		if (a <= d) {
			sum++;
		}
	}
	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int D, contests[370], ans[370];
lint c[30], s[370][30];
set<int> held_days[30];
lint best_score;

lint get_score(int dd){
    For(i, 1, 27){
        held_days[i].clear();
        held_days[i].insert(0);
        held_days[i].insert(D+1);
    }
    lint ret = 0;
    For(day, 1, dd+1){
        For(i, 1, 27){
            if(contests[day] == i){
                ret += s[day][i];
                held_days[i].insert(day);
            }
            else ret -= c[i] * (day - *next(held_days[i].rbegin()));
        }
    }
    return ret;
}

lint fsum(int n){
    return n*(n+1)/2;
}

lint score_diff(int day, int idx){
    lint ret = 0;
    int prev_id = contests[day];
    contests[day] = idx;

    ret += s[day][idx];
    auto r = held_days[idx].lower_bound(day), l = prev(r);
    ret += c[idx] * fsum(*r-1-*l);
    ret -= c[idx] * (fsum(day-1-*l) + fsum(*r-1-day));
    held_days[idx].insert(day);

    ret -= s[day][prev_id];
    auto m = held_days[prev_id].find(day);
    r = next(m); l = prev(m);
    ret += c[prev_id] * (fsum(day-1-*l) + fsum(*r-1-day));
    ret -= c[prev_id] * fsum(*r-1-*l);
    held_days[prev_id].erase(day);

    return ret;
}

void input(){
    scanf("%d", &D);
    For(i, 1, 27) scanf("%lld", &c[i]);
    For(i, 1, D+1)For(j, 1, 27) scanf("%lld", &s[i][j]);
}

void output(){
    For(i, 1, D+1) printf("%d\n", ans[i]);
}

int main(){
    input();

    For(i, 1, D+1) ans[i] = contests[i] = i%26 + 1;

    double temperature = 100000, colding_rate = 0.99999;
    lint score = get_score(D);
    best_score = score;
    random_device rd;
    mt19937 mt(rd());
    uniform_real_distribution<> dist(0.0, 1.0);
    clock_t start = clock();
    while((clock() - start) / CLOCKS_PER_SEC < 1.0){
        int day = mt()%D + 1;
        int idx = mt()%26 + 1;
        int prev_id = contests[day];
        lint diff = score_diff(day, idx);

        if(diff > 0) score += diff;
        else{
            double prob = dist(mt);
            if(prob <= exp(diff / temperature)) score += diff;
            else score_diff(day, prev_id);
        }

        if(chmax(best_score, score)){
            For(i, 1, D+1) ans[i] = contests[i];
        }

        temperature *= colding_rate;
    }

    output();
}

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

using namespace std;

void solve()
{
    int n;
    cin >> n;
    vector<int> xs(n);
    for (int i = 0; i < n; i++)
    {
        cin >> xs[i];
    }
    sort(xs.begin(), xs.end());
    cout << (xs.back() - xs.front() + 1) / 2 << endl;
}

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



Measured memory_bytes: 3144
#include<stdio.h>

int H, A[2000001];

void maxHeapify(int i){
  int l, r, largest, temp;

  l = 2 * i;
  r = 2 * i + 1;

  if(l <= H && A[l] > A[i])         largest = l;
  else                              largest = i;

  if(r <= H && A[r] > A[largest])   largest = r;

  if(largest != i){
    temp = A[i];
    A[i] = A[largest];
    A[largest] = temp;
    maxHeapify(largest);
  }
}

void buildMaxHeap(){
  int i;

  for(i = H / 2; i >= 1; i--){
    maxHeapify(i);
  }
}

int main(){
  int i;
  
  scanf("%d", &H);
  for(i = 1; i <= H; i++){
    scanf("%d", &A[i]);
  }

  buildMaxHeap();

  for(i = 1; i <= H; i++)
    printf(" %d", A[i]);
  printf("\n");
  
  return 0;
}

Measured memory_bytes: 2552
import sys

def main():
    N = int(input())
    H = list(map(int, sys.stdin.readline().split()))

    last = 10**10
    for h in reversed(H):
        if h > last + 1:
            print('No')
            sys.exit()
        elif h > last:
            continue
        else:
            last = h

    print('Yes')

if __name__=='__main__':
    main()

Measured memory_bytes: 14168
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = INT64_MAX;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;
using Vi = vector<long long int>;
typedef pair<int, int> P; typedef pair<ll, ll> PLL;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i=0;i<N;i++)
auto max(auto x,auto y){if(x>y){return x;}else{return y;}}
auto min(auto x,auto y){if(x>y){return y;}else{return x;}}
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
typedef vector<vector<ll> > matrix;
void princ(auto x){cout<<x<<" ";}; void print(auto x){cout<<x<<"\n";};
///////////////////////////////////////////////////////////////////////////////////

ll p,q,r;


int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>p>>q>>r;
    ll ans = INF;
    chmin(ans,p+q);
    chmin(ans,q+r);
    chmin(ans,p+r);
    print(ans);
    return 0;
}

Measured memory_bytes: 256
import java.util.*;



public class Main{
    
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        int C=sc.nextInt();
        int[][]D=new int[C][C];
        int[][]c=new int[N][N];
        for(int i=0;i<C;i++){
            for(int j=0;j<C;j++){
                D[i][j]=sc.nextInt();
            }
        }
        int[][]kazu=new int[3][50];
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                c[i][j]=sc.nextInt()-1;
                kazu[(i+j)%3][c[i][j]]++;

            }
        }
        
        int ans=1000000000;
        int sum[][]=new int[3][C];
        for(int i=0;i<3;i++){
            for(int j=0;j<C;j++){
                for(int k=0;k<C;k++){
                    sum[i][j]+=D[k][j]*kazu[i][k];
                }
            }
        }
        for(int i=0;i<C;i++){
            for(int j=0;j<C;j++){
                for(int k=0;k<C;k++){
                    if((i==j)||(j==k)||(i==k)){
                        continue;
                    }
                    ans=Math.min(ans,sum[0][i]+sum[1][j]+sum[2][k]);
                }
            }
        }
        System.out.println(ans);
        

        
        

            

        
        
        
        
            

        
        

    }
    }


Measured memory_bytes: 93180
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[2005];
int mi[2005];
int main() {
   int n;
    int x;
    scanf("%d%d",&n,&x);
    
    int i;
    for(i=1;i<=n;i++)
        {
        scanf("%d",&a[i]);
        mi[i] = a[i];
    }
    ll ans = 1000000007;
    ans = ans*ans;
    ll st;
    for(st=0;st<n;st++)
        {
       // printf("after %d steps\n",st);
        for(i=1;i<=n;i++)
            {
            int ne = i+st;
            if(ne>n)ne-=n;
            if(mi[ne] > a[i])mi[ne] = a[i];
          //  printf("cost of %d is %lld\n",ne,st*x+a[i]);
        }
        ll cur = 0;
        for(i=1;i<=n;i++)cur += mi[i];
        cur += (ll)st*x;
        if(cur < ans)ans = cur;
        
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int K = 100010;
int dp[K];
int a[110];
int n, k;
int mini;
bool get(int x) {
    if(dp[x] != -1) return dp[x];
    else if(x < mini) {
        dp[x] = 0;
        return false;
    } else {
        for(int i = n-1; i >= 0; i --) {
            int curr = a[i];
            if(x >= curr && !get(x - curr) ) {
                dp[x] = 1;
                return true;
            }
        }
        dp[x] = 0;
        return false;
    }
}

int main() {
    cin >> n >> k;
    for(int i = 0; i < n; i ++) {
        cin >> a[i];
    }
    memset(dp, -1, sizeof dp);
    sort(a, a+n);
    mini = a[0];
    if(get(k)) {
        cout << "First" << endl;
    } else {
        cout << "Second" << endl;
    }
    return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
int main(){
    int64_t A,B,K;
    cin >> A >> B >> K;

    int64_t Kb = K-A;
    if(Kb<0){
        Kb = 0;
    }
    A -= K;
    if(A<0){
        A = 0;
    }
    B -= Kb;
    if(B<0){
        B = 0;
    }
    
    cout << A << ' ' << B << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#ifndef bhartiya
    #pragma GCC optimize("Ofast")
    #pragma GCC optimize("unroll-loops")
    // #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif


typedef long long ll;
typedef pair<ll, ll> pll;
typedef gp_hash_table<long long, long long> umap;
typedef tree<int, null_type, less<int>, rb_tree_tag,
		tree_order_statistics_node_update> oset;
// not that imp
typedef pair<pll, ll> plll;
typedef vector<ll> vl;
typedef vector<pll> vll;

#define inf 200000000000000ll
#define mod 1000000007ll
#define eps 1e-7
#define PI 3.1415926535897932385
// #define PI acos(-1)

#define pb push_back
#define bitc  __builtin_popcountll
#define mp make_pair
#define ff first
#define ss second
#define all(ar) ar.begin(), ar.end()

#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define foreach(it,ar) for (auto it = ar.begin(); it != ar.end(); it++)
#define fill(ar,val) memset(ar, val, sizeof(ar))

#ifdef bhartiya
#define trace(...) __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...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif

mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
inline bool equals(double a, double b) {return fabs(a - b) < 1e-9;}
ll gcd(ll a, ll b){ return b==0 ? a : gcd(b, a%b); }

const ll maxn = 500005;
ll n;

int main() 
{ 
	ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0), cout.precision(10); //cout<<fixed;
    cin.exceptions(cin.failbit);
    #ifdef bhartiya
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int t = 1;
    // cin>>t;
    while(t--){
        ll m;
        cin>>n>>m;
        vector<pll> a;
        rep(i,m){
            ll x,y;
            cin>>x>>y;
            a.push_back(mp(x,y));
        }
        ll l = 0, r= maxn;
        sort(all(a));
        rep(i,m){
            if(r < a[i].ff){
                l=-1; r=-2;
            }
            else if(a[i].ss < l){
                l=-1;r=-2;
            }
            else{
                l = max(l,a[i].ff);
                r = min(r,a[i].ss);
            }
        }
        cout<<r-l+1;
    }
    end_routine();
}


Measured memory_bytes: 2420
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int min = Integer.MAX_VALUE,max = Integer.MIN_VALUE;
        long sum = 0;

        for(int i = 0 ; i < n ; i++) {
        	int num = sc.nextInt();
        	if(min > num)min = num;
        	if(max < num)max = num;
        	sum += num;
        }

        System.out.println(min + " " + max + " " + sum);
        sc.close();
	}

}



Measured memory_bytes: 41600
#include<iostream>
#include<map>
#include<vector>
#include<queue>
using namespace std;

int main(){
    int n;
    cin >> n;
    map<string, int> pri;
    for(int i = 0; i < n; i++){
        string s;   int x;
        cin >> s >> x;
        pri[s] = x;
    }
    int m;
    cin >> m;
    map<string, vector<string>> v;
    for(int i = 0; i < m; i++){
        string s, t;
        cin >> s >> t;
        v[s].push_back(t);
        v[t].push_back(s);
    }
    int ans = 0;
    map<string, int> visit;
    for(auto p : pri){
        if(visit.count(p.first))  continue;
        int val = p.second, cnt = 1;
        queue<string> q;
        q.push(p.first);
        visit[p.first] = 1;
        while(!q.empty()){
            string s = q.front();   q.pop();
            for(string t : v[s]){
                if(visit.count(t) == 0){
                    cnt++;
                    visit[t] = 1;
                    val = min(val, pri[t]);
                    q.push(t);
                }
            }
        }
        ans += cnt*val;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4556
#include <iostream>
#include <fstream>
using namespace std;
long long F[100005][5], n;
int main()
{
    //freopen("VACATION.INP", "r", stdin);
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        long long a, b, c;
        cin >> a >> b >> c;
        F[i][1] = max(F[i - 1][2], F[i - 1][3]) + a;
        F[i][2] = max(F[i - 1][1], F[i - 1][3]) + b;
        F[i][3] = max(F[i - 1][1], F[i - 1][2]) + c;
    }

    cout << max(F[n][1], max(F[n][2], F[n][3]));
    return 0;
}


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

static const int MAX = 100;
static const int INF = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

void dijkstra() {
    int minv;
    int d[MAX], color[MAX];

    rep(i,n) {
        d[i] = INF;
        color[i] = WHITE;
    }

    d[0] = 0;
    color[0] = GRAY;
    // 最短経路の候補の中で最小の頂点を選ぶ
    while(1){
        minv = INF;
        int u = -1;
        rep(i,n) {
            if (minv > d[i] && color[i] != BLACK) {
                u = i;
                minv = d[i];
            }
        }
        if (u == -1) break;
        color[u] = BLACK;

    // 次の最短経路の頂点を見つける
        rep(v,n) {
            if (color[v] != BLACK && M[u][v] != INF){
                if (d[v] > d[u] + M[u][v]) {
                    d[v] = d[u] + M[u][v];
                    color[v] = GRAY;
                }
            }
        }
    }
    rep(i,n){
        cout << i << " " << ((d[i] == INF)? -1 : d[i]) << endl;
    }
}

int main(){
    cin >> n;
    rep(i,n){
        rep(j,n) M[i][j] = INF;
    }

    int k, c, u, v;
    rep(i,n){
        cin >> u >> k;
        rep(j,k){
            cin >> v >> c;
            M[u][v] = c;
        }
    }
    dijkstra();
    return 0;
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;

// 插入此處

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    LL X; cin >> X;
    bool find = false;
    for (LL i = -1000; !find && i <= 1000; ++i) {
        for (LL j = -1000; !find && j <= 1000; ++j) {
            LL t1 = i * i * i * i * i;
            LL t2 = j * j * j * j * j;
            if (t1 - t2 == X) {
                cout << i << ' ' << j << endl;
                find = true;
            }
        }
    }
    return 0;
}


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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
#if loc||local
template<class T>void dump(T&& t){cerr<<t<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

template<class T,class F>
struct segment_tree{
  std::vector<T> data;
  int n;F f;T identity;
  segment_tree(){}
  segment_tree(int sz,T ide,F _f):f(_f),identity(ide){
    n=1;while(n<sz)n<<=1;
    data.resize(2*n,identity);
  }
  segment_tree(std::vector<T> const& v,T ide,F _f):f(_f),identity(ide){
    build(v);
  }
  void build(std::vector<T> const& v){
    int sz=v.size();
    n=1;while(n<sz)n<<=1;
    data.resize(2*n,identity);
    for(int i=0;i<sz;++i)data[i+n]=v[i];
    for(int i=n-1;i>0;--i)data[i]=f(data[i<<1|0],data[i<<1|1]);
  }
  void set(int i,T x){
    i+=n;data[i]=x;
    while(i,i>>=1)data[i]=f(data[i<<1|0],data[i<<1|1]);
  }
  T fold(int l,int r)const{
    l+=n,r+=n;
    T x=identity;
    while(l<r){
      if(l&1)x=f(x,data[l++]);
      if(r&1)x=f(x,data[--r]);
      l>>=1,r>>=1;
    }
    return x;
  }
  T operator[](int i)const{return data[i+n];}
};
template<class T,class F>
auto make_segtree(int n,T ide,F f){
  return segment_tree<T,F>(n,ide,f);
}
template<class T,class F>
auto make_segtree(std::vector<T>const& v,T ide,F f){
  return segment_tree<T,F>(v,ide,f);
}

signed main(){

  int n;
  cin>>n;
  vector<ll> a(n);
  cin>>a;

  auto seg = make_segtree<ll>(a,0,[](auto a,auto b){return a^b;});

  rep(i,n){
    cout<<(seg.fold(0,i)^seg.fold(i+1,n))<<" ";
  }
  cout<<endl;


}


Measured memory_bytes: 8984
#include <bits/stdc++.h> 
using namespace std;
int main()
{
    long long int a[5],i,ans=0,n;
    scanf("%lld",&n);
    for(i=0;i<5;i++)
    {
    scanf("%lld",&a[i]);
    }
    sort(a,a+5);
    if(n%a[0]!=0)
    ans=(n/a[0])+5;
    else
    ans=(n/a[0])+4;
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll=long long;
typedef pair<int,int> P;
const int INF=1e9;
int main(){
    string s;
    cin>>s;
    rep(i,1<<3){
        int sum=0;
        sum+=s[0]-'0';
        for(int j=1;j<4;j++){
            if(i>>(j-1)&1) sum+=s[j]-'0';
            else sum-=s[j]-'0';
        }
        if(sum==7){
            cout<<s[0];
            rep(j,3){
                if(i>>j&1) cout<<'+';
                else cout<<'-';
                cout<<s[j+1];
            }
            break;
        }
    }
    cout<<"=7";
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

int main()
{
	int n;
	cin >> n;
	vll a(n + 1, 0);
	for(int i = 1; i <= n; i ++)
		cin >> a[i];
	ll ans = 0;
	for(int i = 2; i <= n; i ++)
	{
		if(a[i] < a[i - 1])
		{
			ans += a[i - 1] - a[i];
			a[i] = a[i - 1];
		}
	}
	cout << ans;





	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

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

template <class T>
inline void read(T &x)
{
    x = 0;
    int f = 0;
    char ch = getchar();
    while (!isdigit(ch))    { f |= ch == '-'; ch = getchar(); }
    while (isdigit(ch))     { x = (x << 1) + (x << 3) + (ch ^ 48); ch = getchar(); }
    x = f ? -x : x;
    return;
}

int a, b;

int main()
{
    read(a), read(b);
    printf(a == b ? "Yes\n" : "No\n");
    return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
 
using namespace std;
 
int N;
int abc[3][100000];
int dp[3][100000];

int main()
{
    cin >> N;
    // Input
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 3; ++j) cin >> abc[j][i];
    }
    // Initial Values
    for (int i = 0; i < 3; ++i) dp[i][0] = abc[i][0];
    // DP
    for (int i = 1; i < N; ++i){
        dp[0][i] = max(dp[1][i-1] + abc[0][i], dp[2][i-1] + abc[0][i]);
        dp[1][i] = max(dp[0][i-1] + abc[1][i], dp[2][i-1] + abc[1][i]);
        dp[2][i] = max(dp[0][i-1] + abc[2][i], dp[1][i-1] + abc[2][i]);
    }
    
    cout << max({dp[0][N-1], dp[1][N-1], dp[2][N-1]}) << endl;
    
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a, b) ((a < b) ? a : b)
#define _max(a, b) ((a < b) ? b : a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a) ? 1 : -1)
#define SORT(v) sort(v.begin(), v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

int main() {
    cout << fixed << setprecision(10);
    string S,T;
    cin>>S>>T;
    int cnt=0;
    REP(i,3){
        if(S[i]==T[i])cnt++;
    }
    cout<<cnt;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)
#define max(a,b) (a < b ? b : a)
#define min(a,b) (a > b ? b : a)
#define AAA (1000000007)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;



ll gcd(ll a, ll b) {
	if (a < b) {
		ll t = a;
		a = b;
		b = t;
	}
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
}

ll lcm(ll a,ll b) {
	return a * b / gcd(a, b);
}

int main() {
	ll i, j, k;
	ll N, M, K;
	ll ans = 0;

	cin >> N >> M;
	if (N == M) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	
	
	return 0;

}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int h = sc.nextInt();
		int n = sc.nextInt();
		int[] arr = new int[n];
		long[] brr = new long[n];
		for(int i = 0; i < n; i++) {
			arr[i] = sc.nextInt();
			brr[i] = sc.nextInt();
		}
		long[] val = new long[h+1];
		Arrays.fill(val, Integer.MAX_VALUE);
		val[0] = 0;
		for(int i = 0; i < n; i++) {
			for(int j = 1; j <= Math.min(arr[i], h); j++) {
				val[j] = Math.min(val[j], brr[i]);
			}
			for(int j = 0; j+arr[i] <= h; j++) {
				val[j+(int)arr[i]] = Math.min(val[j+(int)arr[i]], val[j] + brr[i]);
			}
		}
		System.out.println(val[h]);
	}
	
	static class FastScanner {
		public BufferedReader reader;
		public StringTokenizer tokenizer;
		public FastScanner() {
			reader = new BufferedReader(new InputStreamReader(System.in), 32768);
			tokenizer = null;
		}
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch(IOException e) {
				throw new RuntimeException(e);
			}
		}
	}

}


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

using namespace std;
using ll = long long;

int main(void) {
	int w, h, n;
	scanf("%d %d %d", &w, &h, &n);
	int down = 0, up = h, left = 0, right = w;
	for (int i = 0; i < n; i++) {
		int x, y, a;
		scanf("%d %d %d", &x, &y, &a);
		if (a == 1) left = max(left, x);					
		else if (a == 2) right = min(right, x);
		else if (a == 3) down = max(down, y);
		else if (a == 4) up = min(up, y);
	}
	if (left >= right || up <= down)
		puts("0");
	else 
		printf("%d\n", (right - left) * (up - down));
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<ll, P> E;
#define cost first
#define from second.first
#define to second.second
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

int main(void){
	int r,g,b;
	cin >> r >> g >> b;
	cout << (((g*10+b)%4)?"NO":"YES") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
char c;
long long  a, b;
long long ans;
bool check()
{
    return a%b==0;
}
void solve()
{
    if (check())
        ans = -1;
    else
        ans = a*(b-1);
    return;
}
main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin >> a >> b;
    solve();
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<math.h>
#include<numeric>
#include<cassert>
#include<random>
#include<deque>
#include<chrono>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
const ll E=1e18+7;
#define F first
#define S second
#define MK make_pair

//無向
class Bridge{
private:
    typedef vector<vector<ll>> edge;
    edge E;
    ll v;
    vector<pll> count;
    
    ll dfs(ll w,ll depth,ll parent){
        if(count[w].F!=-1){return 1e18;}
        count[w]={depth,depth};
        bool p=true;
        for(int i=0;i<E[w].size();i++){
            if(E[w][i]==parent){
                if(!p){count[w].S=min(count[E[w][i]].F,count[w].S);}
                p=false;
            }
            else if(count[E[w][i]].F==-1){count[w].S=min(dfs(E[w][i],depth+1,w),count[w].S);}
            else{count[w].S=min(count[E[w][i]].F,count[w].S);}
        }
        return count[w].S;
    }
    
public:
    Bridge(ll v,edge e={}):v(v),E(e){
        E.resize(v);
        count.resize(v,{-1,-1});
    }
    
    void add_edge(ll from,ll to){
        E[from].push_back(to);
        E[to].push_back(from);
    }
    
    void search(){
        dfs(0,1,-1);
    }
    
    bool is_bridge(ll u,ll v){
        if(count[u].F==count[v].F){return false;}
        if(count[u].F>count[v].F){swap(u,v);}
        if(count[u].F>=count[v].S){return false;}
        return true;
    }
    
    vector<pll> bridge(){
        vector<pll> ret;
        for(int i=0;i<v;i++){
            for(int t=0;t<E[i].size();t++){
                if(i<E[i][t] && is_bridge(i,E[i][t])){ret.push_back({i,E[i][t]});}
            }
        }
        return ret;
    }
    
    void test(){
        for(int i=0;i<v;i++){
            cout<<"test "<<i<<" "<<count[i].F<<" "<<count[i].S<<endl;
        }
    }
};




int main(){
    ll v,e;
    cin>>v>>e;
    Bridge B(v);
    for(int i=0;i<e;i++){
        ll s,t;
        cin>>s>>t;
        B.add_edge(s,t);
    }
    B.search();
    vector<pll> b=B.bridge();
    sort(b.begin(),b.end());
    //B.test();
    for(int i=0;i<b.size();i++){
        cout<<b[i].F<<" "<<b[i].S<<endl;
    }
    
    return 0;
}



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

#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;
using ll = long long;
int mod = 1000000007;

void solve();

int main(void){
    int N; cin >> N;
    bool ok = true;
    int A[N];
    int X[N] = {}; //作業用配列
    rep(i, N){
        int a; cin >> a;
        if(a > i) ok = false;
        A[i] = a;
    }
    if(ok){
        //末尾から決めてく
        int idx = N-2;
        int highest_stair = N-1;
        ll ans = A[N-1];
        while(idx >= 0){
            //A[idx - A[idx]] = 0, A[idx - A[idx] + 1] = 1,...という階段を作る
            //位置iでこれまでに作られた最も高い階段の高さはA[highest_stair] - (highest_stair - i)
            //これ、不可能を弾くとなると実はhighest_stair = idx+1です
            int eval = A[idx+1] - 1;
            if(eval > A[idx]){
                cout << -1 << endl;
                return 0;
            }
            else if(eval < A[idx]){
                ans += A[idx];
            }
            highest_stair = idx;
            idx--;
        }
        cout << ans << endl;
    }
    else cout << -1 << endl;
    return 0;
}

void solve(){}

Measured memory_bytes: 1792
#include<iostream>
#include<queue>
#include<vector>
#include <cstdio>
#include <iomanip>

using namespace std;

const int MAX = 30 + 10;
const int MAX_V = 30 + 1;
const double INF = 100000000;

class Road {
public:
	int start;
	int end;
	int dist;
	int vLimit;

};

class State {
public:
	int from;
	int end;
	int v;
	double time;
	
	bool operator<(const State&s)const {
		return time > s.time;
	}
};

int changeV[3]{ -1, 0 ,1 };


int main() {
	int city_num;
	int road_num;

	while (cin >> city_num >> road_num) {
		if (!city_num && !road_num) return 0;
		int start;
		int end;
		cin >> start >> end;
		start--;
		end--;
		vector<Road> map[MAX];
		double cost[MAX][MAX][MAX_V];
		if (road_num == 0) {
			cout << "unreachable" << endl;
		}
		else {
			for (int i = 0; i < road_num; i++) {
				int from;
				int to;
				int dist;
				int vLimit;
				cin >> from >> to >> dist >> vLimit;
				from--;
				to--;
				Road temp;
				temp.start = from;
				temp.end = to;
				temp.dist = dist;
				temp.vLimit = vLimit;
				map[from].push_back(temp);
				temp.start = to;
				temp.end = from;
				map[to].push_back(temp);
			}

			for (int i = 0; i < MAX; i++) {
				for (int j = 0; j < MAX; j++) {
					for (int k = 0; k < MAX_V; k++) {
						cost[i][j][k] = INF;
					}
				}
			}

			priority_queue<State> que;
			State tmp;
			tmp.from = start;
			tmp.end = start;
			tmp.time = 0;
			tmp.v = 0;
			que.push(tmp);
			while (!que.empty()) {
				State temp = que.top();
				que.pop();	
				for (int i = 0; i < map[temp.end].size(); i++) {
					Road tp = map[temp.end][i];
					if (tp.end != temp.from) {
						for (int j = 0; j < 3; j++) {
							int nowV = temp.v + changeV[j];
							if (nowV > 0 && nowV <= tp.vLimit) {
								if (temp.time + (double)tp.dist / nowV < cost[tp.start][tp.end][nowV]) {
									cost[tp.start][tp.end][nowV] = temp.time + (double)tp.dist / nowV;
									State tpp;
									tpp.from = tp.start;
									tpp.end = tp.end;
									tpp.v = nowV;
									tpp.time = cost[tp.start][tp.end][nowV];
									que.push(tpp);
								}
							}
						
						}
					}
				}
			}


			double result = INF;
			for (int i = 0; i < city_num; i++) {
				result = min(result, cost[i][end][1]);
			}

			if (result == INF) {
				cout << "unreachable" << endl;
			}
			else
				cout <<fixed<<setprecision(5)<< result << endl;
		}
	}



}


Measured memory_bytes: 3936
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define ms(a,b) memset(a,b,sizeof(a))
#define msn(a,n,b) for(int i=0;i<=n;i++)a[i]=b
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define fi first
#define se second
using namespace std;
mt19937 rng_32(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef double db;
const int mod=998244353;
const int seed=233;
const double PI=acos(-1.0);
const double eps=1e-7;
const int inf=0x3f3f3f3f;
const int max_n=3005;
ll ceil(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?(x+y-1)/y:-x/y;}
ll floor(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?x/y:-(x+y-1)/y;}
char str[max_n];
void reads(string& s){scanf(" %s",str);s=str;}
namespace {
    inline int Add(int x,int y){return (x+=y)>=mod?x-mod:x;}
    inline int Sub(int x,int y){return (x-=y)<0?x+mod:x;}
    inline int Mul(int x,int y) {return 1ll*x*y%mod;}
    inline int Pow(int x,int y=mod-2){int res=1;while(y){if(y&1)res=1ll*res*x%mod;x=1ll*x*x%mod;y>>=1;}return res;}
}
/**********************head************************/
int n,s,a[max_n];
int dp[max_n];
int inv2=Pow(2,mod-2);
int main(){
    scanf("%d%d",&n,&s);
    for(int i=1;i<=n;i++)scanf("%d",a+i);
    dp[0]=1;
    for(int i=1;i<=n;i++){
        for(int j=s;j>=a[i];j--){
            dp[j]=Add(dp[j],Mul(inv2,dp[j-a[i]]));
        }
    }
    printf("%d\n",Mul(dp[s],Pow(2,n)));
    return 0;
}

Measured memory_bytes: 3860
#include <iostream>

using namespace std;

int main()
{
  int t,n;
  int s,f;
  int sum;

  while(1){
    sum = 0;
    cin>>t;

    if(t == 0){
      break;
    }

    cin>>n;

    for(int i = 0;i < n;++i){
      cin>>s>>f;
      sum += f - s;
    }

    if(sum>=t){
      cout<<"OK"<<endl;
    }
    else{
      cout<<t - sum<<endl;
    }
  }
  return 0;
}

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

int main(){
  string s;
  string c, p = "";
  int ans = 0;
  
  cin >> s;
  for(int i  = 0; i < s.size(); i++){
    c += s[i];
    if(c == p){
      continue;
    }else{
      p = c;
      c = "";
      ans++;
    }
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 640
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#define _GLIBCXX_DEBUG // check []
#define DIVISOR 1000000007

using namespace std;
typedef pair<int,int> pii;
typedef pair<int64_t, int64_t> pII;

template<typename T>
void cins(vector<T>& arr) { for(T& e: arr) cin >> e; }

#ifdef DEBUG
#define debug(fmt, ...) \
    printf("[debug: %s] " fmt, __func__, __VA_ARGS__)
#define ps(arr) \
    debug("size %ld: ", arr.size()); \
    for(auto e: arr) cout << e << " "; \
    cout << endl;
#else
#define debug(fmt, ...)
#define ps(arr)
#endif

#define _x first
#define _y second
int main(void) {
    int num;
    cin >> num;
    vector<pii> points(num);
    for(int i = 0; i < num; i++) {
        int x, y;
        cin >> x >> y;
        points[i] = make_pair(x, y);
    }

    map<pii, vector<pii>> map;
    for(int i = 0; i < num; i++) {
        for(int j = i+1; j < num; j++) {
            pii p = make_pair(
                points[j]._x - points[i]._x,
                points[j]._y - points[i]._y
            );
            pii pinv = make_pair(-p._x, -p._y);
            map[p].push_back(make_pair(i, j));
            map[pinv].push_back(make_pair(i, j));
        }
    }

    int mmax = 0;
    for(auto pair: map) {
        debug("[%d, %d] -> %ld\n", pair.first._x, pair.first._y, pair.second.size());
        // pair.second.size(): edges
        mmax = max((int)pair.second.size(), mmax);
    }
    cout << num-mmax << endl;
    return 0;
}

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

int main()
{
    int n,m; cin >> n >> m;
    vector<int> l(m),r(m);
    rep(i,m) {
        cin >> l[i] >> r[i];
    }
    sort(l.rbegin(),l.rend()); sort(r.begin(),r.end());

    int x = min(r[0],n);

    if (x - l[0] < 0) {
        cout << 0 << endl;
    } else {
        cout << x - l[0] + 1 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1024
import itertools
import math
import fractions
import functools
import copy
n, q = map(int, input().split())
s = input()
l = []
r = []
for i in range(q):
    li, ri = map(int, input().split())
    li -= 1
    ri -= 1
    l.append(li)
    r.append(ri)

count_list = [0] * n
amount = 0
for i in range(1, n):
    if s[i-1] == "A" and s[i] == "C":
        amount += 1
        count_list[i] = amount
    else:
        count_list[i] = amount


count = 0


for i in range(q):
    print(count_list[r[i]]-count_list[l[i]])


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

const ll maxs = 2e5+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'

void pre(){
    
}

void solve(){
    
    ll n;
    cin >> n;
    map<ll,ll> MAP;
    ll ans=0;
    for(ll i=1;i<=n;i++){
        ll val;
        cin >> val;
        //ans += MAP[val-i];
        ans += MAP[i-val];
        MAP[i+val]++;
    }
    cout << ans;
}

int main(){
    IOS;
    pre();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

Measured memory_bytes: 26352