akhauriyash/Code-Regression huggingface dataset:
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const long long inf = 1ll << 61;
typedef pair<int, int> P;
string s[806];
int dist[806][805];
int dist2[805][805];
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 };

void disp(int h, int w) {
	rep(i, h) {
		rep(j, w) {
			if (j)cout << ' ';
			cout << (dist[i][j]==inf?-1:dist[i][j]);
		}
		cout << endl;
	}
}

signed main() {
	int h, w, k; cin >> h >> w >> k;
	rep(i, h)cin >> s[i];
	int sh, sw;
	rep(i, h)rep(j, w)if (s[i][j] == 'S')sh = i, sw = j;
	
	rep(i, h)rep(j, w)dist[i][j] = inf;
	dist[sh][sw] = 0;
	queue<P>Q;
	Q.push(P(sh, sw));
	while (Q.size()) {
		P p = Q.front();
		Q.pop();
		if (dist[p.first][p.second] == k)continue;
		rep(i, 4) {
			int nh = p.first + dx[i], nw = p.second + dy[i];
			if (0 <= nh&&nh < h && 0 <= nw&&nw < w&&dist[nh][nw] == inf&&s[nh][nw]=='.') {
				dist[nh][nw] = dist[p.first][p.second] + 1;
				Q.push(P(nh, nw));
			}
		}
	}

	rep(i, h) {
		rep(j, w) {
			if (dist[i][j] != inf) {
				Q.push(P(i, j));
				dist2[i][j] = 0;
			}
			else dist2[i][j] = inf;
		}
	}
	while (Q.size()) {
		P p = Q.front();
		Q.pop();
		rep(i, 4) {
			int nh = p.first + dx[i], nw = p.second + dy[i];
			if (0 <= nh&&nh < h && 0 <= nw&&nw < w&&dist2[nh][nw] == inf) {
				dist2[nh][nw] = dist2[p.first][p.second] + 1;
				Q.push(P(nh, nw));
			}
		}
	}
	int ans = inf;
	rep(i, h) {
		ans = min(ans, (dist2[i][0]+k-1) / k + 1);
		ans = min(ans,( dist2[i][w - 1]+k-1) / k + 1);
	}
	rep(i, w) {
		ans = min(ans, (dist2[0][i]+k-1) / k + 1);
		ans = min(ans, (dist2[h - 1][i]+k-1) / k + 1);

	}
	cout << ans << endl;
}


Measured memory_bytes: 21392
#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 < (int)(n); i++)
using namespace std;
using p = pair<int, int>;

int main()
{
    int x;
    cin >> x;

    int v500 = x / 500;
    x -= v500 * 500;

    int v5 = x / 5;

    int ans = v500 * 1000 + v5 * 5;
    cout << ans << endl;

    return 0;
}

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

using namespace std;

struct UnionFind {
    vector< int > data;
    
    UnionFind(int sz) {
        data.assign(sz, -1);
    }
    
    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if(x == y) return (false);
        if(data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return (true);
    }
    
    int find(int k) {
        if(data[k] < 0) return (k);
        return (data[k] = find(data[k]));
    }
    
    int size(int k) {
        return (-data[find(k)]);
    }
};

int main(void) {
    int N, M;
    cin >> N >> M;
    vector<int> a(M), b(M);
    for(int i=0; i<M; i++) {
        cin >> a[i] >> b[i];
        --a[i];
        --b[i];
    }

    int ans = M;
    for(int i=0; i<M; i++) {
        UnionFind uf(N);
        for(int j=0; j<M; j++) {
            if(i != j) {
                uf.unite(a[j], b[j]);
            }
        }
        bool ok = true;
        int p = uf.find(0);
        for(int k=1; k<N; k++) {
            if(uf.find(k) != p) {
                ok = false;
            }
        }
        if(ok) {
            --ans;
        }
    }

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


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

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

  int x, a;
  cin >> x >> a;
  if (x < a)
    cout << 0 << endl;
  else
    cout << 10 << endl;
}


Measured memory_bytes: 256
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int n, q, m, c, i, max;
    int[] d;

    d = new int[101];
    for(;;){
      n = sc.nextInt(); q = sc.nextInt();
      if(n == 0 && q == 0)break;
      for(i = 0;i < 101;i++)d[i] = 0;
      for(;n-- > 0;)for(m = sc.nextInt();m-- > 0;){
        c = sc.nextInt(); d[c]++;
      }

      max = 0;
      for(i = 0;i < 101;i++){
        if(d[i] >= q && d[max] < d[i])max = i;
      }
      out.println(max);
    }

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

Measured memory_bytes: 62608
x,y = map(int,input().split())

a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
c = [2]

if x in a and y in a:
    print('Yes')
elif x in b and y in b:
    print('Yes')
elif x in c and y in c:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
import java.util.Scanner; //繰り返し2乗法

public class Main {
	
	static int M = 1000000007;
    
    static long ans(long m,int n) {
        if(n==1) return m%M;
        else if(n%2==0) return ans(((m%M)*(m%M))%M,n/2);
        else  return (ans(((m%M)*(m%M))%M,n/2) * m%M)%M;
    }
    
    void main() {
        Scanner sc = new Scanner(System.in);
        long m = sc.nextInt();
        int n =sc.nextInt();
        System.out.println(ans(m,n));
    }

    public static void main(String[] args) {
        new Main().main();
    }
}


