akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#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)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

string n;
string ans;

bool res(int v, string s){
    int p = (int)s.size() + 1;
    if(p == 4){
        if(v == 7){
            ans = s;
            return true;
        }
        else return false;
    }
    int c = ((int)n[p] - '0') ;
    bool flag = res(v+c, s+'+') || res(v-c, s+'-');
    return false;
}

int main(int argc, char const* argv[])
{
    cin >> n;
    res(((int)n[0] - '0'), "");
    rep(i, 3){
        cout << n[i] << ans[i];
    }
    cout << n[3] << "=7" << endl;
    return 0;
}


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

int main() {

  string s;
  while(true) {

    cin>>s;
    if( s == "0" ) break;

    int a=0,b=0;
    for(int i=1; i<s.length(); i++) {
      if( s[i] == 'A' ) a++;
      else b++;
    }

    ( a > b ) ? a++ : b++;

    cout<<a<<" "<<b<<endl;
  }
}

Measured memory_bytes: 0
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;
const int MOD = 1000000007;

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

  int n; cin >> n;
  vi a(n); rep(i, n) cin >> a[i];
  int m; cin >> m;
  vi b(m); rep(i, m) cin >> b[i];
  vi res;

  set_difference(begin(a), end(a), begin(b), end(b), inserter(res, end(res)));

  for_each(begin(res), end(res), [](int x){cout << x << '\n';});

  return 0;
}


Measured memory_bytes: 5516
# Problem A - Sorted Arrays

# input
N = int(input())
a_list = list(map(int, input().split()))

# initialization
ans = 0
pos = 0

# count
while pos<N:
    pos_1 = pos
    pos_2 = pos

    # up
    while pos_1<N-1 and a_list[pos_1]<=a_list[pos_1+1]:
        pos_1 += 1

    # down
    while pos_2<N-1 and a_list[pos_2]>=a_list[pos_2+1]:
        pos_2 += 1

    large = max(pos_1, pos_2) + 1
    pos = large
    ans += 1

# output
print(ans)


Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
const long long INF = 1<<29;
int main(){
    int n; cin >> n;
    vector<int> x(n);
    rep(i,n) cin >> x[i];
    int sum=0;
    rep(i,n) sum += x[i];
    int mid = floor(sum/n);
    long long ans = INF;
    rep(i,2){
        long long res=0;
        rep(j,n){
            res += (long long)pow(x[j]-mid-i,2);
        }
        ans = min(ans,res);
    }
    cout << ans << endl;
    return 0;
}

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

public class Main implements Runnable {
	public static void main (String[] args) {new Thread(null, new Main(), "_cf", 1 << 28).start();}

	public void run() {
		FastScanner fs = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		System.err.println("");

		int n = fs.nextInt();
		int[] a = fs.nextIntArray(n);
		Arrays.sort(a);
		if(a[n/2] == a[n/2-1]) out.println(0);
		else out.println(a[n/2]-a[n/2-1]);
		
		out.close();
	}

	class FastScanner {
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;

		public FastScanner() {
			in = new BufferedInputStream(System.in, BS);
		}

		public FastScanner(String s) {
			try {
				in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
			}
			catch (Exception e) {
				in = new BufferedInputStream(System.in, BS);
			}
		}

		public char nextChar(){
			while(bId==size) {
				try {
					size = in.read(buf);
				}catch(Exception e) {
					return NC;
				}                
				if(size==-1)return NC;
				bId=0;
			}
			return (char)buf[bId++];
		}

		public int nextInt() {
			return (int)nextLong();
		}

		public long nextLong() {
			num=1;
			boolean neg = false;
			if(c==NC)c=nextChar();
			for(;(c<'0' || c>'9'); c = nextChar()) {
				if(c=='-')neg=true;
			}
			long res = 0;
			for(; c>='0' && c <='9'; c=nextChar()) {
				res = (res<<3)+(res<<1)+c-'0';
				num*=10;
			}
			return neg?-res:res;
		}

		public double nextDouble() {
			double cur = nextLong();
			return c!='.' ? cur:cur+nextLong()/num;
		}

		public String next() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c>32) {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}
		
		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for(int i = 0; i < n; i++) res[i] = nextInt();
			return res;
		}
		
	}

}

Measured memory_bytes: 27928
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

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

func scanInts(n int) []int {
	sl := make([]int, n)
	for i := range sl {
		sl[i] = scanInt()
	}
	return sl
}

func scanStrings(n int) []string {
	sl := make([]string, n)
	for i := range sl {
		sl[i] = scanString()
	}
	return sl
}

func init() {
	sc.Split(bufio.ScanWords)
}

type changeType struct {
  B int
  C int
}

type changeTypeList []changeType

func (c changeTypeList) Len() int {
  return len(c)
}

func (c changeTypeList) Less(i, j int) bool {
  return c[i].C > c[j].C
}

func (c changeTypeList) Swap(i, j int) {
  c[i], c[j] = c[j], c[i]
}

