akhauriyash/Code-Regression huggingface dataset:
from bisect import bisect_left
import sys
input = sys.stdin.readline

a, b, q = map(int, input().split())
INF = 10**12
s = [-INF] + [int(input()) for i in range(a)] + [INF]
t = [-INF] + [int(input()) for i in range(b)] + [INF]


for _ in range(q):
    x = int(input())
    k = bisect_left(s, x)
    l = bisect_left(t, x)
    sm = x - s[k - 1]
    sM = s[k] - x
    tm = x - t[l - 1]
    tM = t[l] - x
    ans = min(2 * sm + tM, 2 * sM + tm, 2 * tm + sM, 2 * tM + sm, max(sm, tm), max(sM, tM))
    print(ans)


Measured memory_bytes: 96300
#include<stdio.h>

#define mod 1000000007

long long ru2(int a){
	long long r=1;
	for(int i=0;i<a;i++){
		r*=2;
		r%=mod;
	}
	return r;
}

int main(){
	int i,n;
	char l[100102];
	scanf("%s",l);
	for(i=0;l[i]!=0;i++);
	n=i;
	long long dp[100101]={1},dps[100101]={1};
	for(i=1;i<100010;i++){
		dp[i]=dp[i-1]*3;
		dp[i]%=mod;
		dps[i]=dp[i-1]*2;
		dps[i]%=mod;
	}
	long long ans=dp[n-1];
	int list[100101]={0},c=0;
	for(i=0;i<n;i++){
		if(l[i]=='1')list[c++]=n-i;
	}
//	list[c++]=0;
	long long am=2;
	for(i=c-1;i>=1;i--){
		am+=dp[list[i]-1];
		am*=2;
		am%=mod;
	}
	ans+=am;
	ans%=mod;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1408
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func geti() int {
	n, _ := strconv.Atoi(read())
	return n
}

// 10 11 12 => [10, 11, 12]
func getli(size int) []int {
	a := make([]int, size)
	list := strings.Split(read(), " ")
	for i, s := range list {
		n, _ := strconv.Atoi(s)
		a[i] = n
	}
	return a
}

func get2byte(size int) [][]byte {
	a := make([][]byte, size)
	for i := 0; i < size; i++ {
		var low string
		fmt.Scan(&low)
		a[i] = []byte(low)
	}
	return a
}

func transpose(a [][]int) {
	n := len(a)
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			a[i][j], a[j][i] = a[j][i], a[i][j]
		}
	}
}

func main() {
	n := geti()
	dict := map[string]struct{}{}
	for i := 0; i < n; i++ {
		dict[read()] = struct{}{}
	}
	fmt.Println(len(dict))
}


Measured memory_bytes: 14972
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cctype>
using namespace std;
typedef long long lint;
#define cout cerr
#define ni (next_num<int>())
template<class T>inline T next_num(){
	T i=0;char c;
	while(!isdigit(c=getchar())&&c!='-');
	bool neg=c=='-';
	neg?c=getchar():0;
	while(i=i*10-'0'+c,isdigit(c=getchar()));
	return neg?-i:i;
}
template<class T1,class T2>inline void apmax(T1 &a,const T2 &b){if(a<b)a=b;}
template<class T1,class T2>inline void apmin(T1 &a,const T2 &b){if(b<a)a=b;}
template<class T>inline void mset(T a,int v,int n){memset(a,v,n*sizeof(a[0]));}
const int N=310;
int O;
namespace gmath{
	int c[N][N];
	inline void main(int n){
		memset(c,0,sizeof(c));
		for(int i=0;i<=n;i++){
			c[i][0]=1;
			for(int j=1;j<=i;j++){
				c[i][j]=(c[i-1][j-1]+c[i-1][j])%O;
			}
		}
	}
}
using gmath::c;
int n;
int f[N],g[N];
inline void dp_exp(){//g=exp(f)
	g[0]=1;
	assert(f[0]==0);
	for(int i=1;i<=n;i++){
		int &ans=g[i]=0;
		for(int j=1;j<=i;j++){
			ans=(ans+(lint)f[j]*g[i-j]%O*c[i-1][j-1])%O;
		}
	}
}
int main(){
	n=ni;
	int tot=ni;
	O=ni;
	gmath::main(n);
	mset(f,0,n+1);
	for(;tot--;){
		dp_exp();
		for(int i=1;i<=n;i++){
			f[i]=(f[i]+g[i-1])%O;
		}
	}
	dp_exp();
	printf("%d\n",g[n]);
	return 0;
}


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

int main() {
	int N, M;
	cin >> N;
	vector<string> vec(N);
	vector<int> count(N,0);
	int idx = 0;

	for (int i = 0; i < N; i++) {
		string tmp;
		cin >> tmp;
		bool isin = false;
		for (int j = 0; j < idx; j++) {
			if (tmp == vec.at(j)) {
				count.at(j)++;
				isin = true;
			}
		}
		if (!isin) {
			vec.at(idx) = tmp;
			count.at(idx) = 1;
			idx++;
		}
	}

	cin >> M;
	int ans = 0;

	for (int i = 0; i < M; i++) {
		string tmp;
		cin >> tmp;

		for (int j = 0; j < idx; j++) {
			if (tmp == vec.at(j)) {
				count.at(j)--;
			}
		}

	}

	for (int i = 0; i < N; i++) {
		if (ans < count.at(i)) {
			ans = count.at(i);
		}
	}
	cout << ans << endl;
}

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

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

	ll N,K;
	//ll now=1;
	ll now=0;
	ll prev=0;
	int i;

	cin >> N >> K;

	vector<int> gv(N);
	rep(i,N) cin >> gv[i];

	//for(i=0;i<K;i++) now*=gv[i];
	for(i=0;i<K;i++) now+=gv[i];

	for(i=K-1;i<N-1;i++){
		prev=now;
		//cout << prev << endl;
		//now=(prev/gv[i-(K-1)]) * gv[i+1];
		now=(prev-gv[i-(K-1)]) + gv[i+1];

		if(prev<now)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
	//cout << now << endl;

	return 0;
}