Measured memory_bytes: 26332
import java.util.Scanner;

public class Main {

	static Scanner scanner;

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

	    int N=gi();
	    String s=gs();
	    String t=gs();
	    
        int min=N;
        while(true) {
        	if(s.equals(t))break;
        	s=s.substring(1);
        	t=t.substring(0, t.length()-1);
        	min++;
        }
	    System.out.println(min);
        
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

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

int main() {
    long x;
    cin >> x;
    int minRange = -150;
    int maxRange = 150;

    for (long i = minRange; i < maxRange; ++i)
        for (long j = minRange; j < maxRange; ++j)
            if (pow(i, 5) - pow(j, 5) == x) {
                cout << i << " " << j << endl;
                return 0;
            }
}


Measured memory_bytes: 4080
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int n; cin >> n;
    cout << "ABC"+toString(n) << endl;
    return 0;
}

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

int main(){
  int A, B;
  cin >> A >> B;
  if(A-1>=B){
    cout << 2*A-1 << endl;
  }else if(A<=B-1){
    cout << 2*B-1 << endl;
  }else{
    cout << A+B << endl;
  }
  return 0;
}

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

int main(){
  int n;
  cin>>n;
  if(n%10==3){
    cout<<"bon"<<endl;
    return 0;
  }
  if(n%10==0 || n%10==1 || n%10==6 || n%10==8){
    cout<<"pon"<<endl;
    return 0;
  }
  cout << "hon" << endl;
}

Measured memory_bytes: 3584
#include<stdio.h>
#include<string.h>
int main(){
	char s[100001];
	int i,a=0,b=0;
	scanf("%s",s);
	for(i=0;i<strlen(s);i++){
		if(i%2){if(s[i]-49)a++; else b++;}
		else{if(s[i]-48)a++; else b++;}
	}
	printf("%d",a>b?b:a);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;
ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}
using namespace std;

