akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define veci vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))


using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
//template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
//template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x:vec) is >> x;
    return is;
}
const ll INF=1e9+7;


int main()
{
    ll n;
    cin >> n;
    vector<ll> s(n);
    rep(i,n){
        cin >> s[i];
    }
    sort(s.begin(),s.end());
    ll q;
    cin >> q;
    ll ans=0;
    rep(i,q){
        ll t;
        cin >> t;
        if(lower_bound(s.begin(),s.end(),t)!=upper_bound(s.begin(),s.end(),t)){
            ans++;
        }
        
    }
    cout << ans << endl;
    return 0;
} 


Measured memory_bytes: 3528
//Keep Working Hard
  // I__Like__Food  
  #include<bits/stdc++.h>
  #include <ext/pb_ds/assoc_container.hpp> 
  #include <ext/pb_ds/tree_policy.hpp>
  #define rep(i,a,b) for(int i = a; i <=b; i++)
  #define rep2(i,a,b) for(int i = a; i>=b; i--)
  #pragma GCC optimize("O3")
  #pragma GCC optimize("Ofast") 
  #pragma GCC optimize("unroll-loops")
  using namespace std;
  using namespace __gnu_pbds;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define all(v) v.begin(),v.end()
  #define PB push_back
  #define MP make_pair
  #define double long double
  #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
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int mod = 1e9 + 7;
  const int N = 200005;
  const int INF = 1e16;
  const double PI = acos(-1);

int32_t main()
{
    int n,x,y;
    cin >> n >> x >> y;
    int ans[n] = {0};
  
    for(int i = 1; i <= n; i++)
      for(int j = i + 1; j <= n; j++)
      {
        int a  = min(1 + abs(x-i) + abs(y-j),(j-i));
        ans[a]++;
      }

    for(int i = 1; i < n; i++)cout << ans[i] << endl;

  return 0;
} 

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

using namespace std;


#include<iostream>
#include<algorithm>

using namespace std;

int main() {
	int x;
	int temp1, temp2;

	cin >> x;

	temp1 = x / 500;
	x -= temp1 * 500;
	temp2 = x / 5;
	cout << temp1 * 1000 + temp2 * 5;
}


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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    cin >> k >> n;
    ll cnt = 0;
    ll M = -10;
    ll A[n];
    for(i = 0; i < n; i++) {
        cin >> A[i];
        if(i>0){
            M = max(M, A[i] - A[i - 1]);
        }
    }
    M = max(M, k - A[n - 1] + A[0]);
    cout << k - M << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
// __builtin_ctz : no of trailing zeros
#define ll long long
#define pp pair<ll,ll>
#define mod 1000000007
#define trace(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 sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;
ll max(ll x, ll y)
{
    return x>y ? x : y;
}
ll min(ll x, ll y)
{
    return x<y ? x : y;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin >> n;
    ll a[n];
    for (int i = 0; i < n; ++i)
    {
    	cin >> a[i];
    }
    ll ans=1e18;
    for(ll i=1;i<=100;i++)
    {
    	ll dans=0;
    	for (int j = 0; j < n; ++j)
    	{
    		dans+=(i-a[j])*(i-a[j]);
    	}
    	ans=min(ans,dans);
    }
    cout << ans;
    }

Measured memory_bytes: 256
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = list(input())
d = []
for i in range(K):
  d.append(T[i])
  
p = {'r': P, 's': R, 'p': S, 'X': 0}
ans = 0

for i in range(0, N - K):
  if d[i] == T[i + K]:
    d.append('X')
  else:
    d.append(T[i + K])
    
for i in range(N):
  ans += p[d[i]]
  
print(ans)

Measured memory_bytes: 4792
#include "bits/stdc++.h"
 
using namespace std;
 
typedef long long ll;
 
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
 
int main(){
    int n,m,s;
    while(cin>>n>>m>>s){
        if(n==0&&m==0&&s==0)break;
         
        static int dp[2][2300][3300];
         
        rep(i,2)rep(j,2300)rep(k,3300)dp[i][j][k]=0;
        dp[0][0][0] = 1;
         
        for(int i=1;i<=n*n;i++){
            for(int j=0;j<2300;j++)
                for(int k=0;k<3300;k++)
                    dp[i%2][j][k] = 0;
            for(int j=1;j<=m;j++){
                for(int k=1;k<=s;k++){
                    if(k-j>=0){
                        dp[i%2][j][k] += dp[i%2][j-1][k-1] + dp[(i-1)%2][j-1][k-j];
                        dp[i%2][j][k] %= 100000;
                    }
                }
            }
        }
         
 
        ll ans = 0;
        for(int i=0;i<=m;i++){
            ans+=dp[(n*n)%2][i][s];
            ans%=100000;
        }
        cout<<ans<<endl;   
    }
}

