akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;
const int INF = 1e8;

const int MX = 500*100+10;
PII dp[2][MX];

int main(){
  int N;
  while(scanf("%d",&N), N){
	VI ps(N);
	REP(i,N) scanf("%d", &ps[i]);

	fill((PII*)dp, (PII*)dp+2*MX, MP(0,-INF));
	int crt = 0, nxt = 1;
	dp[crt][0] = MP(0, -0);
	REP(i,N){
	  REP(x,MX)
		dp[nxt][x] = dp[crt][x];

	  int p = ps[i] % 1000;
	  if(p == 0){
		for(int x=500;x<MX;++x){
		  PII tmp = dp[crt][x];
		  if(tmp.SS <= -INF) continue;
		  tmp.FF++;
		  tmp.SS -= ps[i];
		  maxi(dp[nxt][x-500], tmp);
		}
	  }
	  else if(p <= 500){
		for(int x=0;x<MX;++x){
		  PII tmp = dp[crt][x];
		  if(tmp.SS <= -INF) continue;
		  tmp.FF++;
		  tmp.SS -= ps[i];
		  maxi(dp[nxt][x+500-p], tmp);
		}
	  }
	  else{
		int p_ = p - 500;
		for(int x=0;x<MX;++x){
		  if(x >= p_){
			PII tmp = dp[crt][x];
			if(tmp.SS > -INF){
			  tmp.FF++;
			  tmp.SS -= ps[i];
			  maxi(dp[nxt][x-p_], tmp);
			}
		  }
		  PII tmp = dp[crt][x];
		  if(tmp.SS <= -INF) continue;
		  tmp.SS -= ps[i];
		  maxi(dp[nxt][x+1000-p], tmp);
		}
	  }
	  swap(crt, nxt);
	}

	PII ans(0,-0);
	REP(x,MX){
	  maxi(ans, dp[crt][x]);
	}
	printf("%d %d\n", ans.FF, -ans.SS);
  }

  return 0;
}

Measured memory_bytes: 3976
# coding: utf-8
n=int(input())
s=input()
dp=[0 for i in range(n)]
for i in range(1,n):
    if s[i-1]!=s[i]:
        dp[i]=max(dp[i-1],dp[i-2]+1 if i-2>=0 else 1)
    else:
        dp[i]=dp[i-1]
print(dp[-1])



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

using namespace std;

typedef long long ll;
#define fi first
#define se second
#define pb push_back

const int N = 22;
string s[N];
int n, m, vis[N][N], T = 1;
int dx[4] = {0, -1, 0, 1};
int dy[4] = {-1, 0, 1, 0};

bool val(int x, int y) {
	return 0 <= x && x < n && 0 <= y && y < m && s[x][y] != '#';
}

int bfs(int i, int j) {
	int ret = 0;
	queue <pair <int, pair <int, int> > > q;
	q.push({i, {j, 0}});
	vis[i][j] = T;
	while (!q.empty()) {
		int x = q.front().fi, y = q.front().se.fi, w = q.front().se.se;
		q.pop();
		ret = max(ret, w);
		for (int k = 0; k < 4; k++) {
			int nx = x + dx[k], ny = y + dy[k];
			if (val(nx, ny) && vis[nx][ny] != T) {
				q.push({nx, {ny, w + 1}});
				vis[nx][ny] = T;
			}
		}
	}
	return ret;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	int res = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (s[i][j] == '.') {
				res = max(res, bfs(i, j));
				T++;
			}
		}
	}
	cout << res;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n;
    scanf("%d", &n);
    int i;
    double a[100005];
    for (i = 0; i < n; i++)
        scanf("%lf", &a[i]);
    double ans[2];
    double sb, sa;
    if (a[0] <= 0)
    {
        ans[0] = 1 - a[0];
        sb = 1;
    }
    else
    {
        ans[0] = 0;
        sb = a[0];
    }
    for (i = 1; i < n; i++)
    {
        sa = sb + a[i];
        if (i % 2 == 1)
        {
            if (sa >= 0)
            {
                ans[0] += sa + 1;
                sa = -1;
            }
        }
        else
        {
            if (sa <= 0)
            {
                ans[0] += 1 - sa;
                sa = 1;
            }
        }
        sb = sa;
    }
    if (a[0] >= 0)
    {
        ans[1] = a[0] + 1;
        sb = -1;
    }
    else
    {
        ans[1] = 0;
        sb = a[0];
    }
    for (i = 1; i < n; i++)
    {
        sa = sb + a[i];
        if (i % 2 == 0)
        {
            if (sa >= 0)
            {
                ans[1] += sa + 1;
                sa = -1;
            }
        }
        else
        {
            if (sa <= 0)
            {
                ans[1] += 1 - sa;
                sa = 1;
            }
        }
        sb = sa;
    }
    if (ans[0] < ans[1])
        printf("%.0lf\n", ans[0]);
    else
        printf("%.0lf\n", ans[1]);
    return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std ; 
#define int long long int 
int dp[1000000] ;  


template<typename T> 
class Graph {

	map<int, list<int> >adjlist ; 


public:

	Graph()
	{

	}

	void addEdge(int u , int v)
	{
		adjlist[u].push_back(v); 
		
	}