int main(){
    int n,q;
    string s;
    cin >> n >>q>> s;
    vector<int> cnt(n);
    cnt[0] = 0;
    for(int i=1;i<=n;i++){
        if (s[i]=='C' && s[i-1]=='A') cnt[i] = cnt[i-1]+1;
        else cnt[i] = cnt[i-1];
    }
    rep(i,q){
        int l,r;
        cin >> l >> r;
        cout << cnt[r-1]-cnt[l-1] << endl;

    }

    
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int AB, BC, CA; cin >> AB >> BC >> CA;
    cout << (AB*BC) / 2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
int main(){
  string s;
  cin>>s;
  if(s.substr(5,2)=="04"||s.substr(5,2)=="03"
     ||s.substr(5,2)=="02"||s.substr(5,2)=="01"){
    cout<<"Heisei"<<endl;
  }
  else{
    cout<<"TBD"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os << "[ "; 
  for(auto v:V)os << v << " "; return os << "]";
}
template<class T> ostream& operator<<(ostream &os, set<T> S){ os << "{ "; 
  for(auto s:S) os<<s<<" ";  return os<<"}"; 
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
  return os<<"("<<P.first<<","<< P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
  os<<"{ ";for(auto m:M)os<<"("<<m.first<<":"<<m.second<<")";
  return os<<"}";
}
#define cerr cout
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
//For multiset use less_equal operator but it does support erase operations for multiset
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert 
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define all(v) (v).begin(),(v).end()
#define For(i,n) for(int i=0;i<(int)n;++i)
#define Rev(i,n) for(int i=(int)n-1;i>=0;--i)
#define Rep(i,n) for(int i=1;i<=(int)n;++i)
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mp make_pair
// inline void modadd(int &a,int &b){a+=b;if(a>=mod)a-=mod;} 
int main(){
  fio; cout<<fixed<<setprecision(25);	
  string s; cin >> s;
  int sm = 0;
  for(auto c : s) sm = (sm + (c-'0'))%9;
  if(sm == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3772
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e6;
string X;
stack<int> sta;
int child=0;
int main(){
	cin>>X;
	int a=X.size();
	for(int i=0;i<a;i++){
		if(X[i]=='S')
			sta.push(1);
		else{
			if(!sta.empty()){
				child+=2;
				sta.pop();
			}
		}
	}
	cout<<a-child<<endl;
	return 0;
}


Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
int INF = 1000000000;
int main(){
  int N, K;
  cin >> N >> K;
  vector<int> x(N);
  for (int i = 0; i < N; i++){
    cin >> x[i];
  }
  vector<int> pos, neg;
  for (int i = 0; i < N; i++){
    if (x[i] >= 0){
      pos.push_back(x[i]);
    } else {
      neg.push_back(-x[i]);
    }
  }
  pos.push_back(0);
  while (pos.size() <= K){
    pos.push_back(INF);
  }
  sort(pos.begin(), pos.end());
  neg.push_back(0);
  while (neg.size() <= K){
    neg.push_back(INF);
  }
  sort(neg.begin(), neg.end());
  int ans = INF;
  for (int i = 0; i <= K; i++){
    ans = min(ans, pos[i] * 2 + neg[K - i]);
    ans = min(ans, neg[i] * 2 + pos[K - i]);
  }
  cout << ans << endl;
}

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

int main(){
	int q;
	scanf("%d", &q);
	for(int i = 0; i < q; i++){
		int c, a, n; scanf("%d%d%d", &c, &a, &n);
		int ans = 0;
		if(c <= n || a <= n){
			ans += min(c,a);
			c -= ans; a -= ans;
		} else{
			ans = n;
			c -= n; a -= n;
		}
		if(c <= 2*a){
			printf("%d\n", ans+c/2);
			continue;
		} else{
			ans += a;
		}
		c -= 2*a;
		printf("%d\n", ans+c/3);
	}
}

Measured memory_bytes: 1028
using System;
using System.Linq;


namespace AtC
{
    class Program
    {
        static void Main(string[] args)
        {
            double N = long.Parse(Console.ReadLine());
            var count = new long[5];
            for (int i = 0; i < count.Length; i++)
                count[i] = long.Parse(Console.ReadLine());
            long bottleNeck = count.Min();
            Console.WriteLine((long) Math.Ceiling(N / bottleNeck) + 4);
        }
    }
}

Measured memory_bytes: 13268
#include <cstdio>
#include <utility>
#include <queue>
#include <vector>
#include <iostream> 
#include <algorithm>
#include <math.h>
#include <map>  
#include <string.h> 

using namespace std;

struct edge { int to,dis,cost; };
typedef pair<int,int> P;
const int INF=100000000;
                             
vector<edge> G[10001];
int d[10001],e[10001];

void dijkstra(int V){
  priority_queue<P,vector<P>,greater<P>>que;
  fill(d+1,d+1+V,INF);
  d[1]=0;
  que.push(P(0,1));
  
  while(!que.empty()){
    P p=que.top(); que.pop();
    int v=p.second;
    if(d[v]<p.first) continue;
    for(int i=0; i<G[v].size(); i++){
      edge e=G[v][i];
      if(d[e.to]>d[v]+e.dis){
        d[e.to]=d[v]+e.dis;
        que.push(P(d[e.to],e.to));
       }
      }
    }
}

int main() {
  
  while(1){
    
   int N,M;
    
   scanf("%d %d", &N, &M);
   
   if(N==0) break;
   
   for(int i=0; i<M; i++){
     
     int s,t,v,u;  
     
     scanf("%d %d %d %d", &s, &t, &v ,&u);
     
     edge e1={t,v,u};
     G[s].push_back(e1);
     
     edge e2={s,v,u};          
     G[t].push_back(e2);
    
    }
   
   dijkstra(N); 
   
  for(int u=2; u<=N; u++){
    int mi=INF;
     for(int i=0; i<G[u].size(); i++){
      edge e=G[u][i];
      if(d[e.to]+e.dis==d[u]&&mi>e.cost){
        mi=e.cost;
        }
      }
      e[u]=mi;
    }
    
    int ans=0;
    
    for(int u=1; u<=N; u++){ 
      ans+=e[u];
      }
      
      cout<<ans<<endl;
      
      for(int i=1; i<=N; i++) G[i].clear();
     
   }
}

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

int main(){
    cin >> N >> K;
    int snk[N]; rep(i,N) snk[i] = 0;
    rep(i,K){
        int d; cin >> d;
        rep(j,d){
            int k; cin >> k;
            snk[--k] = 1;
        }
    }
    int ans = 0;
    rep(i,N){
        if(snk[i] == 0) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {
		final String END_OF_TEXT = "END_OF_TEXT";

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {

			// ????´¢?????????????°??????????????????????
			String schStr = br.readLine().toLowerCase();

			String str;
			int cnt = 0;
			while(!(str = br.readLine()).equals(END_OF_TEXT)){

				// ????´¢????±?????°??????????????????????
				str = str.toLowerCase();

				String[] sArr = str.split(" ");
				for(String wrd : sArr){
					if(wrd.equals(schStr)){
						cnt++;
					}

				}
			}
			System.out.println(cnt);

		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (br != null) {
				try {
					br.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}

		}
	}
}

Measured memory_bytes: 24336
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double x1 = sc.nextDouble();
        double y1 = sc.nextDouble();
        double x2 = sc.nextDouble();
        double y2 = sc.nextDouble();
        sc.close();

        System.out.println(String.format("%.8f", Math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))));
    }
}



Measured memory_bytes: 28336
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int, int> pi;

int n, l, t;
int x[200005], w[200005];
int ret[200005];
vector<int> v[2];

int cnt(vector<int> &v, int s, int e){
	if(s > e) return 0;
	if(s < 0) return cnt(v, s+l, l-1) + cnt(v, 0, e);
	if(e >= l) return cnt(v, s, l-1) + cnt(v, 0, e-l);
	return upper_bound(v.begin(), v.end(), e) - lower_bound(v.begin(), v.end(), s);
}

int main(){
	scanf("%d %d %d",&n,&l,&t);
	for(int i=0; i<n; i++){
		scanf("%d %d",&x[i],&w[i]);
		w[i]--;
		v[w[i]].push_back(x[i]);
	}
	for(int i=0; i<2; i++) sort(v[i].begin(), v[i].end());
	for(int i=0; i<n; i++){
		lint cidx = ((2ll * t) / l) * ((int)v[w[i] ^ 1].size());
		if(w[i] == 0) cidx += cnt(v[1], x[i] + 1, x[i] + (2ll * t) % l);
		else cidx += cnt(v[0], x[i] - (2ll * t) % l, x[i] -1);
		if(w[i] == 1) cidx *= -1;
		cidx += i;
		cidx %= n;
		cidx += n;
		cidx %= n;
		ret[cidx] = (x[i] + 1ll * (1 - 2 * w[i]) * t) % l + l;
		ret[cidx] %= l;
	}
	for(int i=0; i<n; i++) printf("%d\n", ret[i]);
}


Measured memory_bytes: 2892
import java.awt.*;
import java.util.*;
import java.io.*;
import java.math.BigDecimal;
import java.nio.file.Files;
import java.nio.charset.StandardCharsets;
//给出两个数a,b 求出[a,b]中各位数字之和能整除原数的数的个数。
public class Main {
    int mod  = (int) 1e9+7;
    void solve(long[] a1, long[] a2, int k) {
        int cnt = 0;
        int n = a1.length;
        int m = a2.length;
        long tot = 0;
        int i=0;
        int j=0;
        int ans = 0;
        for(;i<n;i++){
            tot+=a1[i];
            if(tot>k){
                tot-=a1[i];
                i--;
                break;
            }else{
                cnt++;
            }
            if(i==n-1)break;
        }

        ans = Math.max(ans,cnt);
        ///System.out.println(i+" "+cnt);
        for(int p = 0;j<m;j++){
            tot+=a2[j];
            cnt++;
            while(i>-1&&tot>k){
                tot-=a1[i];
                cnt--;
                i--;
            }
            while(i<=-1&&p<=j&&tot>k){
                tot-=a2[p];
                p++;
                cnt--;
            }
            if(p>0) break;
            ans = Math.max(ans,cnt);
        }

        System.out.println(ans);
    }
    //0 1 2 3 4 5 6 7
    //1 7 3 4 7 6 2 9
    //1 7 4 3 7 6 2 9;
    //1 2 1 2 1
    public static void main(String[] args)  throws IOException {
        // Use the Scanner class

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String[]  s = br.readLine().split(" ");
        Main test = new Main();
        int n = Integer.parseInt(s[0]);
        int m = Integer.parseInt(s[1]);
        int k = Integer.parseInt(s[2]);
        long[] a1 = new long[n];
        long[] a2 = new long[m];
        s = br.readLine().split(" ");
        for(int i=0;i<n;i++){

            a1[i] = Long.parseLong(s[i]);
        }
        s = br.readLine().split(" ");
        for(int i=0;i<m;i++){

            a2[i] = Long.parseLong(s[i]);
        }
        test.solve(a1,a2,k);
    }
}


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

public class Main{
    public static void main(String[] args)throws Exception{
        Scanner sc=new Scanner(System.in);
        long n=sc.nextLong();
        long total=0;
        for(long i=1;i<=n;i++){
            if(i%3!=0 && i%5!=0){
                total+=i;
            }
        }
        System.out.println(total);
    }
}

Measured memory_bytes: 35784
/****************************************************************
# @Author:      iLovePKU_zbtxdy
# @DateTime:    2020-03-14 20:14:59
# @Description: Think twice . Code once. 
# @More: Once lots of AC, try Brute-force,dynamic programming 
****************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define close std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define eps 1e-8
typedef long long ll;
const int maxn = 1e6;
const int INF = 1e9;
const ll linf = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1.0);
ll mod = 1e9+7;
int main()
{
    ll n, m;
    cin >> n >> m;
    ll ans = (n*m/2)+(((n*m)&1)?1:0);
    if(n==1||m==1)ans =1;
    cout << ans << endl;
}
/***************************************************************************
 *stuff you should look for
 *int overflow, array bounds
 *special cases (n=1?), set tle
 *do smth instead of nothing and stay organized
***************************************************************************/


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <cmath>

#define forr(i, n) for (int i = 0; i < (n); ++i)
#define fori(i, n, init) for (int i = (init); i < (n); ++i)

using namespace std;

typedef long long ll;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll> ,greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;


int main(void){

    int M,N;
    cin >> N >> M;

    vector<ll> v[1000000];

    forr(i, N){
        int a, b;
        cin >> a >> b;
        v[a].push_back(b);
    }

    pq q;
    ll result=0;
    forr(i, M+1){
        for(auto&& x : v[i]) q.push(x);
        if (!q.empty()) {
            result+=q.top();
            q.pop();
        }
    }

    cout << result;

    return 0;
}


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

int main() {
  
  string s;
  cin >> s;
  
  if (s.at(5)=='0' && (s.at(6)=='1'||s.at(6)=='2'||s.at(6)=='3'||s.at(6)=='4')) {
    cout << "Heisei" << endl;
  }
  
  else cout << "TBD" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int a,b,count;
	char ans[15];
	count = 0;
	
	scanf("%s",ans);
	
	for(int  i = 0 ; i < 15 ;i++){
    	if(ans[i] == 'x'){
    	    count++;
    	    //printf("%d",count);
    	}
	}
	
	if(count <= 7){
	    printf("YES");
	    
	}else{
	    printf("NO");
	}
	
	//printf("");
	return 0;
}



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

import static java.lang.Integer.*;
import static java.lang.Long.*;

public class Main {

    public static void main(String[] args) throws IOException {
        StringTokenizer st;
        BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter prnt = new PrintWriter(System.out);

        int x = parseInt(read.readLine());

        if (x >= 400 && x <= 599) {
            prnt.println(8);
        } else if (x >= 600 && x <= 799) {
            prnt.println(7);
        } else if (x >= 800 && x <= 999) {
            prnt.println(6);
        } else if (x >= 1000 && x <= 1199) {
            prnt.println(5);
        } else if (x >= 1200 && x <= 1399) {
            prnt.println(4);
        } else if (x >= 1400 && x <= 1599) {
            prnt.println(3);
        } else if (x >= 1600 && x <= 1799) {
            prnt.println(2);
        } else if (x >= 1800 && x <= 1999) {
            prnt.println(1);
        }
        prnt.close();
    }
}

Measured memory_bytes: 32648
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

const int MAX_N = 200001;

vector<vector<int>> G(MAX_N);
vector<ll> imos(MAX_N);
vector<ll> ans(MAX_N);

void dfs(int cv, int pv){
    if(pv != -1){
        imos[cv] += imos[pv];
        ans[cv] = imos[cv];
    }
    else{
        ans[cv] = imos[cv];
    }

    for(auto nv : G[cv]){
        if(nv == pv) continue;
        dfs(nv, cv);
    }

    return ;
}

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

    int n, q; cin>>n>>q;
    
    for(int i=0; i<n-1; i++){
        int a, b; cin>>a>>b;
        a--, b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }

    for(int i=0; i<q; i++){
        int p, x; cin>>p>>x;
        p--;
        imos[p] += x;
    }

    dfs(0, -1);

    for(int i=0; i<n; i++){
        cout << ans[i] << " \n"[i == n-1];
    }
}

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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

bool dp[5010][5010];

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

    int N, K;
    cin >> N >> K;
    Vl A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());

    int left = -1, right = N;
    while (right - left > 1) {
        int mid = (left + right) / 2;
        memset(dp, 0, sizeof(dp));
        dp[0][0] = true;
        for (int i = 0; i < N; i++) {
            for (int x = 0; x <= K; x++) {
                ll xx = min(x + A[i], (ll)K);
                dp[i + 1][x] |= dp[i][x];
                if (i != mid)
                    dp[i + 1][xx] |= dp[i][x];
            }
        }
        bool ok = false;
        for (int x = max(K - A[mid], 0ll); x < K; x++) {
            if (dp[N][x]) {
                ok = true;
                break;
            }
        }
        if (ok) {
            right = mid;
        }
        else {
            left = mid;
        }
    }

    cout << left + 1 << endl;

    return 0;
}