func main() {
	N, M := scanInt(), scanInt()
	A := scanInts(N)
	sort.Ints(A)

  changes := changeTypeList{}
  for i := 0; i < M; i++ {
    B, C := scanInt(), scanInt()
    changes = append(changes, changeType{B: B, C: C})
  }

  sort.Sort(changes)
  sum := 0
  //fmt.Printf("%v", changes)

  //fmt.Printf("%v", A)
  for i := 0; i < M; i++ {
    //fmt.Printf("%v", A)
    //fmt.Printf("%v", changes[i].C)
    idx := sort.Search(len(A), func(k int) bool { return A[k] >= changes[i].C }) - 1
    //fmt.Printf("%v", idx)
    if idx <0 {
      break
    }
    if ( idx + 1) < changes[i].B {
      sum += (idx + 1) * changes[i].C
      A = A[(idx + 1):]
    } else {
      sum += changes[i].B * changes[i].C
      A = A[changes[i].B:]
    }

    //fmt.Printf("%v", A)
    //fmt.Printf("%v\n", sum)
	}
	//fmt.Printf("%v", A)
  for _, num := range(A) {
    sum += num
  }
	fmt.Println(sum)
}


Measured memory_bytes: 8576
//Akash Kumar Mondol
//Department of ICE,University of Rajshahi,Bangladesh
#include<bits/stdc++.h>
using namespace std;
#define pr(x) cerr << "\n" << (#x) << " is " << (x) << endl
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sci(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define scd(x) scanf("%lf",&x)
#define pfi(x) printf("%d",x)
#define pfl(x) printf("%lld",x)
#define pfd(x) printf("%lf",x)
#define pfc(x) printf("Case %d: ",x)
#define ps printf(" ")
#define pn printf("\n")
#define mod 1000000007
#define Toggle(n,i) (n^(1<<i))
#define Check(n,i) (n&(1<<i))
#define Set(n,i) (n|(1<<i))
#define Reset(n,i) (n&(~(1<<i)))
//#define valid(nx,ny) nx>=0&& nx<r && ny>=0 && ny<c
//memset(a, 0, sizeof(a));
//freopen("file_name.txt","read_or_write",stdout_or_stdin);
int main()
{
    //freopen("file_name.txt","w",stdout);
    //ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    string s;
  cin>>s;
  int ans=0;
  int n=s.size();
  for(int i=0;i<n/2;i++)
  {
   		 if(s[i]!=s[n-i-1])
         {
           ans++;
         }
  }
  cout<<ans<<endl;
    return 0;
}




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

int main() {
    ll a;
    long double b;
    cin >> a >> b;
    cout << ll(a*b) << endl;
    return 0;
 }

Measured memory_bytes: 3732
#include <iostream>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <random>
#include <ctime>
#include <bitset>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define ld long double
#define ull unsigned long long
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fast_io cout.tie(0), cin.tie(0), ios_base::sync_with_stdio(0)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//using namespace __gnu_pbds;
//typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ld eps = (ld)1 / 1e6;
ll inf = LLONG_MAX, mod1 = 1e9 + 7, mod2 = 998244353;
ll sqr(ll a) { return a * a; }
ll qb(ll a) { return a * a * a; }
ll gcd(ll a, ll b) { return !a ? b : gcd(b % a, a); }
ll binpow(ll a, ll b, ll mod) { return b ? (b % 2 ? (a * (sqr(binpow(a, b / 2, mod)) % mod)) % mod : sqr(binpow(a, b / 2, mod)) % mod) : 1; }
ll binmult(ll a, ll b, ll mod) { return b ? (b % 2 ? (2 * binmult(a, b / 2, mod) + a) % mod : (2 * binmult(a, b / 2, mod)) % mod) : 0; }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ll p[16], ans[16], dp[14400000], mn[16], st[16], nb[16], dist[16][16][2];
pll c[16];

int main()
{
    fast_io;
    int n, i, j, t;
    ll s, m, nw;
    vector<int> v;
    cin >> n;
    for (i = 1, st[0] = 1; i <= n; i++) cin >> c[i].first >> c[i].second >> p[i], st[i] = st[i - 1] * 3, ans[i] = inf;
    for (i = 1; i <= n; i++) mn[i] = p[i] * min(abs(c[i].first), abs(c[i].second)), dp[0] += mn[i];
    ans[0] = dp[0];
    for (i = 1; i <= n; i++)
        for (j = 1; j <= n; j++)
            for (t = 0; t <= 1; t++)
                dist[i][j][t] = p[i] * abs(t ? c[i].second - c[j].second : c[i].first - c[j].first);
    for (i = 1; i < st[n]; i++)
    {
        dp[i] = inf;
        t = i, nw = 0;
        v.clear();
        for (j = 1; t > 0 && j <= n; j++, t /= 3)
        {
            nb[j] = t % 3;
            if (nb[j]) nw++, v.pb(j), dp[i] = min(dp[i], dp[i - nb[j] * st[j - 1]]);
        }
        for (j = 1, s = 0; j <= n; j++)
        {
            m = mn[j];
            for (auto f: v) m = min(m, dist[j][f][nb[f] - 1]);
            s += m;
        }
        dp[i] = min(dp[i], s);
        ans[nw] = min(ans[nw], dp[i]);
    }
    for (i = 0; i <= n; i++) cout << ans[i] << '\n';
    return 0;
}

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

int main(){
    string s;
    cin >> s;
    int n = s.size();
    int cnt = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == 'o'){
            cnt++;
        }
    }
    if(cnt + 15 - n >= 8){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

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

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	int n, k;
	cin >> n >> k;
	vi x(n);
	rep(i, n) cin >> x[i];

	ll ans = 0;
	rep(i, n){
		ans += min(x[i], k-x[i]) * 2;
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
template<typename tn> void read(tn &a){
	tn x=0,f=1; char c=' ';
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	a=x*f;
}
const int N = 410;
struct edge{int v,nxt,f;ll w;}e[N*N*4];
int head[N],in[N],fr[N],n,x[N],y[N],m,a[N],b[N],tot,t,flow;
ll d[N],val[N],ans;
char c[N];
void add(int x,int y,int f,ll w){
	e[++tot]={y,head[x],f,w};
	head[x]=tot;
	e[++tot]={x,head[y],0,-w};
	head[y]=tot;
}
bool spfa(){
	memset(d,192,sizeof(d));d[0]=0;
	queue<int> q;q.push(0);
	while(!q.empty()){
		int u=q.front();q.pop();in[u]=0;
		for(int i=head[u];i;i=e[i].nxt)
			if(e[i].f&&d[e[i].v]<d[u]+e[i].w){
				d[e[i].v]=d[u]+e[i].w;
				fr[e[i].v]=i;
				if(!in[e[i].v]) q.push(e[i].v),in[e[i].v]=1;
			}
	}
	return d[t]>-1e18;
}
void update(){
	ans+=d[t];flow++;
	for(int x=t;x;x=e[fr[x]^1].v)
		e[fr[x]].f--,e[fr[x]^1].f++;
}
ll EK(){
	flow=ans=0;
	while(spfa()) update();
	return ans;
}
int main(){
	read(n);
	for(int i=1;i<=n;i++)
		read(x[i]),read(y[i]),read(val[i]);
	read(m);
	for(int i=1;i<=m;i++)
		cin>>c[i],read(a[i]),read(b[i]);
	ll mx=0;
	for(int k=1;k<=n;k++){
		tot=1;t=2*k+2*n+1;
		memset(head,0,sizeof(head));
		for(int j=1;j<=k;j++){
			int xl=0,xr=110,yl=0,yr=110;
			for(int i=1;i<=m;i++){
				if(c[i]=='L'&&b[i]<j) xl=max(xl,a[i]+1);
				if(c[i]=='R'&&b[i]<k-j+1) xr=min(xr,a[i]-1);
				if(c[i]=='D'&&b[i]<j) yl=max(yl,a[i]+1);
				if(c[i]=='U'&&b[i]<k-j+1) yr=min(yr,a[i]-1);
			}
			add(0,j,1,0);
			for(int i=1;i<=n;i++)
				if(x[i]>=xl&&x[i]<=xr) add(j,i+k,1,0);
			add(j+k+n+n,t,1,0);
			for(int i=1;i<=n;i++)
				if(y[i]>=yl&&y[i]<=yr) add(i+k+n,j+k+n+n,1,0);
		}
		for(int i=1;i<=n;i++) add(i+k,i+k+n,1,val[i]);
		mx=max(mx,EK());
	}
	cout<<mx<<'\n';
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, A[201010];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 0, N) cin >> A[i];

	map<int, int> cnt;
	ll ans = 0;
	rep(i, 0, N) {
		ans += cnt[i - A[i]];
		cnt[A[i] + i]++;
	}
	cout << ans << endl;
}







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

int main(){

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

int min;
int temp;

for(int i=0;i<3-1;i++){
    min=i;
    for(int j=i;j<3;j++){

        if(a[j]<a[min]){
            min=j;
        }

    }
   temp = a[i];
   a[i] = a[min]; 
   a[min] = temp;
}
for(int i=0;i<3;i++){
    if(i==3-1){
cout<<a[i]<<endl;
    }else{
cout<<a[i]<<" ";
    }
}

    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define FOR(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define FORUL(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define FORULE(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define FOREACH(it, X) for(__typeof((X).begin()) it = (X).begin(); it != (X).end(); it++)
#if defined(_MSC_VER) || __cplusplus > 199711L
#define AUTOVAR(newvar,v) auto newvar = (v)
#else
#define AUTOVAR(newvar,v) __typeof(newvar) r = (v)
#endif
#define PB(x) push_back(x)
#define MP(x,y) make_pair((x),(y))
#define MEMSET(m,v) memset(m,v,sizeof(m))

typedef long long				 ll;
typedef unsigned long long		ull;

#define DEBUG 1

#if DEBUG
#define DOUT cout<<"["<<__LINE__<<"]:"
#else
#define DOUT 0 && cout
#endif

using namespace std;


int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false);
	int R, N;

	cin >> N >> R;
	int ans = R;
	if(N<=10) {
		ans = R + 100*(10-N);
	}

	cout << ans << endl;

	return 0;
}




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

using namespace std;
using ll = long long;
ll gcd(ll a, ll b);
int main(){
cin.tie(0);
ll n,result=0;
cin>>n;
for(ll a=1;a<n;a++){
    for(ll b=1;b*a<n;b++)
        if(a*b<n)result++;
}
cout<<result;
return 0;
}






ll gcd(ll a, ll b){

   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }

}

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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}

	inline int ts(char *s)
	{
		int a=0,c=fetch();
		while(c<=32 && c!=EOF)c=fetch();
		while(c>32 && c!=EOF)s[a++]=c,c=fetch();
		s[a]=0;
		return a;
	}
}
using ae86::ty;
using ae86::ts;