	int  dfshelper(int node)
	{
		// 
		// visited[node]=true ; 

		if(dp[node] !=-1)
		{
			return dp[node] ; 
		}

		bool leaf =1; 
		int ans =0; 
		for(auto neighbour : adjlist[node])
		{
			leaf=0 ; 
			int sub=1+dfshelper(neighbour) ; 
			ans=max(ans, sub); 

			
		}

		return dp[node]= leaf ? 0 : ans ; 
	

	}

	void DFS()
	{
		// map<int , bool> visited ; 
		int Ans =1 ; 
		memset(dp, -1, sizeof(dp)) ; 
		for(auto i : adjlist )
		{
			int  src=i.first ;  
			int sub = dfshelper(src); 
			Ans=max(Ans, sub) ; 
		} 

		cout<<Ans ; 
	}




} ; 





int32_t main()
{

	Graph <int > g; 
	int n, e; 
	cin>> n>> e; 
	for(int i=0 ; i<e; i++)
	{
		int x,y;
		cin>>x>>y ; 
		g.addEdge(x,y); 

	}
	// g.print() ; 
	g.DFS(); 

	return 0 ; 

}

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

int main()
{
  int n,a[100],sum=0,x=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a,a+n);
  for(int i=0;i<n-1;i++){
    x=a[i]-a[i+1];
    sum+=x;
  }
  cout<<abs(sum);
    return 0;

}


Measured memory_bytes: 3584
#include<stdio.h>
int main(void)
{
   char s1[20],s2[20],s3[20];
   scanf("%s%s%s",s1,s2,s3);
   printf("%c%c%c\n",s1[0]-'a'+'A',s2[0]-'a'+'A',s3[0]-'a'+'A');
   return 0;
}


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

int main(){
	int N;
  cin>>N;
  if(N<2)
    cout<<1<<endl;
  else if(N<4)
    cout<<2<<endl;
  else if(N<8)
    cout<<4<<endl;
  else if(N<16)
    cout<<8<<endl;
  else if(N<32)
    cout<<16<<endl;
  else if(N<64)
    cout<<32<<endl;
  else
    cout<<64<<endl;
}

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

int d[100003];

int main()
{
    int N;
    cin >> N;
    while (N--)
    {
        int t;
        cin >> t;
        d[t]++;
        d[t + 1]++;
        d[t + 2]++;
    }
    cout << *max_element(d + 2, d + 100000) << endl;
    return 0;
}

Measured memory_bytes: 3780
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int main()
{
	int i,j,k,as=0,bs=0;
	string a,b;
	cin>>a>>b;
	string c;
	for(i=0;i<a.size();i++){
		cout<<a[i];
		if(i<b.size()) cout<<b[i];
	}
	return 0;
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

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



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,t; cin>>n>>t;
  vpll p(n);
  rep(i,n){
    ll c,t; cin>>c>>t;
    p[i]={c,t};
  }
  vsort(p);
  rep(i,n){
    if(p[i].second<=t){
      cout<<p[i].first<<endl;
      return 0;
    }
  }
  cout<<"TLE"<<endl;
}


Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.Scanner;