Measured memory_bytes: 24960
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int D = sc.nextInt();

		int[][] x = new int[N + 1][D + 1];
		for (int i = 1; i < N + 1; i++) {
			for (int j = 1; j < D + 1; j++)
				x[i][j] = sc.nextInt();
		}
		int s = 0;
		int count = 0;
		for (int i = 1; i < N + 1; i++) {
			for (int j = i + 1; j < N + 1; j++) {
				for (int d = 1; d < D + 1; d++) {
					s += Math.pow(x[i][d] - x[j][d], 2);
				}
				int a = (int) Math.sqrt(s);
				if (s == a * a)
					count++;
				s=0;
			}
		}
		System.out.println(count);

	}

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

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


Measured memory_bytes: 21460
#include<iostream>
#include<cstdio>
#define N 100005
using namespace std;

typedef long long ll;
ll n,c,s,ans,x[N],cal[N],mx[N]={0},mx2[N]={0};
int main(){
  ll i;
  cin>>n>>c;
  for(i=0;i<N;i++){
    scanf("%lld %lld",&x[i],&cal[i]);
  }  
  for(i=n-1;i>=0;i--){
    s+=cal[i];//consumed calories
    mx[i] = max(mx[i+1],s-(c-x[i]));
    mx2[i] = max(mx2[i+1],s-(c-x[i])*2);
  }
  ans = max(mx[0],mx2[0]);
  s=0;
  for(i=0;i<n;i++){
    s+=cal[i];
    ans = max(ans, s-x[i]*2 + mx[i+1]);
    ans = max(ans, s-x[i] + mx2[i+1]);
  }
    cout << ans;
  return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
signed main()
{
   SPEED;
   int a,b,c,d;
   cin>>a>>b>>c>>d;
   while(1)
   {
       c-=b;
       if(c<=0)
       {
           cout<<"Yes";
           return 0;
       }
       a-=d;
       if(a<=0)
       {
           cout<<"No";
           return 0;
       }
   }
}

Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

string s[3];

int main() {
    cin >> s[0] >> s[1] >> s[2];

    llong c = 0;
    llong ptr[3] = {};
    while (s[c][ptr[c]] != 0) {
        c = s[c][ptr[c]++] - 'a';
    }

    cout << (char)('A' + c) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';


using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;

// AtCoder
const i64 CYCLES_PER_SEC = 2800000000;

struct Timer {
	i64 start;
	Timer(){reset();}
	void reset(){start=getCycle();}
	inline double get(){return (double)(getCycle()-start)/CYCLES_PER_SEC;}
	inline i64 getCycle(){
		u32 low,high;
		__asm__ volatile ("rdtsc" : "=a" (low), "=d" (high));
		return ((i64)low)|((i64)high<<32);
	}
};

Timer timer;


uint32_t xor128(){
  static uint32_t x = 123456789;
  static uint32_t y = 362436069;
  static uint32_t z = 521288629;
  static uint32_t w = 88675123;
  uint32_t t = x ^ (x << 11);
  x = y; y = z; z = w;
  return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
}

//INSERT ABOVE HERE
const int A = 26;
const int MAX_D = 365;
int cs[A+1];
int s[MAX_D+1][A+1];
int ts[MAX_D+1];

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

  int D;
  cin>>D;

  for(int j=1;j<=A;j++) cin>>cs[j];

  for(int i=1;i<=D;i++)
    for(int j=1;j<=A;j++)
      cin>>s[i][j];

  {
    vector<int> ls(A+1,0);
    for(int i=1;i<=D;i++){
      vector<int> ss(A+1,0);
      for(int j=1;j<=A;j++)
        ss[j]=s[i][j]+cs[j]*(i-ls[j]);
      ts[i]=max_element(ss.begin()+1,ss.end())-ss.begin();

      ls[ts[i]]=i;
    }
  }

  auto calcScore=[&]()->int{
    int res=0;
    vector<int> ls(A+1,0);
    for(int i=1;i<=D;i++){
      res+=s[i][ts[i]];
      ls[ts[i]]=i;
      for(int j=1;j<=A;j++)
        res-=cs[j]*(i-ls[j]);
    }
    return res;
  };

  int iter_num = 0;
  int tmpScore=calcScore();


  double start_temp = 1000, end_temp = 1;

  const double LIM = 2.0;
  while(timer.get()<LIM){
    iter_num++;
    int d=xor128()%D+1;
    int q=xor128()%A+1;

    int p=ts[d];
    ts[d]=q;

    int nxtScore=calcScore();

    double temp = start_temp + (end_temp - start_temp) * timer.get() / LIM;
    double prob = exp((nxtScore-tmpScore)/temp);

    const int INF = 1<<30;
    if(prob > (xor128()%INF)/(double)INF){
      tmpScore=nxtScore;
    }else{
      ts[d]=p;
    }
  }

  cerr<<iter_num<<endl;
  cerr<<tmpScore<<":"<<calcScore()<<endl;
  for(int i=1;i<=D;i++) cout<<ts[i]<<newl;
  return 0;
}


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

int s[500000], count = 0;

void margeSort(int left, int right, int mid){
	int index, i, j = mid, t[500000];
	index = i = left;
	while(i < mid && j < right){
		if (s[i] < s[j]) {
			t[index++] = s[i++];
		} else {
			t[index++] = s[j++];
		}
	}
	while (j < right) t[index++] = s[j++];
	while(i < mid) t[index++] = s[i++];
	j = left;
	for (int i = left; i < right; i++,j++) {
		s[i] = t[j];
	}
	count += right - left;
}

void marge(int left, int right) {
	if (right - 1 != left) {
		int mid = (left + right) / 2;
		marge(left, mid);
		marge(mid, right);
		margeSort(left, right, mid);
	}
}

int main(void) {
	int n;

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	marge(0, n);

	for (int i = 0; i < n; i++) {
		cout << s[i];
		if(i != n - 1) cout << " ";
	}
	cout << endl << count << endl;
	return 0;
}

Measured memory_bytes: 5060
#include <bits/stdc++.h>
#define INF pow(10, 9) + 7
#define rep(i, N) for(ll i = 0; i < N; i++)
#define rep2(i, j, k) for(ll i = j; i < k; i++)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define chmax(x, y) x = max(x, y)
#define print(x) cout << x << "\n"
#define ALL(v) v.begin(), v.end()
#define SUM(v) accumulate(ALL(v), 0)
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define SORT(v) sort(ALL(v))
#define REV(v) reverse(ALL(v))
typedef long long int ll;
using namespace std;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vs = vector<string>;
using vvs = vector<vector<string>>;

void solve(){
	
	ll N, K;
	cin >> N >> K;
	vl A(N);
	rep(i, N) cin >> A[i];	
	
	rep(i, min(K, (ll)50)){
		
		vl acc(N);
		
		rep(i, N){
			acc[max((ll)0, i - A[i])] += 1;
			if(i + A[i] + 1 <= N - 1)  acc[i + A[i] + 1] -= 1;
		}

		A[0] = acc[0];
		rep2(i, 1, N) A[i] = acc[i] + A[i - 1];
		
	}
	
	rep(i, N) print(A[i]);

}	

int main(){
    
    fastio;
	solve();
    
	return 0;
	
}



Measured memory_bytes: 6376
N = int(input())

S = input()

ma = 0
for i in range(1, N):
  a = S[i:]
  b = S[:i]
  cnt = 0
  a = list(set(a))
  for j in a:
    if j in b:
      cnt += 1
  if cnt > ma:
    ma = cnt

print(ma)

Measured memory_bytes: 40176
#include <set>
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <limits>
#include <map>
#include <numeric>

#define ll long long
using namespace std;
static ll imin = std::numeric_limits<ll>::min();
static ll imax = std::numeric_limits<ll>::max();
#define rep(i, n) for(int i = 0; (i)<(n); ++(i))
#define rep1(i, n) for(int i = 1; (i)<(n); ++(i))
#define rev_rep(i, n) for(int i = (n) - 1; (i) >= 0; --(i))
#define range(a, i, b) for(int i = (a); (i) < (b); ++(i))
#define dump(x) cout << #x << ":" << x << "\n";
#define all(v) v.begin(), v.end()
#define readl(N) ll N; cin >> N
#define readlv(N, vec) vector<ll> vec(N); rep(i, N){cin >> vec[i];}
#define greater_than [](ll l, ll r){return l > r;}
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::map<T1, T2>& mp);
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::pair<T1, T2>& pair);
template<class T>
std::ostream& operator << (std::ostream& os, std::vector<T>& vec);
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::pair<T1, T2>& pair){
  os << '(' << pair.first << ',' << pair.second << ')';
  return os;
}

