akhauriyash/Code-Regression huggingface dataset:
#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);

	int N;
	int i,k;
	int AC=0;
	int WA=0;
	int TLE=0;
	int RE=0;
	int ans=0;
	int ctr=0;
	string S;

	cin >> N;

	rep(i,N){
		cin >> S;
		if(S=="AC") AC++;
		else if(S=="WA") WA++;
		else if(S=="TLE") TLE++;
		else if(S=="RE") RE++;
	}

	cout << "AC x " << AC << endl;
	cout << "WA x " << WA << endl;
	cout << "TLE x " << TLE << endl;
	cout << "RE x " << RE << endl;

	return 0;
}



Measured memory_bytes: 3676
import java.io.*;
import java.math.*;
import java.util.*;
import java.util.regex.*;


public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static long cnt=0;
	public static PrintWriter pw = new PrintWriter(System.out);
	public static void main(String[] args) throws Exception {
//		solveA(args);
//		solveB(args);
//		solveC(args);
//		solveD(args);
		solveE(args);
		if(in!=null){
			in.close();
		}
		pw.flush();
		pw.close();
	}

	public static void solveA(String[] args) throws Exception{
		String a = nextString();
		if('a'<= a.charAt(0) && a.charAt(0) <='z') {
			pw.println("a");

		}else {
			pw.println("A");
		}
	}
	public static void solveB(String[] args) throws Exception{
		int N=nextInt();
		int K=nextInt();

		int[] p = nextInts();
		Arrays.sort(p);
		int ans = 0;
		for(int i=0;i<K;i++) {
			ans+=p[i];
		}
		pw.println(ans);
	}
	public static void solveC(String[] args) throws Exception{
		long n = nextLong();
		String ans = "";
		while((n-1)/26!=0) {
			ans=(char)('a'+(n-1)%26)+ans;
			n=(n-1)/26;
		}
		ans=(char)('a'+(n-1)%26)+ans;
		pw.println(ans);
	}
	public static void solveD(String[] args) throws Exception{
		int N = nextInt();
		long[] A = nextLongs();
		int Q = nextInt();
		long[] B = new long[Q];
		long[] C = new long[Q];
		HashMap<Long,Integer> map = new HashMap<>();
		long ans = 0;
		for(int i=0;i<N;i++) {
			map.put((long)A[i],map.getOrDefault(A[i], 0)+1);
			ans+=A[i];
		}

		for(int i=0;i<Q;i++) {
			B[i]=nextLong();
			C[i]=nextLong();
			ans-=B[i]*map.getOrDefault(B[i], 0);
			ans+=C[i]*map.getOrDefault(B[i], 0);
			if(map.containsKey(B[i])) {
				map.put((long)C[i],map.getOrDefault(C[i], 0)+map.get(B[i]));
				map.put((long)B[i],0);
			}
			pw.println(ans);

		}

	}
	public static void solveE(String[] args) throws Exception{
		int N = nextInt();
		int[] a = nextInts();

		int[] e = new int[N];
		int t = 0;
		for(int i=0;i<N;i++) {
			t=t^a[i];
		}
		for(int i=0;i<N;i++) {
			pw.println(t^a[i]);
		}

	}


	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}

}



Measured memory_bytes: 69388
package main

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

func main() {
	list := getStdinIntArr64()
	N := uint64(list[0])
	divitors := make([]uint64, N+1)

	var i uint64 = 0
	var j uint64 = 0
	for i = 1; i <= N; i++ {
		for j = i; j <= N; j += i {
			divitors[j]++
		}
	}

	var k uint64 = 1
	var ans uint64 = 0
	for ; k <= N; k++ {
		ans += k * divitors[k]
	}
	fmt.Printf("%d\n", ans)
}

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinInt2() (int, int) {
	list := getStdinIntArr()
	return list[0], list[1]
}
func getStdinInt3() (int, int, int) {
	list := getStdinIntArr()
	return list[0], list[1], list[2]
}
func getStdinInt64() int64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return rtn
}
func getStdinInt64_2() (int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1]
}
func getStdinInt64_3() (int64, int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1], list[2]
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}
func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}
func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, _ := sc.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 82824
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long MOD = 1e9 + 7;
using namespace std;
typedef long long ll;

map<ll, int> mp;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int a, b;
	cin >> a >> b;
	vector<int> p(n);
	for (int i = 0; i < n; i++) cin >> p[i];
	int one = 0;
	int two = 0;
	int three = 0;
	for (int i = 0; i < n; i++) {
		if (p[i] <= a) {
			one++;
		}
		else if (p[i] >= b + 1) {
			three++;
		}
		else {
			two++;
		}
	}
	cout << min(one, min(two, three)) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <vector>

static const int IINF = 1 << 30;
static const long long LINF = 1LL << 60;
static const long long MOD = 998244353;

template <typename T> std::vector<T> vectors(std::size_t n, T val) {
  return std::vector<T>(n, val);
}

template <typename T, typename... Args>
auto vectors(std::size_t n, Args... args) {
  return std::vector<decltype(vectors<T>(args...))>(n, vectors<T>(args...));
}

template <class T> inline bool chmin(T &a, const T &b) {
  return (a > b) ? a = b, true : false;
}

template <class T> inline bool chmax(T &a, const T &b) {
  return (a < b) ? a = b, true : false;
}

template <class T> inline void chadd(T &a, const T &b) {
  a += b, a %= MOD;
  if (a < 0)
    a += MOD;
}