class Main {
    public static void main(final String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        StringBuffer str = new StringBuffer(s);
        String r = str.reverse().toString();
        int size = r.length();
        int ans = 0;
        int[] count = new int[2019];
        BigInteger total = BigInteger.ZERO;
        BigInteger mod = new BigInteger("2019");
        BigInteger exp = BigInteger.ONE;
        int index = 0;
        for (int i = 0; i < size; i++) {
            count[index]++;
            total = total.add(new BigInteger(r.substring(i, i + 1)).multiply(exp));
            index = total.remainder(mod).intValue();
            ans += count[index];
            exp = exp.multiply(BigInteger.TEN).remainder(mod);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 58220
#include <cstdio>
#include <algorithm>
using namespace std;

int main(){
	int n, *a;
	scanf("%d", &n);
	a=new int[n+1];
    for(int i=1; i<=n; i++)
		scanf("%d", &a[i]);
	sort(a+1, a+1+n);
	int val=a[n], pp=a[1];
	for(int i=2; i<=n-1; i++){
        if(min(pp, val-pp) < min(a[i], val-a[i]))
			pp = a[i];
	}
	printf("%d %d\n", val, pp);
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
        using namespace std;
        #define int long long
const int MAX = 2000003;
const int MOD = 1000000007;

//
int fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
int COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
        signed main() {
    cout<<fixed<<setprecision(10);
    COMinit();
       int r1, c1, r2, c2;
       cin>>r1>>c1>>r2>>c2;
       r2++;c2++;
       cout<<(COM(r2+c2,r2)+COM(r1+c1,r1)+(MOD-(COM(r1+c2,r1)))+(MOD-(COM(r2+c1,r2))))%MOD;


        }


Measured memory_bytes: 47104
### constant

MAX_VAL =  10000
MIN_VAL = -10000

### subroutines

### <exp>  := <term> (('+'|'-') <term>)*
### <term> := <elm> ('*' <elm>)*
### <elm>  := '('<exp>')' | <num> | 'i'

def exp()
  res = term()
  return nil if res.nil?

  while $expr[$pos] == '+' || $expr[$pos] == '-'
    op = $expr[$pos]
    $pos += 1

    res0 = term()
    return nil if res0.nil?

    if op == '+'
      res[0] += res0[0]
      res[1] += res0[1]
    else
      res[0] -= res0[0]
      res[1] -= res0[1]
    end
    return nil if
      res[0] > MAX_VAL || res[0] < MIN_VAL ||
      res[1] > MAX_VAL || res[1] < MIN_VAL
  end

  res
end

def term()
  res = elm()
  return nil if res.nil?

  while $expr[$pos] == '*'
    $pos += 1

    res0 = elm()
    return nil if res0.nil?

    rr = res[0] * res0[0] - res[1] * res0[1]
    ri = res[0] * res0[1] + res[1] * res0[0]
    return nil if rr > MAX_VAL || rr < MIN_VAL || ri > MAX_VAL || ri < MIN_VAL

    res = [rr, ri]
  end

  res
end

def elm()
  if $expr[$pos] == '('
    $pos += 1
    res = exp()
    return nil if res.nil?
    $pos += 1
    return res
  elsif $expr[$pos] == 'i'
    $pos += 1
    return [0, 1]
  else
    num = 0
    while /[0-9]/ =~ $expr[$pos]
      num = num * 10 + $expr[$pos].ord - '0'.ord
      $pos += 1
    end
    return nil if num > MAX_VAL || num < MIN_VAL
    return [num, 0]
  end
end

def cn2s(cn)
  return 'overflow' if cn.nil?

  if cn[1] == 0
    return cn[0].to_s
  elsif cn[0] == 0
    return sprintf("%di", cn[1])
  elsif cn[1] > 0
    return sprintf("%d+%di", *cn)
  else
    return sprintf("%d%di", *cn)
  end
end

### main

while line = gets
  $expr = line.strip
  $pos = 0

  ans = exp()
  if ! ans.nil? && ! $expr[$pos].nil?
    puts 'parse error'
    break
  end
  puts cn2s(ans)
end

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

int main(){
  int n, q;
  cin >> n >> q;
  ll a[n], x[q];
  rep(i,n) cin >> a[i];
  rep(i,q) cin >> x[i];
  rep(i,q) {
    ll res = 0;
    ll ans = 0;
    int r = 0;
    rep(l,n) {
      while(r < n && a[r] + res <= x[i]) {
        res += a[r++];
      }
      ans += r-l;
      if(r == l) r++;
      else res -= a[l];
    }
    cout << ans << endl;
  }  
  return 0;
}





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

int main(){
  string S;
  cin >> S;
  int d_01 = 0, d_10 = 0;
  for(int i = 0; i < S.size() ; i++){
    if(i % 2 == 0 && S.at(i) == '0'){
      d_10 += 1;
    }
    if(i % 2 == 0 && S.at(i) == '1'){
      d_01 += 1;
    }
    if(i % 2 != 0 && S.at(i) == '0'){
      d_01 += 1;
    }
    if(i % 2 != 0 && S.at(i) == '1'){
      d_10 += 1;
    }
  }
  cout << min(d_10,d_01);
}

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

namespace AtCoder
{
	public class Program
	{
		static void Main(string[] args)
		{
			int[] vs = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();
			int n = vs[0];
			int x = vs[1];
			int[] l = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();

			int pos = 0;
			for (int i = 0; i < l.Length; i++) {
				pos += l[i];
				if (pos > x) {
					Console.WriteLine(i + 1);
					return;
				}
			}
			Console.WriteLine(n + 1);
		}
	}
}


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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


ll p[105], dp[105][105];

void solve() {
    int n; cin >> n;
    rep1(i, n) cin >> p[i-1] >> p[i];

    Rep1(i, 0, n)Rep1(j, 0, n){
        if(i == j) dp[i][j] = 0;
        else dp[i][j] = INF;
    }

    Rep1(l, 2, n){
        Rep1(i, 1, n-l+1){
            int j = i + l - 1;
            Rep(k, i, j){
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k+1][j] + p[i-1]*p[k]*p[j]);
            }
        }
    }

    cout << dp[1][n] << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}



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

int main() {
  int A , B , C , D , E;
  cin >> A;
	B = A/1000;
  	C = A/100%10;
  	D = A/10%10;
  	E = A%10;
  if (C != D ) {
    cout << "No" << endl;
  }
  else if (B == C ) {
    cout << "Yes" << endl;
  }
  else if (D == E ) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3608
import sys
from heapq import heapify, heappop
read=sys.stdin.read

n,*a=map(int,read().split())
a.append(max(a)+1)
heapify(a)
x=heappop(a)
f=1
ans=0
while a:
  y=heappop(a)
  if x==y:
    f^=1
  else:
    ans+=f
    f=1
    x=y
print(ans)
    
    

Measured memory_bytes: 19964
from collections import deque

n = int(input())
node = [[] for _ in range(n)]

for i in range(n-1):
  a, b = map(int, input().split())
  node[a-1].append(b-1)
  node[b-1].append(a-1)

not_yet = deque(node[0])
dist = [0]*n
par = [0]*n
for v in node[0]:
  dist[v] = 1
  par[v] = 0

while not_yet:
  key = not_yet.popleft()
  for v in node[key]:
    if dist[v] or v == 0:
      continue
    dist[v] = dist[key]+1
    par[v] = key
    not_yet.append(v)

k = n-1
for _ in range((dist[n-1]-1)//2):
  k = par[k]

ans = 0
not_yet = deque([])
already = [False]*n
already[0] = True
already[k] = True
already[n-1] = True
for v in node[0]:
  if already[v]:
    continue
  ans += 1
  not_yet.append(v)
  already[v] = True
while not_yet:
  key = not_yet.popleft()
  for v in node[key]:
    if already[v]:
      continue
    ans += 1
    not_yet.append(v)
    already[v] = True

judge = (n-2)//2+1
if ans >= judge:
  print("Fennec")
else:
  print("Snuke")

Measured memory_bytes: 26968
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

//typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18;
ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define Se second
#define Fi first
#define rep(i, n) for(int i=0;i<n;i++)
#define pb(x) push_back(x)

vector <pair<ll, pii>> Ve;
vector <pair<ll, pii>> Ve2;

vector <pll> conn[1050];
ll par[1050][2];
int dep[1050];

int r[1050];
int root(int x) {
	return (x == r[x]) ? x : (r[x] = root(r[x]));
}

bool dchk[1050];
void DFS(int n) {
	dchk[n] = true;
	for (auto it : conn[n]) {
		if (dchk[it.second]) continue;
		par[it.second][0] = it.first;
		par[it.second][1] = n;
		dep[it.second] = dep[n] + 1;
		DFS(it.second);
	}
}
ll getdis(int a, int b) {
	if (dep[a] > dep[b]) swap(a, b);

	ll rv = 0;
	while (dep[b] > dep[a]) {
		rv = max(rv, par[b][0]);
		b = par[b][1];
	}
	while (a != b) {
		rv = max(rv, par[a][0]);
		rv = max(rv, par[b][0]);
		a = par[a][1];
		b = par[b][1];
	}
	return rv;
}

ll po2[2050];
int main() {
	int N, M, i, j;
	ll X;
	scanf("%d %d", &N, &M);
	scanf("%lld", &X);

	po2[0] = 1;
	for (i = 1; i <= 2020; i++) po2[i] = po2[i - 1] * 2 % MOD;

	for(i = 1; i <= M; i++) {
		int t1, t2, t3;
		scanf("%d %d %d", &t1, &t2, &t3);
		Ve.emplace_back(t3, pii(t1, t2));
	}
	sort(all(Ve));

	for (i = 1; i <= N; i++) r[i] = i;
	for (auto it : Ve) {
		ll d = it.first, x = it.second.first, y = it.second.second;
		if (root(x) != root(y)) {
			X -= d;
			r[root(x)] = root(y);
			conn[x].emplace_back(d, y);
			conn[y].emplace_back(d, x);
		}
		else Ve2.push_back(it);
	}
	DFS(1);

	if (X < 0) return !printf("0\n");
	
	ll ans = 0;
	if (X == 0) ans += (po2[N - 1] - 2) * po2[M - N + 1] % MOD;

	int c1 = 0, c2 = 0, c3 = 0;
	for (auto it : Ve2) {
		ll d = it.first - getdis(it.second.first, it.second.second);
		if (d < X) c1++;
		if (d == X) c2++;
		if (d > X) c3++;
	}

	ll a2 = po2[c2] - 1;
	a2 = (a2 * po2[c3]) * 2 % MOD;
	return !printf("%lld\n", (ans + a2 + MOD) % MOD);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define Int long long
#define pb push_back
using namespace std;

Int N,K,T;
Int ceilS(Int A,Int B){
    return (A+B-1)/B;
}
int main()
{
   int t;t=1;
   while(t--){
       cin>>N;
       vector<Int> A(N);
       for(auto &x:A){
           cin>>x;
       }
       vector<Int> news=A;
       Int ans=0;
       for(int i=1;i<N;++i){
           news[i]=max(news[i-1],news[i]);
           ans+=(news[i]-A[i]);
       }
       cout<<ans<<"\n";
   }
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000007;
const long long INF = 1LL << 60;
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; }

int main() {
    int N; cin >> N;
    vector<int> h(N);
    for (int i = 0; i < N; ++i) cin >> h[i];
    vector<ll> dp(N+1, INF);
    dp[0] = 0;
    for (int i = 0; i < N; ++i) {
        chmin(dp[i+1], dp[i] + abs(h[i] - h[i+1]));
        if (i+2 < N) chmin(dp[i+2], dp[i] + abs(h[i] - h[i+2]));
    }
    cout << dp[N-1] << endl;
    return 0;
}

Measured memory_bytes: 4572
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    int K;
    cin >> s >> K;
    set<string> st;
    REP(i, 0, s.size()) {
        REP(j, 0, K) {
            st.insert(s.substr(i, j + 1));
        }
    }

    auto it = begin(st);
    REP(i, 0, K - 1) {
        it++;
    }

    cout << *it << endl;

    return 0;
}


Measured memory_bytes: 1664
#include <stdio.h>
#include <math.h>

#define PI 3.14159265

int main(void)
{
	double a, b, x;

	scanf("%lf %lf %lf" ,&a, &b, &x);
	x /= a; // Making the situation flat

	if (x <= a * b / 2.0)
	{
		double tmp = 2.0 * x / (b * b);
		printf("%.6lf", 90.0 - atan(tmp) * 180.0 / PI);
	}
	else
	{
		double tmp = 2.0 * (a * b - x) / (a * a);
		printf("%.6lf", atan(tmp) * 180.0 / PI);
	}
	return 0;
}

Measured memory_bytes: 256
import sys
from io import StringIO
import unittest
import os
from collections import deque

# 再帰処理上限(dfs作成時に設定するのが面倒なので限度近い値を組み込む)
sys.setrecursionlimit(999999999)


# 実装を行う関数
def resolve(test_def_name=""):
    n = int(input())
    ab_s = [list(map(int, input().split())) for i in range(n - 1)]

    ref_s = [[] for i in range(n + 1)]

    for ab in ab_s:
        ref_s[min(ab)].append(max(ab))

    # deq作成
    que = deque()
    que.appendleft((1, 0))  # 始める場所はどこでもいい。

    ans = {}
    # BFS開始
    while len(que) is not 0:

        pop = que.pop()
        parent = pop[0]
        parent_col = pop[1]

        child_col = 0

        # 繋がる点に移動
        for child in ref_s[parent]:

            child_col += 1
            if child_col == parent_col:
                child_col += 1

            key1 = min(parent, child)
            key2 = max(parent, child)

            # 処理対象のチェック
            # 処理済みなら何もしない
            if ans.get((key1, key2), 0) != 0:
                continue

            # 処理済み状態にする
            ans[(key1, key2)] = child_col

            # 処理対象に対する処理
            # キューに追加(先頭に追加するのでappendleft())
            que.appendleft((child, child_col))

    # 色数を出力
    print(max(ans.values()))

    # 辺の色を出力
    for ab in ab_s:
        key1 = min(ab[0], ab[1])
        key2 = max(ab[0], ab[1])
        print(ans.get((key1, key2)))


# テストクラス
class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """3
1 2
2 3"""
        output = """2
1
2"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """8
1 2
2 3
2 4
2 5
4 7
5 6
6 8"""
        output = """4
1
2
3
4
1
1
2"""
        self.assertIO(test_input, output)

    def test_input_3(self):
        test_input = """6
1 2
1 3
1 4
1 5
1 6"""
        output = """5
1
2
3
4
5"""
        self.assertIO(test_input, output)

    # 自作テストパターンのひな形(利用時は「tes_t」のアンダーバーを削除すること
    def tes_t_1original_1(self):
        test_input = """データ"""
        output = """データ"""
        self.assertIO(test_input, output)


# 実装orテストの呼び出し
if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        # AtCoder提出時の場合
        resolve()

    else:
        # 自PCの場合
        unittest.main()


Measured memory_bytes: 120616
import sys
def input():return sys.stdin.readline()[:-1]
def N(): return int(input())
def NM():return map(int,input().split())
def L():return list(NM())
def LN(n):return [N() for i in range(n)]
def LL(n):return [L() for i in range(n)]
def YesNo(x):print("Yes")if x==True else print("No")
n,m=NM()
edge=[[] for i in range(n+1)]
for i in range(m):
    a,b=map(int,input().split())
    edge[a].append(b)
    edge[b].append(a)
pre=[-1]*(n+1)
from collections import deque
def bfs(s,n):
    d=[-1 for i in range(n+1)]
    d[s]=0
    q=deque([s])
    while q:
        x=q.popleft()
        for i in edge[x]:
            if d[i]==-1:
                d[i]=d[x]+1
                pre[i]=x
                q.append(i)
    return d
bfs(1,n)
if -1 in pre[2:]:
    print("No")
else:
    print("Yes")
    for i in pre[2:]:
        print(i)

Measured memory_bytes: 34868
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <utility>
#include <algorithm>
using namespace std;


int main(void){
    // Your code here!
    string s;
    cin>>s;
    
    
    int cmin=10000;
    for(int i=0; i<s.size()-2; i++){
        string ss=s.substr(i, 3);
        
        if(cmin>fabs(stoi(ss)-753)){
            cmin=fabs(stoi(ss)-753);
        }
    }
    
    cout<<cmin<<endl;
}


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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll X,A,ans;
  cin >> X>>A;
  if(X<A){
    ans = 0;
  }else{
    ans = 10;
  }
  cout << ans<< endl;
  return 0;
}

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

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

    int n;
    int a;

    cin >> n >> a;
    if ((n % 500) > a) {
      cout << "No" << endl;
    } else {
      cout << "Yes" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
N,W = map(int, input().split())

wv = [tuple(map(int, input().split())) for _ in range(N)]

#i番目まで選べる時に価値がｊとなる最小の重み
dp = [{} for _ in range(N+1)]
dp[0][0] = 0

for i, (w, v) in enumerate(wv):
    # i番目のアイテムまで選んで作れる価値とその時の最小重さの組を取り出す
    for v0, w0 in dp[i].items():
        # 価値v0になる組み合わせが、i番目までの中から選ぶ中で既に存在しているばあい
        if v0 in dp[i+1]:
            # 軽い方を残す
            dp[i+1][v0] = min(dp[i+1][v0], w0) #同じ価値で重さが違うとか、組み合わせで価値は同じだが重さが違うみたいな場合
        # i番目まで選んだ時に重さw0になる組がない場合
        else:
            # i番目まで使い、i+1番目は使わない
            dp[i+1][v0] = w0
        
        # i番目（重さw）を使って、或る組み合わせの価値＋i番目で重量制限を超えたらアウト
        if w0 + w > W:
            continue
        # 上と同じ感じで、今まで+i番目の価値と同じ価値の組が、既に存在する場合、軽いほうを残す
        if v0 + v in dp[i+1]:
            dp[i+1][v0 + v] = min(dp[i+1][v0 + v], w0 + w)
        else:
            dp[i+1][v0 + v] = w0 + w

#最後まで選べる中で、最も価値が大きいもの（重さがオーバーするものはcontinueで落ちてるから問題ない）
print(max(dp[-1].keys()))
        


Measured memory_bytes: 286856
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;

int main()
{
  int64_t n,m;
  cin>>n>>m;
  priority_queue<int64_t> pque;
  for (int i = 0; i < n; ++i)
  {
    int64_t tmp;
    cin>>tmp;
    pque.push(tmp);
  }
  
  for (int i = 0; i < m; ++i)
  {
    int64_t tmp=pque.top();
    pque.pop();
    tmp/=(int64_t)2;
    pque.push(tmp);
  }
  int64_t ans=0;
  for (int i = 0; i < n; ++i)
  {
    ans+=pque.top();
    pque.pop();
  }
  cout<<ans;
}

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

using namespace std;

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

    int pp = 0;
    reverse(s.begin(),s.end());
    for(char c : s) if(c == '1') pp++;
    vector<int> cs1(n),cs2(n);
    int bs1 = 0, bs2 = 0;
    if(s[0] == '1') bs1++, bs2++;
    cs1[0] = cs2[0] = 1;
    if(pp > 1){
        for(int i=1;i<n;i++){
            cs1[i] = (cs1[i-1] * 2) % (pp-1);
            if(s[i] == '1') bs1 = (bs1+cs1[i])%(pp-1);
        }
    }
    for(int i=1;i<n;i++){
        cs2[i] = (cs2[i-1] * 2) % (pp+1);
        if(s[i] == '1') bs2 = (bs2+cs2[i])%(pp+1);
    }
    vector<int> ans;
    for(int i=0;i<n;i++){
        int res = 0;
        if(s[i] == '0'){
            int cnt = (bs2+cs2[i])%(pp+1);
            res = 1;
            while(cnt){
                res++;
                cnt = cnt % __builtin_popcount(cnt);
            }
        }else{
            if(pp > 1){
                int cnt = (bs1-cs1[i])%(pp-1);
                if(cnt < 0) cnt += pp-1;
                res = 1;
                while(cnt){
                    res++;
                    cnt = cnt % __builtin_popcount(cnt);
                }
            }
        }
        ans.push_back(res);
    }
    reverse(ans.begin(),ans.end());
    for(int it : ans) cout << it << '\n';
}

Measured memory_bytes: 6048
A = input()
B = input()
C = input()
player = 'a'
while True:
    if player == 'a':
        if len(A) == 0:
            print('A')
            exit()
        else:
            player = A[0]
            A = A[1:]
    elif player == 'b':
        if len(B) == 0:
            print('B')
            exit()
        else:
            player = B[0]
            B = B[1:]
    else:
        if len(C) == 0:
            print('C')
            exit()
        else:
            player = C[0]
            C = C[1:]


Measured memory_bytes: 3064
import java.util.Scanner;

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

		if (a < 10) {
			if (b < 10) {
				System.out.println(a * b);
			} else {
				System.out.println("-1");
			}
		} else {
			System.out.println("-1");
		}
	}
}

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

using namespace std;

int x;
int y;
string answer;

void Down() {
  y--;
  answer += "D";
}

void Up() {
  y++;
  answer += "U";
}

void Left() {
  x--;
  answer += "L";
}

void Right() {
  x++;
  answer += "R";
}

int main() {
  int sx, sy, tx, ty;
  scanf("%d %d %d %d", &sx, &sy, &tx, &ty);
  x = sx;
  y = sy;

  while (y < ty) Up();
  while (x <= tx) Right();
  while (sy <= y) Down();
  while (sx < x) Left();
  while (y < sy) Up();
  assert(x == sx);
  assert(y == sy);

  Left();
  while (y <= ty) Up();
  while (x < tx) Right();
  while (sy < y) Down();
  while (sx < x) Left();
  assert(x == sx);
  assert(y == sy);

  cout << answer << endl;

  return 0;
}


Measured memory_bytes: 256
//inlclude before define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<assert.h>
#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> P1;
typedef long long int ll;

//define
#define INF 1e9
#define NUM 1000000007
#define all(x) begin(x),end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);i++)
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))

//function

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

/*ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a * (b / g);
}*/

int dig(int a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}

int main() {
	string s;
	cin >> s;
	int size = s.size();
	bool flag = true;
	REP(i, 1, size) {
		if (s[i] != '9') flag =  false;
	}

	int ans = 0;
	if (flag) {
		ans = s[0] - '0' + (size - 1) * 9;
	} else {
		ans = s[0] - '0' - 1 + (size - 1) * 9;
	}
	cout << ans << endl;

}



Measured memory_bytes: 256
t1, t2 = map(int,input().split())
a1, a2 = map(int,input().split())
b1, b2 = map(int,input().split())
 
def ispos(x):
    return x==abs(x)

first = (a1-b1)*t1
second = (a2-b2)*t2
net = first+second
if net == 0:
    print("infinity")
elif ispos(first) == ispos(net):
    print(0)
else:
    res = 1
    first = -abs(first)
    second = abs(second)
    net = first+second
    res += 2*int(abs(first)/net)
    if first%net == 0:
        res -= 1
    print(res)


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

int main() {
  long int A1, A2, A3;
  std::cin >> A1 >> A2 >> A3;
  if(A1 + A2 + A3 >= 22) std::cout << "bust" << std::endl;
  else std::cout << "win" << std::endl;
  return 0;
}


Measured memory_bytes: 888
//const int N=1e5;
#define INF 1e9
#include <bits/stdc++.h>
using namespace std;



void sol() {
	string s, t;
	cin >> s;
	cin >> t;
	int ans = 0;
	for (int i = 0; i < s.length(); i++)
		ans += s[i] != t[i];
	cout << ans;
}

int main() {
	std::ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int t = 1;
	//cin >> t;
	while (t--) {
		sol();
	}

	return 0;
}

Measured memory_bytes: 3804
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class B { public static void Main() => (new Solver()).Solve(); }

public class Solver
{
	public void Solve()
	{
		long N = GetLong();
		var L = GetLongs(N);
		Array.Sort(L);

		long cnt = 0;
		for(long i = 0; i < N; i++)
		{
			for(long j = i + 1; j < N; j++)
			{
				if(L[i] == L[j])
					continue;

				for(long k = j + 1; k < N; k++)
				{
					if(L[j] == L[k])
						continue;

					if(L[i] + L[j] > L[k])
						cnt++;
				}
			}
		}
		WriteLine(cnt);
	}
}

public static class MyIO
{
	private static string[] args = new string[0];
	private static int cnt = 0;
	private static IEnumerable<string> getArgs(long N) => Range(0, N).Select(_ => getArg());
	private static string getArg()
	{
		if(cnt == args.Length) { args = Console.ReadLine().Split(); cnt = 0; }
		return args[cnt++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
	public static long[] GetLongs(long N) => getArgs(N).Select(long.Parse).ToArray();
	public static double[] GetDoubles(long N) => getArgs(N).Select(double.Parse).ToArray();
	public static decimal[] GetDecimals(long N) => getArgs(N).Select(decimal.Parse).ToArray();
	public static string[] GetStrings(long N) => getArgs(N).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) < 0) x = y; }
	public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) > 0)	x = y; }
	public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; }
	public static long rightShift(long x, long y) => (x >> (int)y);
	public static long leftShift(long x, long y) => (x << (int)y);
	public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
	public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
	public static long lcm(long x, long y) => (x / gcd(x,y)) * y;	
	public static IEnumerable<int> Range(long start, long count) => Enumerable.Range((int)start, (int)count);
	public static void Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}


Measured memory_bytes: 28400
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define rem(i, m, n) for (int i = m; i > n; --i)
const int MOD = 1000000007;

int main() {
  int N; cin >> N;
  vector<int> p(N);
  rep(i, 0, N) cin >> p[i];
  int ans = 0;
  rep(i, 1, N-1) {
    if(p[i-1] < p[i] && p[i] < p[i+1]) ans++;
    if(p[i-1] > p[i] && p[i] > p[i+1]) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <string>
#include <unordered_map>
#define int long long
#define M 998244353
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define Zero(dp) memset(dp,0,sizeof(dp))
using namespace std;
bool check(string s)
{
    string t=s;
    reverse(all(t));
    return s==t;
}
int32_t main(){
ios
int t=1;
//cin>>t;
while(t--)
{ 
    string s;cin>>s;
    int n=s.length();
    int a=(n-1)/2,b=(n+3)/2;
    if(check(s.substr(0,a)) and check(s) and check(s.substr(b-1)))cout<<"Yes\n";
    else cout<<"No\n";

}
}


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

int h, w;

int bomb_count(vector<vector<char>> &v, int x, int y) {
  vector<int> dx{ -1, -1, -1,  0, 0,  1, 1, 1 };
  vector<int> dy{ -1,  0,  1, -1, 1, -1, 0, 1 };

  int num = 0;
  for (int i = 0; i < 8; i++) {
    int xx = x - dx.at(i);
    int yy = y - dy.at(i);
    if (xx >= 0 && xx < h && yy >= 0 && yy < w) {
      if (v.at(xx).at(yy) == '#') {
        num++;
      }
    }
  }
  return num;
}

int main() {
  cin >> h >> w;

  vector<vector<char>> v(h, vector<char>(w));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> v.at(i).at(j);
    }
  }

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (v.at(i).at(j) == '.') {
        cout << bomb_count(v, i, j);
      } else {
        cout << '#';
      }
    }
    cout << endl;
  }

  return 0;
}


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

int main() {
  string s;
  cin >> s;
  if(s.size() < 4){
    cout << "No" << endl;
    return 0;
  }
  if(s.substr(0,4) == "YAKI") cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define INF 100000000000000000
#define modulo 1000000007
#define int long long int
using namespace std;

int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
  //    freopen("q.gir","r",stdin);
  //    freopen("q.cik","w",stdout);
      int n;
      cin>>n;
      vector<int>data(62,0);
      for(int i=0;i<n;i++){
            int x;
            cin>>x;
            bitset<62> A(x);
            for(int i=0;i<62;i++){
                  if(A[i]==1)data[i]++;
            }
      }
      int ans=0;
      for(int i=0;i<62;i++){
            ans=(ans+((int)1<<i)%modulo*data[i]%modulo*(n-data[i])%modulo)%modulo;
      }
      cout<<ans;
}


Measured memory_bytes: 256
#include<bits//stdc++.h>
using namespace std;
int main(){
	int m,minn,maxn;
	while(cin>>m>>minn>>maxn&&m!=0){
		int a[200];
		for(int i=0;i<m;i++){
			cin>>a[i];
		}
		sort(a,a+m);
		reverse(a,a+m);
		int go=-1;
		int n=0;
		for(int i=minn;i<=maxn;i++){
			if(go<a[i-1]-a[i]){
				go=a[i-1]-a[i];
				n=i;
			}
			else if(go==a[i-1]-a[i]){
				n=i;
			}
		}
		cout<<n<<endl;
	}
}

Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
int main()
{
  long a,b,c,d;
  cin>>a>>b>>c>>d;
  vector<long>v;
  v.pb(a*c);
  v.pb(a*d);
  v.pb(b*c);
  v.pb(b*d);
  sort(v.begin(),v.end());
  cout<<v[v.size()-1];
  return 0;
}


Measured memory_bytes: 3596
#include <algorithm>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e10;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

signed main() {
  int n;
  cin >> n;
  vector<int> a;
  int tmp = 1;
  while (tmp <= 2 * 1e9) {
    a.push_back(tmp);
    tmp *= 3;
  }
  auto itr = lower_bound(all(a), n);
  cout << itr - a.begin() << endl;

  return 0;
}



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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

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

void Main()
{
	int x, a, b;
	cin >> x >> a >> b;
	if(a-b>=0) puts("delicious");
	else if(b-a<=x) puts("safe");
	else puts("dangerous");
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 256
import math

number_to_check = int(input())

def if_prime(number):
    for i in range(2, int(math.sqrt(number) + 1)):
        if number%i == 0:
            return 0
    
    return 1

def check_next_prime(X):
    while(True):
        if if_prime(X):
            break 
        else:
            X += 1
            continue
    print(X)


check_next_prime(number_to_check)



Measured memory_bytes: 2940
#include <stdio.h>

#define A 500
#define B 100
#define C 50

int varidateABC(int);
int isX(int, int, int, int);

int
main(){
  int a, b, c, x, count = 0;
  int i, j, k;
  scanf("%d", &a);
  if (a < 0 || 50 < a)
    return 1;
  scanf("%d", &b);
  if (b < 0 || 50 < b)
    return 1;
  scanf("%d", &c);
  if (c < 0 || 50 < c || (a + b + c) < 1)
    return 1;
  scanf("%d", &x);
  if(x < 50 || 20000 < x || x % 50)
    return 1;
  
  for(i = 0; i <= a; i++){
    for(j = 0; j <= b; j++){
      for(k = 0; k <= c; k++){
        if(!isX(i, j, k, x)){
          count += 1;
        }
      }
    }
  }
  printf("%d\n", count);
  return 0;
}


int isX(int a, int b, int c, int x){
  return (x == A * a + B * b + C * c) ? 0:1;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
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; }
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,M;
    cin >> N >> M;
    vector<string> A(N),B(N);
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    for(int i=0; i<N; i++){
        cin >> B[i];
    }
    int cnt = 0;
    for(int i=0; i<N; i++){
        for(int j=0; j<M; j++){
            if(A[i][j] != B[i][j]) cnt++;
        }
    }
    cout << cnt << "\n";
    return 0;
}


Measured memory_bytes: 11396
#include<stdio.h>
#define N 250

int parent(int i){
  return i/2;
}

int left(int i){
  return 2*i;
}

int right(int i){
  return 2*i+1;
}

int main(void){
  int heap_size, i, A[N];
  
  scanf("%d", &heap_size);
  for(i=1; i<=heap_size; i++) scanf("%d", &A[i]);
  
  for(i=1; i<=heap_size; i++){
    
    printf("node %d: key = %d, ", i, A[i]);
    
    if(parent(i) > 0) printf("parent key = %d, ", A[parent(i)]);
    if(left(i) <= heap_size) printf("left key = %d, ", A[left(i)]);
    if(right(i) <= heap_size) printf("right key = %d, ", A[right(i)]);
    
    printf("\n");
    
  }
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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(){
    ll n,r; cin>>n>>r;
    if(n>=10) cout<<r<<endl;
    else cout<<r+100*(10-n)<<endl;
    return 0;
}

Measured memory_bytes: 256