template<class T>
std::ostream& operator << (std::ostream& os, std::vector<T>& vec){
  std::size_t n = vec.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(ll i = 0; i<n - 1; ++i){
    os << vec[i] << " ";
  }
  os << vec[n - 1];
  os << std::endl;
  return os;
}

template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::map<T1, T2>& mp){
  std::size_t n = mp.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(auto && x:mp){
    os << x << " ";
  }
  os << std::endl;
  return os;
}

template<class T>
std::ostream& operator << (std::ostream& os, std::set<T>& mp){
  std::size_t n = mp.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(auto && x:mp){
    os << x << " ";
  }
  os << std::endl;
  return os;
}

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

ll fact(ll n){
  ll res=1;
  while(n>=0){
    res*=n;
    n--;
  }
  return res;
}
    
ll pow(ll i, ll n){
  ll res=1;
  while(n>=0){
    res*=i;
    n--;
  }
  return res;
}

ll gcd(ll l, ll r){
  if(l<r){
    return gcd(r, l);
  }
  if(r == 0){
    return l;
  }
  return gcd(r, l % r);
}

template<class T>
vector<T> accum_sum(vector<T> a){
  vector<T> b(a.size() + 1);
  b[0] = a[0];
  rep(i, a.size()){
    b[i + 1] = b[i] + a[i];
  }
  return b;
}