Measured memory_bytes: 60452
#include<bits/stdc++.h>
typedef long long i64;
const int N=128;
int _()
{
	int x;
	scanf("%d",&x);
	return x;
}
int n;
struct pos
{
	int x,y;
	double a;
	bool operator<(const pos&w)const
	{
		return a<w.a;
	}
} ps[N*2];
const double pi=acos(-1);
int main()
{
	n=_();
	for(int i=1; i<=n; ++i)
	{
		ps[i].x=_();
		ps[i].y=_();
		ps[i].a=atan2(ps[i].y,ps[i].x);
		if(!ps[i].x&&!ps[i].y)--i,--n;
	}
	std::sort(ps+1,ps+n+1);
	int sx=0,sy=0;
	i64 ans=0;
	for(int i=1,j=1; i<=n; ++i)
	{
		ps[n+i]=(pos)
		{
			ps[i].x,ps[i].y,ps[i].a+pi*2
		};
		for(; j<n+i&&ps[j].a-ps[i].a<pi+1e-13; ++j)
		{
			sx+=ps[j].x;
			sy+=ps[j].y;
			i64 v=(i64)sx*sx+(i64)sy*sy;
			if(v>ans)ans=v;
		}
		sx-=ps[i].x;
		sy-=ps[i].y;
		i64 v=(i64)sx*sx+(i64)sy*sy;
		if(v>ans)ans=v;
	}
	double t=sqrt(double(ans));
	printf("%.18lf\n",t);
	return 0;
}

Measured memory_bytes: 512
#include <valarray>
#include <cstdio>
using namespace std;
typedef valarray<int>V;
int N,M,A,B,C,T;
V mul(const V &a, const V &b){
	V c(N*N);
	int i=0,j;
	for(;i<N;i++)for(j=0;j<N;j++)c[i*N+j]=(a[slice(i*N,N,1)]*b[slice(j,N,N)]).sum()%M;
	return c;
}
V exp(const V &a, const int n){
	if(n==1)return a;
	if(n&1)return mul(exp(a,n-1),a);
	V b=exp(a,n>>1);
	return mul(b,b);
}
V s,x;
void output(const V &r){
	int i=0;
	for(;i<N-1;i++)printf("%d ",(r[slice(i*N,N,1)]*s).sum()%M);
	printf("%d\n",(r[slice(i*N,N,1)]*s).sum()%M);
}
main(){
	int i;
	for(;scanf("%d%d%d%d%d%d",&N,&M,&A,&B,&C,&T),N;){
		s.resize(N);
		for(i=0;i<N;i++)scanf("%d",&s[i]);
		x.resize(0);
		x.resize(N*N);
		if(T){
			x[0]=B;
			x[1]=C;
			for(i=1;i<N-1;i++){
				x[i*N+i-1]=A;
				x[i*N+i]=B;
				x[i*N+i+1]=C;
			}
			x[i*N+i-1]=A;
			x[i*N+i]=B;
			output(exp(x,T));
		}else{
			for(i=0;i<N;i++)x[i*N+i]=1;
			output(x);
		}
	}
}

Measured memory_bytes: 1084
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

void Main()
{
  int k;
  string s;
  cin >> k >> s;
  
  if(s.size() <= k){
    std::cout << s;
  }
  else{
    for(int i = 0; i < k; i++){
      std::cout << s[i];
    }
    string s2 = "...";
    std::cout << s2;
  }
}

int main()
{
  std::cout << std::fixed << std::setprecision(15);
  Main();
}



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

void findfactors(int num,int array[]){
  for(int i=2;i<=num;i++){
    while(num%i==0){
      array[i]++;
      num/=i;
    }
  }
  return ;
}
int main(){
  
  int n;
  cin >>n;

  int ans=0;
  int arr[101];

  for(int i=0;i<=n;i++){
   arr[i]=0;
  }
  if(n==1){
    cout <<ans<<endl;
    return 0;
  }

  for(int i=2;i<=n;i++){
    findfactors(i,arr);
  }

  // for(int i=0;i<=n;i++){
  //   cout <<i<<":"<<arr[i]<<endl;
  // }

  int a=0;
  int b=0;
  int c=0;
  int d=0;
  int e=0;
  for(int i=2;i<=n;i++){
    if(arr[i]>=74){
      e+=1;
    }else if(arr[i]>=24){
      d+=1;
    }else if(arr[i]>=14){
      c+=1;
    }else if(arr[i]>=4){
      b+=1;
    }else if(arr[i]>=2){
      a+=1;
    }
  }
  // cout <<a<<","<<b<<","<<c<<","<<d<<","<<e<<","<<endl;

  ans+=e;
  ans+=(d+e)*(a+b+c+(d-1)+e);
  ans+=(c+d+e)*(b+(c-1)+d+e);
  if((b+c+d+e)>=2){
    ans+=a*(b+c+d+e)*(b+c+d+e-1)/2;
  }
  if((b+c+d+e)>=3){
    ans+=(b+c+d+e)*(b+c+d+e-1)*(b+c+d+e-2)/2;
  }
  cout <<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){ 
    int N;
    cin >>N;
    int ans = 0;
    for(int i = 1;i < N+1;i++){
        if(1 <= i && i < 10) ans++;
        if(100 <= i && i < 1000) ans++;
        if(10000 <= i && i < 100000) ans++;
        if(1000000 <= i && i < 100000000) ans++;
    }
    cout << ans << endl;
}   