const int _ = 1007;

int n,got[256]={0};
char s[_];

int main()
{
	n=ts(s+1);
	for(int i=1;i<=n;i++)got[(int)s[i]]=1;

	if(got['N']!=got['S'] || got['E']!=got['W'])puts("No");
	else puts("Yes");

	return 0;
}


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


int main(){
  int n,i;
  long long mod=1000000000+7;
  cin >> n;
  vector<int> a(n);
  map<int,int> mp;
  for(i=0;i<n;++i){
    cin >> a[i];
    mp[a[i]]++;
  }
  int ha=0;
  if(n%2==1){
    for(auto p : mp){
      if(p.first%2!=0 && p.second!=2){
        ha=1;
      }
      if(p.first==0 && p.second==2){
        ha=1;
      }
    }
  }else{
    for(auto p : mp){
      if(p.first%2!=1 && p.second!=2){
        ha=1;
      }
    }
  }
  int ca=n/2;
  long long ans=1;
  if(ha==0){
    while(ca>=1){
      ans=ans*2%mod;
      ca--;
    }
  }else{
    ans=0;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3584
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

ll parent[100005];
ll siz[100005];

ll root(ll x) {
  if(x==parent[x]) return x;
  else return parent[x] = root(parent[x]);
}

bool same(ll x, ll y) {
  return root(x)==root(y);
}

ll unite(ll x, ll y) {
  x = root(x);
  y = root(y);
  if(siz[x]<siz[y]) swap(x, y);
  ll ans;
  if(x==y) {
    ans = 0;
    return ans;
  }
  else ans = siz[x]*siz[y];
  parent[y] = x;
  siz[x] += siz[y];
  return ans;
}

int main() {
  ll N, M;
  cin>>N>>M;
  for(ll i=0;i<N;++i) {
    parent[i] = i;
    siz[i] = 1;
  }
  ll A[M], B[M];
  for(ll i=0;i<M;++i) {
    cin>>A[i]>>B[i];
    A[i]--;
    B[i]--;
  }
  ll ans[M];
  ans[M-1] = N*(N-1)/2;
  for(ll i=M-2;i>=0;--i) {
    ans[i] = ans[i+1]-unite(A[i+1], B[i+1]);
  }
  for(ll i=0;i<M;++i) cout<<ans[i]<<endl;
}



Measured memory_bytes: 7496
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    vector<vector<int>> G(N);    // 隣接リスト表現によるグラフ
    vector<pair<int, int>> E_in; // 辺の入力の順番を保持する
    for (int i = 1; i < N; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
        pair<int, int> p = make_pair(a, b);
        E_in.emplace_back(p);
    }
    queue<int> que;
    vector<int> used(N, 0);
    vector<int> parent(N, 0); // 親との間にある辺の数値
    int max_color = 0;
    map<pair<int, int>, int> E_num; // 辺への割り振った番号を保持する
    que.emplace(0); // 最初のものは何でも良いので0からにする
    used[0] = 1;
    while (que.size() != 0) {
        int state = que.front(); // 現在の状態
        que.pop();
        int color_num = 0;
        for (auto next : G[state]) {
            if (used[next] != 1) {
                color_num++;
                used[next] = 1;
                if (color_num == parent[state]) {
                    // 親との間にある辺と番号が被らないようにする
                    color_num++;
                }
                pair<int, int> p = make_pair(state, next);
                E_num[p] = color_num; //辺彩色
                parent[next] = color_num;
                que.push(next); //次の状態をqueueへ格納
            }
        }
        max_color = max(max_color, color_num);
    }
    cout << max_color << "\n";
    for (auto i : E_in) {
        cout << E_num[i] << "\n";
    }
    return 0;
}


Measured memory_bytes: 13812
#include <stdio.h>
int main(void){
    int a,b;
    scanf("%d %d",&a,&b);
    if (a==b)
    printf("a == b\n");
    else if (a>b)
    printf("a > b\n");
    else if (a<b)
    printf("a < b\n");
    return 0;
}



Measured memory_bytes: 2064
package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var n int
	Fscan(in, &n)
	kmp := func(text, s []int) (pos []int) {
		f := make([]int, n)
		c := 0
		for i := 1; i < n; i++ {
			b := s[i]
			for c > 0 && s[c] != b {
				c = f[c-1]
			}
			if s[c] == b {
				c++
			}
			f[i] = c
		}
		c = 0
		for i, b := range text {
			for c > 0 && s[c] != b {
				c = f[c-1]
			}
			if s[c] == b {
				c++
			}
			if c == n && i-n+1 < n {
				pos = append(pos, i-n+1)
				c = f[c-1]
			}
		}
		return
	}

	a := make([]int, n)
	for i := range a {
		Fscan(in, &a[i])
	}
	c := make([]int, n)
	for i, v := range a {
		c[i] = v ^ a[(i+1)%n]
	}
	c = append(c, c...)
	b := make([]int, n)
	for i := range b {
		Fscan(in, &b[i])
	}
	d := make([]int, n)
	for i, v := range b {
		d[i] = v ^ b[(i+1)%n]
	}
	for _, p := range kmp(c, d) {
		Fprintln(out, p, a[p]^b[0])
	}
}

