akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();

        List<Long> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            long d = sc.nextLong();
            list.add(d);
        }
        Collections.sort(list);

        int index = (list.size() - 1) / 2;
        long min = list.get(index);
        long max = list.get(index + 1);
        System.out.println(max - min);
    }
}

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

/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>,
rb_tree_tag,tree_order_statistics_node_update>
//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).
*/
using namespace std;

#define LL long long
#define LD long double
#define PB push_back
#define MP make_pair
#define all(x) x.begin(), x.end()
#define fi first
#define se second
const LL MOD = 1000000000 + 7;
const LD EPS = 0.0000001;
#define MPP(a, b, c) MP(MP(a, b), c)
#define PII pair<pair<LL, LL>, LL>

LL pows(LL a, LL b) {
    if (b == 0) return 1LL;
    LL temp = pows(a, b / 2);
    temp = (temp * temp) % MOD;
    if (b % 2) temp = (temp * a) % MOD;
    return temp;
}

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

    LL n, k;
    cin >> n >> k;
    LL arr[n];
    for (int i = 0; i < n; i++) cin >> arr[i];

    // 	for (int i = 0; i < n; i++){
    // 	    for (int j = 0; j <= k; j++) dp[i][j] = 0;
    // 	}

    if (k == 0) {
        cout << 1 << endl;
        return 0;
    }
    vector<vector<LL> > dp(n, vector<LL>(k + 1));

    for (int i = 0; i <= min(arr[0], k); i++) dp[0][i] = 1;
    for (int i = 1; i <= k; i++) dp[0][i] += dp[0][i - 1];

    for (LL i = 1; i < n; i++) {
        dp[i].resize(k + 1, 0);
        for (LL j = 0; j <= k; j++) {
            int mn = max(0LL, j - arr[i]);
            dp[i][j] = dp[i - 1][j];
            if (mn != 0) {
                dp[i][j] = (dp[i][j] - dp[i - 1][mn - 1] + MOD) % MOD;
            }
        }
        for (int j = 1; j <= k; j++) dp[i][j] = (dp[i][j] + dp[i][j - 1]) % MOD;
    }

    // for (int i = 0; i < n; i++){
    //     for (int j = 1; j <= k; j++){
    //         cout << dp[i][j] - dp[i][j - 1] << " ";
    //     }
    //     cout << endl;
    // }

    LL ans = (dp[n - 1][k] + MOD - dp[n - 1][k - 1]) % MOD;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 79488
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
//typedef pair<int,int> P;
//priority_queue<int> pque;
//priority_queue<int, vector<int>, greater<int>> pque;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 1000000000;//10^9
ll MOD  = 998244353;

int N,W;
int w[100010];
ll v[100010];
ll dp[110][100010];

ll Knapsack(int N, int W){
    for(int i = 0; i <= N; i++){
        dp[i][0] = 0;
    }
    
    for(int i = 1; i <= N; i++){
        for(int j = 0; j <= W; j++){
            dp[i][j] = dp[i-1][j];
            if(j-w[i-1] >= 0){
                dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i-1]] + v[i-1]);
            }
        }
    }
    ll max = 0;
    for(int i = 0; i <= W; i++){
        if(max < dp[N][i]){
            max = dp[N][i];
        }
    }
    return max;
    
}



int main(void){
    cin >> N >> W;
    for(int i = 0; i < N; i++){
        cin >> w[i] >> v[i];
    }
    cout << Knapsack(N, W) << endl;;
}



Measured memory_bytes: 81408
#include <stdio.h>

int main()
{
  int a[32];
  a[0]=a[1]=a[2]=a[4]=a[6]=a[10]=a[12]=a[14]=a[16]=a[18]=a[22]=a[28]=a[30]=1;
  a[3]=a[5]=a[8]=a[9]=a[13]=a[20]=a[21]=a[24]=a[25]=2;
  a[27]=a[29]=4;
  a[7]=a[11]=a[17]=a[19]=a[26]=5;
  a[15]=14;
  a[23]=15;
  a[31]=51;
  int K;
  scanf("%d",&K);
  printf("%d",a[K-1]);
}

Measured memory_bytes: 128
//In the name of ALLAH the most merciful the most beneficial

#include<cstdio>
#include<cstring>
#include<bits/stdc++.h>
#include<iostream>
#include<math.h>
#include<fstream>
#define sc(x) scanf("%d",&x)
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORd(i,a,b) for(int i=a;i>b;i--)
#define ff first
#define ss second
#define sz(x) x.size()
#define pb push_back

using namespace std;