Measured memory_bytes: 256
program main
  implicit none
  integer(8) :: n, a, b, res, m
  read (*, *) n, a, b
  m = 1000000007
  res = pow(2_8, n, m) - combi(n, a, m) - combi(n, b, m) - 1
  write(*, "(i0)") modulo(res, m)
  contains

  function combi(n, k, m)
    implicit none
    integer(8), intent(in) :: n, k, m
    integer(8) :: combi, numera, denomi
    numera = perm(n, k, m)
    denomi = mod(fact(k, m), m)
    combi = mod(numera * inv(denomi, m), m)
  end function combi

  function perm(n, k, m)
    integer(8), intent(in) :: n, k, m
    integer(8) :: i, perm
    perm = 1
    do i = n, n - k + 1, -1
      perm = mod(perm * i, m)
    end do
  end function perm

  function fact(n, m)
    implicit none
    integer(8), intent(in) :: n, m
    integer(8) :: i, fact
    fact = 1
    do i = 1, n
      fact = mod(fact * i, m)
    end do
  end function fact

  function inv(n, m)
    implicit none
    integer(8), intent(in) :: n, m
    integer(8) :: inv
    inv = pow(n, m - 2, m)
  end function inv

  recursive function pow(n, p, m) result(res)
    implicit none
    integer(8), intent(in) :: n, p, m
    integer(8) :: res
    if (p == 0) then
      res = 1
    else if (mod(p, 2_8) == 0) then
      res = mod(pow(n, p / 2, m) ** 2, m)
    else
      res = mod(pow(n, p - 1, m) * n, m)
    end if
  end function pow
end program main


Measured memory_bytes: 512
#include <iostream>
#include <string>

int main()
{
  int n;
  std::cin >> n;
  double total = 0;
  for (int i = 0; i < n; i++) {
    double value;
    std::string type;
    std::cin >> value >> type;
    if (type == "JPY") {
      total += value;
    } else if (type == "BTC") {
      total += value * 380000;
    } else {
      std::cerr << "Unknown type: " << type << '\n';
      return 1;
    }
  }
  std::cout << total << '\n';
  return 0;
}


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

int main() {
    stack<int> S;
    int a, b;
    string s;

    while(cin >> s) {
        if(s[0] == '+') {
            a = S.top();
            S.pop();
            b = S.top();
            S.pop();
            S.push(a + b);
        }
        else if(s[0] == '-') {
            a = S.top();
            S.pop();
            b = S.top();
            S.pop();
            S.push(b - a);
        }
        else if(s[0] == '*') {
            a = S.top();
            S.pop();
            b = S.top();
            S.pop();
            S.push(a * b);
        }
        else {
            S.push(atoi(s.c_str()));
        }        
    }
    cout << S.top() << endl;

    return 0;
}



Measured memory_bytes: 3228
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
     	int n = Integer.parseInt(st.nextToken());
     	int k = Integer.parseInt(st.nextToken());
     	int ar[] = new int[n];
   		int dp[] = new int[n];
   		st = new StringTokenizer(br.readLine());
       	for(int i =0;i<n;i++) {
       		ar[i] = Integer.parseInt(st.nextToken());
       	}
       
       	dp[0] = 0;
       	for(int i =1;i<n; i++) {
       		dp[i] = Integer.MAX_VALUE;
       		for(int j = i-1; j>=Math.max(0, i-k); j--)
       			dp[i] = Math.min(dp[i] , Math.abs(ar[i] - ar[j]) + dp[j]);
       	}
       	
       	System.out.println(dp[n-1]);
     
       
	}
}

Measured memory_bytes: 43400
#include <bits/stdc++.h>
#define rep(i, x, y) for (long long i = x; i <= y; i++)
using namespace std;

typedef long long ll;
const int N = 1e5 + 10, inf = 1e9 + 7;
ll node[N * 10], ans[15];
ll h, w, n, cnt;

int main() {
    cin >> h >> w >> n;
    ans[0] = 1ll * (h - 2) * (w - 2);
    rep(i, 1, n) {
        ll a, b; cin >> a >> b;
        rep(j, max(1ll, a - 2), min(h - 2, a)) {
            rep(k, max(1ll, b - 2), min(w - 2, b)) {
                node[++cnt] = inf * j + k;
            }
        }
    }
    sort(node + 1, node + cnt + 1);
    ll num = 1;
    rep(i, 1, cnt) {
        if (node[i] == node[i + 1]) num++;
        else ans[num]++, num = 1, ans[0]--;
    }
    rep(i, 0, 9) printf("%lld\n", ans[i]);
    return 0;
}


Measured memory_bytes: 7296
#include <stdio.h>

#define MAX 200000

int max(int a,int b) { return a>b ? a: b;}
int min(int a,int b) { return a<b ? a: b;}

int main(void){
int R[MAX], i, n;

scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&R[i]);

int maxv = -2000000000;
int minv = R[0];

for(int i=1; i<n; i++){
maxv = max(maxv, R[i] - minv);
minv = min(minv, R[i]);
}
printf("%d\n",maxv);

return 0;
}


Measured memory_bytes: 2512
decks=Hash.new()
decks.store("a",gets.chomp)
decks.store("b",gets.chomp)
decks.store("c",gets.chomp)

pointer="a"

#Until is the opposite of while. It repeats when the condition is false.
until decks[pointer].length==0 do
	pointer=decks[pointer].slice!(0)
end