func main() { run(os.Stdin, os.Stdout) }


Measured memory_bytes: 24576
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define mod 1000000007
#define fastio std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define deb(x) cout<<#x<<" "<<x<<endl;
const ll INF = 1e9 + 7;

int main(){
  fastio;
  ll n,k;
  cin>>n>>k;
  vector<ll> h(n+1);
  for (ll i = 1; i <= n; i++) {
    cin>>h[i];
    //deb(i);
  }
  vector<ll> jump(k+1,0);
  for (ll i = 1; i <= k; i++) {
    jump[i] = i;
  }

  vector<ll> dp(n+1,INF);

  dp[1] = 0;

  for (ll i = 1; i <= k; i++) {
    for (ll j = 1; j <= n; j++) {
      for (ll type = 1; type <= i; type++){
      ll diff = INF;
      if(j - jump[type] > 0) diff = dp[j-jump[type]] + abs(h[j] - h[j - jump[type]]);
      dp[j] = min(dp[j] , diff );
    }
  }
    // std::cout << '\n';
    // deb(jump[i]);
    // for (ll i = 0; i <= n; i++) {
    //   std::cout << dp[i] << ' ';
    // }
  }

  // for (ll i = 0; i <= n; i++) {
  //   std::cout << dp[i] << ' ';
  // }

  std::cout<< dp[n] << '\n';
}


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