#ifndef BOOST_TEST_MAIN
int main(int const argc, char const** argv){
  readl(N); readl(M);
  ll res = 0;
  vector<bool> xs(M, true);
  rep(n, N){
    ll k;
    cin >> k;
    vector<bool> ys(M, false);
    rep(i, k){
      ll a;
      cin >> a;
      a--;
      ys[a] = true;
    }
    rep(m, M){
      xs[m] = xs[m] && ys[m];
    }
    // dump(ys);
  }

  rep(m, M){
    if(xs[m]){
      res++;
    }
  }
  // dump(xs);
  cout << res << endl;
}
#endif


Measured memory_bytes: 256
def digit_sum(x):
    net = 0
    for f in str(x):
        net += int(f)
    return net

def main():
    a, n, m = map(int, input().split())
    cnt = 0
    x = 0

    while True:
        y = (x + a) ** n
        if y > m:
            break
        
        if y > 0 and digit_sum(y) == x:
            cnt += 1
        
        x += 1

    print(cnt)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5596
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <math.h>
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;

ll p[20];
int main() {
	ll n; cin >> n;
	rep(i, 0, n)cin >> p[i];
	ll ans = 0;
	rep(i, 1, n-1) {
		if ((p[i] > p[i - 1] && p[i] < p[i + 1]) || p[i]<p[i - 1] && p[i]>p[i + 1]) {
			ans++;
		}
	}
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int N = sc.nextInt();
			int K = sc.nextInt();
			int Q = sc.nextInt();
			int[] points = new int[N];
			for (int i = 0; i < Q; i++) {
				int pointGetter = sc.nextInt() - 1;
				points[pointGetter]++;
			}
			for (int i = 0; i < N; i++) {
				if (K - Q + points[i] > 0) {
					System.out.println("Yes");
				} else {
					System.out.println("No");
				}
			}
		}
	}
}