typedef pair<int,int> pii;
typedef vector<pii> vii;
const int con = 1e5+7;
static const int INF = 0x3f3f3f3f;
static const int MOD = 1e9+7;

int main(){
    /*
    clock_t start,end;
    start = clock();*/

    int n,l;
    cin >> n >> l;
    string arr[n];
    FOR(i,0,n)
        cin >> arr[i];

    sort(arr,arr+n);
    for(string s:arr)
        cout << s;

    /*end = clock();
    double time = double(end-start)/(double)CLOCKS_PER_SEC;
    cout <<fixed<< time/1000 << "sec";*/
}

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

using namespace std;

int main(void){
    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    
    if (a == 0){
        cout << 1 << endl;
    }
    else if (b == 0){
        cout << 2 << endl;
    }
    else if (c == 0){
        cout << 3 << endl;
    }
    else if (d == 0 ){
        cout << 4 << endl;
    }
    else {
        cout << 5 << endl;
    }
    return 0;
}


Measured memory_bytes: 3620
n = gets.chop.to_i
a = []
n.times { a << gets.to_s }
dictionary = a.sort
counts = {}
dictionary.each do |word|
  if counts[:"#{word}"] == nil
    counts[:"#{word}"] = 1
  else
    counts[:"#{word}"] = counts[:"#{word}"] + 1
  end
end

new_dic = []
max = counts.max{ |x, y| x[1] <=> y[1] }[1]
#while max == counts.max{ |x, y| x[1] <=> y[1] }[1] do
#  word = counts.max{ |x, y| x[1] <=> y[1] }[0]
#  max = counts.max{ |x, y| x[1] <=> y[1] }[1]
#  new_dic.push(word)
#  counts.delete(word)
#  break if counts.size == 0
#end
counts.each do |word|
  new_dic.push(word[0]) if word[1] == max
end

#puts " "
puts new_dic.sort


Measured memory_bytes: 92904
a, b = map(int, input().split())

ans = [0]*40

def f(n):
    ret = [0]*40
    if n%4 == 1 or n%4 == 2:
        ret[0] = 1
    else:
        ret[0] = 0
    
    for i in range(1,40):
        m = i+1
        tmp = (n+1)%(2**m)
        if tmp<=2**(m-1):
            ret[i] = 0
        else:
            ret[i] = (tmp-2**(m-1))%2
    return ret

fa = f(a-1)
fb = f(b)
ans = 0
for i in range(40):
    if (fb[i]-fa[i])%2==1:
       ans += 2**i
print(ans) 


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int N, D;
    cin >> N >> D;
    int d[N];
    rep(i, N) cin >> d[i];
    int pos[N+1]; //i回目の移動後の目的地との距離
    pos[0] = D;
    rep(i, N){
        pos[i+1] = min(pos[i], abs(pos[i]-d[i]));
    }
    int r[N+1];
    r[N] = 0;
    rep3(i, N-1, 0){
        if(r[i+1] < d[i]/2) r[i] = r[i+1];
        else r[i] = r[i+1]+d[i];
    }
    int Q;
    cin >> Q;
    rep(i, Q){
        int q;
        cin >> q;
        if(pos[q-1] <= r[q]) cout << "NO" << endl;
        else cout << "YES" << endl;
    }
}

Measured memory_bytes: 9436
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin >> n;
	long long*a = new long long[n];
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	long long min;
	long long max;
	long long sum = 0;
	for (int i = 0; i < n; i++)
	{
		if (i == 0)
		{
			min = a[i];
			max = a[i];
		}
		else
		{
			if (min > a[i]) min = a[i];
			if (max < a[i]) max = a[i];
		}
		sum += a[i];
	}
	cout << min << " " << max << " " << sum << endl;
}

Measured memory_bytes: 1272
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
int n;
ll a[100001];
int main(){
	ios::sync_with_stdio(0);
	cin>>n;
	ll sum=1;
	rep(i,n){
		cin>>a[i];
		
	}
	sort(a,a+n);
	rep(i,n){
		ll last=sum;
		sum*=a[i];
		if(a[i]!=0ll&&sum<last||sum>(ll)(1e18)){
			cout<<-1;
			re 0;
		}
	}
	
	if(sum>(ll)(1e18))
	cout<<-1;
	else
	cout<<sum;
	re 0;
}

Measured memory_bytes: 4428
import sys

S = input()
l = [0]*26
alfa = [chr(i) for i in range(97, 97+26)]
for i in range(len(S)):
    index = alfa.index(S[i])
    l[index] += 1
    if l[index] == 2:
        print("no")
        sys.exit()