template <class T>
std::ostream &operator<<(std::ostream &s, const std::vector<T> &v) {
  if (v.empty())
    return s;
  s << *v.begin();
  for (auto iter = v.begin() + 1; iter != v.end(); ++iter)
    if (std::is_fundamental<T>::value)
      s << " " << *iter;
    else
      s << std::endl << *iter;
  return s;
}

int main() {
  // Input
  int N;
  std::cin >> N;
  assert(3 <= N and N <= 300);
  std::vector<int> a(N);
  for (int i = 0; i < N; ++i) {
    std::cin >> a[i];
    assert(1 <= a[i] and a[i] <= 300);
  }

  // Initialization
  int M = 100000;
  // (RGB に塗るときの) i 番目までみて赤の長さが r の場合の数
  std::vector<std::vector<long long>> dp1(N);
  // (RG に塗るときの) i 番目までみて赤の長さが r の場合の数
  std::vector<std::vector<long long>> dp2(N);
  for (int i = 0; i < N; ++i) {
    dp1[i].assign(M, 0);
    dp2[i].assign(M, 0);
  }

  // Initial condition
  dp1[0][0] = 2;
  dp1[0][a[0]] = 1;
  dp2[0][0] = 1;
  dp2[0][a[0]] = 1;

  // DP main
  for (int i = 0; i < N - 1; ++i) {
    for (int r = 0; r < M; ++r) {
      chadd(dp1[i + 1][r], 2 * dp1[i][r]);
      chadd(dp2[i + 1][r], dp2[i][r]);
      if (r + a[i + 1] < M) {
        chadd(dp1[i + 1][r + a[i + 1]], dp1[i][r]);
        chadd(dp2[i + 1][r + a[i + 1]], dp2[i][r]);
      }
    }
  }

  // Output
  long long all = 1;
  long long S = 0;
  for (int i = 0; i < N; ++i) {
    all *= 3;
    all %= MOD;
    S += a[i];
  }

  long long res = all;
  for (int r = (S + 1) / 2; r < M; ++r)
    chadd(res, -3 * dp1[N - 1][r]);
  if (S % 2 == 0)
    chadd(res, 3 * dp2[N - 1][S / 2]);

  std::cout << res << std::endl;

  return 0;
}


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

