akhauriyash/Code-Regression huggingface dataset:
using System.Linq;using static System.Console;class K{int[]G=>ReadLine().Split().Select(i=>int.Parse(i)-1).ToArray();int N;static void Main()=>new K().Z();void Z(){var I=G;N=I[0]+1;WriteLine(string.Join(" ",C(G,G,I[1]).Select(i=>i+1)));}int[]C(int[]p,int[]q,int K){int[]P=I(p),Q=I(q),x=E(M(q,P,Q,p),K/6),y=I(x);switch(K%6){case 0:return M(x,p,y);case 1:return M(x,q,y);case 2:return M(x,q,P,y);case 3:return M(x,q,P,Q,y);case 4:return M(x,q,P,Q,p,Q,y);default:return M(x,q,P,Q,p,p,Q,y);}}int[]I(int[]a){var c=new int[N];for(var i=0;i<N;i++)c[a[i]]=i;return c;}int[]M(int[]a,int[]b){var p=new int[N];for(var i=0;i<N;i++)p[i]=a[b[i]];return p;}int[]M(params int[][]a)=>a.Aggregate(M);int[]E(int[]a,int b){int[]p=new int[N],f=new int[N],l=new int[N];for(var i=0;i<N;i++)if(f[i]<1){int x=i,C=0;while(f[x]<1){l[C++]=x;f[x]=1;x=a[x];}for(var j=0;j<C;j++)p[l[j]]=l[(j+b)%C];}return p;}}

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