print("yes")

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vii;
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	int n;
	scanf("%d", &n);
	vii jobs(n);
	for (int i = 0; i < n; i++) {
		scanf("%d%d", &jobs[i].second, &jobs[i].first);
	}
	sort(all(jobs));

	int current = 0;
	bool ok = true;
	for (auto p : jobs) {
		current += p.second;
		if (current > p.first) {
			ok = false;
			break;
		}
	}
	printf("%s\n", ok? "Yes" : "No");
}


Measured memory_bytes: 1792
n = gets.to_i
strs = n.times.map { gets.chomp.split(' ').map(&:to_i) }

dp = Array.new(n + 10) { Array.new(3, 0) }
n.times do |i|
  3.times do |j|
    3.times do |k|
      next if j == k
      value = dp[i][j] + strs[i][k]
      dp[i+1][k] = value if dp[i+1][k] < value
    end
  end
end
puts dp[n].max

Measured memory_bytes: 11900
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class ABlackjack {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int a, b, c;
        in>>a>>b>>c;
        if(a+b+c>=22) out<<"bust\n";
        else out<<"win\n";
    }
};


int main() {
	ABlackjack solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3584
#define dbg(...) fprintf(stderr,__VA_ARGS__)
#define dpr(x) cerr<<#x<<": "<<x<<endl;
#define dprc(c) do{cerr<<#c<<":";for(auto&_i:(c)){cerr<<" "<<_i;}cerr<<endl;}while(0)
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
int INF = 1e9+7;
#define all(c) (c).begin(), (c).end()
#define tr(i,c) for(auto i=(c).begin();i!=(c).end();i++)
#define rtr(i,c) for(auto i=(c).rbegin();i!=(c).rend();i++)
#define rep(i,b) for(auto i=0;i<(b);i++)
#define pb push_back
#define sz(c) int((c).size())

int main(int argc, char **argv)
{
  int n;
  scanf("%d", &n);

  vector<vector<pii>> G(n, vector<pii>());
  for (int i = 0; i < n; i++) {
    int u, k, v, c;
    scanf("%d %d", &u, &k);
    for (int j = 0; j < k; j++) {
      scanf("%d %d", &v, &c);
      G[u].pb(pii(v, c));
    }
  }

  vi d(n, INF);
  vector<bool> visited(n, false);
  int vc = 0;
  priority_queue<pii, vector<pii>, greater<pii>> q;

  d[0] = 0;
  visited[0] = true;
  vc = 1;
  q.push(pii(0, 0));
  
  while(!q.empty()) {
    pii p = q.top(); q.pop();
    int u = p.second;

    if (d[u] < p.first) continue;

    visited[u] = true;
    for (auto e:G[u]) {
      int v = e.first;
      int c = e.second;
      if (!visited[v] && (d[u] + c < d[v])) {
        d[v] = d[u] + c;
        q.push(pii(d[v], v));
      }
    }
  }

  for (int i = 0; i < n; i++) {
    printf("%d %d\n", i, d[i]);
  }

  return 0;
}

Measured memory_bytes: 3236
#include<stdio.h>
#include<string.h>

#define M 1076401
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(long long key){ return key%M; }
int h2(long long key){ return 1+key%(M-1); }

int find(char str[]){
  int sum;
  int f1,f2;
  long long a;
  a=getKey(str);
  f1=h1(a);
  f2=h2(a);
 
    if(strcmp(H[f1],str)==0){
      return 1;
    }
    if(H[f1][0]=='\0'){
      return 0;
    }
   sum=f1;

   while(1){
      sum=(sum+f2)%M;
   if(H[sum][0]=='\0'){
      return 0;
    }
    else if(strcmp(H[sum],str)==0){
      return 1;
    }
    
    
  }
  return 0;
  
}
void insert(char str[]){
  int sum;
  int f1,f2;
  long long a;
  a=getKey(str);
  f1=h1(a);
  f2=h2(a);
    if(H[f1][0]=='\0'){
      strcpy(H[f1],str);
      return;
    }
    sum=f1;

    while(1){
     sum=(sum+f2)%M;
   if(H[sum][0]=='\0'){
       strcpy(H[sum],str);

      break;
    }
  }
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)==1){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}

Measured memory_bytes: 14000
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();

		System.out.println(Math.max(a - 2 * b, 0));
	}
}