Measured memory_bytes: 56528
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  int x,a;
  cin >> x >> a;
  if(x<a){
    cout << 0 << endl;
  }else{
    cout << 10 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(200000)

N = int(raw_input())
tree = [[] for _ in xrange(N)]

for i in range(N-1):
    a, b, c = map(int, raw_input().split())
    a -= 1; b -= 1;
    tree[a].append((b, c))
    tree[b].append((a, c))

Q, K = map(int, raw_input().split())
K -= 1

depth = [0 for _ in xrange(N)]

def dfs(v, p = -1, d = 0):
    depth[v] = d
    for i, j in tree[v]:
        if i == p:
            continue
        dfs(i, v, d + j)

dfs(K)

for i in range(Q):
    x, y = map(int, raw_input().split())
    x -= 1; y -= 1
    print depth[x] + depth[y]


Measured memory_bytes: 144600
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
typedef long long ll;
const int mod= 1e+9+7;

int main() {
    vector<string>a(3);
    rep(i,3)cin>>a[i];
    int k=0;
    rep(i,330){
        //
        if(k==0){
            if(a[0]==""){
                cout<<"A"<<endl;
                return 0;
            }
              else if(a[0][0]=='a'){
            a[0].erase(a[0].begin()+0);
            k=0;
        }
        else if(a[0][0]=='b'){
            a[0].erase(a[0].begin()+0);
            k=1;
        }
         else {
            a[0].erase(a[0].begin()+0);
            k=2;
        }
        }
        //
        else if(k==1){
             if(a[1]==""){
                cout<<"B"<<endl;
                return 0;
            }
              else if(a[1][0]=='a'){
            a[1].erase(a[1].begin()+0);
            k=0;
        }
        else if(a[1][0]=='b'){
            a[1].erase(a[1].begin()+0);
            k=1;
        }
         else {
            a[1].erase(a[1].begin()+0);
            k=2;
        }
        }
        //
        else{
            if(a[2]==""){
             cout<<"C"<<endl;
                return 0;
            }   
          else if(a[2][0]=='a'){
            a[2].erase(a[2].begin()+0);
            k=0;
        }
        else if(a[2][0]=='b'){
            a[2].erase(a[2].begin()+0);
            k=1;
        }
         else {
            a[2].erase(a[2].begin()+0);
            k=2;
        }
    }
}
}

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

#define endl '\n'
using namespace std;
using ll = long long;

struct Node
{
    ll val;
};

class Seg1D
{
private:
    static const int N = 200005;
    static const ll INF = 1ll<<60;
    int _n;
    Node st[N*4];
    void _up(int idx, int lson, int rson)
    {
        st[idx].val = max(st[lson].val, st[rson].val);
    }
    void _build(int l, int r, int idx, ll *arr)
    {
        if(l == r) 
        {
            st[idx].val = arr[l]; return;
        }
        int mid = (l+r)/2, lson = idx*2, rson = lson+1;
        _build(l, mid, lson, arr);
        _build(mid+1, r, rson, arr);
        _up(idx, lson, rson);
    }
    ll _query(int l, int r, int idx, int L, int R)
    {
        if(r < L || R < l) return -INF;
        if(L <= l && r <= R) return st[idx].val;
        int mid = (l+r)/2, lson = idx*2, rson = idx*2+1;
        return max(_query(l, mid, lson, L, R), _query(mid+1, r, rson, L, R));
    }
    void _modify(int l, int r, int idx, int pos, ll val)
    {
        if(pos < l || r < pos) return;
        if(l == pos && r == pos) { st[idx].val = val; return; }
        int mid = (l+r)/2, lson = idx*2, rson = idx*2+1;
        _modify(l, mid, lson, pos, val);
        _modify(mid+1, r, rson, pos, val);
        _up(idx, lson, rson);
    }
public:
    void build(int n) { _n = n; }
    void build(ll *arr, int n) { _n = n, _build(0, n-1, 1, arr); }
    ll query(int l, int r) { return _query(0, _n-1, 1, l, r); }
    void modify(int pos, ll val) { _modify(0, _n-1, 1, pos, val); }
};

const int N = 200005;
int n;
ll h[N], a[N];
Seg1D st;

void init();
void process();

int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    init();
    process();
    cout.flush();
    return 0;
}