Measured memory_bytes: 3984
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int N, T; cin >> N >> T;
    vector<int> A(N+1, 0), B(N+1, 0);
    repr(i, 1, N+1) cin >> A[i] >> B[i];

    vector<vector<int>> dpleft(N+5, vector<int>(T+10, 0)), dpright(N+5, vector<int>(T+10, 0));

    repr(i, 1, N+1) rep(j, T){
        // not use
        chmax(dpleft[i][j], dpleft[i-1][j]);
        // use
        if(j-A[i]>=0) chmax(dpleft[i][j], dpleft[i-1][j-A[i]]+B[i]);
    }

    reprrev(i, 1, N+1) rep(j, T){
        // not use
        chmax(dpright[i][j], dpright[i+1][j]);
        // use
        if(j-A[i]>=0) chmax(dpright[i][j], dpright[i+1][j-A[i]]+B[i]);
    }

    int ans = 0;
    repr(l, 1, N+1){
        rep(i, T) chmax(ans, B[l] + dpleft[l-1][i] + dpright[l+1][T-1-i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 71168
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = sc.nextInt() - 1;
		int y = sc.nextInt() - 1;
		int[] result = new int[n];
		for(int i=0; i<n; i++){
			int[] ary = bfs(i, n, x, y);
			for(int j: ary){
				result[j] += 1;
			}
		}
		for(int i=1; i<n; i++){
			System.out.println(result[i]/2);
		}
	}
	
	static int[] bfs(int vertex, int n, int x, int y) {
		// キューを用意
		ArrayDeque<Integer> dq = new ArrayDeque<>();
		dq.add(vertex);
		int[] moves = new int[n];
		Arrays.fill(moves, -1);
		// スタート地点を探索済みにする。
		moves[vertex] = 0;
		while (dq.size() > 0) {
			Integer nowVertex = dq.removeFirst();
			if(nowVertex-1 != -1 && moves[nowVertex-1] == -1) {
				dq.add(nowVertex-1);
				moves[nowVertex-1] = moves[nowVertex] +1;
			}
			if(nowVertex+1 != n && moves[nowVertex+1] == -1) {
				dq.add(nowVertex+1);
				moves[nowVertex+1] = moves[nowVertex] +1;
			}
			if(nowVertex == x && moves[y] == -1) {
				dq.add(y);
				moves[y] = moves[nowVertex] +1;
			}
			if(nowVertex == y && moves[x] == -1) {
				dq.add(x);
				moves[x] = moves[nowVertex] +1;
			}
		}
		return moves;
	}
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

const int MAX_N = 1010;
double x[MAX_N];
double y[MAX_N];
double r[MAX_N];

double dist[MAX_N][MAX_N];


double memo[MAX_N];
struct State {
  double d;
  int pos;
  bool operator < (const State &o) const {
    return d > o.d;
  }
};


int main2() {
  cin >> x[0] >> y[0] >> x[1] >> y[1];
  r[0] = 0;
  r[1] = 0;
  int N; cin >> N;
  REP(i, N) {
    cin >> x[i+2] >> y[i+2] >> r[i+2];
  }
  
  N += 2;
  REP(i, N) {
    REP(j, N) {
      double d = hypot(x[i] - x[j], y[i] - y[j]);
      d = max(d - r[i] - r[j], 0.0);
      dist[i][j] = d;
    }
  }

  const double EPS = 1e-10;
  REP(i, MAX_N) memo[i] = 1e18;
  priority_queue< State > pq;
  pq.push( (State){0, 0} );
  memo[0] = 0;

  while (!pq.empty()) {
    auto cur = pq.top(); pq.pop();
    if (cur.d > memo[cur.pos] + EPS) continue;
    REP(i, N) {
      double nd = cur.d + dist[cur.pos][i];
      if (memo[i] > nd) {
        memo[i] = nd;
        pq.push((State){nd, i});
      }
    }
  }
  printf("%.10f\n", memo[1]);
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 13680
//#include <bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<cstring>
#include<bitset>
#include<stack>

#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define ALL(x) x.begin(),x.end()
#define mst(var,val) memset(var,val,sizeof(var))
#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ls rt<<1
#define rs rt<<1|1
#ifdef local
#define dbg(a) cout << #a": " << a << endl;
#else
#define dbg(a)
#endif // loacl


using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <double, double> pdd;
const ll inf=0x3f3f3f3f;
const long long INF=0x3f3f3f3f3f3f3f3fLL;
const double PI=acos(-1.0);
const long double eps=1e-6;
const int mod=1e9+7;
const int maxn=20;
const int N=1e6+10;
const int M=N<<1;
const ll mm=(1LL<<32);

template <class T>
inline void read(T &x) {
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar()) f ^= c == '-';
    for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x) {
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    T y = 1;
    int len = 1;
    for (; y <= x / 10; y *= 10) ++len;
    for (; len; --len, x %= y, y /= 10) putchar(x / y + 48);
}
ll qpow(ll a,ll b,ll MOD)
{
    ll ans=1;
    while(b)
    {
        if(b&1) ans=(ans*a)%MOD;
        b>>=1;
        a=(a*a)%MOD;
    }
    return ans;
}


int main()
{
#ifdef local
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
#endif // local
    string s,t;
    cin>>s>>t;
    int cnt=0;
    for(int i=0;i<s.size();++i) if(s[i]==t[i]) cnt++;
    cout<<cnt;
}



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

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

  vector<int> prefix_sum;
  prefix_sum.push_back(1);

  int maxv = 1;
  for (int i = 2;; i++) {
    int last = prefix_sum.back();
    prefix_sum.push_back(last + i);
    if(prefix_sum.back() >= n) {
      maxv = i;
      break;
    }
  }
  int num = prefix_sum.back() - n;
  for (int i = 1; i <= maxv; i++) {
    if(i == num) continue;

    cout << i << '\n';
  }
  return 0;
}

Measured memory_bytes: 3540
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define BIT(n) (1LL << (n))
#define INF 2e9
#define MOD (1000000007)
#define EPS 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long long int lli;
lli B[100][2];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  lli N, K;
  cin >> N >> K;

  vector< lli > A(N);
  K++;
  lli maxK = floor(log2(K)) + 1;
  REP(i, N) { cin >> A[i]; }

  lli maxD = -1;
  REP(i, N) {
    lli j = 0;
    for (; BIT(j) <= A[i]; j++) {
      if (BIT(j) & A[i])
        B[j][1]++;
    }
    maxD = max(maxD, j);
  }
  lli maxDig = max(maxD, maxK);

  vector< lli > ansSum(maxDig + 1);

  REP(i, maxDig) { B[i][0] = N - B[i][1]; }
  ansSum[0] = 0;
  REPS(i, maxDig) {
    ansSum[i] = ansSum[i - 1] + (max(B[i - 1][0], B[i - 1][1]) << (i - 1));
  }
  lli initVal = 0;

  /*  REPR(i, maxDig - 1) { cout << B[i][0] << " "; }
   cout << endl;
   REPR(i, maxDig - 1) { cout << B[i][1] << " "; }
   cout << endl;
   REPR(i, maxDig) { cout << ansSum[i] << " "; }
   cout << endl;
 */
  if (maxK <= maxD) {
    FOR(i, maxK, maxD) { initVal += B[i][1] << i; }
  }

  lli ansVal = 0;
  lli tmp = 0;
  REPR(i, maxK - 1) {
    if (BIT(i) & K) {
      // 0とする。
      ansVal = max(ansVal, tmp + (B[i][1] << i) + ansSum[i]);
      tmp += B[i][0] << i;
    } else {
      tmp += B[i][1] << i;
    }
  }

  cout << initVal + ansVal << "\n";
}