Measured memory_bytes: 22228
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int main(){
    int n; cin>>n;
    vector<int> a(n);
    int amin=1e9, amax=-1e9;
    int minid, maxid;
    for(int i=0; i<n; i++){
        cin>>a[i];

        if(a[i] < amin){
            amin = a[i];
            minid = i;
        }

        if(amax < a[i]){
            amax = a[i];
            maxid = i;
        }
    }

    if(0 <= amin){
        cout << n-1 << endl;
        for(int i=1; i<n; i++){
            cout << i << " " << i+1 << endl;
        }
    }
    else if(amax < 0){
        cout << n-1 << endl;
        for(int i=n; i>1; i--){
            cout << i << " " << i-1 << endl;
        }
    }
    else{
        int cnt=0;
        vector<P> ans;
        if(-amin < amax){
            for(int i=0; i<n; i++){
                if(a[i] < 0){
                    cnt++;
                    ans.eb(P(maxid+1, i+1));
                }
            }

            cout << n-1+cnt << endl;
            for(auto i:ans){
                cout << i.fs << " " << i.sc << endl;
            }
            for(int i=1; i<n; i++){
                cout << i << " " << i+1 << endl;
            }
        }
        else{
            for(int i=0; i<n; i++){
                if(0 < a[i]){
                    cnt++;
                    ans.eb(P(minid+1, i+1));
                }
            }

            cout << n-1+cnt << endl;
            for(auto i:ans){
                cout << i.fs << " " << i.sc << endl;
            }
            for(int i=n; i>1; i--){
                cout << i << " " << i-1 << endl;
            }
        }
    }
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp::{max, min};

fn f(x: usize) -> usize {
    match x % 4 {
        0 => x,
        1 => 1,
        2 => x + 1,
        3 => 0,
        _ => panic!("a"),
    }
}

fn main() {
    input! {
        a: usize,
        b: usize,
    }

    println!("{}", f(a - 1) ^ f(b));
}


Measured memory_bytes: 4352
#[allow(unused_macros)]
macro_rules! input {
    ( $($t:ty),* ) => {{
        let mut s = String::new();
        std::io::stdin().read_line(&mut s);
        let mut splits = s.trim().split_whitespace();
        ($( { splits.next().unwrap().parse::<$t>().unwrap() },)*)
    }}
}

use std::collections::HashMap;

#[allow(unused_must_use)]
#[allow(unused_variables)]
fn solve() {
    let (n, weight) = input!(usize, u64);
    let mut items: HashMap<u64, Vec<u64>> = HashMap::new();

    let (w, v) = input!(u64, u64);

    let base_weight = w;

    items.insert(base_weight, vec![]);
    items.insert(base_weight + 1, vec![]);
    items.insert(base_weight + 2, vec![]);
    items.insert(base_weight + 3, vec![]);

    {
        let vec = items.entry(w).or_insert(vec![]);
        (*vec).push(v);
    }
        
    for _ in 0..(n-1) {
        let (w, v) = input!(u64, u64);
        let vec = items.entry(w).or_insert(vec![]);
        (*vec).push(v);
    }

    for v in items.values_mut() {
        v.sort();
        v.reverse();
    }

    let mut current_max = 0;
    for a in 0..(n + 1) {
        for b in 0..(n + 1 - a) {
            for c in 0..(n + 1 - a - b) {
                for d in 0..(n + 1 - a - b - c) {
                    let mut total_weight: u64 = 0;
                    let mut total_value: u64 = 0;

                    let v = items.get(&base_weight).unwrap();
                    if v.len() < a {
                        continue;
                    }
                    total_weight += base_weight * a as u64;
                    let sum: u64 = v[0..a].iter().sum();
                    total_value += sum;

                    let v = items.get(&(base_weight + 1)).unwrap();
                    if v.len() < b {
                        continue;
                    }
                    total_weight += (base_weight + 1) * b as u64;
                    let sum: u64 = v[0..b].iter().sum();
                    total_value += sum;

                    let v = items.get(&(base_weight + 2)).unwrap();
                    if v.len() < c {
                        continue;
                    }
                    total_weight += (base_weight + 2) * c as u64;
                    let sum: u64 = v[0..c].iter().sum();
                    total_value += sum; 

                    let v = items.get(&(base_weight + 3)).unwrap();
                    if v.len() < d {
                        continue;
                    }
                    total_weight += (base_weight + 3) * d as u64;
                    let sum: u64 = v[0..d].iter().sum();
                    total_value += sum;

                    if total_weight <= weight && total_value > current_max {
                        current_max = total_value;
                    }
                }
            }
        }
    }

    println!("{}", current_max);
}

fn main() {
    solve();
}


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

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> t(n);
    vector<int> ans(n);
    rep(i, n){
        cin >> t.at(i);
        ans.at(i) = 1;
    }
    int a, b;
    rep(i, m){
        cin >> a >> b;
        a--; b--;
        if(t.at(a) < t.at(b)){
            ans.at(a) = 0;       
        }else if(t.at(a) > t.at(b)){
            ans.at(b) = 0;
        }else{
            ans.at(a) = 0;
            ans.at(b) = 0;
        }
    }
    int sum = 0;
    rep(i, n) if(ans.at(i) == 1) sum++;
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m;i>n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl
#define Vecpr(K,L1,L2,N) vector<pair<L1,L2>> K(N)
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,R) vector<vector<L>> K(N, vector<L>(M,R))
#define mod 1000000007
#define MAX 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
   lli A,B,C,L,R,N,M,K,X=0,Y=0,W,H,sum=0,num=0,flag=0;string S,T,O;
   cin >> N;
   Vec(P,lli,N,0);Vec(Q,lli,N,0);
   rep(i,0,N)cin >> P[i] >> Q[i];
   Rev(P);Rev(Q);
   rep(i,0,N)if((P[i]+sum)%Q[i])sum+=Q[i]-(P[i]+sum)%Q[i];
   Out(sum);
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define P pair<ll,ll> 
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N,k,d,ans=0;cin>>N>>k;
  ll l=to_string(N).length();
  set<ll> num{0,1,2,3,4,5,6,7,8,9};
  rep(i,k) {
    cin>>d;
    num.erase(d);
  }
  vector<set<ll>> V(l+2);
  bool is_continue=true;
  V[0].insert(0);
  for(ll i:num) {
    if(i<N) V[1].insert(i);
    else {
      ans=i;
      is_continue=false;
      break;}
  }
  if(!is_continue) {
    print(ans);
    return 0;
  }
  for(ll i=2;i<l+2;++i) {
    for(ll j:V[i-1]) {
      if(j==0) continue;
      for(ll k:num) {
        if(j*10+k<N) V[i].insert(j*10+k);
        else {
          ans=j*10+k;
          is_continue=false;
          break;
        }
      }
      if(!is_continue) break;
    }
    if(!is_continue) break;
  }
  print(ans);
  return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define int long long
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