puts pointer.capitalize

Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                    \
  ifstream in("abc176/abc176_b.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  string N;
  cin >> N;

  ll ans = 0;
  rep(i, N.size()) { ans += N[i] - '0'; }

  cout << (ans % 9 == 0 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3732
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

const ll MOD=1'000'000'007;

ll mpow(ll x,ll n){
    if(n==0) return 1;
    else if(n%2) return x*mpow(x,n-1)%MOD;
    return mpow(x*x%MOD,n/2)%MOD;
}

ll N,K;
ll A[100000];

ll frac[100001];
ll inv[100001];

int main(){
    cin>>N>>K;
    rep(i,N) cin>>A[i];

    sort(A,A+N);

    frac[0]=1;
    repn(i,N){
        frac[i]=frac[i-1]*i%MOD;
    }
    inv[0]=1;
    repn(i,N){
        inv[i]=mpow(frac[i],MOD-2);
    }

    ll ans=0;
    rep(i,N){
        if(i>=K-1){
            ans+=A[i]*frac[i]%MOD*inv[i-(K-1)]%MOD*inv[K-1]%MOD;
        }
        if(N-i-1>=K-1){
            ans-=A[i]*frac[N-i-1]%MOD*inv[(N-i-1)-(K-1)]%MOD*inv[K-1]%MOD;
        }
        ans%=MOD;
    }
    ans%=MOD;

    cout<<ans<<endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
using namespace std;
long long n,a[100002],z,zs;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    sort(a+1,a+n+1);
    z=1;
    for(int i=2;i<=n;i++)
    {
        if(a[i]==a[i-1])
		z=(z+1)%2;
        else
		zs+=z,z=1;
    }
    if(z%2)zs++;
    cout<<zs<<endl;
    return 0;
}

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

int main(){
    ll n;
    cin>>n;
    vector<ll>a(n+1);
    for(ll i=1;i<n+1;i++){
        for(ll j=i;j<n+1;j+=i){
            a[j]+=1;
        }
    }
    ll ans=0;
    for(ll i=1;i<n+1;i++){
        ans+=i*a[i];
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 81380
#include<stdio.h>
int main(void)
{
	int d;
	scanf("%d",&d);
	if(d==25){
		printf("Christmas\n");
	}
	else if(d==24){
		printf("Christmas Eve\n");
	}
	else if(d==23){
		printf("Christmas Eve Eve\n");
	}
	else{
		printf("Christmas Eve Eve Eve\n");
	}
	return 0;
}

Measured memory_bytes: 128
n = int(input())
p = [int(i) for i in input().split()]

counter = 0
for t in range(1, n - 1):
    if p[t - 1] < p[t] < p[t + 1] or p[t + 1] < p[t] < p[t - 1]:
        counter += 1

print(counter)


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

using namespace std;

int main()
{
  int n; cin >> n;
  vector<int> v;
  for (int i=0; i < n; i++) {
    int p; cin >> p;
    v.push_back(p);
  }

  int ans = 0;
  for (int i=1; i < v.size()-1; i++) {
    if (v.at(i-1) < v.at(i) && v.at(i) < v.at(i+1)) ans++;
    if (v.at(i+1) < v.at(i) && v.at(i) < v.at(i-1)) ans++;
  }
  

  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */


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

    int n; cin >> n;
    string s; cin >> s;
    vector<int> a(n, 0);
    int minv = 1000;
    rep(i, n){
        if(s[i] == '(') a[i] = (i==0? 0:a[i-1]) + 1;
        else a[i] = (i==0? 0:a[i-1]) - 1;
        chmin(minv, a[i]);
    }

    if(minv < 0){
        string t(abs(minv), '(');
        s = t + s;
        a[n-1] += abs(minv);
    }

    if(a[n-1] > 0){
        string t(a[n-1], ')');
        s += t;
    }

    cout << s << endl;
    
    return 0;
}

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

#define Maxi                      10000000000000000
#define lcm(a,b)                     (a*b)/__gcd(a,b)
#define ll                            long long
 
#define vll                          vector<ll>
#define vi                           vector<long long>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
//#define mp                           make_pair
#define all(v)                       v.begin(),v.end()
#define lbnd                         lower_bound
#define ubnd                         upper_bound
#define bs                           binary_search
#define F                            first  
#define S                            second
#define rep(i,a,b)                   for(i=a;i<b;i++)
#define parr(a,n)                    for(i=0;i<n;i++) cout<<a[i]<<" ";cout<<endl;
#define pcont(a)                     for(auto i:a) cout<<i<<" ";cout<<endl;
#define ret(x)                       return cout<<x,0;
#define dbg(x)                       cout << #x << " is " << x << endl;
#define endl                           '\n'
 
 
// Debug //
 
#define trace(x)                 cerr << #x << ": " << x << endl;
#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;
 
 
using namespace std;


void fun(ll n,map<ll,ll>&m1)
{
	ll c=0;

	while(n%2==0)
	{
		if(m1.find(2)==m1.end())
		{
			m1[2]=1;
		}
		else
		{
			m1[2]++;
		}
		n/=2;
	}

	for(ll i=3;i<=sqrt(n);i++)
	{
		while(n%i==0)
		{
		  if(m1.find(i)==m1.end())
		  {
			m1[i]=1;
		  }
		  else
		  {
			m1[i]++;
		  }
		  n/=i;
		}
	}


	if(n>1)
	{
		if(m1.find(n)==m1.end())
			m1[n]=1;
		else
			m1[n]++;
	}








}




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


	
	ll r;
	cin>>r;

	cout<<float(2*22*r)/float(7)<<endl;


	



	
	




}

Measured memory_bytes: 3828
#include <stdio.h>

int main(void){
        int n,a,b,c,d,i=0;
        while( (scanf("%d",&n)) != EOF){
              for(a=0;a<10;a++){
               for(b=0; b<10;b++){
                for(c=0;  c<10;c++){
                 for(d=0;d<10; d++){
                         if( a+b+c+d == n)
                            i++;
                      }
                    }
                  }
                }
                    printf("%d\n",i);
                        i =0;
             }
                return 0;
}
                  

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    EACH(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    REP(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
    REP(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

struct Edge {
    ll to, c, eid;
};
struct Node {
    int v, c, cost;
};
bool operator>(const Node& n1, const Node& n2) {
    return n1.cost > n2.cost;
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int N, M; cin >> N >> M;
    vector< map<ll, vector<Edge>> > G(N);
    REP(i, M) {
        ll p, q, c; cin >> p >> q >> c; --p, --q;
        G[p][c].pb({q, c, i});
        G[q][c].pb({p, c, i});
        G[p][0].pb({q, c, i});
        G[q][0].pb({p, c, i});
    }
    priority_queue<Node, vector<Node>, greater<Node>> Q;
    vector< map<ll, ll> > dist(N);
    dist[0][0] = 0;
    Q.push({0, 0, 0});
    while ( !Q.empty() ) {
        Node node = Q.top(); Q.pop();
        ll v = node.v, c = node.c, cost = node.cost;
        if (dist[v].count(c) > 0 && cost > dist[v][c]) continue;
        EACH(e, G[v][c]) {
            vector<ll> ncs = {0LL, e.c};
            EACH(nc, ncs) {
                ll ncost = cost;
                if (e.c != c) ++ncost;
                if (dist[e.to].count(nc) == 0 || ncost < dist[e.to][nc]) {
                    dist[e.to][nc] = ncost;
                    Q.push({e.to, nc, ncost});
                }
            }
        }
    }
    ll ans = dist[N-1].count(0) > 0 ? dist[N-1][0] : inf;
    // ll ans = inf;
    // REP(i, edges.size()) {
    //     if (edges[i].p == N-1 || edges[i].q == N-1) {
    //         ans = min(ans, dist[i]);
    //     }
    // }
    if (ans == inf) {
        cout << -1 << endl;
    }
    else {
        cout << ans << endl;
    }
    // cout << dist << endl;
    // cout << ans << endl;
}


Measured memory_bytes: 107568
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned ll
#define PI acos(-1)
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<typename T> using v2 = vector<vector<T>>;
template<typename T> using v3 = vector<vector<vector<T>>>;
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
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; }
const int MOD = 1e9 + 7;
const int INF = 1e9 + 200;
const ll INFLL = 2e18 + 200;

int main() {
    int X, N;
    cin >> X >> N;
    set<int> explore;
    for (int i = -200; i <= 200; i++) explore.insert(i);
    for (int i = 0; i < N; i++) {
        int temp;
        cin >> temp;
        explore.erase(temp);
    }
    auto itr = explore.lower_bound(X);
    int dif = INF, ans = INF;
    for (auto now = next(itr, -1); now != next(itr, 1); now++) {
        int temp = abs(*now - X);
        if (dif > temp) {
            ans = *now;
            dif = temp;
        }
    }
    cout << ans << endl;
}

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

int main(){
	int a[5];
	while( cin >> a[0] , a[0] ){
		if( a[0] == 3 ) a[0]++;
		for(int i=1 ; i<5 ; ++i ){
			cin >> a[i];
			if( a[i] == 3 ) a[i]++;
		}
		int x=0;
		for(int i=0; i<5 ; ++i ){
			x |= a[i];
		}
		for(int i=0 ; i<5 ; ++i ){
			if( x == 1 || x == 2 || x == 4 || x == 7 ){
				cout << 3 << endl;
			}else{
				int y = x ^ a[i];
				if( (y>>1) == a[i] || (a[i] == 4 && y == 1) ){
					cout << 1 << endl;
				}else{
					cout << 2 << endl;
				}
			}
		}
	}
}

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if(a + b + c >= 22) cout << "bust" << endl;
    else cout << "win" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

long long int lcm(long long int a, long long int b)
{
   return a * b / gcd(a, b);
}

int main()
{
   long long int a, b;
   cin >> a >> b;
   cout << lcm(a, b) << endl;
   return 0;
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	struct Block {
		int w;
		int s;
		int val;
	};
	Block blocks[n];
	for (int i = 0; i < n; i++) {
		int w = ri(), s = ri(), val = ri();
		blocks[i] = {w, s, val};
	}
	std::sort(blocks, blocks + n, [] (auto i, auto j) { return i.w + i.s < j.w + j.s; });
	int64_t dp[20001];
	memset(dp, 0, sizeof(dp));
	for (int i = 0; i < n; i++) {
		for (int j = blocks[i].s; j >= 0; j--) {
			int next = j + blocks[i].w;
			if (next <= 20000) dp[next] = std::max(dp[next], dp[j] + blocks[i].val);
		}
	}
	std::cout << *std::max_element(dp, dp + 20001) << std::endl;
	return 0;
}


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

int main(){
  string s; cin >> s;
  int n = s.size();
  int scr = n / 2;
  for(int i = 0; i < n; i++){
    if(s[i] == 'p') scr--;
  }
  cout << scr;
}

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

using namespace std;

 

int main()

{

	int n,x,sum=0;

	scanf("%d",&n);

	for(int i=1;i<=n;++i)

	{

		scanf("%d",&x);

		sum+=x-1;

	}

	printf("%d\n",sum);

}


Measured memory_bytes: 256
N = int(input())
ssorted = []
for i in range(N):
    ssorted.append("".join(sorted(list(input()))))
sdict = {}
for i in ssorted:
    if i in sdict:
        sdict[i] += 1
    else:
        sdict[i] = 1
count = 0
for i in sdict:
    s = sdict[i]
    if s >= 2:
        count += s*(s-1)//2
print(count)


Measured memory_bytes: 66904
#include <bits/stdc++.h>
using namespace std;
vector<int> dp;

int get_dp(int a) {
    if (a == 0) {
        return 0;
    }
    if (dp.at(a) != 0) {
        return dp.at(a);
    }
    int minx = a;
    int x = a;
    int b = 0;
    while(1) {
        b++;
        if (a < pow(6, b)) break;
    }
    for (int i = 1; i < b; i++) {
        x = 1 + get_dp(a - pow(6, i));

        minx = min(x, minx);
    }
    int c = 0;
    while(1) {
        c++;
        if (a < pow(9, c)) break;
    }
    for (int i = 1; i < c; i++) {
        x = 1 + get_dp(a - pow(9, i));

        minx = min(x, minx);
    }

    dp.at(a) = minx;
    return minx;
}

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

    for (int i = 0; i < (n + 1); i++) {
        dp.push_back(0);
    }

    //get_dp(n);
    /*for (int i = 0; i < (n + 1); i++) {
        cout << get_dp(i) << endl;
    }*/

    cout << get_dp(n) << endl;
}

Measured memory_bytes: 1784
eq=input().split(' ')

class Stack():
	def __init__(self):
		self.S=[]
		self.top=-1
		
	def initialize(self):
		self.top=-1
	
	def isEmpty(self):
		if self.top==-1:
			return('Empty')
		else:
			return('Not Empty')
	
	def push(self,x):
		self.S.append(x)
		self.top+=1
	
	def pop(self):
		a=self.S[self.top]
		del self.S[self.top]
		self.top-=1
		return(a)
		
	
	
	
c=Stack()
for i in range(len(eq)):
	if eq[i].isdigit():
		c.push(eq[i])
	else:
		a=c.pop()
		b=c.pop()
		if eq[i]=='+':
			c.push(int(b)+int(a))
		elif eq[i]=='-':
			c.push(int(b)-int(a))
		else:
			c.push(int(b)*int(a))
			
print(c.pop())


Measured memory_bytes: 5604
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
const int INF = 1000000009;
const ll LINF = 1e18;

int main() {
  string n;
  cin >> n;
  ll sum = 0;
  for (int i = 0; i < n.size(); ++i) {
    sum += n[i] - '0';
  }
  if (sum % 9 == 0) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
}


Measured memory_bytes: 3360
#include <stdio.h>
#include <cmath>
#include <bits/stdc++.h>



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#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)



int main(void){

	int N; cin >> N;
	vector<string> blue(N);
	REP(i,N) cin >> blue[i];
	int M; cin >> M;
	vector<string> red(M);
	REP(i,M) cin >> red[i];

	int ans = 0;
	REP(i,N){
		int p = 0;
		REP(j,N){
			if(blue[i] == blue[j]) p++;
		}
		REP(j,M){
			if(blue[i] == red[j]) p--;
		}
		ans = max(ans, p);
	}
	
	cout << ans << endl;


	return 0;

}


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 K = sc.nextInt();
		int[] height = new int[N];
		int con = 0;
		for (int i = 0; i < N; i++) {
			height[i]=sc.nextInt();
		}
		for (int i : height) {
			if (K<= i) {
				con++;
			}
		}
		System.out.println(con);
	}

}

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

#define F first
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 300010, M = 2 * N;

int n, m;
int h[N], ne[M], e[M], idx;
int q[M], d[N];

void add(int a, int b)
{
	e[idx] = b, ne[idx] = h[a], h[a] = idx ++ ;
}

int bfs(int st, int ed)
{
	int hh = 0, tt = -1;
	q[ ++ tt] = st;
	
	while (hh <= tt)
	{
		int t = q[hh ++ ];
		
		for (int i = h[t]; ~i; i = ne[i])
		{
			int j = e[i];
			if (d[j]) continue;
			
			q[ ++ tt] = j;
			d[j] = d[t] + 1;
		}
	}
	
	if (d[ed]) return d[ed] / 3;
	else return -1;
}

int main()
{
	memset(h, -1, sizeof h);
	
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i ++ )
	{
		int a, b;
		scanf("%d%d", &a, &b);
		add(3 * a, 3 * b + 1);
		add(3 * a + 1, 3 * b + 2);
		add(3 * a + 2, 3 * b);
	}
	
	int st, ed;
	scanf("%d%d", &st, &ed);
	printf("%d\n", bfs(3 * st, 3 * ed));
	return 0;
}

Measured memory_bytes: 9600
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
#include<set>
using namespace std;
#define ll long long
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define fi first
#define se second
#define pr(x) cerr<<#x<<"="<<(x)<<endl
#define pri(x,lo) {cerr<<#x<<"={";for (int ol=0;ol<=lo;ol++)cerr<<x[ol]<<",";cerr<<"}"<<endl;}
#define inf 100000000
#define N 1000
ll n,k,ans,b,i;
int main()
{
	scanf("%lld %lld",&n,&k);
	if (k==0)
	{
		printf("%lld\n",n*n);
		return 0;
	}
	for (i=k;i<=n;i++)
	{
		//pr(i);pr(n/i*(i-k));pr(max(0,n%i-k+1));
		ans+=n/i*(i-k);
		ans+=max(0ll,n%i-k+1);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void)
{
    char s[100], p[100], ss[200];
    scanf("%s%s", s, p);
    //ss???s?????£????????????
    strcat(ss, s);
    strcat(ss, s);
    
    //ss?????????p????????¨????????°?????????
    if(strstr(ss, p) != NULL){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 532
import sys
input = sys.stdin.readline


def q(i):
    print(i, flush=True)
    s = input().strip()
    if s == "Vacant":
        exit()
    return s


def f(l, r, lc, rc):
    m = (l+r)//2
    mc = q(m)

    if ((m-l) % 2 and lc == mc) or ((m-l) % 2 == 0 and lc != mc):
        f(l, m, lc, mc)
    elif ((r-m) % 2 and mc == rc) or ((r-m) % 2 == 0 and mc != rc):
        f(m, r, mc, rc)


def main():
    N = int(input())
    lc = q(0)
    rc = q(N-1)
    f(0, N-1, lc, rc)


if __name__ == '__main__':
    main()


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

int main() {
  int n;
  cin >> n;
  vector<int> p(n), q(n);
  rep (i,n) cin >> p[i], p[i]--;
  rep (i,n) cin >> q[i], q[i]--;
  vector<int> a(n);
  rep (i,n) a[i] = i;

  map<vector<int>, int> mp;
  int iter = 0;
  do {
    mp[a] = iter++;
  } while (next_permutation(a.begin(), a.end()));

  int ans = abs(mp[p] - mp[q]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5248
#include <iostream>
#include <vector>
#include <iterator>
#include <numeric>
#include <algorithm>

typedef long long ll;

using std::cin;
using std::cout;

const int MaxN = 100005;

int n, m; ll k;
int buk[MaxN];
ll arr[MaxN], tmp[MaxN];
bool vis[MaxN];

int main() {
	cin >> n;
	std::copy_n(std::istream_iterator<int>(cin), n, arr);
	cin >> m >> k;
	std::iota(buk, buk + n, 0);
	while (m--) {
		int pos; cin >> pos;
		std::swap(buk[pos - 1], buk[pos]);
	}
	std::adjacent_difference(arr, arr + n, tmp);
	for (int i = 0; i < n; ++i) {
		if (!vis[i]) {
			std::vector<int> vec;
			int j = i;
			do {
				vis[j] = true;
				vec.push_back(j);
				j = buk[j];
			} while (j != i);
			int len = vec.size();
			for (int p = 0; p < len; ++p) {
				int from = vec[p];
				int to = vec[(p + k) % len];
				arr[from] = tmp[to];
			}
		}
	}
	std::partial_sum(arr, arr + n, std::ostream_iterator<ll>(cout, "\n"));
	return 0;
}

Measured memory_bytes: 3440
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;
ll INF=1e10;

int main(){
  ll n; cin>>n;
  ll ans=0;
  for(int i=1;i<=n;i++){
    ans+=n/i*(i+(n/i)*i)/2;
  }
  cout<<ans<<endl;
}



























































































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

int main() {
	string r, a;
	while(cin >> r >> a, a != "0" && r != "0") {
		int hit, blow;
		int tmp[10] = {};
		hit = blow = 0;
		for(int i = 0; i < a.size(); i++)
			hit += a[i] == r[i];
		for(int i = 0; i < a.size(); i++) {
			tmp[a[i]-'0']++;
		}
		for(int i = 0; i < r.size(); i++) {
			if(tmp[r[i]-'0']) {
				blow++;
				tmp[r[i]-'0']--;
			}
		}
		blow -= hit;
		cout << hit << " " << blow << endl;
	}
}

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

int a;
set<int> s;

int main()
{
	ios::sync_with_stdio(false);
	for (int i = 1; i <= 3; i++)
	{
		cin >> a;
		s.insert(a);
	}
	if (s.size() == 2) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**5)
N,M,K = list(map(int,input().split(' ')))

friend_list = [0]*(N+1)
bad_list = [0]*(N+1)
group = {}

parent = [i for i in range(N+1)]
rank = [0]*(N+1)

def union(x,y):
    x = find(x)
    y = find(y)
    if x==y:
        return
    if rank[x]<rank[y]:
        parent[x]=y
    else:
        parent[y]=x
        if rank[x]==rank[y]:
            rank[x]+=1

def find(x):
    if parent[x] == x:
        return x
    else:
        parent[x]= find(parent[x])
        return parent[x]





for i in range(M):
    A,B = list(map(int,input().split(' ')))
    friend_list[A]+=1
    friend_list[B]+=1
    
    union(A,B)

for i in range(1,N+1):
    oya = find(i)
    parent[i] = oya
    #print(oya)
    if oya in group:
        group[oya] = group[oya]+1
    else:
        group[oya]=1

for i in range(K):
    A,B = list(map(int,input().split(' ')))
    if find(A)==find(B):
        bad_list[A]+=1
        bad_list[B]+=1
    
    #union(A,B)



#print(parent)
#print('parent')

#print('friend')
#print(friend_list)
#print('bad')
#print(bad_list) 
#print(group)

kouho = [0]*N

for i in range(1,N+1):
    oya = find(i)
    abc = group[oya]-friend_list[i]-bad_list[i]-1
    kouho[i-1] = abc

for k in kouho:
    print(k,end=" ")
print()

#print(parent)

Measured memory_bytes: 18628
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn = 200100;
ll arr[maxn], cnt[maxn];
ll n;

ll f(ll x) {
	if(x <= 1) return 0LL;
	else return 1LL * x * (x - 1) / 2;
}

int main() {
	cin>>n;
	for(int i=1;i<=n;i++) {
		cin>>arr[i];
		cnt[arr[i]]++;
	}

	ll result = 0LL;
	for(int i=1;i<=n;i++) {
		result += f(cnt[i]);
	}

	for(int i=1;i<=n;i++) {
		result -= f(cnt[arr[i]]);
		cout<<result + f(cnt[arr[i]] - 1)<<"\n";
		result += f(cnt[arr[i]]);
	}
}

Measured memory_bytes: 4736
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    PrintWriter out = new PrintWriter(System.out);

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

    void run() {

        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i=0; i<n; i++) arr[i] = sc.nextInt()*(-1);
        Arrays.sort(arr);
        for (int i=0; i<n; i++) arr[i] *= (-1);

        int ans = 1;

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

        out.print(ans);
        out.flush();



    }

}


Measured memory_bytes: 21716
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;

int ans[5];
int main()
{
	int a,b,c,x,y;
	while(scanf("%d%d%d%d%d",&a,&b,&c,&x,&y)!=EOF){
		ans[1] = a*x+b*y;
		if(x>y){
			ans[2] = a*(x-y)+2*c*y;
		}
		else{
			ans[2] = b*(y-x)+2*c*x;
		}
		ans[3] = 2*c*(max(x,y));
		int minx = ans[1];
		for(int i=2;i<=3;++i){
			if(ans[i]<minx)
				minx = ans[i];
		}
		cout<<minx<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use proconio::{input, marker::*};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

fn main() {
    input! {
        n: usize,
        ab: [(usize, usize);n],
    }

    let mut a = Vec::new();
    let mut b = Vec::new();
    for e in ab {
        a.push(e.0);
        b.push(e.1);
    }

    a.sort();
    b.sort();

    if n % 2 == 1 {
        println!("{}", b[n / 2] - a[n / 2] + 1);
    } else {
        println!("{}", b[n / 2] + b[n / 2 - 1] - a[n / 2] - a[n / 2 - 1] + 1);
    }
}


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

int main() {
  ll n, k; cin >> n >> k;
  vector<ll> l(k), r(k);
  rep(i,k) cin >> l[i] >> r[i];

  vector<ll> dp(n+1);
  vector<ll> dpsum(n+1);
  dp[1] = 1;
  dpsum[1] = 1;

  for(int i = 2; i <= n; i++){
    rep(j,k){
      int li = i-r[j];
      int ri = i-l[j];
      if(ri < 0) continue;
      li = max(li,1);
      dp[i] += dpsum[ri] - dpsum[li-1];
      dp[i] += mod;
      dp[i] %= mod;
    }
    dpsum[i] += dpsum[i-1]+dp[i];
    dpsum[i] %= mod;
    //cout << dp[i] << " " << dpsum[i] << endl;
  }
  cout << dp[n] << endl;
}


Measured memory_bytes: 6424
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
typedef long long ll;
 
//dp解
//dp[i][j] -> i,jから始めた時一致している長さ
int dp[5005][5005];
 
int main(){
  int N;
  cin >> N;
  string s;
  cin >> s;
  for (int i = N-1; i >= 0; i--) {
    for (int j = N-1; j >= 0; j--) {
      if(s[i] != s[j] )dp[i][j] = 0;
      else dp[i][j] = dp[i+1][j+1] + 1;
    }
  }
  int res = 0;
  rep(i,N) for(int j=i;j<N;++j) {
     
    int now = min(dp[i][j], j - i);//i文字目を終端とした時のlenの最大
    res = max(res,now);
  }
  
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 98048
#include <bits/stdc++.h>
using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

using ll = long long;
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define tc() int t; cin>>t; while(t--)
#define print(n) cout<<n<<"\n"
#define inp(n) int n; cin>>n
#define all(cont) cont.begin(), cont.end()
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define mp make_pair
#define pb push_back
#define maxn 1000010
#define mod 1e9+7
#define ff  first
#define ss  second
#define fora(var, start, end) for(int var = start; var < end; var++)
int main()
{
    fast();
    string s;int k;
    cin>>k>>s;
    int ans=0;
    fora(i,0,k-2)
    {
        if(s[i]=='A' and s[i+1]=='B' and s[i+2]=='C') ans++;
    }
    print(ans);
    return 0;
}

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

int main()
{
  int64_t N, cnt = 0;
  cin >> N;
  vector<int64_t> L(N);
  for (int64_t i = 0; i < N; i++)
    cin >> L.at(i);
  sort(L.begin(), L.end());
  for (int64_t i = 0; i < N - 2; i++)
  {
    int64_t a = L.at(i);
    for (int64_t j = i + 1; j < N - 1; j++)
    {
      int64_t b = L.at(j);
      for (int64_t k = j + 1; k < N; k++)
      {
        if (L.at(k) < a + b)
          cnt++;
      }
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  if(n>=400 && n<=599)
    cout<<8<<endl;
  else if(n>=600 &&n<=799)
    cout<<7<<endl;
   else if(n>=800 &&n<=999)
    cout<<6<<endl;
   else if(n>=1000 &&n<=1199)
    cout<<5<<endl;
   else if(n>=1200 &&n<=1399)
    cout<<4<<endl;
   else if(n>=1400 &&n<=1599)
    cout<<3<<endl;
   else if(n>=1600 &&n<=1799)
    cout<<2<<endl;
   else
     cout<<1<<endl;
  return 0;
}

Measured memory_bytes: 3640