int main(){
    // 入力
    int a, b, c;
    cin >> a >> b >> c;

    // 処理
    // C++では a <= c <= b のように書くと違う意味になってしまう
    // a <= c && c <= b とするとよい
    if(a <= c && c <= b){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
N,K = map(int,input().rstrip().split(" "))
A = [list(map(int,input().rstrip().split(" ")))]
imos = [0 for i in range(N + 1)]
P = 0
flag = True
counter = 0
while flag:
    A.append([0 for i in range(N)])
    P = 0
    for i in range(N+1):
        imos[i] = 0
    for i in range(N):
        imos[max(0,i - A[counter][i])] += 1
        imos[min(N,i + A[counter][i] + 1)] -= 1
    if imos[0] == N and imos[N] == -1 * N:
        flag = False
    for i in range(N):
        P += imos[i]
        A[counter + 1][i] = P
    counter += 1
    if counter == K:
        break
print(" ".join(map(str,A[-1])))

Measured memory_bytes: 187224
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge {c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int nax = 305;
int dp[nax][nax][nax];

void maxi(int & a, int b) {
	a = max(a, b);
}

int main() {
	string s;
	cin >> s;
	const int n = s.length();
	int k;
	cin >> k;
	assert(k <= n);
	int answer = 0;
	for(int low = 0; low < n; ++low)
		for(int high = n - 1; high >= low; --high)
			for(int used = 0; used <= k; ++used) {
				int me = dp[low][high][used];
				if(low == high) {
					maxi(answer, 2 * me + 1);
					continue;
				}
				if(low + 1 == high) {
					maxi(answer, 2 * me + 1);
					if(s[low] == s[high] || used < k)
						maxi(answer, 2 * me + 2);
					continue;
				}
				maxi(dp[low+1][high][used], me);
				maxi(dp[low][high-1][used], me);
				if(s[low] == s[high])
					maxi(dp[low+1][high-1][used], me + 1);
				maxi(dp[low+1][high-1][used+1], me + 1);
			}
	printf("%d\n", answer);
}


Measured memory_bytes: 110848
#include<bits/stdc++.h>
#define MAX 150000
#define fi first
#define se second
using namespace std;
#define int long long
typedef pair<char,int> P;
int n,q,num,cur=1,N,idx,su,cnt;
char s[MAX*2];
int RSQ[MAX*4+1];
P data[MAX*4];
void add(int k,int x){
    k+=n-1;
    RSQ[k]+=x;
    while(k>0){
        k=(k-1)/2;
        RSQ[k]+=x;
    }
}
int fin(int a,int b,int k,int l,int r){
    if(r<=a || b<=l)return 0;
    if(a<=l && r<=b)return RSQ[k];
    else{
      int v1=fin(a,b,k*2+1,l,(l+r)/2);
      int v2=fin(a,b,k*2+2,(l+r)/2,r);
      return v1+v2;
  }
}
void Segtree(){
    int tmp=1;
    while(tmp<n)tmp*=2;
    n=tmp;
    for(int i=0;i<n*2-1;i++)data[i]=P('|',1e8);
}
void update(int k,int x){
    k+=n-1;
    if(x==1e8)data[k]=P('|',1e8);
    else data[k]=P(s[x],x);
    while(k>0){
        k=(k-1)/2;
        if(data[k*2+1].fi<data[k*2+2].fi)
            data[k]=data[k*2+1];
        else if(data[k*2+1].fi==data[k*2+2].fi&&data[k*2+1].se<data[k*2+2].se)
            data[k]=data[k*2+1];
        else data[k]=data[k*2+2];
    }
}
P find(int a,int b,int k,int l,int r){
    if(r<=a || b<=l)return P('z'+1,1e8);
    if(a<=l && r<=b)return data[k];
    P v1=find(a,b,k*2+1,l,(l+r)/2);
    P v2=find(a,b,k*2+2,(l+r)/2,r);
    if(v1.fi<v2.fi) return v1;
    else if(v1.fi==v2.fi&&v1.se<v2.se) return v1;
    else return v2;
}
bool b[200001];
int nibun(){
    int l=0,r=N;
    while(l<r){
        int mid=(l+r)/2;
        int sum=fin(0,mid,0,0,n)-1;
        if(sum==num)return mid;
        if(sum>num)r=mid;
        else l=mid+1;
    }
    return N-1;
}
main(){
    string ans;
    scanf("%s%d",s,&num);
    n=N=strlen(s)+1;
    s[N-1]='|';
    Segtree();
    for(int i=0;i<N;i++)update(i,i);
    for(int i=0;i<N;i++)add(i,1);
    while(num>0){
        P p=find(0,nibun(),0,0,n);
        update(p.se,1e8);
        add(p.se,-1);
        num-=fin(0,p.se,0,0,n);
        cout<<p.fi;
        b[p.se]=1;
        if(++cnt==N-1)break;
    }
    for(int i=0;i<N-1;i++)
        if(!b[i])cout<<s[i];
    cout<<endl;
}

Measured memory_bytes: 16072
# -*- coding: utf-8 -*-
#ABC116C
import sys

n = int(input())
tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))

sum=hoge[0]
for i in range(1,n):
	if(hoge[i]>hoge[i-1]):
		sum += (hoge[i]-hoge[i-1])
print(sum)


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

int dp[1001][1001];
int list[1001][2];

int main(void){
	int set,i,j;
	int n,w,rem,cal;
	int ans_p,ans_w;

	for(set=1;scanf("%d",&w) && w;set++){
		scanf("%d",&n);
		for(i=0;i<n;i++){
			scanf("%d,%d",&list[i][0],&list[i][1]);
		}

		memset(dp,0,sizeof(dp));
		for(i=1;i<=n;i++){
			for(j=1;j<=w;j++){
				dp[i][j] = dp[i-1][j];
				rem = j - list[i-1][1];

				if(rem >= 0){
					cal = dp[i-1][rem] + list[i-1][0];
					if(dp[i][j] < cal) dp[i][j] = cal;
				}
			}
		}

		ans_p = 0;

		for(j=1;j<=w;j++){
			if(ans_p < dp[n][j]){
				ans_w = j;
				ans_p = dp[n][j];
			}
		}

		printf("Case %d:\n%d\n%d\n",set,ans_p,ans_w);
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iomanip>
#include <vector>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
 
using namespace std;
 
#define endl '\n'
#define MOD 1000000007
#define INF 1ll<<30
#define MAX 100010
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES
 
 
 
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
  //  freopen("./input.txt","r",stdin);
  //  freopen("./output.txt","w",stdout);
    long long int n;
    cin>>n;
    int a[n],b[n],c[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(int i=0;i<n;i++)
    {
        cin>>b[i];
    }
    for(int i=0;i<n-1;i++)
    {
        cin>>c[i];
    }
    long long int ans = 0;
    long long int prev = -1;
    for(int i=0;i<n;i++)
    {
        if(prev==-1)
        {
          
            ans+=b[a[i]-1];
        }
        else
        {
            if(a[i]==prev+1)
            {
                ans+=b[a[i]-1];
                ans+=c[prev-1];
            }
            else
                ans+=b[a[i]-1];
        }
        prev = a[i];
    }
    cout<<ans;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String args[]){

		Scanner sc = new Scanner (System.in);
		int n= sc.nextInt();
		int num[]= new int[n];
		for (int i=n-1;i>=0;--i){
			num[i]= sc.nextInt();
		}
		System.out.print(num[0]);
		for (int i=1;i<=n-1;++i){
			System.out.print(" "+num[i]);
		}
		System.out.println();
	}
}


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

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

int dp[1025][100001];//dp[i][j]:頂点iまでで重みj以下最大、ただし頂点番号は問題のまま
struct P{int w,v;};
template<typename T>
void chmax(T &a,T b){
  if(a<b)a=b;
}

int main(){
  int n;cin>>n;
  vector<int> v(n),w(n);
  REP(i,n)cin>>v[i]>>w[i];
  REP(i,min(n,1<<10))
    REP(j,100001){
      dp[i+1][j]=dp[(i+1)/2][j];
      if(j-w[i]>=0)chmax(dp[i+1][j],dp[(i+1)/2][j-w[i]]+v[i]);
      if(j>0)chmax(dp[i+1][j],dp[i+1][j-1]);
    }
  int q;cin>>q;
  while(q--){
    int a,l,ans=0;cin>>a>>l;
    vector<P> S;
    S.push_back({0,0});
    while(a>1024){
      int t=S.size();
      REP(i,t)if(S[i].w+w[a-1]<=l)S.push_back({S[i].w+w[a-1],S[i].v+v[a-1]});
      a>>=1;
    }
    for(P p:S)chmax(ans,dp[a][l-p.w]+p.v);
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 405444
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
using namespace std;
using ll=long long;
#define MOD  1000000007

int main(int argc, char const *argv[]) {
  string n;
  std::cin >> n;

  if(n[0]=='1') n[0]='9';
  else n[0]='1';

  if(n[1]=='1') n[1]='9';
  else n[1]='1';

  if(n[2]=='1') n[2]='9';
  else n[2]='1';

  std::cout << n << '\n';
  return 0;
}


Measured memory_bytes: 256
/**
 *
 * AtCoder Beginner Contest 101 - Problem B: Digit Sums (https://abc101.contest.atcoder.jp/tasks/abc101_b)
 *
 * Process a string of symbols '+' and '-' and find the result.
 *
 * Ad-Hoc solution: sum +1 for each '+', subtract one for each '-', starting from zero.
 */
#include <iostream>

using namespace std;

void solve(int N)
{
    int S = 0, n = N;

    while (n)
    {
        S += (n % 10);
        n /= 10;
    }

    cout << (N % S ? "No" : "Yes") << endl;
}

int main()
{
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    solve(N);

    return 0;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    ll i=1;
    ll ans = -1;
    while(i <= N){
        i *= 2;
        ans++;
    }
    cout << ll(pow(2, ans)) << endl;
    return 0;
}

Measured memory_bytes: 4000
#include <iostream>

using namespace std;
int a;
int f(int n,int s,int i){
  if(n==1&&i>=s&&s>=0){
    a++;
    return 0;
  }
  if(s<=0||s>=i*n) return 0;
  for(int j=i;j>=n-1;j--) f(n-1,s-j,j-1);
}
int main(){
  int n,s;
  while(cin>>n>>s){
    a=0;
    if(n==0&&s==0) break;
    f(n,s,9);
    cout<<a<<endl;
  }
  return 0;
}

Measured memory_bytes: 1164
import bisect

N = int(input())
A = sorted(map(int, input().split()))
B = map(int, input().split())
C = sorted(map(int, input().split()))

counts = 0
checked = {}
for _numB in B:
    if _numB not in checked:
        countsA = bisect.bisect_left(A, _numB)
        countsC = bisect.bisect_right(C, _numB)
        checked[_numB] = countsA * (N - countsC)
    counts += checked[_numB]
print(counts)


Measured memory_bytes: 34608
import java.util.*;

public class Main {
    public void main(Scanner sc) {
        int k = sc.nextInt();

        long n = 1;
        for (int i = 0; i < k; i++) {
            System.out.println(n);
            n = next(n + 1);
        }
    }

    private long next(long n) {
        double min = Double.MAX_VALUE;
        long minn = 0;
        for (long tmp = 1; tmp <= n; tmp *= 10) {
            for (int i = (int) ((n / tmp) % 10); i <= 9; i++) {
                long next = ((n / tmp / 10) * 10 + i) * tmp + (tmp - 1);
                int s = s(next);
                if (min > (next * 1.0 / s)) {
                    min = (next * 1.0 / s);
                    minn = next;
                }
            }
        }

        return minn;
    }

    private int s(long n) {
        int wa = 0;
        while (n != 0) {
            wa += n % 10;
            n /= 10;
        }

        return wa;
    }

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


Measured memory_bytes: 21204
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647 >> 1); // 10^9 + 5000
static const ll LLINF = (9223372036854775807 >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;

namespace Kunitaka{
    template<
        typename TYPE,
        std::size_t SIZE
    >
    std::size_t array_length(const TYPE (&array)[SIZE])
    {
        return SIZE;
    }
}
using namespace Kunitaka;
namespace Printer{
    void br(){
        cout << endl;
    }

    void loop_cnt(int i){
        cout << "i = " << i << endl;
    }

    void loop_cnt(int i, int j){
        cout << "i = " << i << ", " << "j = " << j << endl;
    }

    template<class T>
    void print(T x){
        cout << x << endl;
    }

    template<class T, class S>
    void print(T x, S y){
        cout << x << "," << y << endl;
    }

    template<class T, class S, class U>
    void print(T x, S y, U z){
        cout << x << "," << y << "," << z << endl;
    }

    template<class T, class S>
    void print(pair<T, S> p){
        cout << p.first << ", " << p.second << endl;
    }

    template<
        typename TYPE,
        std::size_t SIZE
    >
    void print(const TYPE (&array)[SIZE]){
        int lim = array_length(array);
        for(int i=0; i<lim; i++){
            if(i) cout << " ";
            cout << array[i];
        }
        cout << endl;
    }

    template<class S>
    void print(vector<S> v){
        for(int i=0; i<v.size(); i++){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    template<class S>
    void print(vector<vector<S> > vv){
        for(int i=0; i<vv.size(); i++){
            for(int j=0; j<vv[i].size(); j++){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void yesno(bool x){
        if(x) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
};
using namespace Printer;

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//


    // input
    cout << fixed << setprecision(10);
    int A, B; cin >> A >> B;

    rep2(i, 1, MAX){
        if((int)(i * 0.08) == A && (int)(i * 0.1) == B){
            print(i);
            return 0;
        }
    }
    print(-1);
    
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main (void)
{
  int a,b,n,i,j,k,l,ans;
  n=0;ans=0;
  cin>>n>>a>>b;
  for(i=0;i<10;i++)
  {
    for(j=0;j<10;j++)
    {
      for(k=0;k<10;k++)
        for(l=0;l<10;l++)
        { if(1000*i+100*j+10*k+l>n){cout<<ans;return 0;}
          if(i+j+k+l<=b&&i+j+k+l>=a){ans+=1000*i+100*j+10*k+l;}
        }
    }
  }
  
  if(n==10000&&a==1&&b>=1)ans+=10000;
    
  cout<<ans;
  return 0; 
}

Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <functional>
#include <bitset>
#include <string>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <list>
#include <deque>
using namespace std;
#define INF 10000000
#define LLINF 100000000000000
typedef pair<int, int> P;
typedef long long ll;
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define VSORT(v) sort(v.begin(), v.end());
#define fi first
#define se second
#define out(x) cout << x << endl;
int dx[] = { 1, 0, -1, 0 }, dy[] = { 0,1,0,-1 };
ll MOD = 1000000007;
struct edge {
	ll from, to, cost;
};

vector<int> g[10005];
int v, e;
int gt[10005] = { 0 };
vector<int>res;

void tsort(int s) {
	queue<int>que;
	que.push(s);
	while (!que.empty()) {
		int now = que.front();
		que.pop();
		res.pb(now);
		gt[now] = -1;
		for (int u = 0; u < g[now].size(); u++) {
			int to = g[now][u];
			gt[to]--;
			if (gt[to] == 0) {
				que.push(to);
			}
		}
	}
	return;
}

int main() {
	cin >> v >> e;
	for (int i = 0; i < e; i++) {
		int s, t;
		cin >> s >> t;
		g[s].pb(t);
		gt[t]++;
	}
	for (int i = 0; i < v; i++) {
		if (gt[i] == 0) tsort(i);
	}
	for (int i = 0; i < v; i++) {
		out(res[i]);
	}
	return 0;
}


Measured memory_bytes: 3880
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(K):
    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]
    return A[K-1]


def main():
    K = read_int()
    print(slv(K))


if __name__ == '__main__':
    main()


Measured memory_bytes: 6724
# -*- coding: utf-8 -*-

# input
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

# solve
ans = 0
min_ave_temp = T - H[0] * 0.006
for i in range(1, N):
    ave_temp = T - H[i] * 0.006
    if abs(A - ave_temp) < abs(A - min_ave_temp):
        ans = i
        min_ave_temp = ave_temp

# output
print(ans + 1)


Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			char[] str = in.nextString().toCharArray();
			int n = 0, w = 0, s = 0, e = 0;

			for (int i = 0; i < str.length; i++) {
				if (str[i] == 'N') {
					n++;
				} else if (str[i] == 'W') {
					w++;
				} else if (str[i] == 'S') {
					s++;
				} else if (str[i] == 'E') {
					e++;
				}
			}

			boolean ns = false, we = false;
			if ((n == 0 && s == 0) || (n >= 1 && s >= 1)) {
				ns = true;
			}

			if ((w == 0 && e == 0) || (w >= 1 && e >= 1)) {
				we = true;
			}

			out.println(ns && we ? "Yes" : "No");


		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 24916
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;


fn main() {
    input! {
        n:usize,
        ps:[(i64,i64,i64); n]
    };
    let mut ps = ps;
    ps.insert(0, (0,0,0));
    //debug!(ps);

    for i in 1..n+1 {
        let (t_prev,x_prev,y_prev) = ps[i-1];
        let (t,x,y) = ps[i];
        let dt = t - t_prev;
        let dx = x - x_prev;
        let dy = y - y_prev;
        let d = dx + dy;
        //debug!(dt,d);
        if dt%2==0 && d%2!=0 || dt%2!=0 && d%2==0 || dt<d {
            println!("No");
            return ();
        }
    }

    println!("Yes");

}


Measured memory_bytes: 12540
#include<bits/stdc++.h>
using namespace std;
int main(){ 
    ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    int a, b;
    cin >> a >> b;
    if(a <= 5) cout << 0 << endl;
    else if( a >= 6 and a <= 12) cout << b / 2 << endl;
    else cout << b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i,n) for(int (i) = 0; (i) < (int)(n); (i)++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int a, v, b, w;
    cin >> a >> v >> b >> w;
    int t;
    cin >> t;
    if(v <= w) {
        NO();
        return 0;
    } 
    int lim = (abs(a-b)+v-w-1)/(v-w);
    if(lim <= t) {
        YES();
    }else{
        NO();
    }
}

Measured memory_bytes: 3640
#include<stdio.h>
#include<bitset>
#include<vector>
#define N 50000
int main()
{
	typedef long long L;
	std::bitset<N>x;
	std::vector<L>v;
	for(L i=2;i<N;++i)
		if(!x[i])
		{
			v.push_back(i);
			for(L j=i*i;j<N;j+=i)
				x[j]=1;
		}
	int p,q,a,b,m;
	while(scanf("%d%d%d",&m,&a,&b),m)
	{
		p=q=0;
		for(int i=0;i<5133;++i)
			for(int j=i;j<5133;++j)
			{
				if(v[i]*v[j]>m)break;
				if(a*v[j]<=v[i]*b&&v[i]*v[j]>L(p)*q)
					p=v[i],q=v[j];
			}
		printf("%d %d\n",p,q);
	}
	return 0;
}

Measured memory_bytes: 932
from collections import deque
n,m=map(int,input().split())
node=[[] for _ in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    node[b-1].append(a-1)
    node[a-1].append(b-1)
distance=[-1]*n
distance[0]=0

d=deque()
d.append(0)
while d:
    v=d.popleft()
    for i in node[v]:
        if distance[i]!=-1:
            continue
        distance[i]=v+1
        d.append(i)
print('Yes')
for i in range(1,n):
    print(distance[i])

Measured memory_bytes: 36916
#include <bits/stdc++.h>
#define inf 0x7fffffff
#define ll long long
#define REP(i,a,b) for(int i=a;i<=b;i++)
using namespace std;

int main() {
        ios_base::sync_with_stdio(false); 
        cin.tie(NULL);
        // Code Starts...
        ll n;
        cin>>n;
        vector<ll > v(n);
        for (int i=0;i<n;i++)
            cin>>v[i];
        vector<ll > dp(n,inf); // it stores the min cost incurred so far...
        dp[0] = 0; // cost at stone 1 is 0...
        for (int i=1;i<n;i++)
        {
            //dp[i] = min(dp[i-1]+abs(v[i]-v[i-1]),dp[i-2]+abs(v[i]-v[i-2]));
            for (int j=1;j<=2;j++)
                dp[i] = min(dp[i],dp[i-j] + abs(v[i]-v[i-j])); 
        }
        cout<<dp[n-1]<<endl;
        // Code Ends...
        return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int n, ans, d[100005]={1};
vector<int> vt;
int main() {
	int i, j;
	cin>>n;
	vt.push_back(1);
	for(i=6; i<=n; i*=6) vt.push_back(i);
	for(i=9; i<=n; i*=9) vt.push_back(i);
	for(i=1; i<=n; i++) {
		d[i] = 1e9;
		for(j=0; j<vt.size(); j++) {
			if(i>=vt[j]) d[i] = min(d[i], d[i-vt[j]] + 1);
		}
	}
	cout<<d[n]-1;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FRE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define all(v) (v).begin(),(v).end()
#define endl "\n"
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=a;i>b;i--)
#define vi vector<int>
#define pii pair<int,int>
#define mii map<int,int>
#define SET(A,VAL) memset(A, VAL, sizeof(A))
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
const int MAX = 1e6+8;
const int sz = 1e5+5;
void f_io(){
    IOS;
    // #ifndef ONLINE_JUDGE
    // FRE
    // #endif
}
int32_t main(){
    f_io();
    int t = 1;
    //cin>>t;
    while(t--){
        int n; cin >> n;
        int k = (n / 11), r = n % 11;
        int cnt = (!r?0:(r<=6?1:2));
        cout <<2*k + cnt << endl;
    }
}

Measured memory_bytes: 256
// -----------------------------------
// Author     : MatsuTaku
// Affiliation: Tokushima University
// Country    : Japan
// Date       : 04/07/2020
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  map<ll, int> L;
  int n; cin>>n;
  for (int i = 0; i < n; i++) {
    int a; cin>>a;
    L[a]++;
  }
  auto solve = [&]() -> ll {
    ll a;
    auto it = --L.end();
    for (; it != L.end(); --it) {
      if (it->second <= 1)
        continue;
      if (it->second >= 4)
        return it->first*it->first;
      if (it->second >= 2) {
        a = it->first;
        break;
      }
    }
    for (--it; it != L.end(); --it) {
      if (it->second <= 1)
        continue;
      if (it->second >= 2) {
        return a*it->first;
      }
    }
    return 0;
  };
  cout << solve() << endl;

  return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3005;
int dp[N][N], from[N][N];
string res = "";
string s, t;
void find(int i, int j) {
	if (i == 0 || j == 0)
		return;
	if (from[i][j] == 3) {
		res += s[i - 1];
		return find(i - 1, j - 1);
	}
	if (from[i][j] == 1) return find(i, j - 1);
	return find(i - 1, j);
}

void solve() {
	cin >> s >> t;
	int n = s.size(), m = t.size();
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			if (dp[i][j - 1] > dp[i - 1][j]) {
				dp[i][j] = dp[i][j - 1];
				from[i][j] = 1;
			}
			else {
				dp[i][j] = dp[i - 1][j];
				from[i][j] = 2;
			}
			if (s[i - 1] == t[j - 1]) {
				dp[i][j] = dp[i - 1][j - 1] + 1;
				from[i][j] = 3;
			}
		}
	}
	find(n, m);
	reverse(res.begin(), res.end());
	cout << res;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t = 1;
	//cin >> t;
	for (int i = 1; i <= t; i++) {
		solve();
	}
}

Measured memory_bytes: 73996
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(int argc, char const *argv[]) {
	int N,M;
	std::cin >> N >> M;
	int a[N][M];
	// 各スポーツの人数
	int s[M];
	// 各スポーツが開催されるか
	bool flag[M];
	// 初期化
	for (size_t i = 0; i < M; i++) {
		flag[i] = true;
	}
	// 行列の入力
	for (size_t i = 0; i < N; i++) {
		for (size_t j = 0; j < M; j++) {
			std::cin >> a[i][j];
			a[i][j]--;
		}
	}

	int mmax = 10000;
	int submax = 0;
	int sport;
	// スポーツを一つづつ閉鎖していく
	for (size_t i = 0; i < M; i++) {
		//初期化
		for (size_t j = 0; j < M; j++) {
			s[j] = 0;
		}
		// 各スポーツに参加する人数を数える
		for (size_t j = 0; j < N; j++) {
			for (size_t k = 0; k < M; k++) {
				if (flag[a[j][k]]) {
					s[a[j][k]]++;
					break;
				}
			}
		}

		submax = 0;
		// 最も人数の多いスポーツを探索
		for (size_t j = 0; j < M; j++) {
			if (submax < s[j]) {
				submax = s[j];
				sport = j;
			}
		}
		// 人数の少ない方を選ぶ
		mmax = min(mmax,submax);
		// 最も人数の多かったスポーツを閉鎖
		flag[sport] = false;
	}

	std::cout << mmax << '\n';
	return 0;
}


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

int main(){
  int A;
  cin >> A;
  vector<int> B(A);
  for(int i = 0;i < A;i++){
    cin >> B.at(i);
  }
  int ans = 0;
  int tmp = 0;
  for(int i = 0;i < A - 1;i++){
    if(B.at(i) >= B.at(i+1)){
      tmp++;
    }
    else{
      tmp = 0;
    }
    ans = max(ans,tmp);
  }
  cout << ans << endl;

}

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

signed main(){
    
    int n, k; cin >> n >> k;
    k--;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    vector<int> c;
    int sum = 0;
    for(int i = 1; i < n; i++){
        c.push_back(a[i] - a[i - 1] - 1);
        sum += a[i] - a[i - 1] - 1;
    }
    sort(c.rbegin(), c.rend());
    int ans = n + sum;
    int cnt = k;
    //for(int i = 0; i < c.size(); i++) cout << c[i] << " ";
    //cout << endl;

    for(int i = 0; i < cnt; i++){
        ans -= c[i];
    }
    cout << ans << endl;
    return 0;
}


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


int main(){
  int N;
  int s;

  cin >> N;
  vector<int> vec(N);
  for(int i=0;i<N-1;++i){
    cin >> s;
    vec.at(s-1) += 1;
  }

  for(int i=0;i<N;++i){
    cout << vec.at(i) << endl;
  }
}


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

typedef long long ll;
ll n[105], w[105];

ll dp[100005];

void solve(ll N, ll W)
{
    for (int x = 0; x < N; x++)
    {
        for (int y = W - w[x]; y >= 0; y--)
        {
            dp[y + w[x]] = max(dp[y] + n[x], dp[y + w[x]]);
        }
    }
    ll max = -1;
    for (int x = 0; x < N; x++)
    {
        if (dp[x] > max)
        {
            max = dp[x];
        }
    }
    cout << dp[W] << endl;
}

int main()
{
    ll N, W;
    cin >> N >> W;
    ll i = 0;
    for (int x = 0; x < 100005; x++)
    {
        // for (int y = 0; y < 105; y++)
        dp[x] = 0;
    }
    while (i < N)
    {
        cin >> w[i] >> n[i];
        i++;
    }
    solve(N, W);
    // cout << ans << endl;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000; //10^15
typedef long long ll;
typedef unsigned long long ull;

int main(void) {

  ll n;
  cin >> n;
  ll le = 0, ri = n + 100, med;
  while (ri - le > 1) {
    med = (le + ri) >> 1;
    if (med * (med - 1) / 2 < n) le = med;
    else ri = med;
  }
  if (ri * (ri - 1) / 2LL != n) {
    cout << "No" << endl;
    return 0;
  }

  vector<int> s[1000];
  int m = (int)ri;
  int k = 0;
  for (int i = 0; i < m; i++) {
    for (int j = i + 1; j < m; j++) {
      s[i].push_back(k + 1);
      s[j].push_back(k + 1);
      k++;
    }
  }
  cout << "Yes" << endl;
  cout << m << endl;
  rep(i, m) {
    cout << s[i].size() << " ";
    rep(j, s[i].size()) cout << s[i][j] << " ";
    cout << endl;
  }
  return 0;
}
    


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

int main() {
	int N, K;
	cin >> N >> K;
	map<int,int> B;
	for (int i = 0; i < N; i++) {
		int a; cin >> a;
		B[a]++;
	}
	int cnt = B.size();
	priority_queue<int> C;
	for (auto it = B.begin(); it != B.end(); it++) {
		C.push(-(*it).second);
	}
	int ans = 0;
	for (int i = 0; i < cnt - K; i++) {
		ans += -C.top();
		C.pop();
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 10748
import copy
from itertools import combinations

def count_sharp(a):
	count = 0
	for i in range(len(a)):
		for j in range(len(a[0])):
			if a[i][j] == '#':
				count += 1
	return count

H,W,K = map(int, input().split())
h = [x for x in range(H)]
w = [x for x in range(W)]

c = list()
for i in range(H): c.append(list(input()))

h_sub = list()
for i in range(len(h) + 1):
	for con in combinations(h, i):
		h_sub.append(con)

w_sub = list()
for i in range(len(w) + 1):
	for con in combinations(w, i):
		w_sub.append(con)

count = 0
for h in h_sub:
	for w in w_sub:
		cc = copy.deepcopy(c)
		if len(h) != 0:
			for hh in h:
				width = len(cc[0])
				for j in range(width): cc[hh][j] = 'r'
		if len(w) != 0:
			for ww in w:
				height = len(cc)
				for i in range(height):
					cc[i][ww] = 'r'
		if count_sharp(cc) == K:
			count += 1

print(count)

Measured memory_bytes: 9356
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"
#include "set"
#include "stack"
 
#define lp(n) for (int i = 0; i < n; i++)
#define LP(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
typedef long long ll;
using namespace std;

ll n,s;

ll f(ll x, ll y){
	if(x==0)return 0;
	return x%y+f(x/y,y);
}

int main(){
	cin>>n>>s;
    if(s>n){
        cout<<-1<<endl;
        return 0;
    }
	if(s==n){
		cout<<n+1<<endl;
		return 0;
	}
	for(ll i=2;i*i<=n;i++){
		if(f(n,i)==s){
			cout<<i<<endl;
			return 0;
		}
	}
	for(ll i=sqrt(n)+1;i>=1;i--){
		if((n-s)/i+1!=1&&f(n,(n-s)/i+1)==s){
			cout<<(n-s)/i+1<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
#define ll long long
#define cpp boost::multiprecision::cpp_int
#define dequeue deque
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = 1; i <= n; i++)
#define drep(i, n) for(int i = n-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define vi vector<int>
#define P pair<ll, ll>
int mod = 1'000'000'000 + 7;
const double PI = 3.1415926535897932384626433832795;
struct edge {
	int to;
	ll cost;
};
void reverse(string* s) {
	reverse((*s).begin(), (*s).end());
}
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
void COME_LET_THE_GAMES_BEGIN() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << setprecision(20);
}
int main() {
	COME_LET_THE_GAMES_BEGIN();
	int n;
	cin >> n;
	vector<int> p(n);
	rep(i, n)cin >> p[i];
	int a = 0;
	for (int i = 1; i <= n - 2; i++) {
		if (p[i - 1] < p[i] && p[i] < p[i + 1]) {
			a++;
		}
		if (p[i - 1] > p[i] && p[i] > p[i + 1]) {
			a++;
		}
	}
	cout << a << endl;
}

Measured memory_bytes: 256
'''
Introduction to Heuristics Contest
A - AtCoder Contest Scheduling
'''

def main():
    # 本番テストケースは365
    D = int(input())

    # コンテストタイプごとの満足度の下がりやすさ
    C = list(map(int, input().split()))

    # 満足度row日目にコンテストcolタイプを開催したときの満足度の増加
    S = []
    for _ in range(D):
        sday = list(map(int, input().split()))
        S.append(sday)

    ''' とりあえず順番にやってくだけ
    for i in range(D):
        tmp = i % 26 + 1
        print(tmp)
    '''

    ''' 満足度Siの最高を選ぶ、満足度低下するCは未考慮
    for i in range(D):
        high = S[i].index(max(S[i])) + 1
        print(high)
    '''

    # さいごに開催したコンテストの日付
    last = [-1] * 26

    # トータルスコア
    score = 0

    # その日時点での、満足度と不満度を計算して、最もプラスになるものを選ぶ
    for d in range(D):
        vals = []
        for idx in range(26):
            satis = S[d][idx]
            last[idx] = d
            complain = 0
            for j in range(26):
                complain += C[j] * (d - last[j])
            vals.append(satis - complain)
        idx = vals.index(max(vals))
        last[idx] = d
        score += max(vals)
        print(idx+1)

main()

def intro_heuristics_b():
    # 本番テストケースは365
    D = int(input())

    # コンテストタイプごとの満足度の下がりやすさ
    C = list(map(int, input().split()))

    # 満足度row日目にコンテストcolタイプを開催したときの満足度の増加
    S = []
    for _ in range(D):
        sday = list(map(int, input().split()))
        S.append(sday)

    # 回答(出力)
    T = [int(input()) for _ in range(D)]

    # さいごに開催したコンテストの日付
    last = [-1] * 26

    # 満足度と不満度を計算して出力
    val = 0
    for d in range(D):
        idx = T[d] - 1
        satis = S[d][idx]
        last[idx] = d
        complain = 0
        for j in range(26):
            complain += C[j] * (d - last[j])
        val += satis - complain
        print(val)

#def intro_heuristics_c():


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

int main(){
	ios::sync_with_stdio(0);
	cout << setprecision(10) << fixed;
	int n , k;
	cin >> n >> k;
	vector<int> dp(n , INF);
	vector<int> h(n);
	for (int i = 0; i < n; i++){
		cin >> h[i];
	}
	dp[0] = 0;
	for (int i = 0; i < n; i++){
		for (int j = 1; j <= k; ++j){
			if (i + j < n)
				dp[i + j] = min(dp[i + j] , dp[i] + abs(h[i] - h[i + j]));
		}
	}
	cout << dp[n - 1];
	return 0;
}


Measured memory_bytes: 1024
def main():
    n = int(input())
    a = tuple(map(int, input().split()))

    if 0 in a:
        print(0)
        exit()

    ans = 1
    for i in a:
        ans = ans * i
        if ans > 10 ** 18:
            print(-1)
            exit()

    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 21912
n,m = map(int,input().split())
a=[]
b=[]
c=[]
d=[]
for i in range(n):
    A,B=map(int,input().split())
    a.append(A)
    b.append(B)
for j in range(m):
    C,D=map(int,input().split())
    c.append(C)
    d.append(D)
ans=[]
for k in range(n):
    L=[]
    for l in range(m):
        L.append(abs(a[k]-c[l])+abs(b[k]-d[l]))
    ans.append(L.index(min(L))+1)
for o in ans:
    print(o)

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

int main() {
    int K, S;
    cin >> K >> S;

    // 方向性
    // 3重ループはTLEになるため、一つループを減らす

    ll counter = 0;
    rep(x, K + 1) {
        rep(y, K + 1) {
            // (x, y, S - x - y)
            // cout << "x: " << x << " y: " << y << " z: " << S - x - y << endl;
            if (0 <= S - x - y && S - x - y <= K) {
                counter++;
            }
        }
    }

    cout << counter << endl;

    return 0;
}

Measured memory_bytes: 256
import numpy as np
    
N=int(input())
V=np.array(list(map(int,input().split())))
C=np.array(list(map(int,input().split())))
XY=V-C
sum=0
i=0
while i<N:
    if XY[i]>0:
        sum+=XY[i]
    i+=1
    
print(sum)

Measured memory_bytes: 12392
D=int(input())
C=list(map(int,input().split()))
S=list()
for i in range(D):
  S.append(list(map(int,input().split())))
t=list()
for i in range(D):
  t.append(int(input()))

M=0
di=[0]*26
for d in range(D):
  for i in range(26):
    if i==t[d]-1:
      di[i]=0
    else:
      di[i]+=1
  M+=S[d][t[d]-1]
  for i in range(26):
    M-=C[i]*(di[i])
  print(M)

Measured memory_bytes: 9148
a = 3.times.map { gets.chomp.split.map(&:to_i) }
d = Array.new(2) { Array.new(3) }
(0..2).each do |i|
  d[0][i] = a[i][0] - a[i][1]
  d[1][i] = a[i][0] - a[i][2]
end

key = 1
(0..1).each do |i|
  if d[i].min != d[i].max
    key = 0
  end
end

puts key == 1 ? "Yes" : "No"

Measured memory_bytes: 1916
#include<iostream>
#include<algorithm>
#include<utility>
#include<queue>
#include<vector>

using namespace std;
int main(){
  
    int n;
  cin>>n;
  
  for(int i=9;i>2;i--){
  	if(n%i==0){
    	n/=i;
      break;
    }
  }
  
  if(n<10){
  	cout<<"Yes";
  }else{
  	cout<<"No";
  }
    
    
}

Measured memory_bytes: 888
#include <iostream>
using namespace std;
int main(){
  int a,b,seisuu;
  double x;
  cin >> a >> b;
  x = (a+b)/2.0;
  seisuu = x;
  if (x == seisuu){
    x = seisuu;
  }else {
    x = x + 1;
    seisuu = x;
    x = seisuu;
  }
  cout << x << "\n";
}

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

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

    int cou[4];
    for(int i = 0; i < 4; i++){
        cou[i] = 0;
    }
    char che[4] = {'N', 'W', 'S', 'E'};

    int len = s.length();
    for(int i = 0; i < len; i++){
        for(int j = 0; j < 4; j++){
            if(s[i] == che[j]){
                cou[j]++;
            }
        }
    }

    int flag = 0;
    if((cou[0] != 0 && cou[2] == 0) || (cou[0] == 0 && cou[2] != 0)){
        flag = 1;
    }else if((cou[1] != 0 && cou[3] == 0) || (cou[1] == 0 && cou[3] != 0)){
        flag = 1;
    }

    if(flag == 1){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}

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

int init_pn_vec(vector<int> &prime_number);

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  int i, j;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<int> prime_number;
  init_pn_vec(prime_number);
  int result = 0;
  for (i = 0; i < n; i++) {
    for (j = 0; j < prime_number.size(); j++) {
      if (a[i] == prime_number[j]) {
        result++;
        break;
      } else if (a[i] % prime_number[j] == 0) {
        // cout << a[i] << ' ' << prime_number[j] << endl;
        break;
      }
      if (j == prime_number.size() - 1) {
        result++;
        break;
      }
    }
  }
  cout << result << endl;
  return 0;
}

int init_pn_vec(vector<int> &prime_number) {
  prime_number.push_back(2);
  int i, j;
  for (i = 3; i < 10000; i++) {
    for (j = 0; j < prime_number.size(); j++) {
      if (i % prime_number[j] == 0) {
        break;
      }
      if (j == prime_number.size() - 1 || sqrt(j) > prime_number[i]) {
        prime_number.push_back(i);
        break;
      }
    }
  }
  return 0;
}



Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1ll<<60;

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

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

template<class T>
bool chmax(T &a, initializer_list<T> l)
{
	return chmax(a, *max_element(l.begin(), l.end()));
}

template<class T>
bool chmin(T &a, initializer_list<T> l)
{
	return chmin(a, *min_element(l.begin(), l.end));
}

ll dp[110][110];
ll N;
ll P[110];
ll c{0};

ll solve(ll l, ll r)
{
	if (dp[l][r] != -1) return dp[l][r];
	
	//	if (c++ == 10) exit(-1);
	if (abs(l - r) <= 1) return dp[l][r] = 0;

	ll res{INF};
	for (ll mid = l+1; mid < r; ++mid)
	{
		chmin(res, solve(l, mid) + solve(mid, r) + P[l] * P[r] * P[mid]);
	}

	return dp[l][r] = res;
}

int main(int argc, char **argv)
{
	cin >> N;
	for (ll i = 0;i < N; ++i)
		cin >> P[i] >> P[i+1];

	for (ll i = 0; i < 110; ++i) for (ll j = 0; j < 110; ++j) dp[i][j] = -1;
	std::cout << solve(0, N) << std::endl;
}



Measured memory_bytes: 3200
declare function require(x: string): any;

const input: string = require('fs').readFileSync('/dev/stdin', 'utf8')

// const input: string = require('fs').readFileSync('./input.txt', 'utf8')


const [a, b, c] = input.split(" ").map(num => parseInt(num, 10)).sort((a, b) => a - b)

if (a + b === c) {
  console.log("Yes")
}
else {
  console.log("No")
}

Measured memory_bytes: 7372