typedef pair< int, int > pii;
typedef long long ll;

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(11);
	}
};
initializer _____;

int N, M, K, T, Q;
signed main() {
	cin >> N;
	vector< int > A(N);
	rep(i, N) cin >> A[i];
	sort(A.begin(), A.end());
	if (A[N - 1] - A[0] > 1) {
		cout << "No" << endl;
		return 0;
	}
	int B = A[N - 1] - A[0];
	int K = A[N - 1];
	if (B == 1) {
		int x = 0, y;
		rep(i, N) if (A[i] == K - 1)++ x;
		y = N - x;
		if (x < K && y >= 2 * (K - x))
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	} else {
		if (N >= K * 2 || N == K + 1)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
	return 0;
}

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

int main() {
	// your code goes here
	ll n;
	 cin>>n;
	 int count1=0,count2=0,count3=0,count4=0;
	 while(n--)
	 { 
	     string s;
	     cin>>s;
	     if(s=="AC")
	    count1++;
	    else if(s=="WA") 
	    count2++;
	    else if(s=="TLE")
	    count3++;
	    else
	    count4++;
	 }
	 cout<<"AC x "<<count1<<endl;
	 cout<<"WA x "<<count2<<endl;
	 cout<<"TLE x "<<count3<<endl; 
	 cout<<"RE x "<<count4<<endl;
	return 0;
}


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

N = int(readline())
Edge = [[] for _ in range(N)]
for i in range(N):
    S = readline().strip()
    for j in range(N):
        if S[j] == '1':
            Edge[i].append(j)

def check(Edge):
    s = 0
    Q = deque([s])
    N = len(Edge)
    col = [None]*N
    col[s] = 0
    while Q:
        vn = Q.pop()
        for vf in Edge[vn]:
            if col[vn] == col[vf]:
                return False
            if col[vf] is None:
                col[vf] = 1 - col[vn]
                Q.appendleft(vf)
    
    return True

def bfs(s, Edge):
    N = len(Edge)
    Q = deque([s])
    inf = 10**9+7
    dist = [inf]*N
    dist[s] = 0
    used = set([s])
    while Q:
        vn = Q.pop()
        for vf in Edge[vn]:
            if vf in used:
                continue
            used.add(vf)
            dist[vf] = min(dist[vn]+1, dist[vf])
            Q.appendleft(vf)
    
    return dist

if not check(Edge):
    print(-1)
else:
    ans = 0
    for i in range(N):
        ans = max(ans, max(bfs(i, Edge)))
    print(ans+1)

Measured memory_bytes: 42608
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}