int main() {
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;

  if (e - a > k) cout << ":(" << endl; else cout << "Yay!" << endl;
}
/*
1
2
4
8
9
15
 */

 


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

int convert(char c, int r, int s, int p) {
  if(c=='r') return p;
  if(c=='s') return r;
  if(c=='p') return s;

  return 0;
}

int score(string t, int n, int k, int m, int r, int s, int p) {
  int ans = 0;
  bool flag = false;
  int i=1;
  ans += convert(t[m], r,s,p);
  while(i*k+m<n) {
    if(t[(i-1)*k+m] != t[i*k+m]) {
      ans += convert(t[i*k+m], r,s,p);
      flag = false;
    }
    else {
      if(flag) {
        ans += convert(t[i*k+m], r,s,p);
        flag = false;
      }
      else flag = true;
    }
    i++;
  }
  return ans;
}


int main() {
  int n,k,r,s,p;
  cin>>n>>k>>r>>s>>p;
  string t;
  cin>>t;

  int ans = 0;
  for(int i=0; i<k; i++) ans += score(t,n,k,i,r,s,p);

  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 512
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  int n, m;
  readf("%s %s\n", &n, &m);
  auto a = readln.chomp.split.to!(int[]);
  int cnt;
  auto vote = a.sum;
  foreach (i; 0..n) {
    if (4 * m * a[i] >= vote) {
      cnt++;
    }
  }

  if (cnt >= m) {
    writeln("Yes");
  } else {
    writeln("No");
  }
}