int main()
{
	int n, k;
	cin >> n >> k;
	int ans = 1;
	for (int i = 0; i < n; i++) {
		if (ans <= k) {
			ans *= 2;
		}
		else {
			ans += k;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AOJ0089
{
    class Program
    {
        static void Main()
        {
            var data = new List<int[]>();
            string line;
            while ((line = Console.ReadLine()) != null)
            {
                data.Add(line.Split(',').Select(int.Parse).ToArray());
            }

            Console.WriteLine(Calculate(data));
        }

        private static int Calculate(IList<int[]> data)
        {
            for (var i = 1; i < data.Count; i++)
            {
                for (var j = 0; j < data[i].Length; j++)
                {
                    var candidate1 = 0;
                    var candidate2 = 0;

                    if (data[i - 1].Length < data[i].Length)
                    {
                        if (j < data[i - 1].Length)
                        {
                            candidate1 = data[i - 1][j];
                        }

                        if (j - 1 >= 0)
                        {
                            candidate2 = data[i - 1][j - 1];
                        }
                    }
                    else
                    {
                        candidate1 = data[i - 1][j];
                        candidate2 = data[i - 1][j + 1];
                    }

                    data[i][j] += Math.Max(candidate1, candidate2);
                }
            }

            return data[data.Count - 1][0];
        }
    }
}

Measured memory_bytes: 6132
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); --i)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int FFTMOD = 119 << 23 | 1;
const int INF = (int) 1e9 + 23111992;
const ll LINF = (ll) 1e18 + 23111992;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ull isqrt(ull k) {ull r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
mt19937 mt(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int mrand() {return abs((int) mt());}
#define db(x) cerr << "[" << #x << ": " << (x) << "] ";
#define endln cerr << "\n";

void chemthan() {
    long long n; cin >> n;
    cout << (n - 2) * 180 << "\n";
}

int main(int argc, char* argv[]) {
    ios_base::sync_with_stdio(0), cin.tie(0);
    if (argc > 1) {
        assert(freopen(argv[1], "r", stdin));
    }
    if (argc > 2) {
        assert(freopen(argv[2], "wb", stdout));
    }
    chemthan();
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}


Measured memory_bytes: 256
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<bitset>
#include<random>
#include<cstdint>
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
#define shosu setprecision(17)
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<char,P> Q;
ll longinf=(1ll<<60);
int inf=1<<21;

int N;
int main(){
      cin>>N;
      int a[N];
      int S=0;
      rep0(i,N){
            cin>>a[i];
      }
      rep0(i,N) S+=a[i];
      int minim=inf;
      int ans=0;
      rep0(i,N){
            if(abs(S-N*a[i])<minim){
                  ans=i;
                  minim=abs(S-N*a[i]);
            }
      }
      cout<<ans<<endl;

      return 0;
}

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

int main()
{
	int n;
	cin >> n;
	int ans = 32;
	for(auto i = 0; i < n; ++i){
		int a;
		cin >> a;
		int cnt = 0;
		while(a > 0 && a % 2 == 0){
			++cnt;
			a >>= 1;
		}
		if(cnt < ans) ans = cnt;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        (mut n ,m): (isize, usize),
        a: [isize; m],
    }
    for i in 0..m {
        n -= a[i]
    }
    let ans: isize = if n >= 0 {
        n
    } else {
        -1
    };
    println!("{}", ans)
}

Measured memory_bytes: 2168
#include <stdio.h>

int main(int argc, char const *argv[])
{
	int g, h=0;
	scanf("%d", &g);
	while(g>=500){
	g-=500;
	h+=1000;
	}

	while(g>=5){
		h += 5;
		g-=5;
	}

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


	return 0;
}


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

#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
#define CININIT cin.tie(0),ios::sync_with_stdio(false)
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

int main(){
    string X;cin>>X;
    int N=X.size();

    int numS=0,numT=0;
    for(int i=0;i<N;i++){
        if(X[i]=='S') break;
        else if(X[i]=='T') numT++;
    }
    for(int i=N-1;i>=0;i--){
        if(X[i]=='T') break;
        else if(X[i]=='S') numS++;
    }
    int numST = numS+numT;
    string s=X.substr(numT,N-numST);
    N = s.size();

    queue<int> que;
    int cnt=0;
    debug(s);
    for(int i=0;i<N;i++){
        if(s[i]=='S') que.push(i);
        else if(s[i]=='T'){
            if(que.empty()) continue;
            que.pop();
            cnt++;
        }
    }

    debug(cnt);
    debug(N);
    cout << numST + N - cnt*2 << endl;
}


Measured memory_bytes: 1028
n,m,l = map(int,input().split())
A = list()
B = list()
for i in range(n):
    A.append(list(map(int,input().split())))
for i in range(m):
    B.append(list(map(int,input().split())))
for i in range(n):
    C = list()
    for j in range(l):
        sum = 0
        for k in range(m):
            sum += A[i][k] * B[k][j]
        C.append(sum)
    print(" ".join(list(map(str,C))))


Measured memory_bytes: 6244
# 解説AC
# 二部グラフでないグラフの性質や，パスの長さを考察する

def main():
    N, M = (int(i) for i in input().split())
    G = [[] for _ in range(N)]
    for _ in range(M):
        a, b = (int(i) for i in input().split())
        G[a-1].append(b-1)
        G[b-1].append(a-1)

    def dfs(s):
        """
        二部グラフか判定
        """
        stack = [s]
        color = [-1]*N
        color[s] = 0
        while stack:
            v = stack.pop()
            for u in G[v]:
                if color[u] != -1:
                    if color[u] == color[v]:
                        # 二部グラフでない
                        return False, color
                    continue
                color[u] = color[v] ^ 1
                stack.append(u)
        return True, color

    is_bipartite, color = dfs(0)
    if is_bipartite:
        # 二部グラフである
        b = sum(color)
        w = N - b
        print(b*w - M)
    else:
        # 二部グラフでない
        # 完全グラフになるので，{}_N C_2 - (既に張られている辺の数)
        print(N*(N-1)//2 - M)


if __name__ == '__main__':
    main()


Measured memory_bytes: 91260
#include <bits/stdc++.h>
using namespace std;
int b[26];
bool f=1;
string a;
int main(){
	cin>>a;
	for(int i=0;i<a.size();i++)
		b[a[i]-'a']++;
	for(int i=0;i<26;i++)
		if(b[i]%2==1)
			f=0;
	if(f==1)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <list>
#include <map>
#include <set>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <memory.h>
#include <ctime>
#include <bitset>
#include <vector>
#include <string>

using namespace std;

void solution() {
    int n;
    cin >> n;
    vector <int> v1(n), v2(n), vp(n);
    for (int i = 0; i < n; i++) {
        cin >> v1[i];
        vp[i] = i + 1;
    }
    for (int i = 0; i < n; i++) {
        cin >> v2[i];
    }

    int ans = 0;
    int d1 = 1;
    int d2 = -1;
    do {
        bool f1 = false, f2 = false;
        for (int i = 0; i < n; i++) {
            if (v1[i] != vp[i]) {
                f1 = true;
            }
            if (v2[i] != vp[i]) {
                f2 = true;
            }
        }        
        if (!f1) {
            d1 = 0;
        }
        if (!f2) {
            d2 = 0;
        }
        ans += d1 + d2;
    } while (next_permutation(vp.begin(), vp.end()));
    cout << abs(ans) << endl;
}

/*-------------------*/

int main()
{
#ifdef Files
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    /*Test*/
    //freopen("input.txt", "w", stdout);

    double OcZ2X = clock();
#else
    //freopen("joke.in", "r", stdin);
    //freopen("joke.out", "w", stdout);
#endif

    solution();

#ifdef Time
    double P2HxQ = clock();
    printf("\n*** Total time = %.3f sec ***\n", (P2HxQ - OcZ2X) / CLOCKS_PER_SEC);
#endif
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define sz(a) (int)(a).size()
 
using namespace std;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
const int INF = 1e5+2;
const long long hell = 998244353ll;

int n , m , ans = 0;
vector<int>cats(INF);
vector<vector<int>>arr(INF);
vector<bool>bani(INF,false);

void dfs(int v , int km){
	if( bani[v] || km > m ) return;
	bani[v] = true;
	for(int i = 0 ; i < sz(arr[v]); i++ ){
	 	if(!bani[arr[v][i]]){
	 	 	dfs(arr[v][i] , (km+1)*cats[arr[v][i]] );
	 	}
   	}
     	if(sz(arr[v]) == 1 && ( v != 1 || n == 1 ) ) { ans++; } 
}

void solve(){
	/*cin>> n >> m;
	for(int i = 1 ; i <= n ; i++ ) cin >> cats[i];
	int a , b;
	for(int i = 0 ; i < n-1 ; i++ ){
	        cin >> a >> b;
	        arr[a].push_back(b);
	        arr[b].push_back(a);
	}
	dfs(1,cats[1]);
	cout<< ans << endl;*/
	int n ;
	cin >> n ;
	vector<int>arr(n);
	for(int i =0 ; i < n ; i++ ){
	        cin >> arr[i] ; 
	}
	int ans =0 ;
	for( int i = 1 ; i < n-1 ; i++ ){
	 	if(arr[i] > min(arr[i+1],arr[i-1]) && arr[i] < max(arr[i+1] , arr[i-1])) ans++;
	}
	cout << ans << endl;
}
int main(){
    	
	ios_base::sync_with_stdio(0);cin.tie(0);
    	
	int q=1;
#ifdef LOCAL
  	cin>>q;
#endif
  	while(q--){
  		solve();
  	}
#ifdef LOCAL
   	cout << "Time elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms.\n";
#endif	
	return 0;
}

Measured memory_bytes: 3072
M, D = map(int, input().split())

result = 0

if D < 22:
    print(0)
else:
    for m in range(1, M+1):
        for d in range(22, D+1):
            d1 = d%10
            d10 = d//10
            if d1 > 1 and d1*d10 == m:
                result += 1
    print(result)

Measured memory_bytes: 3060
def linearSearch(key, list):
    for e in list:
        if key == e:
            return 1
    return 0


N1 = int(input())
arr1 = list(set([int(n) for n in input().split()]))
N2 = int(input())
arr2 = list(set([int(n) for n in input().split()]))

print(sum([linearSearch(key, arr2) for key in arr1]))



Measured memory_bytes: 6552
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://arc075.contest.atcoder.jp/tasks/arc075_b>
問題文============================================================
 あなたが散歩していると、突然 N 体の魔物が出現しました。
 それぞれの魔物は 体力 という値を持ち、i 体目の魔物の出現時の体力は hi です。
 体力が 0 以下となった魔物は直ちに消滅します。
 
 幸い、あなたは熟練の魔法使いであり、爆発を引き起こして魔物を攻撃できます。
 一回の爆発では、以下のように魔物の体力を減らすことができます。
 
 生存している魔物を一体選び、その魔物を中心に爆発を引き起こす。
 爆発の中心となる魔物の体力は A 減り、その他の魔物の体力はそれぞれ B 減る。
 ここで、A と B はあらかじめ定まった値であり、A>B である。
 すべての魔物を消し去るためには、最小で何回の爆発を引き起こす必要があるでしょうか？
=================================================================

解説=============================================================

 蟻本の練習問題に類題があるね。（すぐ気づけなくて、悩んでしまった。精進が足りない）
 
 にぶたん
 
 先に m 回攻撃すると決めてしまえば、
 全ての敵に m*B のダメージが入っている状態とみなすことができる。
 そして、まだ体力が残っている敵に対して A - B のダメージを与えていく問題と考えることができる
 
 したがって、敵一体に対して h > m*B であれば
 倒すのに　(h - m*B + A - B - 1 )/(A-B) 回　必要だとわかる
 
 よって全ての敵に対して 必要な回数が m 以下であるか、 m より大きいかで判定できる
 
================================================================
*/
ll N,A,B;
vector<ll> h;

bool C(ll m){
    ll cnt = 0;
    ll dif = A - B;
    for(int i = 0; i < N;i++){
        ll X = h[i] - m*B;
        if(X <= 0) continue;
        cnt += (X + dif - 1)/dif;
    }
    return cnt <= m;
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    cin >> N >> A >> B;
    h.resize(N);
    for(auto &in:h) cin >> in;
    ll l = 0, r = INF;
    while(r - l > 1){
        ll m = (l + r)/2;
        if(C(m)){
            r = m;
        }else{
            l = m;
        }
    }
    cout << r << endl;
	return 0;
}


Measured memory_bytes: 1152
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int count = 0;
		while(scan.hasNext()){
			String str = scan.nextLine();
			if(str.length() == 1){
				count++;
				continue;
			}
			int i = 0;
			int j = str.length() - 1;
			while(true){
				if(i >= j){
					count++;
					break;
				}
				Character ch1 = new Character(str.charAt(i));
				Character ch2 = new Character(str.charAt(j));
				if(!ch1.equals(ch2)){
					break;
				}
				i++;
				j--;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 17148
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long k = sc.nextInt();
        long[] arr = new long[n + 1];
        for (int i = 1; i <= n; i++) {
            arr[i] = arr[i - 1] + sc.nextInt() - k;
        }
        ArrayList<Long> list = new ArrayList<>();
        list.add(Long.MIN_VALUE);
        list.add(0L);
        list.add(Long.MAX_VALUE);
        long count = 0;
        for (int i = 1; i <= n; i++) {
            int left = 0;
            int right = list.size() - 1;
            while (right - left > 1) {
                int m = (left + right) / 2;
                if (arr[i] < list.get(m)) {
                    right = m;
                } else {
                    left = m;
                }
            }
            count += left;
            list.add(right, arr[i]);

        }
        System.out.println(count);
    }
}


Measured memory_bytes: 69028
///=======================///
/// coder: Andy - Tohrumi ///
///=======================///

#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fastio ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0);
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define rep(i, a, b) for(__typeof(b) i = a; i < b; i++)
#define Rep(i, a, b) for(__typeof(a) i = a; i > b; i--)

using namespace std;

typedef pair<ll, ll> pll;	typedef pair<int, int> ii;
typedef vector<pll> vll;	typedef vector<string> vs;		typedef vector<ii> vii;
typedef vector<int> vi; 	typedef vector<ll> vl;

///======code start here======///

signed main() {
	fastio;
	int n; cin >> n;
	int a[n][3];
	rep(i, 0, n) {
		rep(j, 0, 3) {
			cin >> a[i][j];
		}
	}
	int dp[n + 1][3];
	rep(i, 0, 3) dp[0][i] = 0;
	rep(i, 1, n + 1) {
		rep(j, 0, 3) {
			dp[i][j] = a[i - 1][j];
			dp[i][j] += max(dp[i - 1][(j + 1) % 3], dp[i - 1][(j + 2) % 3]);
		}
	}
	cout << max(max(dp[n][0], dp[n][1]), dp[n][2]);
	return 0;
}



Measured memory_bytes: 2560
import java.util.*;

public class Main {
    public static void main(String args[]){
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        int r = stdIn.nextInt();
        // int c = stdIn.nextInt();
        // String s = stdIn.next();
        // boolean flag = true;
        
        // int num[] = new int[n];
        
        // for(int i = 0; i < n; i++){
        //     num[i] = stdIn.nextInt();
        // }
        
        // char c[] = s.toCharArray();
        
        // for(int i = 0; i < s.length(); i++){
        //     c[i];
        // }
        
        
        if(n >= 10){
            System.out.println(r);
        }else{
            System.out.println(r + (10 - n) * 100);
        }
        
        // if(flag){
        //     System.out.println("Yes");
        // }else{
        //     System.out.println("No");
        // }
        
        // System.out.println();
        // System.out.print();
    }
}

Measured memory_bytes: 22228
from collections import deque
import sys
input = sys.stdin.readline

h,w = map(int,input().split())
ch,cw = map(int,input().split())
dh,dw = map(int,input().split())
S = [list(input()[:-1]) for i in range(h)]

d = [[10**20]*w for i in range(h)]

dq = deque([(ch-1,cw-1,0)])
d[ch-1][cw-1] = 0
dx = [0,-1,0,1]
dy = [-1,0,1,0]

while dq:
    nx,ny,nd = dq.popleft()
    if nd < d[nx][ny]:continue
    for delta in range(4):
        tx,ty = nx+dx[delta], ny + dy[delta]
        if 0 <= tx < h and 0 <= ty < w and S[tx][ty] == "." and d[tx][ty] > d[nx][ny]:
            d[tx][ty] = d[nx][ny]
            dq.appendleft((tx,ty,d[tx][ty]))
    for deltax in range(-2,3):
        for deltay in range(-2,3):
            tx,ty = nx+deltax, ny + deltay
            if 0 <= tx < h and 0 <= ty < w and S[tx][ty] == "." and d[tx][ty] > d[nx][ny]+1:
                d[tx][ty] = d[nx][ny] + 1
                dq.append((tx,ty,d[tx][ty]))

print(d[dh-1][dw-1] if d[dh-1][dw-1] != 10**20 else -1)


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

int main(void){
	int n;
	cin >> n;
	for(int i=0;i<n;i++){
		int in[3] = {0};
		for(int j=0;j<3;j++){
			cin >> in[j];
		}
		for(int j=0;j<3;j++){//Sort
			for(int k=j+1;k<3;k++){
				if(in[j]<in[k]){
					int tmp = in[j];
					in[j] = in[k];
					in[k] = tmp;
				}
			}
		}
		cout << ((in[0]*in[0]==in[1]*in[1]+in[2]*in[2])?"YES\n":"NO\n");
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int a[4], b, c, ans;
	
	cin>>a[0]>>a[1]>>a[2];
	
	
	if(a[0] > a[1] && a[0] > a[2]) {
		cout<<'A'<<endl;
	} 
	else if(a[1] > a[0] && a[1] > a[2]){
		cout<<'B'<<endl;
	} else {
		cout<<'C'<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 3184
N = int(input())
a = list(map(int,input().split()))
a.sort()
A = 0
renzoku = 0
a_ta = [0]
for i in range(N):
    if A == a[i]:
        renzoku += 1
        pass
    elif A + 1 == a[i]:
        a_ta.append(renzoku)
        renzoku = 1
        A = a[i]
    else:
        a_ta.append(renzoku)
        tobi = a[i] - A - 1
        A = a[i]
        renzoku = 1
        for j in range(tobi):
            a_ta.append(0)
a_ta.append(renzoku)
a_ta.append(0)

ans = []
#print(a_ta)
for i in range(len(a_ta)-2):
    b = sum(a_ta[i:i+3])
    ans.append(b)

print(max(ans))
  



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

using namespace std;

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

    int data[n];
    for(int i=0; i<n; i++){
        data[i] = 0;
    }
    for(int i=0; i<k; i++){
        int d;
        cin >> d;

        int a[d];
        for(int j=0; j<d ; j++){
            int x;
            cin >> x;
            data[x-1] = 1;
        }
    }
    int count=0;
    for(int i=0; i<n; i++){
        if(data[i]==0){
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

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

int main(){
    unsigned long  arr[3];
    unsigned long result;
    
    cin >> arr[0] >> arr[1] >> arr[2];

    sort(arr, arr+3);

    if(arr[2]%2 == 0){
	result = 0;
    } else {
	result = arr[0] * arr[1];
    }

    cout << result << "\n";
}


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

int main(){
  int n;
  cin >>n;
  vector<int> a(n);
  int i=0;
  int ans =0;
  for(int i=0;i<n;i++){
    cin >> a.at(i);
  }
  while(true){
    if(a.at(i)%2==1){
      cout << ans << endl;
      break;
    }
    else {
      a.at(i)/=2;
    }
    if(i == a.size()-1){
      i =-1;
      ans++;
    }
    i++;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi =vector<vi>;

int main(){
  string s;
  cin >> s;
  int n = s.size();
  vector<string>A(n);
  for(int i=0;i<n;i++) A[i]=s[i];
  string t;
  cin >> t;
  int m = t.size();
  vector<string>B(m);
  for(int i=0;i<m;i++) B[i]=t[i];
  bool ans = 1;
  for(int i=0;i<n;i++) if(A[i]!=B[i]) ans = 0;
  if(ans)cout << "Yes" << endl;
  else cout << "No" << endl;
  
}

Measured memory_bytes: 3632
#include <cstdio>
#define LOOP(x) (x%1000000007)
#define ROOP(x,y) ((x+1000000007-y)%1000000007)
//#define LOOP(x) (x)
//#define ROOP(x,y) ((x-y))

long long a[200001];

int main()
{
	int n;
	scanf("%d",&n);
	int i;
	long long sum;
	for (i = 0; i < n; i++) {
		long long sv;
		scanf("%lld", &sv);
		a[i] = sv;
		sum = LOOP(sv + sum);
	}

	long long res = 0;	
	for (i = 0; i < n; i++) {
		sum = ROOP(sum,a[i]);
		res = LOOP(a[i] * sum + res);
	}
	printf("%lld\n", res);
	return 0;
}

Measured memory_bytes: 3216
n,k = gets.chomp.split.map(&:to_i)
h = gets.chomp.split.map(&:to_i)
 
dp = Array.new(n, Float::INFINITY)
dp[0] = 0
dp[1] = (h[0] - h[1]).abs
 
(2..(n - 1)).each do |i|
  (1..k).each do |j|
    break if i < j 
    cost = dp[i - j] + (h[i - j] - h[i]).abs
  	dp[i] = cost if dp[i] > cost 
    end
end
 
puts dp[n - 1]

Measured memory_bytes: 12452
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll aa[1000];
string ss[10000];
int main()
{
	int a,b=0;
	cin>>a;
	for(int i=0;i<a;i++){
		cin>>aa[i];
		if(i>0){
			if(aa[i]<aa[i-1]){
			    b=b+aa[i-1]-aa[i];
		    }
		}
	}
	b=b+aa[a-1];
	cout<<b;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  string s;
  cin >> s;
  if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I') {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
n=gets.to_i
a=[0]*-~n
b=[0]*-~n
z=gets.split.map &:to_i
n.times{|i|a[i+1]=a[i].gcd z[i]}
n.downto(1){|i|b[i-1]=b[i].gcd z[i-1]}
p n.times.map{|i|a[i].gcd b[i+1]}.max

Measured memory_bytes: 11012
N, Y = map(int, input().split())
Y = Y // 1000
for x in range(N + 1):
	for y in range(N + 1):
		if 10 * x + 5 * y + (N - x - y) == Y and 0 <= N - x - y <= N:
			print(x, y, N - x - y)
			exit()
print(-1, -1, -1)


Measured memory_bytes: 2940
n,m,q = map(int,input().split())
a=[0]*q
b=[0]*q
c=[0]*q
d=[0]*q
for i in range(q):
    a[i],b[i],c[i],d[i] = map(int,input().split())

As = [[i] for i in range(1,m+1)]

for ii in range(n+1):
    As = [ca+[j]  for i,ca in enumerate(As) for j in range(ca[-1],m+1)]

ans=0
for A in As:
    temp=0
    for i in range(q):
        if A[b[i]-1]-A[a[i]-1] == c[i]:
            temp+=d[i]
    if temp>ans:
        ans=temp
print(ans)

Measured memory_bytes: 205708
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int p[11000];
int ans[110][110];
int main(){
	int h,w,n;
	scanf("%d%d%d",&h,&w,&n);
	for(int i=0;i<n;i++)scanf("%d",p+i);
	int row=0;
	int col=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<p[i];j++){
			ans[row][col]=i+1;
			if(row%2==0){
				if(col+1<w)col++;
				else row++;
			}else{
				if(col)col--;
				else row++;
			}
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++)printf("%d ",ans[i][j]);
			printf("\n");
	}
}


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

#include <iostream>
using namespace std;
int main() {
  int k, a, b;
  cin >> k >> a >> b;
  int num = a / k;
  if ((k * num >= a && k * num <= b) ||
      (k * (num + 1) >= a && k * (num + 1) <= b)) {
    cout << "OK" << endl;
  } else {
    cout << "NG" << endl;
  }

  return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>

int main(){
  int a,b;
  scanf("%d%d", &a,&b);
  if (1 <= a && a <= 9 && 1 <= b && b <= 9){
    printf("%d", a*b);
  }
  else{
    printf("%d", -1);
  }
  return 0;
}

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

int main(void){
int n;
int yes=0;
int min=-999999;
int p[200005];
scanf("%d",&n);

for(int i=0;i<n;i++){
    scanf("%d",&p[i]);
}
min=p[0];yes++;
for(int i=1;i<n;i++){
    if(min>p[i]){yes++;min=p[i];}
}
printf("%d\n",yes);


}

Measured memory_bytes: 896
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int n,k;
  cin >> n >> k;
  if((n-1)*(n-2)/2<k){
    cout << -1 << endl;
    return 0;
  }
  int m = n-1+(n-1)*(n-2)/2-k;
  cout << m << endl;
  rep(i,n-1)cout << 1 << " " << i+2 << endl;
  int add = (n-1)*(n-2)/2-k;
  for(int i=2;i<n;i++){
    for(int j=i+1;j<n+1;j++){
      if(add==0)return 0;
      cout << i << " " << j << endl;
      add--;
    }
  }
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;

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

ll N;

void solve() {
    cin >> N;
    ll dp[101010] = {};
    REP(i,1,N+1) {
        ll mn = dp[i-1] + 1;
        if (i >= 1) mn = min(mn, dp[i-1] + 1);
        if (i >= 6) mn = min(mn, dp[i-6] + 1);
        if (i >= 36) mn = min(mn, dp[i-36] + 1);
        if (i >= 216) mn = min(mn, dp[i-216] + 1);
        if (i >= 1296) mn = min(mn, dp[i-1296] + 1);
        if (i >= 7776) mn = min(mn, dp[i-7776] + 1);
        if (i >= 46656) mn = min(mn, dp[i-46656] + 1);
        if (i >= 9) mn = min(mn, dp[i-9] + 1);
        if (i >= 81) mn = min(mn, dp[i-81] + 1);
        if (i >= 729) mn = min(mn, dp[i-729] + 1);
        if (i >= 6561) mn = min(mn, dp[i-6561] + 1);
        if (i >= 59049) mn = min(mn, dp[i-59049] + 1);
        dp[i] = mn;
    }
    cout << dp[N] << endl;
}

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


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	ll n; cin>>n;
	string s; cin>>s;
	string t=s;
	vl vec(n);
	ll cnt=0;
	rep(i,0,n){
		if(s[i]=='E')cnt++;
		vec[i]=cnt;
	}
	cnt=0;
	for(int i=n-1;i>=0;--i){
		if(s[i]=='W')cnt++;
		vec[i]+=cnt;
	}
	ll ans=MOD;
	rep(i,0,n){
		ll k=n-vec[i];
		chmin(ans,k);
	}
	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 3332
import std.stdio, std.conv, std.string, std.algorithm, std.array, std.math;

void main()
{
  long[] xs = readln.split().to!(long[]);
  long n;
  readf("%d", &n);

  xs = xs.sort().array;
  xs[$-1] = xs[$-1]*pow(2, n);

  writeln(xs.sum());


}


Measured memory_bytes: 256
import scala.collection.mutable

object Main extends App {
  import scala.io.StdIn._


  val v = readInt()
  val edges = Array.tabulate(v){_ ⇒ readLine.trim}
  val vertex = Array.tabulate(v){_ ⇒ new UnionFindTree}
  for (i ← 0 until v; j ← i + 1 until v if edges(i)(j) =='Y'){
    vertex(i).merge(vertex(j))
  }
  val wholeEdge = edges.map(_.count('Y' == _)).sum / 2
  val tops = vertex.filter(_.isTop)
  implicit val memo = mutable. Map[(Int, Int, Int), Boolean]()
  val res = calWin(tops.map(u ⇒ u.size * (u.size - 1) / 2).sum - wholeEdge, tops.count(_.size % 2 == 0), tops.count(_.size % 2 == 1))
  println(if(res) "Taro" else "Hanako")
  def calWin(e: Int, ce: Int, co: Int)(implicit memo: mutable.Map[(Int, Int, Int), Boolean]): Boolean = {
    if (memo.isDefinedAt((e % 2, ce, co))) {
      memo((e % 2, ce, co))
    }
    else {
        val result = if (ce + co == 2){
          if (e % 2 == 0) false
          else true
        }else {
          !List[Option[Boolean]](
            if (e % 2 == 1) Some(calWin(0, ce, co)) else None,
            if (ce > 0) Some(calWin((e + 1) % 2, ce - 1, co)) else None,
            if (co > 1) Some(calWin(e % 2, ce + 1, co - 2)) else None).flatten.forall(i ⇒ i)
        }
        memo.update((e % 2, ce, co), result)
        result
    }
  }
  class UnionFindTree{
    private var mParent: Option[UnionFindTree] = None
    private var mSize: Int = 1
    private def parent: UnionFindTree = {
      mParent.map{_.parent} match {
        case None ⇒ this
        case c@Some(p) ⇒
          mParent = c
          p
      }
    }
    def isTop: Boolean = mParent.isEmpty
    def size: Int = parent.mSize
    def isSameUnion(that: UnionFindTree): Boolean = {
      parent == that.parent
    }
    def merge(that: UnionFindTree): Unit = {
      if (!isSameUnion(that)){
        val p = parent
        val tp = that.parent
        if (p.mSize > tp.mSize){
          tp.mParent = Some(p)
          p.mSize += tp.mSize
        }else {
          p.mParent = Some(tp)
          tp.mSize += p.mSize
        }
      }
    }
  }
  implicit class Extension[T](val value :T) extends AnyVal {
    @inline
    def let[A](@inline func: T ⇒ A): A = func(value)
    @inline
    def also(@inline func: T ⇒ Unit): T = {func(value); value}
    @inline
    def takeIf(@inline predicate: T ⇒ Boolean): Option[T] = Some(value).filter(predicate)
  }
}


Measured memory_bytes: 237492
//>>>>>>>>>>>>>>>>>>>>>>>>>>JAI BAJRANG BALI<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<//
#define HARSH_JUDGE
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define db(x)                   cout<<#x<<"="<<x<<'\n'
#define db2(x,y)                 cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define ll long long
#define ld long double
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define ull unsigned long long
#define setbits(x)      __builtin_popcountll(x)
#define str string
#define bhaag_basanti ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fo(i,a,n) for(ll i=a;i<n;i++)
#define forr(i,n,a) for(ll i=n;i>=a;i--)
#define cases   long long t;cin>>t;while(t--)
#define eb emplace_back
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define ff first
#define ss second
#define pb push_back
#define mem(a,x) memset(a,x,sizeof(a))
#define sp(x,y)         fixed<<setprecision(y)<<x
#define nl '\n'
#define sz(x) ((int)(x).size())
const int mod = (int) 1e9 + 7 ;
const int MOD = (int) 998244353 ;
const ll INF = 1e18 ;
const ll N = 1e5 + 5;
#define printall(a) fo(i,0,a.size()) cout<<a[i]<<" "; cout<<endl;



typedef vector<int> vi;
typedef map<ll, ll> mll;
typedef set<int> si;
typedef unordered_set<int> usi;
typedef map<ll, int> mli;
typedef map<char, int> mci;
typedef vector<long long> vll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpl;
typedef vector<vector<int> > vv;

bool cmp(const pair<ll, ll>& a, const pair<ll, ll>& b)
{

	return a.ss < b.ss;
}

// >>>>>>>>>>>>>>>>>>>>>>>>>>TOR DE DUSHMAN KI NALI<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<//


void solve()
{
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	ll ans = min(a, d);
	d -= ans;
	if (d)
	{
		d = max(0LL, d - b);
	}
	ans -= d;
	cout << ans;


	return;
}


int main()
{
	bhaag_basanti
#ifndef HARSH_JUDGE
	freopen("inputf.in", "r", stdin);
	freopen("outputf.in", "w", stdout);
#endif
	ll t = 1;
	// cin >> t;
	// clock_t timest = clock();
	// cerr << "[Executes in " << (double)(clock() - timest) / CLOCKS_PER_SEC << "s]" << endl;
	while (t--)
	{
		solve();

	}
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  cin>>A>>B;
  int count=0;
  for(int i=0;i<B-A+1;++i){
    int k=i+A;
    if(k/10000==k%10&&k/1000%10==k%100/10) ++count;
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256
main()
{
    char S[100000];
    int X, len, i, a1=0, a2=1, ans1=0, ans2=0;
    scanf("%s", S);len=strlen(S);
    for(i=0;i<len;i++)
    {
        ans1 += (S[i] != (0x30+a1));a1^=1;
        ans2 += (S[i] != (0x30+a2));a2^=1;
    }
    printf("%d", ans1<=ans2?ans1:ans2);
}


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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

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

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

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int q; cin >> q;
  REP(i, q) {
    ll a, b; cin >> a >> b;
    if(a == b) {
      cout << 2 * b - 2 << endl;
      continue;
    }
    ll l = 1, r = 3e9;
    while(r - l > 1) {
      ll mid = (l + r) / 2;
      mid++;
      ll ma = mid / 2 * (mid - mid / 2);
      mid--;
      if(ma >= a * b) {
        r = mid;
      } else {
        l = mid;
      }
    }
    cout << l-1 << endl;
  }

}























Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[105];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	double ans=a[1];
	for(int i=2;i<=n;i++)ans=(double)(ans+a[i])/2;
	printf("%.10lf",ans);
	return 0;
}

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

namespace abc175_c
{
  class Program
  {
    static void Main(string[] args)
    {
      var X = Math.Abs(CIn.ReadLong());
      var K = CIn.ReadLong();
      var D = CIn.ReadLong();

      var c = X / D;

      if (K < c)
      {
        Console.WriteLine(X - K * D);
        return;
      }

      var m = X % D;

      if ((K - c) % 2 == 0)
      {
        Console.WriteLine(m);
      }
      else
      {
        Console.WriteLine(Math.Abs(m - D));
      }
    }
  }

  static class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }
      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(int n)
    {
      var array = new string[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }
      return array;
    }

    public static int[] ReadIntArray(int n)
    {
      var array = new int[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }
      return array;
    }

    public static long[] ReadLongArray(int n)
    {
      var array = new long[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }
      return array;
    }

    public static double[] ReadDoubleArray(int n)
    {
      var array = new double[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }
      return array;
    }

    public static char[,] ReadCharMatrix(int h, int w)
    {
      var array = new char[h, w];
      for (var i = 0; i < h; i++)
      {
        var l = Console.ReadLine().ToCharArray();
        for (var j = 0; j < w; j++)
        {
          array[i, j] = l[j];
        }
      }
      return array;
    }
  }
}


Measured memory_bytes: 27832
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <limits>
#include <set>
#include <map>

int main()
{
    int n{}, m{};
    std::cin >> n >> m;

    const auto result = n * (n - 1) / 2 + m * (m - 1) / 2;
    std::cout << result << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iso646.h>

int main(){
  int r,g,b;

  scanf("%d %d %d",&r,&g,&b);
  if((((10 * g) + b) % 4) == 0){
    printf("YES\n");
  }else{
    printf("NO\n");
  }
  return 0;
}

Measured memory_bytes: 128