int main(){
    cin.tie(0);
    
    string s; cin >> s;
    int ans = s.length() - 1;
    for (int i = 1; i < s.length(); i++){
        if (s[i] != s[i-1]) break;
        else if (i == s.length() - 1){
            ans = 0;
            cout << ans << endl;
            return 0;
        }
    }

    for (int i = 0; i < 26; i++){
        int select = 'a' + i;
        string tmp = s;
        for (int j = 1; j < s.length(); j++){
            for (int k = 0; k < s.length() - j; k++){
                tmp[k] = tmp[k];
                if (tmp[k+1] == select) tmp[k] = tmp[k+1];
            }
            for (int k = 0; k < s.length() - j; k++){
                if (tmp[k] != select) break;
                else if (k == s.length() - j - 1){
                    ans = min(ans, j);
                    j = s.length();
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
} 


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

template <class T>
void cout_vec2(const vector<vector<T>> &vec){
  rep(i,vec.size()){
    rep(j,vec[i].size()){
      cout<<vec[i][j]<<' ';
    }
    cout<<endl;
  }
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  double n,m,d;
  cin>>n>>m>>d;
  double ans;
  if(d==0){
    ans=1.0/(double)n;
  }else{
    ans=2.0*(n-d)/(n*n);
  }
  ans*=(m-1);
  cout<<setprecision(10)<<ans<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int,int> PP;

/*
 freopen("input","r",stdin);
 freopen("output","w",stdout);
*/

int DP[3010][3010];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    string s, t;
    cin >> s >> t;
    memset(DP, 0, sizeof(DP));
    for (int i = 1;i <= s.size();i++) {
        for (int j = 1;j <= t.size();j++) {
            DP[i][j] = max(DP[i][j], DP[i - 1][j]);
            DP[i][j] = max(DP[i][j], DP[i][j - 1]);
            if (s[i - 1] == t[j - 1]) {
                DP[i][j] = max(DP[i][j], DP[i - 1][j - 1] + 1);
            }
        }
    }
    vector<char> ans;
    int a = s.size(), b = t.size();
    while (a > 0 && b > 0) {
        if (s[a - 1] == t[b - 1]) {
            ans.push_back(s[a - 1]);
            a--;
            b--;
        }
        else if (DP[a][b] == DP[a - 1][b]) a--;
        else b--;
    }
    for (int i = ans.size() - 1;i >= 0;i--) cout << ans[i];
    cout << endl;
    return 0;
}


Measured memory_bytes: 35840
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a<b?a:b
#define REP(i,x,n) for(int i=x;i<n;i++)
#define REPR(i,x,n) for(int i=n-1;i>=x;i--)
#define pb  push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLr(obj) (obj).rbegin(), (obj).rend()
#define endl "\n"
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;



int main() {
    string s,s2,s3;cin>>s;
    bool f=1;
    rep(i,s.size()/4){
        if(s[s.size()/2-i-1]!=s[i])f=0;
        if(s[s.size()/2+i+1]!=s[s.size()-i-1])f=0;
        
    }
    rep(i,s.size()){
       if(s[i]!=s[s.size()-i-1])f=0;
    }
    if(f)cout<<"Yes";
    else cout<<"No";cout<<endl;
}


Measured memory_bytes: 256
import Control.Monad
import Control.Applicative
import Debug.Trace

main :: IO ()
main = do
  n <- readLn :: IO Int
  ns <- getInts
  let (ls, c) = solve ns
  putStrLn $ unwords $ map show ls
  print c

getInts :: IO [Int]
getInts = map read . words <$> getLine

solve :: [Int] -> ([Int], Int)
solve xs = go xs 1 
  where
    n = length xs
    go ns i
      | i == n = (ns, 0)
      | otherwise =
      let (m, idx) = minimum $ zip ns [0..]
          (ls, _:rs) = splitAt idx ns
          cnt' = if idx /= 0 then 1 else 0
          x = head ns
          ls' = if x == m then [] else tail ls ++ [x]
          (r, c) = --trace (show (m, idx)) $
            go (ls' ++ rs) (i+1) in
        (m:r, c+cnt')
        

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

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define fst first
#define snd second

int ans;

void rec(int n, int base)
{
    if(n == 0)
        return;
    rec(n / base, base);
    ans++;
}

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

    rec(n, k);

    cout << ans;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int n;
	cin>>n;
	int a[n];
	rep(i,n)cin>>a[i];
	sort(a,a+n);
	cout<<a[n-1]-a[0]<<endl;
	return 0;
}

Measured memory_bytes: 256
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout) 
#define primeDEN 727999983
//cout<<fixed<<setprecision(15)<<ans;
 
template <typename T>
void printvec(vector<T>& vec){
	for(int i=0;i<vec.size();i++){
		cout<<vec[i]<<" ";
	}
	cout<<endl;
}


ll a[612345],pre[612345];
int main(){
    std::ios::sync_with_stdio(false);
    ll n,x;
    ll i;
    cin>>n>>x;
    fd(i,n-1,0){
    	cin>>a[i];
    }
    pre[0]=a[0];
    ll ans,j,mini=inf,val;
    mini*=inf;
    ll iinf=inf;
    iinf*=inf;
    f(i,1,2*n+100){
    	pre[i]=pre[i-1]+a[i];
    }
    f(i,1,n+1){
    	ans=5*(pre[i-1])+x*i;
    	//cout<<pre[i-1]<<"dsdsa"<<endl;
    	val=5;
    	for(j=i;j<n;j+=i){
    		if(iinf/val<pre[j+i-1]-pre[j-1])
    			ans=iinf;
    		else
    			ans+=val*(pre[j+i-1]-pre[j-1]);
    		if(ans>iinf){
    			ans=iinf;
    		}
    		val+=2;
    	}
    	//cout<<i<<" "<<ans<<endl;
    	mini=min(mini,ans);
    }
    cout<<mini+x*n<<endl;
    return 0;   
}



Measured memory_bytes: 8448
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations,groupby
import sys
import bisect
import string
import math
import time
import random
def S_():
    return input()
def LS():
    return [i for i in input().split()]
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def NI(n):
    return [int(input()) for i in range(n)]
def NI_(n):
    return [int(input())-1 for i in range(n)]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def LtoS(ls):
    return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
sys.setrecursionlimit(10**5)
input=lambda: sys.stdin.readline().rstrip()

def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True

from functools import reduce
ans=0
n=I()
d=Counter(LI())
m=I()
t=Counter(LI())

ans='YES'
for i,j in t.items():
    if d[i]<j:
        ans='NO'
print(ans)




Measured memory_bytes: 124876
#include<bits/stdc++.h>
using namespace std;
int n,m,d,a,b;
char c[4]={'R','Y','G','B'};
int main()
{
	scanf("%d%d%d",&n,&m,&d);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			a=((m+i+j)/d)%2;b=((m+i-j)/d)%2;
			//cout<<a<<" "<<b<<endl;
			printf("%c",c[a*2+b]);
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
int main()
{
    int n,i,a[100],count=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=1;i<n-1;i++)
    {
        if(a[i]>a[i-1] && a[i]<a[i+1])
            count++;
        else if(a[i]<a[i-1] && a[i]>a[i+1])
            count++;
    }
    printf("%d",count);
}

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

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  for (int i=0 ; i<N ; i++)
    cin >> A.at(i);
  
  for (int i=0 ; i<N-K ; i++){
    if (A.at(i) < A.at(i+K))
      cout << "Yes" << endl;
    else 
      cout << "No" << endl;
  }
}

Measured memory_bytes: 3980
/*input
10
AC
AC
AC
AC
AC
AC
AC
AC
AC
AC
*/

#include <bits/stdc++.h>
#include <unistd.h>

#define rep(i,j,n) for(i=j;i<n;i++)
#define repi(i,j,n) for(i=j;i>n;i--)
#define inf 1e18
#define M 1000000007
#define pie 3.141592653589793238
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define pb push_back
#define F first
#define S second
#define UQ(x) (x).resize(distance((x).begin(),unique(x.begin(),x.end())))

using namespace std;

mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
mt19937_64 rnd64(chrono::high_resolution_clock::now().time_since_epoch().count());

ll power(ll a,ll m,ll mod){
	ll ans=1;
	while(m){
		if(m%2){
			ans*=a;
			ans%=(mod);
		}
		a=(a*a)%(mod);
		m>>=1;
	}
	return ans;
}


void init(ll* a,ll n,ll val){
	for(ll i=0;i<n;i++)
		a[i]=val;
}

void solve(){
	ll i,j,_;
	ll n;
	cin>>n;
	string s[4]={"AC","WA","TLE","RE"};
	string s1;
	map<string,ll> mp;
	while(n--){
		cin>>s1;
		mp[s1]++;
	}
	rep(i,0,4){
		cout<<s[i]<<" x "<<mp[s[i]]<<endl;
	}
}

int main()
{
	ios::sync_with_stdio(0);
 	cin.tie(0);
	ll T=1;
//	cin>>T;
	while(T--){
		solve();
	}
	return 0;
}




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

// 小数点以下桁数
// fixed << setprecision(i)

int gcd(int a,int b){return (a%b==0?b:gcd(b, a%b));}
int lcm(int a,int b){return a*b/gcd(a, b);}

int main()
{
  string s;
  int ans = 0, n, i = 1;

  cin >> s;
  n = s.size();
  while (s.size() > i)
  {
    if (i == 0)
    {
      i++;
      continue;
    }
    if (s[i] != s[i - 1])
    {
      s.erase(i - 1, 2);
      ans += 2;
      i--;
    }
    else
      i++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 5005;
const ll mod = 1e9 + 7;
const ll INF = 1e9 + 7;
vector<int> p;
int main()
{
    int n,m,k,t=0;

    cin>>n>>m>>k;


    for (int q=1;q<=min(n,m);q++)
    {
        if (n%q==0&&m%q==0)
        {
            p.push_back(q);
        }
    }


    cout<<p[p.size()-k]<<endl;


    return 0;



}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }

const ll mod = 1'000'000'007;
ll dp[100005][3];

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	string s; read(s);
	int n = sz(s);
	s = ' ' + s;

	ll qmult = 1;

	rep(i, 1, n + 1) {
		dp[i][0] = dp[i - 1][0], dp[i][1] = dp[i - 1][1], dp[i][2] = dp[i - 1][2];
		if (s[i] == 'A') dp[i][0] += qmult;
		if (s[i] == 'B') (dp[i][1] += dp[i - 1][0]) %= mod;
		if (s[i] == 'C') (dp[i][2] += dp[i - 1][1]) %= mod;
		if (s[i] == '?') {
			dp[i][0] = (dp[i - 1][0] * 3 + qmult) % mod;
			dp[i][1] = (dp[i - 1][1] * 3 + dp[i - 1][0]) % mod;
			dp[i][2] = (dp[i - 1][2] * 3 + dp[i - 1][1]) % mod;
			qmult = qmult * 3 % mod;
		}
		//printf("%d %lld %lld %lld\n", i, dp[i][0], dp[i][1], dp[i][2]);
	}

	die(dp[n][2]);
}


Measured memory_bytes: 2796
/*
Author : Xinyuan
*/
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef long long int  ll;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int nxt() {int x;scanf("%d", &x);return x;}


int main(){
    int n = nxt(), m = nxt();
    VI height(n);
    for (int i = 0; i < n; i+=1){
        height[i] = nxt();
    }
    VI good(n, 1);
    for (int i = 0; i < m; i+=1){
        int a = nxt(), b = nxt();
        a--;b--;
        if(height[a] <= height[b]) good[a] = 0;
        if(height[b] <= height[a]) good[b] = 0;
    }
    int count = 0;
    for (int i = 0; i < n; i+=1){
        if(good[i]) count++;
    }
    printf("%d\n", count);
    return 0;
}



Measured memory_bytes: 4076
#include<stdio.h>

long long min(long long x,long long y){
	if(x<y)return x;
	return y;
}

long long ab(long long x){
	if(x<0)return -x;
	return x;
}

int main(){
	int N;
	scanf("%d",&N);
	long long h[N];
	for(int i=0;i<N;i++)scanf("%lld",&h[i]);
	
	long long cost[N];
	cost[0]=0;
	for(int i=1;i<N;i++)cost[i]=99999999999999;
	
	for(int i=0;i<N;i++){
		if(i+1<N)cost[i+1]=min(cost[i+1],cost[i]+ab(h[i]-h[i+1]));
		if(i+2<N)cost[i+2]=min(cost[i+2],cost[i]+ab(h[i]-h[i+2]));
	}
	
	printf("%lld\n",cost[N-1]);
	
	return 0;
}

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

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> L(N);
    rep(i,N){
        cin >> L.at(i);
    }
    sort(L.begin(),L.end());

    int maxofL = 0;
    int flag = K;
    for(int i = N-1; flag > 0; i--){
        maxofL += L.at(i);
        flag--;
    }
    
    cout << maxofL << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
left_dic = {}
def add_dic(p):
    if not p in left_dic:
        left_dic[p] = 1
    else:
        left_dic[p] += 1
for i in range(n):
    add_dic(a[i]+i)
def cnt_dic(p):
    if not p in left_dic:
        return 0
    return left_dic[p]
ans = 0
for j in range(n):
    ans += cnt_dic(j-a[j])
print(ans)

Measured memory_bytes: 111724