Measured memory_bytes: 1024
package main

import (
	"fmt"
	"sort"
)

type ll int64

type job struct {
	deal_time int
	end_time int
}

type ByEND []job

func (a ByEND) Len() int           { return len(a) }
func (a ByEND) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
//昇順ソート,　降順ソートにするには不等号を逆にする
func (a ByEND) Less(i, j int) bool { return a[i].end_time < a[j].end_time }

func main() {

	var N int
	fmt.Scan(&N)

	job_slice := make([]job,N)

	var a int = 0
	var b int = 0
	var i int = 0
	for i=0;i<N;i++{
		fmt.Scan(&a,&b)
		job_slice[i].deal_time = a
		job_slice[i].end_time = b
	}
	//代入まではok

	//sort
	sort.Sort(ByEND(job_slice))

	//calc
	var time int = 0
	flag := true
	for k:=0;k<N ;k++  {
		time += job_slice[k].deal_time
		if time > job_slice[k].end_time {
			flag = false
			break
		}
	}

	//out
	if flag {
		fmt.Println("Yes")
	}else {
		fmt.Println("No")
	}



}



Measured memory_bytes: 9728
#include<bits/stdc++.h>
using namespace std;
int n,len[555],st[555],period[555];
int main(){
	scanf("%d",&n);--n;
	for(int i=0; i<n; i++)
		scanf("%d%d%d",&len[i], &st[i], &period[i]);
	for(int i=0; i<n; i++){
		int cur = st[i] + len[i];
		for(int j=i+1; j<n; j++){
			if(cur < st[j])cur = st[j];else
			while(cur % period[j] != 0)cur++;
			cur += len[j];
		}
		printf("%d\n",cur);
	}
	printf("0\n");
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

void swap(int array[], int a, int b){
	int c;
	c = array[a];
	array[a] = array[b];
	array[b] = c;
}

int main(){
	int array[50];
	int w,n,a,b;

	for(int i=0 ; i<50 ; i++){
		array[i] = i;
	}
	
	scanf("%d", &w);
	scanf("%d", &n);
	for(int i=0 ; i<n ; i++){
		scanf("%d,%d", &a, &b);
		swap(array,a,b);
	}
	for(int i=1 ; i<=w ; i++){
		printf("%d\n", array[i]);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
 
using namespace std;
 
#define xx         first
#define yy         second
#define pb         push_back
#define mp         make_pair
#define LL         long long
#define inf        INT_MAX/3
#define mod        1000000007ll
#define PI         acos(-1.0)
#define linf       (1ll<<60)-1
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define REP(I,N)   FOR(I,0,N)
#define For(I,N)   for(int I=1;I<=(N);I++)
#define ALL(A)     ((A).begin(), (A).end())
#define set0(ar)   memset(ar,0,sizeof ar)
#define vsort(v)   sort(v.begin(),v.end())
#define setinf(ar) memset(ar,126,sizeof ar)
#define SZ(X) ((int)(X.size()))
#define LG(X) ((int)(X.length()))
#define CL(X) (X).clear()
#define MAXEL(A,B) (*max_element(A,B))
#define MINEL(A,B) (*min_element(A,B))
#define ROPEN(X) freopen(X,"r",stdin)
#define WOPEN(X) freopen(X,"w",stdout)
#define BG(X) (X.begin())
#define EN(X) (X.end())
#define VI vector<int>
#define PII pair<int,int>
 
//cout << fixed << setprecision(20) << p << endl;
 
template <class T> inline T bigmod(T p,T e,T M){
    LL ret = 1;
    for(; e > 0; e >>= 1){
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n;
	cin>>n;
	int cnt=0;
	for(int i=1;i<=n;i*=100){
		int v=min(i*10-1,n);
		cnt+=v-i+1;
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 256
from sys import stdin

lines = stdin.readlines()
N, D = map(int, lines[0].split())
X = [[int(j) for j in lines[i].split()] for i in range(1, N + 1)]
ans = 0
for i in range(N):
    for j in range(i + 1, N):
        acum = 0.0
        for k in range(D):
            acum += (X[j][k] - X[i][k]) ** 2
        if float.is_integer(acum ** 0.5):
            ans += 1
print(ans)


Measured memory_bytes: 3188
k, n = map(int, input().split())
a_array = map(int, input().split())
first_a = a_array.__next__()
forward_a = first_a
max_length = 0
for i in range(n - 1):
    a = a_array.__next__()
    max_length, forward_a = max(max_length, a - forward_a), a
print(k-max(max_length, k - a + first_a))


Measured memory_bytes: 19508
#include <bits/stdc++.h>
using namespace std;
int main() {
        int n, m;
        cin >>n >> m;
        int nm = 1;
        int mm = m;
        while (mm) {
                nm *= 10;
                mm /= 10;
        }
        n = (n * nm) + m;
        int sq = sqrt(n);
        if (sq*sq == n) {
                cout << "Yes";
        } else
                cout << "No";
        return 0;
}


Measured memory_bytes: 256
fun main (args:Array<String>) {
    val material = readLine()!!.toInt()
    val value = readLine()!!.split(" ").map(String::toInt).sorted()
    var ans = value[0].toDouble()
    for(i in 1..material-1){
        ans = (ans + value[i]) / 2.toDouble()
    }
    println(ans)
}

Measured memory_bytes: 38984
import sys
import numpy as np
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
X, Y, A, B, C = [int(x) for x in input().strip().split()]
p = np.array(sorted([int(x) for x in input().strip().split()], reverse=True))[:X]
q = np.array(sorted([int(x) for x in input().strip().split()], reverse=True))[:Y]
r = np.array(sorted([int(x) for x in input().strip().split()], reverse=True))[:min(C, X+Y)]

pq = np.hstack((p, q))
pq.sort()
ri = 0
for i, t in enumerate(pq):
    if t < r[ri]:
        pq[i] = r[ri]
        ri += 1
    if ri == len(r):
        break
print(sum(pq))

Measured memory_bytes: 24972
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <bitset>
#include <complex>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef complex<double> CD;

int main() {
	while (true) {
		int n; cin >> n;
		if (n == 0)break;

		int maxp, maxd = 0;
		rep(i, n) {
			int p, d1, d2; cin >> p >> d1 >> d2;
			if (maxd < d1 + d2) {
				maxp = p;
				maxd = d1 + d2;
			}
		}
		Cout2(maxp, maxd);
	}
}


Measured memory_bytes: 3108
n = int(input())
a1 = [int(x) for x in input().split()]
a2 = [int(x) for x in input().split()]

ans = 0
for k in range(n):
    tmp = 0
    for i in range(n):
        if (i <= k):
            tmp += a1[i]
        if (i >= k):
            tmp += a2[i]
    if tmp > ans:
        ans = tmp

print(ans)


Measured memory_bytes: 3060
N = int(input())
A = [int(x) for x in input().split()]

mn, mx = min(A), max(A)

def op(x, y):
    print(x, y)
    print(x, y)
    A[y - 1] += A[x - 1]
    A[y - 1] += A[x - 1]

print(N * 2)
if abs(mn) < abs(mx):
    base = mx
    bi = A.index(base) + 1
    op(bi, 1)
    for i in range(N-1):
        op(i+1, i+2)
else:
    base = mn
    bi = A.index(base) + 1
    op(bi, N)
    for i in range(N, 1, -1):
        op(i, i-1)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(a) cerr << #a << ": " << a << endl
#define sz(a) int(a.size())
#define rep(i,n) for(int i=0;i<n;i++)
#define forr(i, st, en) for(int i = st; i <= en; i++)
#define all(v) (v).begin(),(v).end()
#define X first
#define Y second
#define pb push_back
#define fast cin.tie(0); ios::sync_with_stdio(false)

int32_t main(){ fast;
	int cnt = 0, l, r, d; cin>>l>>r>>d;
	for(int i = l; i <= r; i++)
		if(i % d == 0)
			cnt++;
	cout<<cnt<<endl;
}
	


Measured memory_bytes: 3588
N = int(input())
a = list(map(int,input().split()))
odd = 0
even = 0
temp = 0
for i in range(N):
    temp += a[i]
    if i % 2 == 0:
        # 奇数番目が正
        if temp < 1:
            odd += 1-temp
            temp = 1
    else:
        if temp > -1:
            odd += 1 + temp
            temp = -1
                   
temp = 0
for i in range(N):
    temp += a[i]
    if i % 2 == 0:
        # 奇数番目が負
        if temp > -1:
            even += 1 + temp
            temp = -1     
    else:
        if temp < 1:
            even += 1-temp
            temp = 1
print(min(odd,even))

Measured memory_bytes: 14468
#include "bits/stdc++.h"
using namespace std;

class Bridge {
public:
	vector<vector<int>> G;
	vector<int> ord, low;
	vector<pair<int, int>> bridges;
	int k;

	Bridge(int N) :k(0) {
		G.resize(N); ord.resize(N, -1); low.resize(N, -1);
	}
	void clear() { G.clear();ord.clear();low.clear(); }
	void add_edge(int s, int t) {
		G[s].emplace_back(t);
		G[t].emplace_back(s);
	}

	bool is_bridge(int u, int v)const {
		if (ord[u] > ord[v])swap(u, v);
		return ord[u] < low[v];
	}

	/* Lowlink */
	void dfs(int u, int rev = -1) {
		ord[u] = low[u] = k;
		k++;
		for (auto v : G[u]) {
			if (v == rev)continue;
			if (ord[v] < 0) {
				dfs(v, u);
				low[u] = min(low[u], low[v]);
			}
			else {
				low[u] = min(low[u], ord[v]);
			}
			if (is_bridge(u, v)) {
				int s = u, t = v;
				if (s > t) swap(s, t);
				bridges.push_back({ s,t });
			}
		}
	}

	void solve() {
		dfs(0);
		sort(bridges.begin(), bridges.end());
	}
};

int main() {
	int N, M; cin >> N >> M;
	Bridge B(N);
	for (int i = 0; i < M;i++) {
		int a, b; cin >> a >> b;
		a--; b--;
		B.add_edge(a, b);
	}
	B.solve();
	cout << B.bridges.size() << endl;
}

Measured memory_bytes: 256
'''input
10 2
7 6 18 6 16 18 1 17 17
6 9 3 10 9 1 10 1 5
'''
# A coding delight
from sys import stdin, stdout
import gc
gc.disable()
 
import sys, time, threading


	
# main starts
string = stdin.readline().strip()
i = 0
j = len(string) - 1
count = 0
while i < j:	
	if string[i] != string[j]:
		count += 1
	i += 1
	j -= 1
print(count)

Measured memory_bytes: 3940
s=0
s=input().split()
a=s[0]
b=s[1]
if a=="A":
    a=10
if a=="B":
    a=11
if a=="C":
    a=12
if a=="D":
    a=13

if a=="E":
    a=14
if a=="F":
    a=15

if b=="A":
    b=10
if b=="B":
    b=11
if b=="C":
     b=12
if b=="D":
    b=13

if b=="E":
     b=14
if b=="F":
     b=15

if a>b:
    print(">")
if b>a:
    print("<")
if a==b:
    print("=")
    


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

using namespace std;
using LL = long long;

constexpr int N = 1e5 + 5;

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

    int n;
    cin >> n;

    int minn = n;
    int result = 0;

    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        minn = min(x, minn);
        if (minn >= x) result++;
    }

    cout << result << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
s = [0]*(n+1)
for i in range(n):
  s[i+1] += s[i] + a[i]
from collections import Counter
c = Counter(s)
ans = 0
for k, v in c.items():
  ans += v*(v-1)//2
print(ans)

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

namespace ITP1_3C
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                String[] inNumberString = Console.ReadLine().Split(' ');
                int inNumberX = int.Parse(inNumberString[0]);
                int inNumberY = int.Parse(inNumberString[1]);

                if ((inNumberX == 0) && (inNumberY == 0)) break;

                if (inNumberX <= inNumberY) Console.WriteLine(inNumberX + " " + inNumberY);
                else Console.WriteLine(inNumberY + " " + inNumberX);
            }
        }
    }
}

Measured memory_bytes: 9240
#include<bits/stdc++.h> 
using namespace std;
int N,h[100001]={0};
int main()
{
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout); 
    cin>>N;
	for(int i=1;i<=N;i++)
	{
		cin>>h[i];
		if(h[i]>h[i-1])	h[i]--;
		if(h[i]==h[i-1])	continue;
		if(h[i]<h[i-1])
		{
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 640
// std input
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),*  )) => {
        ( $(read_value!($iter, $t)),*  )
    };
    ($iter:expr, [ $t:tt ; $len:expr  ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn sub() -> String
{
    input!
    {
        t1: i32,
        t2: i32,
        r1: i32,
        r2: i32,
    }
    if r1 < 0 || r2 < 0 {
        if t1 < t2 {
            "Alice".to_string()
        }
        else if t1 > t2 {
            "Bob".to_string()
        }
        else {
            "Draw".to_string()
        }
    }
    else if r1 > r2 {
        "Alice".to_string()
    }
    else if r1 < r2 {
        "Bob".to_string()
    }
    else {
        "Draw".to_string()
    }
}

fn main()
{
    println!("{}", sub());
}


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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if(a < b){
        if (b < c){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }

    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(v) v.begin(), v.end()
#define mod 1000000007
#define mod2 1000000006
#define inf 1000000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<lli>
#define vii vector<int>
#define is indexed_set
#define eps 0.000001
#define endl '\n'
#define mo 998244353
#define pi 3.141592653589793
#define FF first
#define SS second
using namespace std ;
 
const lli dx4[] = {-1, 0, 1, 0};
const lli dy4[] = {0, 1, 0, -1};
const lli dx8[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const lli dy8[] = {0, 1, 0, -1, -1, 1, -1, 1};
 
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count()); // can give negative values too

#define N 100001

lli power(lli x, lli y, lli p) 
{ 
    lli res = 1;   
    x = x % p;  
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
  
        y = y>>1;  
        x = (x*x) % p;   
    } 
    return res; 
}

lli find(lli x)
{
    lli ans=0;
    while(x > 0)
    {
        lli cnt=0;
        for(lli i=0;i<=18;i++)
        {
            if(x&(1<<i)) cnt++;
        }

        x = x%cnt;
        ans++;
    }
    return ans;
}

void solve()
{
    lli n;
    cin>>n;
    string s;
    cin>>s;

    lli cnt=0,sum=0;
    
    loopl(i,0,n)
    {
        if(s[i] == '1') cnt++;
    }

    lli mn=0,plus=0;

    loopl(i,0,n)
    {
        if(cnt > 1)
        {
            mn = mn*2 + (s[i]=='1');
            mn %= (cnt-1);
        }

        if(cnt <= n)
        {
            plus = plus*2 + (s[i]=='1');
            plus %= (cnt+1);
        }
    }

   // cout<<mn<<endl;
    lli ans[n];

    loopl(i,0,n)
    {
        if(s[i] == '1' && cnt == 1)
        {
            ans[i] = -1;
            continue;
        }

        if(s[i] == '0')
        {
            ans[i] = (plus + power(2,n-1-i,cnt+1))%(cnt+1);
        }

        else
        {
            ans[i] = (mn - power(2,n-1-i,cnt-1) + (cnt-1))%(cnt-1);
        }
    }

    // loopl(i,0,n) cout<<ans[i]<<" ";
    // cout<<endl;


    loopl(i,0,n) 
    {
        if(ans[i] == -1) 
        {
            cout<<0<<endl;
            continue;
        }

        cout<<1+find(ans[i])<<endl;
    }


}

int main()
{
////////////////////////////////////////////   
    fastio;
////////////////////////////////////////////
    
    lli t;
    t=1;
    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 5336
n = int(input())
time = 0
d = [list(map(int, input().split())) for i in range(n-1)]
for i in range(n-1):
    j = i
    time = 0
    while j < n-1:
        m = -((-max(0, time-d[j][1]))//d[j][2])
        time = d[j][1] + d[j][2]*m + d[j][0]
        j += 1
    print(time)
print(0)

Measured memory_bytes: 3188
#include <iostream>
#include <string>

using namespace std;

int main()
{
	int s, t, u, d, w, h;
	string str;
	
	while(1){
		cin >> w >> h;
		if(w == 0 && h == 0){
			break;
		}
		s = t = 1;
		d = 0;
		while(1){
			cin >> str;
			if(str == "STOP"){
				break;
			} else if(str == "FORWARD"){
				cin >> u;
				if(d == 0){
					s+=u;
				} else if(d == 1){
					t+=u;
				} else if(d == 2){
					s-=u;
				} else {
					t-=u;
				}
			} else if(str == "RIGHT"){
				d++;
				if(d == 4){
					d = 0;
				}
			} else if(str == "LEFT"){
				d--;
				if(d < 0){
					d = 3;
				}
			} else if(str == "BACKWARD"){
				cin >> u;
				if(d == 0){
					s-=u;
				} else if(d == 1){
					t-=u;
				} else if(d == 2){
					s+=u;
				} else {
					t+=u;
				}
			}
			if(s < 1){
				s = 1;
			} else if(s > h){
				s = h;
			} else if(t < 1){
				t = 1;
			} else if(t > w){
				t = w;
			}
		}
		cout << t << " " << s << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
using namespace std;
int main() {
	string s;
	cin >> s;
	bool judge = true;
	if (s.at(0) != 'A')judge = false;
	int counter = 0;
	for (int i = 2; i < s.size() - 1 && counter <= 1; i++) {
		if (s.at(i) == 'C')counter++;
	}
	if (counter != 1)judge = false;
	counter = 0;
	for (auto i : s) {
		if (islower(i))counter++;
	}
	if (counter != s.size() - 2)judge = false;
	if (judge) cout << "AC" << endl;
	else cout << "WA" << endl;
}


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

int digitSum(ll x){
    int ret = 0;
    while(x > 0){
        ret += x%10;
        x /= 10;
    }
    return ret;
}

int main(){
    int a, n, m;
    cin >> a >> n >> m;

    int ans = 0;
    for(int i = 1;;i++){
        ll tmp = 1;
        for(int j = 0; j < n; j++){
            tmp *= (i+a);
        }
        if(tmp > m) break;
        if(digitSum(tmp) == i)  ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3096
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
   
//#include <x86intrin.h>
#include <bits/stdc++.h>   
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
     
#define F first
#define S second           
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define al 0x3F3F3F3F
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)3e5 + 123;
const ll inf = (ll)1e18 + 1;
 
const double pi = acos (-1.0);
const double eps = 1e-7;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};
 
int n, k, dp[333][333], h[333]; 

inline void boost () {                    
   ios_base :: sync_with_stdio (NULL);
   cin.tie (NULL), cout.tie (NULL);          
}                                                     
 
inline void Solve () {
   cin >> n >> k;     
   for (int i = 1; i <= n; i ++) cin >> h[i];
   for (int i = 0; i <= n; i ++)
      for (int j = 0; j <= n; j ++)
         dp[i][j] = inf;   
   for (int i = 1; i <= n; i ++) {
      for (int j = 0; j <= min (i, n - k); j ++) {
         if (j == 0) dp[i][j] = 0;
         else if (j == 1) dp[i][j] = h[i];
         else {
            for (int l = 1; l < i; l ++) {
               dp[i][j] = min (dp[i][j], dp[l][j - 1] + max (0ll, h[i] - h[l]));
            }
         }
      }  
   }
   int ans = inf;
   for (int i = 1; i <= n; i ++) ans = min (ans, dp[i][n - k]);
   cout << ans;
}
 
main () {                                       
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
   //cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}
       

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

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

	int cur = 0;
	while(cur < s.size()){
		cout << s[cur];
		cur += w;
	}

	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 100010
#define ll long long
int main()
{
    string s,t;
    cin>>s>>t;
    int ans = s.size();
    for(int start = 0; start+t.size() <= s.size(); start++){
        int sum = 0;
        for(int i = 0; i < t.size(); i++){
            if(t[i] != s[start+i]){
                sum++;
            }
        }
        ans = min(ans,sum);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3608
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#include <bits/stdc++.h>
using namespace std;
 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
 
using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;
 
// ------------------------------------------------------------------------------------------------

ll k, x;

void func() {
    cin >> k >> x;
    for (ll i = x - k + 1; i <= x + k - 1; i++) {
        cout << i << ' ';
    }
    cout << endl;
}

int main() {
    fast_io; cout_precision;
    ll t = 1; // cin >> t;
    for (ll i = 0; i < t; i++) {
        func();
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    
    int d,n;cin>>d>>n;
    
    int d1=pow(100,d);
    
    if(n==100)n=101;
    int ans=d1*n;
    
   cout<<ans<<endl;
    
	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static final Scanner sc  = new Scanner(System.in);
    static final int MOD = (int) 1E9 + 7;
    static final int INF = Integer.MAX_VALUE;
    
    public static void main(String[] args) {
        long x = nint();
        long y = nint();
        
        long min = Long.MAX_VALUE;
        long mx = -x;
        long my = -y;

        if (mx <= my)
            min = min(min, 1 + (my - mx) + 1);

        if (mx <=  y)
            min = min(min, 1 + ( y - mx) + 0);

        if (x  <= my)
            min = min(min, 0 + (my -  x) + 1);
        
        if (x  <=  y)
            min = min(min, 0 + ( y -  x) + 0);
        
        System.out.println(min);
    }
    
    private static int nint() {
        return sc.nextInt();
    }

    private static int[] nints(int n) {
        return nints(n, 0, 0);
    }

    private static int[] nints(int n, int padL, int padR) {
        int[] a = new int[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nint();
        return a;
    }

    private static long nlong() {
        return sc.nextLong();
    }

    private static long[] nlongs(int n) {
        return nlongs(n, 0, 0);
    }

    private static long[] nlongs(int n, int padL, int padR) {
        long[] a = new long[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nlong();
        return a;
    }

    private static double ndouble() {
        return sc.nextDouble();
    }
    
    private static double[] ndoubles(int n) {
        return ndoubles(n, 0, 0);
    }
    
    private static double[] ndoubles(int n, int padL, int padR) {
        double[] d = new double[n + padL + padR];
        for (int i = 0; i < n; i++) {
            d[padL + i] = ndouble();
        }
        return d;
    }

    private static String nstr() {
        return sc.next();
    }

    private static char[] nchars() {
        return sc.next().toCharArray();
    }

    private static char[] nchars(int padL, int padR) {
        char[] temp = sc.next().toCharArray();
        char[] ret = new char[temp.length + padL + padR];
        System.arraycopy(temp, 0, ret, padL, temp.length);
        return ret;
    }
    
    private static char[][] nchars2(int h, int w) {
        return nchars2(h, w, 0, 0);
    }

    private static char[][] nchars2(int h, int w, int padLU, int padRD) {
        char[][] a2 = new char[h + padLU + padRD][w + padLU + padRD];
        for (int i = 0; i < h; i++)
            System.arraycopy(nchars(), 0, a2[padLU + i], padLU, w);
        return a2;
    }
    
    private static long min(long... ls) {
        return Arrays.stream(ls).min().getAsLong();
    }
    
    private static long max(long... ls) {
        return Arrays.stream(ls).max().getAsLong();
    }
}


Measured memory_bytes: 28756
N, M = map(int, input().split(" "))
AL = list(map(int, [input() for _ in range(M)]))

# DP
dp = [1] * (N + 1)
for A in AL:
    dp[A] = 0

for i in range(2, N + 1):
    if dp[i] == 1:
        dp[i] = (dp[i-1] + dp[i-2]) % (10**9 + 7)
print(dp[N])

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

int main(){
	int n;
	cin>>n;
	
	int a[100];
	cin>>a[0];
	int cnt=1;
	int sum=0;
	for(int i=1;i<n;++i){
		cin>>a[i];
		if(a[i]==a[i-1]) cnt++;
		else{
			sum+=cnt/2;
			cnt=1;
		}
		
		if(i==n-1){
			sum+=cnt/2;
		}
	}
	
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

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

int main() {
	int  X, t; cin >> X >> t;

	cout << ((X - t < 0) ? 0 : (X - t)) << endl;

	return 0;
}

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

		int ans = 0;
		for (int i = 0; i < 4; i++) {
			if (S.charAt(i) == '+') 
				ans++;
			else 
				ans--;
		}

		System.out.println(ans);

	}
}

Measured memory_bytes: 21716
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  string s,t,ns = "",nt = "";int i;cin >> s >> t;
  vector<char> a,b;
  for(i=0;i<s.size();i++) a.push_back(s[i]);
  for(i=0;i<t.size();i++) b.push_back(t[i]);
  sort(a.begin(),a.end());
  sort(b.begin(),b.end(),greater<char>());
  for(i=0;i<s.size();i++) ns += a[i];
  for(i=0;i<t.size();i++) nt += b[i];
  cout << ((ns<nt) ? "Yes":"No") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <vector>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    int n;
    cin >> n;
    vector<int> h(n, 0);
    repi(i, n, 0) cin >> h[i];
    for (int i = n - 2; i >= 0; i--)
    {
        if(h[i + 1] - h[i] < -1){
            puts("No");
            return 0;
        }else if(h[i+1] - h[i] < 0){
            h[i]--;
        }
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;


int main(){
    cin>>A>>B;
    ll ans = 0;
    while(A <= B){
        A *= 2;
        ++ans;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  for(int i=0;i<3;i++){
    if(s[i]=='1'){
      s[i]='9';
    }
    else{
      s[i]='1';
    }
  }
  cout<<s<<endl;
}

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

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

    int a[2][n];
    for (int i = 0; i < n; i++) {
        cin >> a[0][i];
    }
    for (int i = 0; i < n; i++) {
        cin >> a[1][i];
    }


    int max = 0;
    for (int i = 0; i < n; i++) {
        int x = 0, count = 0;
        for (int j = 0; j < n; j++) {
            count += a[x][j];
            if (i == j) {
                count += a[++x][j];
            }
        }
        max = (count > max ? count : max);
    }
    cout << max << endl;
    return 0;
}

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

const int mod = 1e9+7;
void tlfclwx(){ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
const int maxn=1e6+10;

int k[maxn];
vector<int> v[maxn];
int main()
{
   int n; cin >> n;
   for(int i = 1; i <= n; i++)
   {
       cin >> k[i];
       v[k[i]].push_back(i);
   }
   if(v[1].size() >= 1) {
      int flag = v[1][0];
      int sum = 1;
      for(int i = 2; i <= n; i++) {
        if(v[i].size() > 0) {
            if(v[i][v[i].size()-1] > flag) {
                int a = lower_bound(v[i].begin(), v[i].end(), flag)-v[i].begin();
                flag = v[i][a];
                sum++;
            }
            else break;
        }
        else break;
      }
      cout << n-sum << endl;
   }
   else cout << -1 <<endl;
}


Measured memory_bytes: 31104
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define INF (ll)(1e18)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }





int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    
    
    int n;
    cin >> n;
    vector<int> a(2 * n);
    rep(i, 2 * n) cin >> a[i];
    sort(all(a));
    ll ans = 0;
    rep(i, n) ans += a[2 * i];
    cout << ans << endl;
}


Measured memory_bytes: 256
// AOJ 0592
#include <iostream>
#include <cmath>

using namespace std;

int main(void)
{
	int ret = 0, a;
	for (int i = 0; i < 5; i++){
		cin >> a;
		ret += max(a, 40);
	}
	cout << ret / 5 << endl;

	return 0;
}

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

int main() {
  int n;
  cin >> n;
  long long pow = 1;
  long long mod = 1e9 + 7;
  for (int i = 1; i <= n; i++) {
    pow = (pow * i) % mod;
  }
  cout << pow;
  return 0;
}


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


string s;
long long f[2019];
long long p = 1;
long long ans;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> s;
    f[0]++;
    long long x=0;
    for (int i = s.size()-1; i >= 0; i--)
    {
        x = ((s[i] - '0') * p + x) % 2019;
        ans += f[x];
        f[x]++;
        p = (p*10)%2019;

    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3656