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

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

    String s = sc.next();
    String head = s.substring(0, s.length() / 2);
    String tail = s.substring(s.length() / 2 + 1);

    if (isKaibun(s) && isKaibun(head) && isKaibun(tail)) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }

  private static boolean isKaibun(String s) {
    char[] chars = s.toCharArray();
    for (int i = 0; i < s.length() / 2; i++) {
      if (chars[i] != chars[s.length() - i - 1]) {
        return false;
      }
    }
    return true;
  }
}


Measured memory_bytes: 25172
from itertools import permutations
N=int(input())
ans=[0]*(10**6)
for x in range(1,N+1):
    if x**2>N:
        break
    for y in range(1,N+1):
        if x**2+y**2>N:
            break
        for z in range(1,N+1):
            if x**2+y**2+z**2>N:
                break
            else:
                kari=[x,y,z]
                #print(kari)
                if x**2+y**2+z**2+x*y+y*z+z*x<=10**5:
                    ans[x**2+y**2+z**2+x*y+y*z+z*x-1]+=1
                    
for i in range(N):
    print(ans[i])

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

int main(void){
	long long int n, m, ans, tmp;

	cin >> n >> m;

	tmp = m - 2 * n;
	if (tmp >= 0){
		ans = n + tmp / 4;
	}
	else {
		ans = m / 2;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn

object Main extends App {

  val s = StdIn.readLine()
  val a = Array.ofDim[Int](26) // a to z
  
  s.foreach(c => a(c - 'a') += 1)
  val r = a.indexWhere(p => p == 0)

  //println(a.mkString(" "))
  
  println(if(r < 0) "None" else (r+'a').toChar)

}


Measured memory_bytes: 27380
#include<stdio.h>
#include<stdlib.h>

int main()
{
  int **arr1;
  int **arr2;
  long long **arr3;
  long long s;
  int n1,n2,n3;
  int num;

  scanf("%d %d %d", &n1, &n2, &n3);
  arr1 = (int**)malloc(sizeof(int*)*n1);
  for(int i = 0; i < n1; i++)
    {
      arr1[i] = (int*)calloc(n2, sizeof(int));
    }
  arr2 = (int**)malloc(sizeof(int*)*n2);
  for(int i = 0; i < n2; i++)
    {
      arr2[i] = (int*)calloc(n3, sizeof(int));
    }
  arr3 = (long**)malloc(sizeof(long*)*n1);
  for(int i = 0; i < n1; i++)
    {
      arr3[i] = (long*)calloc(n3, sizeof(long));
    }
  for(int i = 0; i < n1; i++)
    {
      for(int j = 0; j < n2; j++)
	{
	  scanf("%d", &num);
	  arr1[i][j] = num;
	}
    }
  for(int i = 0; i < n2; i++)
    {
      for(int j = 0; j < n3; j++)
	{
	  scanf("%d", &num);
	  arr2[i][j] = num;
	}
    }
  for(int i = 0; i < n1; i++)
    {
      for(int j = 0; j < n2; j++)
	{
	  for(int k = 0; k < n3; k++)
	    {
	      s =  arr1[i][j]*arr2[j][k];
	      arr3[i][k] += s;
	    }
	}
    }
  for(int i = 0; i < n1; i++)
    {
      for(int j = 0; j < n3-1; j++)
	{
	  printf("%lld ", arr3[i][j]);
	}
      printf("%lld\n", arr3[i][n3-1]);
    }
}



Measured memory_bytes: 2136
#include<iostream>
#include<algorithm>
using namespace std;
int a[100];
int main(){
    int n,count=1;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=1;i<n;i++){
        int f=1;
        for(int j=0;j<i;j++){
            if(a[j]>a[i]){
                f=0;
            }
        }
        if(f)
            count++;
    }
    cout<<count;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FastIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;



void solve(int k, string s){
   int n = s.size();

    if (n <= k){

        cout << s << endl;
    }else{
        string temp = s.substr(0, k);
        temp += "...";
       cout << temp << endl; 
    } 
}



int main()
{
 
    FastIO 



    int k;
    string s;
    cin >> k;
    cin >> s;
    solve(k, s);

    return 0;
        
}
 
  






Measured memory_bytes: 3616
S = input()
T = input()
min_change = 1000

for i in range(len(S)-len(T)+1):
    count = 0
    for j in range(len(T)):
        if T[j] != S[i+j]:
            count += 1
    min_change = min(min_change, count)

print(min_change)


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

int main(){
	int a, b;
	string s;

	cin >> a >> b >> s;

	if(s[a]!='-'){
		cout << "No" << endl;
		return 0;
	}

	for (int i = 0; i < a;i++){
		if(s[i]=='-'){
			cout << "No" << endl;
			return 0;
		}
	}

	for (int i = 0; i < b; i++)
	{
		if (s[i+a+1] == '-')
		{
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
	return 0;
}


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

#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define ssort(n) sort((n).begin(),(n).end())
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
#define repl(i,n) for(ll i=0;i<(n);++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl

int main()
{
    int N;
    cin >> N;
    vector<ll> l(N);
    rep(i,N){
        cin >> l[i];
    }
    ssort(l);
    int count=0;
    if(N<3){
        cout << 0 << endl;
    }else{
        rep(i,N-2){
            FOR(j,N-1,i+1){
                FOR(k,N,j+1){
                    if(l[i]+l[j]>l[k]&&l[i]!=l[j]&&l[i]!=l[k]&&l[j]!=l[k]){
                        count++;
                    }
                }
            }
        }
        cout << count << endl;
    }

}

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

int main(){
  int N,a,b,c;
  long long Y;
  bool ans = false;

  cin >> N >> Y;

  if(Y % 1000 != 0){
    cout << "-1 -1 -1" << endl;
  }
  else{
    for(a = 0; a <= N; a++){
      for(b = 0; b <= N; b++){
        c = N - a - b;
        if((Y == 10000*a + 5000*b + 1000*c) && ans == false && c >= 0){
          ans = true;
          cout  << a << " " << b << " " << c << endl;
        }
      }
    }
    if(ans == false) cout << "-1 -1 -1" << endl;
  }
}


Measured memory_bytes: 256
using System;
using System.Linq;
public class Hello
{

    public static void Main()
    {
        string[] str = Console.ReadLine().Split(' ');
        int H = int.Parse(str[0]);
        int W = int.Parse(str[1]);
        string[,] f = new string[H, W];
        for (int i = 0; i < H; i++)
        {
            string s = Console.ReadLine();
            char[] c = s.ToCharArray();
            string[] c_s = Array.ConvertAll<char, string>(c, delegate (char c_) { return c_.ToString(); });
            for (int j = 0; j < W; j++) f[i, j] = c_s[j];
        }

        string[,] ans = new string[H, W];

        int count = 0;
        for (int i = 0; i < H; i++)
        {
            for (int j = 0; j < W; j++)
            {
                //その場がそうだった場合
                if (f[i, j] == "#")
                {
                    ans[i, j] = "#";
                    continue;
                }

                count = 0;
                //0じゃないなら上を見る
                if (i != 0)
                {
                    //真上
                    if (f[i - 1, j] == "#") count++;
                    //左上
                    if (j != 0)
                    {
                        if (f[i - 1, j - 1] == "#") count++;
                    }
                    //右上
                    if (j != (W - 1))
                    {
                        if (f[i - 1, j + 1] == "#") count++;
                    }
                }
                //右
                if (j != (W - 1))
                {
                    if (f[i, j + 1] == "#") count++;
                }
                //下
                if (i != (H - 1))
                {
                    //真下
                    if (f[i + 1, j] == "#") count++;
                    //右下
                    if (j != (W - 1))
                    {
                        if (f[i + 1, j + 1] == "#") count++;
                    }
                    //左下
                    if (j != 0)
                    {
                        if (f[i + 1, j - 1] == "#") count++;
                    }
                }
                //左
                if (j != 0)
                {
                    if (f[i, j - 1] == "#") count++;
                }
                ans[i, j] = count.ToString();
            }
        }

        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) Console.Write(ans[i, j]);
            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 13220
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const int INF = 1000000000; // 10^9
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    string S;
    cin >> S;
    if(S == "AAA" || S == "BBB"){
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int maxn = 55;
#define _for(i,a,b) for(int i=a;i<=b;i++)
int n,m,a[maxn];
int main(int argc, char const *argv[])
{
    cin>>n>>m;
    if(n<=m)cout<<n<<endl;
    else cout<<n-1<<endl;
    return 0;
}

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

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	while (true) {
		int n, m, p;
		cin >> n >> m >> p;
		if (n == 0 && m == 0 && p == 0)break;

		VI x(n);
		rep(i, n)cin >> x[i];

		int gold = accumulate(all(x), 0) * (100 - p);
		if (x[m - 1] == 0)gold = 0;
		else gold /= x[m - 1];

		cout << gold << endl;
	}
}


Measured memory_bytes: 3016
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);


int main() {
    int n, a, b;
    cin >> n >> a >> b;
    printf("%d %d", min(a, b), max(0, (a + b) - n));
    return 0;
}

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

using namespace std;

typedef long long LL;
bool go(LL x, LL y, LL a, LL b) {
    if(x == a) return true;
    if(y == b) return true;
    if(x + y == a + b) return true;
    if(x - y == a - b) return true;
    return false;
}
typedef pair<int, int> P;

int main(){
    int T;
    cin >> T;
    while(T--){
        LL x1, y1, x2, y2, X, Y;
        cin >> x1 >> y1 >> x2 >> y2 >> X >> Y;

        if(x1 == X && y1 == Y) {
            cout << 0 << endl;
        } else if(x2 == X && y2 == Y) {
            cout << 0 << endl;
        } else if(go(x1, y1, X, Y) && go(x2, y2, X, Y)) {
            cout << 1 << endl;
        } else if(go(x1, y1, X, Y) || go(x2, y2, X, Y)) {
            cout << 2 << endl;
        } else if(go(x1, y1, x2, y2)) {
            cout << 3 << endl;
        } else {
            vector<P> vp;
            for(int iter = 0; iter < 2; iter++){
                vp.push_back(P(x1, y2));
                vp.push_back(P( x1 - y1 + y2, y2));
                vp.push_back(P( x1 + y1 - y2, y2));
                vp.push_back(P(x2, -x1 + x2 + y1));
                vp.push_back(P(x2, +x1 - x2 + y1));
                if((x1 - y1 + x2 + y2) % 2 == 0) {
                    vp.push_back(P((x1 - y1 + x2 + y2) / 2, (-x1 + y1 + x2 + y2) / 2));
                }
                swap(x1, x2); swap(y1, y2);
            }
            bool ok = false;
            for(auto p : vp) {
                assert(p.first != x1 || p.second != y1);
                assert(p.first != x2 || p.second != y2);
                if(go(p.first, p.second, X, Y)) {
                    ok = true;
                }
            }
            cout << (ok ? 3 : 4) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,n) for ( int i = (a); i < (n); ++i)
#define REP(i,n) for( int i = 0; i < (n); ++i )
#define ALL(obj) (obj).begin(), (obj).end()

int main()
{
    int N;
    cin >> N;
    map<int,int> data;

    REP(i,N) {
        int v;
        cin >> v;
        data[v]++;

        if( data[v] >= 2 ) {
            cout << "NO" << endl;
            return 0;
        }
    } 
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 9600
import sys
import math
import itertools
from collections import deque
import copy
import bisect

MOD = 10 ** 9 + 7
INF = 10 ** 18 + 7
input = lambda: sys.stdin.readline().strip()

N, K = map(int, input().split())
print(int(((math.log(N, K)) // 1) + 1))


Measured memory_bytes: 3700
from collections import Counter

n = int(input())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

li = []

for i in range(1,n+1):
    li += prime_factorize(i)

C = Counter(li)

a,b,c,d,e = 0,0,0,0,0

for i in C.values():
    if i >= 74:
        e += 1
    elif i >= 24:
        d += 1
    elif i >= 14:
        c += 1
    elif i >= 4:
        b += 1
    elif i >= 2:
        a += 1

point = 0
point += e
point += (d+e)*(a+b+c) + (d+e)*(d+e-1)
point += (c+d+e)*b + (c+d+e)*(c+d+e-1)
point += a*((b+c+d+e)*(b+c+d+e-1)//2) + (b+c+d+e)*((b+c+d+e-1)*(b+c+d+e-2)//2)

print(point)

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

int main()
{
	char s1[12],s2[13];
	scanf("%s%s",&s1,&s2);
	if(strlen(s2)-strlen(s1)!=1)
	{
		printf("No\n");
			return 0;
	}
	for(int i=0;i<strlen(s1);i++)
	{
		if(s1[i]!=s2[i])
		{
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 1644
//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector") 
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>


#define ll long long
#define ull unsigned long long
#define int ll
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) {cout << a; exit(0);}

using namespace std;

mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b,ll mod) {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;}

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

const int N = 2e5 + 1 , MB = 60;
int n , xsum;
int a[N];
main(){
	cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> a[i] , xsum ^= a[i];

	for(int i = 1 ; i <= n; i++){
		for(int bt = 0 ; bt <= MB;bt++)
			if(xsum&a[i]&(1ll << bt))
				a[i] ^= (1ll << bt);
    }

	int l = 1;
	for(int bt = MB ; bt >= 0 ; bt--){
		int vl = -1;
		for(int i = l ; i <= n; i++)
			if((a[i]&(1ll<<bt))and vl < a[i])
				vl = a[i] , swap(a[l],a[i]);				
		if(vl == -1)continue;
		for(int i = 1 ; i <= n; i++)
			if(i != l and (a[i]&(1ll << bt)))
				a[i] ^= a[l];	
		l++;
	}
	ll res = 0;
	for(int i = 1; i <= n; i++)    	
		res ^= a[i];
	cout << res + (res ^ xsum);
}

Measured memory_bytes: 1024
#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;
# define my_sizeof(type) ((char *)(&type+1)-(char*)(&type)) 
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(ull i=a;i<b;i++)
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define mkp make_pair
#define nl cout<<endl
#define MOD 1000000007
#define trace(s,a) cout<<s<<a,nl
#define MAXN 100002
ll cnt = 0;
vector< ll > v[10];  
ll p[10];
ll pwr( ll a, ll b ){
	if(b == 1)
		return a;

	ll half = pwr(a, b/2);

	if(b%2 == 1)
		return half*half*a;
	else{
		return half*half;
	}
}

bool check(ll* a, ll n){
	ll flag = 0;
	for(ll i=0; i<10; i++){
		ll s = v[i].size();
		ll c = 0;
		for(ll j=0; j<s; j++){
			if(a[v[i][j] - 1] == 1)
				c++;
		}
		if(c%2 != p[i]){
			flag = 1;
			break;
		}
	}
	if(flag == 0)
		return true;
	return false;
}

void poss(ll* a, ll n, ll k){
	if(k == n){
		if(check(a, n))
			cnt++;
		return;
	}
	
		a[k] = 0;
		poss(a, n, k+1);
		a[k] = 1;
		poss(a, n, k+1);
	
}

int main(){
	
    ll n, m; 
    cin>>n>>m;
    ll a[n];
    ll z;
    for(ll i=0; i<m; i++){
    	cin>>z;
    	for(ll j=0; j<z; j++){
    		ll x;
    		cin>>x;
    		v[i].pb(x);
    	}
    }
    for(ll i=0; i<m; i++){
    	cin>>p[i];
    }
    poss(a, n, 0);
    cout<<cnt;

}

Measured memory_bytes: 256
import java.util.*;
     
public class Main {
  private final static int MOD = 1000000007;
     
  private static long solve(int n, int[][] edges) {
    List<List<Integer>> adj = new ArrayList<>(n + 1);
    for (int i  = 0; i <= n; i++) {
      adj.add(new ArrayList<>());
    }
    
    for (int[] edge : edges) {
      adj.get(edge[0]).add(edge[1]);
      adj.get(edge[1]).add(edge[0]);
    }

    long[] res = dfs(adj, 1, -1);
    return (res[0] + res[1]) % MOD;
  }
  
  static long[] dfs(List<List<Integer>> adj, int cur, int parent) {
    long[] res = new long[2]; 
    Arrays.fill(res, 1);

    for (int next : adj.get(cur)) {
      if (next != parent) {
        long[] child = dfs(adj, next, cur);
        res[0] = (res[0] * child[1]) % MOD;
        res[1] = (res[1] * ( child[0] + child[1])) % MOD;
      }
    }

    return res;
  }



  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int n = scanner.nextInt();
    int[][] edges = new int[n-1][2];
    for (int i = 0; i < n-1; i++) {
      edges[i] = new int[] { scanner.nextInt() - 1, scanner.nextInt() - 1};
    }

    long result = solve(n, edges);
    System.out.println(result); 
  } 
}

Measured memory_bytes: 110944
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int h, w, n;
    cin >> h >> w >> n;
    vector<int> c;
    for (int i=0; i<n; i++){
        int a;
        cin >> a;
        for (int j=0; j<a; j++) c.push_back(i+1);
    }

    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            cout << c[i*w + (i%2?(w-j-1):j)] << (j==w-1?'\n':' ');
        }
    }
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do{cout << "\033[32;1m" << #x << "->" ; err(x);} while(0)
void err(){cout << "\033[39;0m" << endl;}
template<template<typename...> class T,typename t,typename... A>
void err(T<t> a,A... x){for (auto v:a) cout << v << ' '; err(x...);}
template<typename T,typename... A>
void err(T a,A... x){cout << a << ' '; err(x...);}
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
        print(v[i],i==(int)(v.size())-1?suc:2);
}
const int INF=0x3f3f3f3f;

int main()
{
	string s;
	cin>>s;
	int cnt=0;
	ll ans=0;
	for(auto u:s)
	{
		if(u=='B') cnt++;
		else ans+=cnt;
	}
	print(ans);
}


Measured memory_bytes: 3740
#include <bits/stdc++.h>
using namespace std;
int a[1000];
int main()
{
    int sum=0;
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(int i=2;i<n;i++)
    {
        int maxx=max(max(a[i-1],a[i+1]),a[i]);
        int minn=min(min(a[i-1],a[i+1]),a[i]);
        if(a[i]!=maxx&&a[i]!=minn)
            sum++;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
 
int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
 
  int h,w,n; cin>>h>>w>>n;
  map<ll,int> cnt;
  for (int i = 0; i < n; i++) {
    int a,b; cin>>a>>b; a--; b--;
    for (int i = -2; i <= 0; i++) {
      if (a+i < 0 or a+i+2 >= h)
        continue;
      for (int j = -2; j <= 0; j++) {
        if (b+j < 0 or b+j+2 >= w)
          continue;
        cnt[(ll(a+i)<<32) + (b+j)]++;
      }
    }
  }
  vector<ll> ans(10);
  ans[0] = ll(h-2)*(w-2);
  for (auto [p,k]:cnt) {
    ans[k]++;
    ans[0]--;
  }
  for (int i = 0; i <= 9; i++) {
    cout << ans[i] << endl;
  }
 
  return 0;
}

Measured memory_bytes: 59824
#include <bits/stdc++.h>
using namespace std;
long INF=10000000000;

//関数



//main関数
int main() {
    
    
    //入力
    long n;
    cin>>n;
    vector<long> v(n);
    for(int i=0;i<n;i++){
        cin>>v.at(i);
    }
    
    //計算
    vector<long> couo(200000),coue(200000);
    for(int i=0;i<n;i++){
        if(i%2==0) coue.at(v.at(i))++;
        else couo.at(v.at(i))++;
    }
    
    long maxo=0,maxe=0,subo=0,sube=0;
    for(int i=0;i<couo.size();i++){
        if(couo.at(i)>couo.at(maxo)){
            subo=maxo;
            maxo=i;
        }else if(couo.at(i)>couo.at(subo)){
            subo=i;
        }
    }
    for(int i=0;i<coue.size();i++){
        if(coue.at(i)>coue.at(maxe)){
            sube=maxe;
            maxe=i;
        }else if(coue.at(i)>coue.at(sube)){
            sube=i;
        }
    }
    //cout<<" maxo "<<maxo<<" maxe "<<maxe<<" subo "<<subo<<" sube "<<sube<<endl;
    //出力
    
    if(maxo!=maxe){
        cout<<n-couo.at(maxo)-coue.at(maxe)<<endl;
    }else{
        cout<<min(n-couo.at(maxo)-coue.at(sube),n-couo.at(subo)-coue.at(maxe))<<endl;
    }
}

Measured memory_bytes: 4224
a=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k=int(input())
print(a[k-1])


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {
    static int N = 100;
    static int WHITE = 0;
    static int GRAY = 1;
    static int BLACK = 2;

    static int n;
    static int[][] M = new int[N][N];
    static int[] color = new int[N];
    static int[] d = new int[N];
    static int[] f = new int[N];
    static int tt;

    // 再帰関数による深さ優先探索
    public static void dfsVisit(int u) {
        int v;
        color[u] = GRAY;
        d[u] = ++tt; // 最初の訪問
        for(v = 0; v < n; v++) {
            if(M[u][v] == 0) continue;
            if(color[v] == WHITE) {
                dfsVisit(v);
            }
        }
        color[u] = BLACK;
        f[u] = ++tt; // 訪問の終了
    }

    public static void dfs() {
        int u;
        // 初期化
        for(u = 0; u < n; u++) color[u] = WHITE;
        tt = 0;

        for(u = 0; u < n; u++) {
            // 未訪問のuを支店として深さ優先探索
            if(color[u] == WHITE) dfsVisit(u);
        }
        for(u = 0; u < n; u++) {
            System.out.println((u+1) + " " + d[u] + " " + f[u]);
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int u, v, k, i, j;
        n = sc.nextInt();
        for(i = 0; i < n; i++) {
            for(j = 0; j < n; j++) M[i][j] = 0;
        }
        for(i = 0; i < n; i++) {
            u = sc.nextInt();
            k = sc.nextInt();
            u--;
            for(j = 0; j < k; j++) {
                v = sc.nextInt();
                v--;
                M[u][v] = 1;
            }
        }
        dfs();
    }
}



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

string s, ans;

int main() {
  cin >> s;
  for(int i = 0; i < s.size(); ++i) {
    if(s[i] == '1' || s[i] == '0')
      ans += s[i];
    else if(ans.size() > 0)
      ans.erase(ans.end() - 1);
  }
  cout << ans << endl;
  return 0;
}

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

#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ller ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
 
const ll MAX = 2e5;
const ll inf = 1e18;
const ll mod = 1e9 + 7;



int main(){
	fastio;
	ll tc,n,m,a,b;
	cin >> a >> b;
	f(i,0,MAX){
		if( (i*2)/25 == a && (i/10) == b ) {
			cout << i << endl;
			return 0;
		}
	}
	cout << "-1\n";
}

Measured memory_bytes: 3616
while True :
    n = int(input())
    if(n == 0) :
        break
    else :
        A = list(map(int, input().split()))
        d = 1000000
        
        for i in range(n - 1) :
            for j in range(i + 1, n) :
                s = abs(A[i] - A[j])
                if(s < d) :
                    d = s
                else :
                    pass
        
        print(d)


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

int selectionSort(int a[], int n){
    int i,j,t,sw = 0, minj;
    for(int i=0;i<n;i++){
        minj = i;
        for(j = i; j < n; j++){
            if(a[j] < a[minj] ) minj = j;
            }
            t = a[i];
            a[i] = a[minj];
            a[minj] = t;
            if( i != minj) sw++;
    }
    return sw;
}

int main(){
    int n, i, sw;
    int a[100];

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

    sw = selectionSort(a, n);

    for(i=0;i<n;i++){
        if(i>0) cout << " ";
        cout << a[i];
    }
    cout << endl;
    cout << sw << endl;

    return 0;
}



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

#define fi first
#define se second
#define pb push_back
#define int long long
#define all(x) (x).begin(), (x).end()

using LL = long long;
using LD = long double;
using pii = pair<int, int>;
using vii = vector<pii>;

const int INF = 1e18;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;

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

    int n, m, q;
    cin >> n >> m >> q;

    vector<int> a(q), b(q), c(q), d(q);
    for (int i = 0; i < q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--, b[i]--;
    }

    int ans = 0;
    string s = string(n, '*') + string(m - 1, '|');
    sort(all(s));
    
    do {
        vector<int> v(n);
        int ptr = 0, curr = 0;
        for (int i = 0; i < (int) s.size(); i++) {
            if (s[i] == '*') {
                v[ptr++] = curr;
            } else {
                curr++;
            }
        }
        int res = 0;
        for (int i = 0; i < q; i++) {
            if (v[b[i]] - v[a[i]] == c[i]) {
                res += d[i];
            }
        }
        ans = max(ans, res);
    } while (next_permutation(all(s)));

    cout << ans;
}

Measured memory_bytes: 3592
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  vector<int> a(5); REP(i, 5) cin >> a[i];
  int ans = 0, kasa = 0;
  REP(i, 5) {
    int tmp = a[i];
    while (tmp % 10 != 0) ++tmp;
    ans += tmp;
    kasa = max(kasa, tmp - a[i]);
  }
  cout << ans - kasa << '\n';
  return 0;
}


Measured memory_bytes: 256
n=int(input())
# 整数 (縦 H 横 W の行列)
l=[list(map(int, input().split())) for i in range(n)]
l=[[0,0,0]]+l
#print(l)
for i in range(n):
    if abs(l[i+1][1]-l[i][1])+abs(l[i+1][2]-l[i][2])>l[i+1][0]-l[i][0]:
        print('No')
        break
    elif abs(l[i+1][1]-l[i][1])+abs(l[i+1][2]-l[i][2])==0:
        if (l[i+1][0]-l[i][0])%2!=0:
            print('No')
            break
    elif (l[i+1][0]-l[i][0])%(abs(l[i+1][1]-l[i][1])+abs(l[i+1][2]-l[i][2]))!=0:
        print('No')
        break
else:
    print('Yes')


Measured memory_bytes: 28068
// Math = ♥️

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

/*-------------------------------------------------------------------------------------------------------------------------*/
#define ll long long                  // Short form for long long
#define ld long double                // Short form for long double
typedef pair<ll, ll> ii;              // Pair of long long
typedef vector<ll> vi;                // Vector of long long
typedef vector<vi> vvi;               // Vector of vector of long long
typedef vector<ii> vii;               // Vector of pairs
typedef vector<vii> vvii;             // Vector of vector of pairs
#define pq priority_queue             // Max heap (To convert to min heap, use negative sign before every value)
#define ff first                      // For pairs
#define ss second                     // For pairs
#define pb push_back                  // Pushback to vector
#define mp make_pair                  // Makes pairs to be stored as pair
#define all(c) (c).begin(), (c).end() // Mainly used by me in sorting
// ordered_set adds two new functions to set - (set).find_by_order([kth element based on zero indexing]) and order_of_key()
// order_of_key returns number of elements less that parameter. If element exists, that order is its index
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
/*-------------------------------------------------------------------------------------------------------------------------*/

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

    ll n, k;
    cin >> n >> k;

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

    ll dp[k + 1];
    dp[0] = 2;

    for (int i = 1; i < k + 1; i++)
    {
        ll flag = 0;
        for (int j = 0; j < n; j++)
        {
            if (i - arr[j] >= 0 && dp[i - arr[j]] == 2)
            {
                flag = 1;
                break;
            }
        }

        if (flag == 1)
            dp[i] = 1;
        else
            dp[i] = 2;
    }

    if (dp[k] == 1)
        cout << "First\n";
    else
        cout << "Second\n";
}


Measured memory_bytes: 1024
from itertools import product
H, W, K = map(int, input().split())
G = [list(input()) for _ in range(H)]

ans = 0
for h_paint in product((0, 1), repeat=H):
	for w_paint in product((0, 1), repeat=W):
		black = 0
		for h in range(H):
			for w in range(W):
				if h_paint[h] or w_paint[w]:
					continue
				if G[h][w] == '#':
					black += 1
		if black == K:
			ans += 1

print(ans)


Measured memory_bytes: 9144
#include <iostream>
#include <sstream>
#include <cstdlib>
#include <stack>

using namespace std;

int main() {

  string op;
  stack<int> st;  
  int sec,fir;

  while(cin >> op){
    if(op=="+"||op=="-"||op=="*"){
      fir = st.top();
      st.pop();
      sec = st.top();
      st.pop();
      if(op=="+") st.push(fir+sec);
      if(op=="-") st.push(sec-fir);
      if(op=="*") st.push(fir*sec);
    }
    else st.push(atoi(op.c_str()));
  }
  cout << st.top() << endl;
  
}


Measured memory_bytes: 3208
import fractions
from functools import reduce

def gcd_ls(num):
	return reduce(fractions.gcd, num)

n, x = map(int, input().split())
ls = list(map(int, input().split()))

ls_sa = [0] * n

for i in range(n):
	ls_sa[i] = abs(ls[i] - x)

print(gcd_ls(ls_sa))

Measured memory_bytes: 16308
#include <stdio.h>
int main(void)
{
  int A, B, C, ans;
  scanf("%d %d %d", &A, &B, &C);
  ans = C - (A - B);
  if(ans >= 0)
    printf("%d", ans);
  else
    printf("%d", 0);

  return 0;
}

  

Measured memory_bytes: 128
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fr first
#define se second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

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

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 80 + 1; //check the limits, dummy


bool dp[MX][MX][30000];
int a[MX][MX], b[MX][MX];

int main() {

    ios_base::sync_with_stdio (0);
    cin.tie (0);

    ll h, w;
    cin >> h >> w;
    F0R (i, h) F0R (j, w) cin >> a[i][j];
    F0R (i, h) F0R (j, w) cin >> b[i][j];

    memset (dp, 0, sizeof (dp) );

    dp[0][0][15000 + a[0][0] - b[0][0]] = 1;
    dp[0][0][15000 + b[0][0] - a[0][0]] = 1;


    F0R (i, h) {
        F0R (j, w) {
            F0R (k, 30000) {
                if (dp[i][j][k] == 0) continue;

                if (i < h - 1) {
                    dp[i + 1][j][k + a[i + 1][j] - b[i + 1][j]] = 1;
                    dp[i + 1][j][k + b[i + 1][j] - a[i + 1][j]] = 1;
                }

                if (j < w - 1) {
                    dp[i][j + 1][k + a[i][j + 1] - b[i][j + 1]] = 1;
                    dp[i][j + 1][k + b[i][j + 1] - a[i][j + 1]] = 1;
                }
            }
        }
    }

    ll ans = 1e9;
    F0R (k, 30000) {
        if (dp[h - 1][w - 1][k]) ans = min (ans, 1ll * abs (15000 - k) );
    }

    cout << ans << '\n';

    return  0;
}


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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;

int main() {
    string s;
    cin >> s;
    ll b = 0;
    ll t = 0;
    for (char c : s) {
        if (c == 'B') {
            b++;
        } else {
            t += b;
        }
    }
    cout << t << endl;
}

Measured memory_bytes: 640
n = int(input())
b = list(map(int, input().split()))
b.reverse()
ans_set = [0]*n
ans = 0

for i in range(n):
    if ans == -1:
        break
    
    for j in range(n):
        if b[j] == n-j:
            ans = b.pop(j)
            ans_set[n-1] = ans
            n -= 1
            break
            
        elif b[j] > n-j:
            ans = -1
            print(ans)
            break

        if n == 0:
            break

if ans != -1:
    for k in ans_set:
        print(k)

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int64_t>>;

typedef int64_t Int;
const double pi = M_PI;

int main() {
    int n, m, x;
    cin >> n >> m >> x;
    set<int> a;
    for (int i = 0; i < m; i++) {
        int b;
        cin >> b;
        a.insert(b);
    }

    int ans = 0;
    for (int i = x; i <= n; i++) {
        if (a.count(i) != 0) {
            ans++;
        }
    }

    int temp = 0;
    for (int i = x; i >= 0; i--) {
        if (a.count(i) != 0) {
            temp++;
        }
    }

    cout << min(ans, temp) << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s1 = sc.next();
        String s2 = sc.next();
        String s3 = sc.next();
        
        String str1 = s1.toUpperCase();
        String str2 = s2.toUpperCase();
        String str3 = s3.toUpperCase();
        
        System.out.print(str1.charAt(0));
        System.out.print(str2.charAt(0));
        System.out.print(str3.charAt(0));
    }
}


Measured memory_bytes: 35612
#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<queue>
#define MAXN 200005
#define MAXM 400005
using namespace std;
int N,M;
bool Ans;

int tot,en[MAXM],las[MAXN],nex[MAXM];
void ADD(int x,int y)
{
	en[++tot]=y;
	nex[tot]=las[x];
	las[x]=tot;
}

void DFS(int x,int dis)
{
	if(Ans)return;
	if(dis==2)
	{
		if(x==N)Ans=true;
		return;
	}
	int i,y;
	for(i=las[x];i;i=nex[i])
	{
		y=en[i];
		if(!Ans)DFS(y,dis+1);
	}
}
int main()
{
	int i,x,y;
	
	scanf("%d%d",&N,&M);
	for(i=1;i<=M;i++)
	{
		scanf("%d%d",&x,&y);
		ADD(x,y);
		ADD(y,x);
	}
	DFS(1,0);
	if(Ans)printf("POSSIBLE");
	else printf("IMPOSSIBLE");
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    string s;
    cin >> s;
    ll ans = 0;
    for (ll i = 0; i < s.size();i++){
        ans += (s[i]-'0');
    }
    if ((ans % 9) == 0) cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 3720
using System;
class Program
{
	static void Main(string[] args)
	{
		string date = Console.ReadLine();
		
        DateTime boundary = DateTime.Parse("2019/04/30");

        DateTime date2 = DateTime.Parse(date);

        if(boundary >= date2)
        {
            Console.WriteLine("Heisei");
        }
        else
        {
            Console.WriteLine("TBD");
        }

		//Console.WriteLine((a+b+c) + " " + s);
	}
}

Measured memory_bytes: 13536
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

// #define _GLIBCXX_DEBUG

#include <algorithm>
#include <chrono>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <string>
#include <vector>

#include <cmath>

#define int long long

using namespace std;

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

  cout << n * n * n << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n, k;
	cin >> n >> k;
	vector<ll> cnt(100005);
	rep(i, n) {
		int a, b;
		cin >> a >> b;
		cnt[a] += b;
	}
	rep(i, 100005) {
		if (k - cnt[i] <= 0) {
			printf("%d\n", i);
			return 0;
		}
		else {
			k -= cnt[i];
		}
	}
	return 0;
}


Measured memory_bytes: 1024
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		String s = sc.next();
		
		// 計算
		String result = "Yes";
		for(int i = 0; i < s.length(); i++){
		    if(i%2 == 0){
		        if(s.charAt(i) == 'L') result = "No";
		    }else{
		        if(s.charAt(i) == 'R') result = "No";
		    }
		}
		// 出力
		System.out.println(result);
		
	}
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define il inline
#define RG register
#define ll long long

using namespace std;

int a[2005],n,z,w;

il int gi(){
  RG int x=0,q=1; RG char ch=getchar();
  while ((ch<'0' || ch>'9') && ch!='-') ch=getchar();
  if (ch=='-') q=-1,ch=getchar();
  while (ch>='0' && ch<='9') x=x*10+ch-48,ch=getchar();
  return q*x;
}

int main(){
  n=gi(),z=gi(),w=gi();
  for (RG int i=1;i<=n;++i) a[i]=gi();
  if (n==1) cout<<abs(a[1]-w),exit(0);
  cout<<max(abs(a[n-1]-a[n]),abs(a[n]-w)); return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF ((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
#define pb emplace_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos(-1))
#define MAXN (300006)
#define MAXK 26
#define MAXX 15000006
#define ll long long int 
#define ld long double
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = ss; ii < ee; ++ii)
#define space " "
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#define ph emplace
#define btinpct(x) __builtin_popcountll(x)
#define p2(x) (1LL<<(x))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
ll n,m;
string a,b;
ll stringtoint(string s){
	return s[1]-48+(s[0]-48)*10;
}
bool month(ll x){
	return 1<=x&&x<=12;
}
int main()
{
	FAST
	string s;
	cin>>s;
	a=to_string(s[0]-48)+to_string(s[1]-48);
	b=to_string(s[2]-48)+to_string(s[3]-48);
	n=stringtoint(a);
	m=stringtoint(b);
	if(month(n)&&!month(m)){
		cout<<"MMYY";
	} else if(!month(n)&&month(m)){
		cout<<"YYMM";
	} else if(month(n)&&month(m)) {
		cout<<"AMBIGUOUS";
	} else {
		cout<<"NA";
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
typedef struct{
  int key;
  int left;
  int right;
  int parent;
  int id;
}tree;
int main(){
  int i,j,k,num1,n;
  scanf("%d",&n);
  tree heap[n+1];
  for(i=1;i<=n;i++){
    scanf("%d",&heap[i].key);
    heap[i].id=i;
    heap[i].parent=heap[i].right=heap[i].left=NULL;
  }
  for(i=1;i<=n;i++){
    if(i/2>0)
      heap[i].parent=heap[i/2].key;
    if(i*2>n)continue;
    if(heap[2*i].key!=NULL)
      heap[i].left=heap[2*i].key;
    if(i*2+1>n)continue;
    if(heap[2*i+1].key!=NULL) 
      heap[i].right=heap[2*i+1].key;
  }
  for(i=1;i<=n;i++){
    printf("node %d: key = %d, ",heap[i].id,heap[i].key);
    if(heap[i].parent!=NULL)
      printf("parent key = %d, ",heap[i].parent);
    if(heap[i].left!=NULL)
      printf("left key = %d, ",heap[i].left);
    if(heap[i].right!=NULL)
      printf("right key = %d, ",heap[i].right);
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define itn int
#define gI gi

using namespace std;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

int n, m;
string ss, t;

int main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	cin >> ss;
	for (int i = 1; i <= ss.size(); i+=1) cout << 'x';
	puts("");
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1 << 21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
    int n;
    cin >> n;
    vector<vector<int>> abc(n, vector<int>(3));
    rep(i, n){
        int a, b, c;
        cin >> a >> b >> c;
        abc[i] = {a, b, c};
    }
    int dp[100500][3];
    rep(i, n){
        dp[i][0] = -2;
        dp[i][1] = -2;
        dp[i][2] = -2;
    }
    // da:0, b:1, c:2
    dp[0][0] = abc[0][0];
    dp[0][1] = abc[0][1];
    dp[0][2] = abc[0][2];

    rep(i, n){
        if (i==0) continue;
        dp[i][0] = max(dp[i-1][1] + abc[i][0], dp[i-1][2] + abc[i][0]);
        dp[i][1] = max(dp[i-1][0] + abc[i][1], dp[i-1][2] + abc[i][1]);
        dp[i][2] = max(dp[i-1][1] + abc[i][2], dp[i-1][0] + abc[i][2]);
    }
    cout << max({dp[n-1][0], dp[n-1][1], dp[n-1][2]}) << endl;
    return 0;
}


Measured memory_bytes: 6912
# import numpy as np

H, W, M = map(int, input().split())
#map_ = np.zeros((H, W), dtype=np.bool)

h_sum = [0] * H
w_sum = [0] * W
point_list = set()

for _ in range(M):
    h, w = map(int, input().split())
    # map_[h-1, w-1] = 1
    point_list.add((h-1, w-1))
    h_sum[h-1] += 1
    w_sum[w-1] += 1

h_max = max(h_sum)
w_max = max(w_sum)

h_argmax = set()
w_argmax = set()

for i, h in enumerate(h_sum):
    if h == h_max:
        h_argmax.add(i) 

for i, w in enumerate(w_sum):
    if w == w_max:
        w_argmax.add(i)

ans = h_max + w_max

for h in h_argmax:
    for w in w_argmax:
        if (h, w) not in point_list:
        # if map_[h, w] == 0:
            print(ans)
            exit()
print(ans - 1)


Measured memory_bytes: 101864
#include <iostream>
#include <map>
#define REP(i, a, n) for(int i = ((int) a); i < ((int) n); i++)
using namespace std;
typedef pair<int, int> pii;

int N, U[2], M, A, C[100000];
map<int, pii> P[2];

int main(void) {
  cin >> N >> U[0] >> U[1] >> M;
  REP(i, 0, 2) REP(j, 0, N) REP(k, 0, N) {
    cin >> A;
    P[i][A] = pii(j, k);
  }
  REP(i, 0, M) cin >> C[i];

  int ans = -1;
  int cnt[2] = { 0, 0 };
  if(N == 1) {
    REP(i, 0, M) {
      bool b[2] = { false, false };
      REP(t, 0, 2) if(P[t].count(C[i])) {
        cnt[t]++;
        if(cnt[t] == U[t]) b[t] = true;
      }
      if(b[0] || b[1]) {
        if(b[0] && !b[1]) ans = 0;
        if(!b[0] && b[1]) ans = 1;
        if(b[0] && b[1]) ans = -1;
        break;
      }
    }
  } else {
    int v[2][500], h[2][500], c1[2] = { 0, 0 }, c2[2] = { 0, 0 };
    REP(i, 0, 2) REP(j, 0, N) h[i][j] = v[i][j] = 0;
    REP(i, 0, M) {
      bool b[2] = { false, false };
      REP(t, 0, 2) if(P[t].count(C[i])) {
        int y = P[t][C[i]].first, x = P[t][C[i]].second;
        if(++v[t][y] == N) cnt[t]++;
        if(++h[t][x] == N) cnt[t]++;
        if(x == y && ++c1[t] == N) cnt[t]++;
        if(N - x - 1 == y && ++c2[t] == N) cnt[t]++;
        if(cnt[t] >= U[t]) b[t] = true;
      }
      if(b[0] || b[1]) {
        if(b[0] && !b[1]) ans = 0;
        if(!b[0] && b[1]) ans = 1;
        if(b[0] && b[1]) ans = -1;
        break;
      }
    }
  }
  cout << (ans == -1 ? "DRAW" : ans == 0 ? "USAGI" : "NEKO") << endl;

  return 0;
}

Measured memory_bytes: 21100