Measured memory_bytes: 256
;;; Utils (quoted from https://competitive12.blogspot.com/2020/03/common-lisp.html)


;; Read fixnum

(declaim (ftype (function * (values fixnum &optional)) read-fixnum))
(defun read-fixnum (&optional (in *standard-input*))
  (declare (inline read-byte)
           #-swank (sb-kernel:ansi-stream in))
  (macrolet ((%read-byte ()
               `(the (unsigned-byte 8)
                     #+swank (char-code (read-char in nil #\Nul))
                     #-swank (read-byte in nil 0))))
    (let* ((minus nil)
           (result (loop (let ((byte (%read-byte)))
                           (cond ((<= 48 byte 57)
                                  (return (- byte 48)))
                                 ((zerop byte) ; #\Nul
                                  (error "Read EOF or #\Nul."))
                                 ((= byte #.(char-code #\-))
                                  (setq minus t)))))))
      (declare ((integer 0 #.most-positive-fixnum) result))
      (loop
        (let* ((byte (%read-byte)))
          (if (<= 48 byte 57)
              (setq result (+ (- byte 48) (the (integer 0 #.(floor most-positive-fixnum 10)) (* result 10))))
              (return (if minus (- result) result))))))))



;; invoke child process

#-swank
(unless (member :child-sbcl *features*)
  (quit
    :unix-status
    (process-exit-code
      (run-program *runtime-pathname*
                   `("--control-stack-size" "128MB"
                     "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
                     "--eval" "(push :child-sbcl *features*)"
                     "--script" ,(namestring *load-pathname*))
                                                                 :output t :error t :input t))))


;-------------------
; Write code here
;-------------------

(defparameter *inf* (expt 10 7))


;; scores: '((0 . score0) (1 . score1) ...)


(defun solve (n m x cost table &optional (ans *inf*))
  (labels ((dp (amount-of-books scores)
             (cond
               ((zerop amount-of-books)
                (if (every (lambda (score) (<= (rest score) 0)) scores)
                    0
                    *inf*))
               (t
                (min (dp (1- amount-of-books) scores)
                     (+ (dp (1- amount-of-books)
                            (mapcar (lambda (score)
                                      (cons (first score)
                                            (- (rest score) (aref table (1- amount-of-books) (first score)))))
                                    scores))
                        (aref cost (1- amount-of-books))))))))
    (let (scores)
      (dotimes (i m)
        (push `(,i . ,x) scores))
      (let ((ans (dp n (reverse scores))))
        (if (= ans *inf*)
            -1
            ans)))))


(defun main ()
  (let* ((n (read))
         (m (read))
         (x (read))
         (cost (make-array n))
         (table (make-array `(,n ,m))))
    (dotimes (i n)
      (setf (aref cost i) (read-fixnum))
      (dotimes (j m)
        (setf (aref table i j) (read-fixnum))))
    (princ (solve n m x cost table))
    (fresh-line)))

(main)


Measured memory_bytes: 27092
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d ;
  bool q = true;
if(abs(a-c) >d){
  if(abs(a-b)>d|| abs(b-c) >d){
    q = false;
  }
}

  if(q ==true)cout << "Yes" << endl;
  else cout << "No" << endl;
}



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

int main(){
    int N;
    cin >> N;
    vector<pair<int64_t, int64_t>> A(N);
    for(int i = 0; i < N; ++i) cin >> A[i].second >> A[i].first;
    sort(A.begin(), A.end());
    long long sum = 0;
    bool b = true;
    for(int i = 0; i < N; ++i){
        sum += A[i].second;
        if(sum > A[i].first){
            b = false;
            break;
        }
    }
    if(b) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(void) {
  int n, k;
  cin >> n >> k;
  int r, s, p;
  cin >> r >> s >> p;
  string t;
  cin >> t;
  int count[3] = {0, 0, 0};
  vector<bool> change(n);
  for(int i = 0; i < n; i++) {
    change[i] = false;
  }
  for(int i = 0; i < n; i++) {
    int j = i - k;
    switch(t[i]) {
      case 'r':
        if(j < 0 || t[j] != 'r'
           || (t[j] == 'r' && change[j])) {
          count[0]++;
        } else if(j >= 0 && t[j] == 'r') {
          change[i] = true;
        }
        break;
      case 's':
        if(j < 0 || t[j] != 's'
           || (t[j] == 's' && change[j])) {
          count[1]++;
        } else if(j >= 0 && t[j] == 's') {
          change[i] = true;
        }
        break;
      case 'p':
        if(j < 0 || t[j] != 'p'
           || (t[j] == 'p' && change[j])) {
          count[2]++;
        } else if(j >= 0 && t[j] == 'p') {
          change[i] = true;
        }
        break;
    }
  }
  cout << count[0] * p + count[1] * r + count[2] * s
       << endl;
  return 0;
}

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

using namespace std;

int main(){

    string n;
    int soma  = 0;

    cin >> n;
    
   for(int i = 0; i < 4; i++){
       soma += n[i] == '2' ? 1 : 0;
   }

   cout << soma << endl;

    return 0;
}

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<"\n"

int main(){
    int l,r,d;
    cin >> l >> r >> d;
    int count = 0;
    FOR(i,l,r+1){
        if(i%d==0)count++;
    }
    COUT(count);
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
string S, T;
int n, m;

void print(int idx)
{
  string s = S.replace(idx, m, T);
  for (int i = 0; i < n; i++)
  {
    if (s[i] == '?')
      cout << 'a';
    else
      cout << s[i];
  }
  cout << endl;
}

bool solve()
{
  for (int i = n - m; i >= 0; i--)
  {
    for (int j = 0; j < m; j++)
    {
      if (S[i + j] == '?' || T[j] == S[i + j])
      {
        if (j == m - 1)
        {
          print(i);
          return true;
        }
      }
      else
      {
        break;
      }
    }
  }
  return false;
}

int main()
{

  cin >> S >> T;
  n = S.size(), m = T.size();
  if (!solve())
    cout << "UNRESTORABLE" << endl;
}

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

int N, T, A, a[10005], ans;

int abs (int x) {
	return x > 0? x: -x;
}

int main(){
	scanf("%d %d %d", &N, &T, &A);
	A = A * 1000;
	T = T * 1000;
	for (int i = 0; i < N; i++) {
		scanf("%d", &a[i]);
	}
	ans = 0;
	for (int i = 0; i < N; i++) {
		if (abs(A - (T - a[i] * 6)) < abs(A - (T - a[ans] * 6))) {
			ans = i;
		}
	}
	printf("%d\n", ans + 1);
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <algorithm>
#include <functional>
#include <chrono>
#include <random>
#include <vector>
#include <string>
#include <cmath>
#include <bitset>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cassert>

#define sq(x) ((x) * (x))
#define err(x) cerr << "["#x"]  " << (x) << "\n";
#define errp(x) cerr << "["#x"]  {" << ((x).first) << ", " << ((x).second) << "}\n";
#define errv(x) {cerr << "["#x"]  [";for(const auto& ___ : (x)) cerr << ___ << ", "; cerr << "]\n";}
#define errvn(x, n) {cerr << "["#x"]  [";for(auto ___ = 0; ___ < (n); ++___) cerr << (x)[___] << ", "; cerr << "]\n";}
#define errf() cerr << "\n\n";

//#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast, unroll-loops", "omit-frame-pointer","inline")
#pragma GCC option("arch=native","tune=native","no-zero-upper")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native,avx2")

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int getrnd(int l, int r) {
    return uniform_int_distribution<int>(l, r)(rng);
}

ll getrndll(ll l, ll r) {
    return uniform_int_distribution<ll>(l, r)(rng);
}

template <typename T1, typename T2>
inline bool relax(T1& a, const T2& b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

template <typename T1, typename T2>
inline bool strain(T1& a, const T2& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}

// :::::::::::::::::::::::::::::::

void solve() {
    int n;
    cin >> n;
    
    int x = 0;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        x ^= a[i];
    }
    
    for (int i = 0; i < n; ++i)
        cout << (x ^ a[i]) << ' ';
    cout << '\n';
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr); cout.tie(nullptr);
    srand(time(0));
    
    int t = 1;
//    cin >> t;
    while (t--)
        solve();
    
    return 0;
}



Measured memory_bytes: 4028
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

lint gcd(lint m,lint n){
  if(n==0)return m;
  else return gcd(n,m%n);
}

lint lcm(lint m,lint n){
  return m/gcd(m,n)*n;
}

int main(){
  lint A,B,C,D,E;
  cin>>A>>B>>C>>D;
  E=lcm(C,D);
  lint ans=B-A+1;
  ans-=B/C-(A-1)/C;
  ans-=B/D-(A-1)/D;
  ans+=B/E-(A-1)/E;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
  {int H, W; cin >> H >> W;
  for (int i = 0; i < H; ++i)
    {for (int j = 0; j < W; ++j)
      {string S; cin >> S;
      if (S == "snuke") cout << char('A' + j) << i + 1 << endl;}}}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
long long dp[110][110000];
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;}
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
  int N, W;
  cin >> N >> W;
  int w[N], v[N];
  rep(i,N){
    cin >> w[i] >> v[i];
  }
  rep(i,110){
    rep(j,110000){
      dp[i][j] = INF;
    }
  }
  dp[0][0]=0;
  rep(i,N){
    rep(j,110000){
      if(j-v[i]>=0)chmin(dp[i+1][j],dp[i][j-v[i]]+w[i]);
      chmin(dp[i+1][j],dp[i][j]);
    }
  }
  long long ans = 0;
  rep(i,100100){
    if(dp[N][i]<=W){
      ans = i;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 98140
#include <iostream>

using namespace std;

int main()
{
	int n,x=0,i,max=0;
	char str[110];
	cin >> n;
	cin >> str;
	
	for (i = 0; str[i] != '\0'; i++) {
		if (str[i] == 'I') {
			x++;
			if (max < x)max = x;
		}
		else x--;
	}
	cout << max << endl;
	return 0;
}

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

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	public static void Main(string[] args)
	{
		var a = Console.ReadLine().ToInt();
		var b = Console.ReadLine().ToInt();
		var h = Console.ReadLine().ToInt();
		Console.WriteLine((a+b)*h/2);
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}

public class BIT
{
	private long[] array;
	private int count;
	public BIT(int n)
	{
		array = new long[n+1];
		count = n;
	}
	
	public long Sum(int i)
	{
		long s = 0;
		while(i > 0)
		{
			s += array[i];
			i -= i & -i;
		}
		return s;
	}
	
	//[i,j]
	public long Sum(int i, int j)
	{
		long left = Sum(i-1);
		long right = Sum(j);
		return right - left;
	}
	
	public void Add(int i, long x)
	{
		while(i <= count)
		{
			array[i] += x;
			i += i & -i;
		}
	}
	
}

Measured memory_bytes: 11092
#include<stdio.h>
int p[524288];
bool chk(int l,int r)
{
	for(int i=l;i<=r;i++)
	{
		if(p[i]<l||p[i]>r)
		{
			return false;
		}
	}
	if(l==r)
	{
		return true;
	}
	if(p[l]==l)
	{
		l++;
	}
	if(p[r]==r)
	{
		r--;
	}
	int now1=0,now2=0;
	for(int i=l;i<=r;i+=2)
	{
		if(p[i]<i)
		{
			if(p[i]<now1)
			{
				return false;
			}
			now1=p[i];
		}
		else
		{
			if(p[i]<now2)
			{
				return false;
			}
			now2=p[i];
		}
	}
	return true;
}
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&p[i]);
	}
	for(int i=1;i<=n;i++)
	{
		if((p[i]^i)&1)
		{
			printf("No\n");
			return 0;
		}
	}
	int now=1;
	for(int i=2;i<=n;i++)
	{
		if((p[i]==i)==(p[i-1]==i-1))
		{
			if(!chk(now,i-1))
			{
				printf("No\n");
				return 0;
			}
			now=i;
		}
	}
	if(chk(now,n))
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>

using namespace std;

#define ll long long

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

    int ans  = 0;
    for(int i = 0;i < n-1;++i){
        if(s[i] != s[i+1]){
            ans++;
        }
    }

    cout << ans+1 << endl;

    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
long long a[100005];
int main()
{
    int n,x;
    long long ans=0,sum,m;
    map<int,int>ma;
    vector<int>vec;
    scanf("%d%lld",&n,&m);
    for(int i=1;i<=n;i++)
        scanf("%lld",&a[i]),a[i]+=a[i-1];
    for(int i=1;i<=n;i++)
    {
        x=a[i]%m;
        if(ma[x]==0)vec.push_back(x);
        ma[x]++;
    }
    int l=vec.size();
    for(int i=0;i<l;i++)
    {
        sum=ma[vec[i]];
        if(vec[i])sum--;
        ans+=sum*(sum+1)/2;
    }
    cout << ans<<endl;
    return 0;
}


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


// type definitions
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vi > vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef complex<int> ci;
typedef complex<double> cd;
typedef complex<long double> cld;

// macros
#define rep(i, a, b) for(int i=a; i<b; i++)
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define all(c) c.begin(), c.end()
#define tr(c, it) for(auto it=(c).begin(); it!=c.end(); it++)
#define pb push_back
#define mp make_pair
#define bitcount __builtin_popcount
#define ispresent(c, x) ((c).find(x) != (c).end())
#define watch(x) cout<< (#x) << " is " << (x) <<"\n";
#define sz(x) ((int)((x).size()))
#define UNIQUE(c) (c).resize(unique(all(c)) - (c).begin())
#define pii2ll(p) ((ll)(p).first<<32 | (p).second)

// template functions
template <typename T>
inline void printV(vector<T>& a) { rep(i, 0, sz(a)) { cout<<a[i]<<" "; } cout<<"\n"; }
template <typename T>
inline void printV(vector<T>& a, int n) { rep(i, 0, n) { cout<<a[i]<<" "; } cout<<"\n"; }
template <typename T>
inline void printVV(vector<vector<T>>& a)
{
	rep(i, 0, sz(a)) {
		printV(a[i]);
	}
	cout<<"\n";
}

template <typename T>
inline void clearVV(vector<vector<T>>& a)
{
	for(auto& x:a) {
		x.clear();
	}
	a.clear();
}
template <typename T>
inline void assignVV(vector<vector<T>> &a, T val)
{
	for(int i=0; i<sz(a); i++) {
		for(int j=0; j<sz(a[i]); j++) {
			a[i][j]=val;
		}
	}
}


// constants
const long double eps = 1e-9;
const int inf = 5e8;
const int modn = 1e9+7;
const int MAX = 1e5;

string s, t;
string lcs;



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // Your code here
    s+='.', t+='.';
    string stmp, ttmp;
    cin>>stmp>>ttmp;
    s+=stmp;
    t+=ttmp;
	int n1=s.size()-1;
	int n2=t.size()-1;
	vector<vector<int>> dp(n1+1, vector<int>(n2+1));
	vector<vector<pair<int, int>>> nx(n1+1, vector<pair<int, int>>(n2+1));
	
	for(int i=1; i<=n1; i++) {
		for(int j=1; j<=n2; j++) {
			
			if(s[i]==t[j]) {
				dp[i][j]=1+dp[i-1][j-1];
				nx[i][j]={i-1, j-1};
			}
			else {
				if(dp[i-1][j]>dp[i][j-1]) {
					dp[i][j]=dp[i-1][j];
					nx[i][j]={i-1, j};
				}
				else {
					dp[i][j]=dp[i][j-1];
					nx[i][j]={i, j-1};
				}
			}
		}
	}
	function<void(int, int)> printlcs = [&](int x, int y)
	{
		if(x<=0 or y<=0) return;
		if(s[x]==t[y]) {
			lcs+=s[x];
		}
		int newx=nx[x][y].first;
		int newy=nx[x][y].second;
		printlcs(newx, newy);
	};
	printlcs(n1, n2);
	//~ for(int i=0; i<sz(nx); i++) {
		//~ for(int j=0; j<sz(nx[i]); j++) {
			//~ cout<<nx[i][j].first<<" "<<nx[i][j].second<<"\n";
		//~ }
	//~ }
	reverse(all(lcs));
	cout<<lcs<<"\n";
    return 0;
}



Measured memory_bytes: 106240
class Tree(): #weighted
    def __init__(self, n, edge, indexed=1):
        self.n = n
        self.tree = [[] for _ in range(n)]
        for e in edge:
            self.tree[e[0] - indexed].append((e[1] - indexed, e[2]))
            self.tree[e[1] - indexed].append((e[0] - indexed, e[2]))

    def setroot(self, root):
        self.root = root
        self.parent = [None for _ in range(self.n)]
        self.parent[root] = -1
        self.depth = [None for _ in range(self.n)]
        self.depth[root] = 0
        self.distance = [None for _ in range(self.n)]
        self.distance[root] = 0
        self.order = []
        self.order.append(root)
        self.cost = [0 for _ in range(self.n)]
        self.size = [1 for _ in range(self.n)]
        stack = [root]
        while stack:
            node = stack.pop()
            for adj, cost in self.tree[node]:
                if self.parent[adj] is None:
                    self.parent[adj] = node
                    self.depth[adj] = self.depth[node] + 1
                    self.distance[adj] = self.distance[node] + cost
                    self.cost[adj] = cost
                    self.order.append(adj)
                    stack.append(adj)
        for node in self.order[::-1]:
            for adj, cost in self.tree[node]:
                if self.parent[node] == adj:
                    continue
                self.size[node] += self.size[adj]

import sys
input = sys.stdin.readline

N = int(input())
E = [tuple(map(int, input().split())) for _ in range(N - 1)]
t = Tree(N, E)
t.setroot(0)

for i in range(N):
    if t.distance[i] % 2 == 0:
        print(0)
    else:
        print(1)

Measured memory_bytes: 62608
P = 998244353
N, K = map(int, input().split())
X = []
for _ in range(K):
    l, r = map(int, input().split())
    X.append((l-1, r))

A = [1] + [0] * N
S = [0, 1] + [0] * N
for i in range(1, N):
    for l, r in X:
        A[i] += S[max(i-l, 0)] - S[max(i-r, 0)]
        A[i] %= P
    S[i+1] = (S[i] + A[i]) % P

print(A[N-1])

Measured memory_bytes: 73820
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

int a,b,c,d,k;

int main()
{
	cin>>a>>b>>c>>d>>k;
	int ans=(c-a)*60; ans+=(d-b); ans-=k;
	cout<<ans<<endl;
	return 0;
}

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

int main()
{
  int N, K;
  cin >> N >> K;
  vector<long long int> h(N);
  for (int i = 0; i < N; i++)
  {
    cin >> h.at(i);
  }
  long long int ans = 100000000000;
  sort(h.begin(), h.end());
  for (int i = 0; i < N - K + 1; i++)
  {
    long long int hmin, hmax;
    hmin = h.at(i);
    hmax = h.at(i + K - 1);
    ans = min(ans, hmax - hmin);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
N = int(input())
Sj = sorted([input() for i in range(N)])

maxCnt = 0
cnt = 0
result = []
str = ''
for S in Sj:
	if S == str:
		cnt += 1
	else:
		str = S
		cnt = 1
	if cnt > maxCnt:
		maxCnt = cnt
		result = [S]
	elif cnt == maxCnt:
		result.append(S)
for rStr in result:
	print(rStr)	

Measured memory_bytes: 20140