void init()
{
    cin >> n;
    for(int i = 0; i < n; i++) cin >> h[i];
    for(int i = 0; i < n; i++) cin >> a[i];
    st.build(N-1);
}

void process()
{
    for(int i = 0; i < n; i++)
    {
        ll dpi = st.query(0, h[i]) + a[i];
        st.modify(h[i], dpi);
    }
    cout << st.query(0, N-1) << endl;
}



Measured memory_bytes: 9600
/*
 * atcode154-a
 */

#include <stdio.h>
#include <stdlib.h>
#include <strings.h>

#define LEN_STR 10

int
main(int argc, char *argv[])
{
  char A[LEN_STR+1];
  char B[LEN_STR+1];
  char U[LEN_STR+1];

  int num_A;
  int num_B;

  scanf("%s", A);
  scanf("%s", B);

  scanf("%d", &num_A);
  scanf("%d", &num_B);

  scanf("%s", U);

  if (strcmp(A, U) == 0)
    --num_A;
  else
    --num_B;

  printf("%d %d\n", num_A, num_B);
}


Measured memory_bytes: 128
#include<stdio.h>
#define MAX 100000
#define NIL -1
 
struct Node{ 
int p,l,r;
};
struct Node T[MAX];
int n,D[MAX];
void rec(int);
int main(){
  int i,j,d,v,c,l,r,a;

  scanf("%d", &n);
 
  for (i=0;i<=n-1;i++){
    T[i].p=T[i].l=T[i].r=NIL;
  }
 
  for (i=0;i<=n-1;i++){
    scanf("%d %d",&v,&d);
    for (j=0;j<d;j++){
      scanf("%d", &c);
      T[c].p=v;
      if(j==0){
	T[v].l=c;
      }      
      else{
	T[l].r=c;
      }
      l=c;
      T[c].p=v;
    }
  }
  for (i=0;i<=n-1;i++){
    if(T[i].p==NIL){
      D[i]=0; 
      rec(i); 
      break;
    }
  }
 
  for (i=0;i<=n-1;i++){
    printf("node %d: parent = %d, depth = %d,",i,T[i].p,D[i]);
    if(T[i].p==NIL){
      printf(" root, [");
    }
    else if(T[i].l==NIL){
      printf(" leaf, [");
    }
    else{
      printf(" internal node, [");
    }
    a=i;
    if(T[a].l!=NIL){ 
      printf("%d",T[a].l);   
      if(T[T[a].l].r==NIL){
	printf("]\n");
      }
      else{
	printf(", ");
      }
      a=T[a].l;
      while(T[a].r!=NIL){
	printf("%d",T[a].r);
	if(T[T[a].r].r==NIL){
	  printf("]\n");
	}
	else{
	  printf(", ");
	}
	a=T[a].r;
      }
    }
    else puts("]");
  
  }
  return 0;
}

void rec(int u){
  int d = 0;
  if(T[u].r!=NIL){
    D[T[u].r]=D[u];
    rec(T[u].r);
  }
  if(T[u].l!=NIL){ 
    D[T[u].l]=D[u]+1;
    rec(T[u].l);
  }
}

Measured memory_bytes: 3732