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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int s, w;
    cin >> s >>  w;
    if (w >= s){
        cout << "unsafe" << endl;
    }else{
        cout << "safe" << endl;
    }
    return 0;
}

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

using namespace std;

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

int main()
{
	int n;
	cin >> n;
	
	vector<long long> t(n);
	for(int i = 0; i < n; i++)
	{
		cin >> t[i];
	}
	
	long long ans = 0;
	for(int i = 0; i < n; i++)
	{
		if(i == 0)
		{
			ans = t[0];
		}
		else
		{
			long long euc = ans > t[i] ? euclid(ans, t[i]) : euclid(t[i], ans);
			ans = ans * (t[i] / euc);
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int N=1000005;
#define M 1000000007
#define double long double
#define init(arr,val) memset(arr,val,sizeof(arr))
#define BINF 1000000000001
const int LG = 22;

int isPrime(int x){
    for(int i = 2; i * i <= x; i++){
        if(x % i == 0) return 0;
    }
    return 1;
}

#undef int 
int main() {
#define int long long int
ios_base::sync_with_stdio(false); 
cin.tie(0); 
cout.tie(0);
    

    int k = 4;
    int a,b;
    cin >> a >> b;
    int c = __gcd(a,b);
    int ans = 0;
    set<int>s;
    for(int i = 1; i * i <= c; i++){
        if(c % i == 0) s.insert(i), s.insert(c / i);
    }

    for(auto i : s){
        if( i == 1 ) ans++;
        else if(isPrime(i)) ans++;
    }

    cout << ans << endl;
    

return 0;  
}


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

const int N = 100000;

int main(int argc, char const *argv[]) {
    int n, a[N];

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

    sort(a, a + n);
    reverse(a, a + n);

    int sum_a = 0;
    int sum_b = 0;
    for (int i = 0; i < n; i++) {
        if (i % 2 == 0) {
            sum_a += a[i];
        } else {
            sum_b += a[i];
        }
    }

    cout << sum_a - sum_b << endl;

    return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

//const long long int MOD = 1000000007;
const int MOD = 1000000007;
//const int MOD = 998244353;
//const long long int MOD = 998244353;
const double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N >> K;
	set<int>s;
	vector<int>v(N);
	for (int i = 0; i < N; i++)v[i] = i;
	vector<pair<int, int>>w(K);
	for (auto &i : w) {
		cin >> i.first >> i.second;
		i.first--;
		i.second--;
	}
	for (int i = K - 1; i >= 0; i--) {
		swap(v[w[i].first], v[w[i].second]);
	}
	int p = 0;
	s.insert(v[0]);
	s.insert(v[1]);
	for (auto i : w) {
		swap(v[i.first], v[i.second]);
		if (i.first == p)p = i.second;
		else if (i.second == p)p = i.first;
		if (p - 1 >= 0)s.insert(v[p - 1]);
		if (p + 1 < N)s.insert(v[p + 1]);
	}
	cout << s.size() << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long INF = 1LL << 60;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int main()
{
  int N;
  string S;
  cin >> N >> S;
  S += "#";
  
  int b = 0, w = 0;
  vector<int> B, W;
  int n = 0;
  char C0 = '.';
  
  for (int i = 0; i < N + 1; i++)
  {
    if (C0 == S.at(i))
    {
      if (S.at(i) == '#') b++;
      else w++;
    }
    else
    {
      if (S.at(i) == '#')
      {
        if (b > 0)
        {
          B.push_back(b);
          W.push_back(w);
          n++;
        }
        b = 1;
        w = 0;
      }
      else w++;
    }
    C0 = S.at(i);
  }
  
  vector<vector<int>> dp(n, vector<int>(2, 10000000));
  int ans = 0;
  if (n > 0)
  {
    dp.at(0).at(0) = B.at(0);
    dp.at(0).at(1) = W.at(0);
  
    for (int i = 1; i < n; i++)
    {
      dp.at(i).at(0) = dp.at(i - 1).at(0) + B.at(i);
      dp.at(i).at(1) = min(dp.at(i - 1).at(0) + W.at(i), 
                           dp.at(i - 1).at(1) + W.at(i));
    }
  
    ans = min(dp.at(n - 1).at(0), dp.at(n - 1).at(1));
  }
  
  cout << ans << endl;
  
  //for (int i = 0; i < n; i++) cout << dp.at(i).at(0) << " " << dp.at(i).at(1) << endl;
}

Measured memory_bytes: 6648
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

// const int mod = 1000000007;
const int mod = 998244353;
struct mint {
    long long x;
    mint(long long x=0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, s;
    cin >> n >> s;
    vi a(n);
    rep(i, n) cin >> a[i];
    
    mint ans = 0;
    vector<mint> f(s+1, 0);
    rep(i, n) {
        f[0] += 1;
        vector<mint> pre = f;
        rep(j, s+1) {
            if (j + a[i] <= s) f[j + a[i]] += pre[j];
        }
        ans += f[s];
    }
    cout << ans << endl;
}

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

void solve(int N, int x) {
    if (x <= 1 || x >= N*2-1) {
        cout << "No" << endl;
        return;
    }

    cout << "Yes" << endl;
    vector<int> res(N*2-1, -1);
    res[N-2] = 1;
    res[N-1] = x;
    res[N] = N*2-1;
    int iter = 0;
    for (int v = 2; v < N*2-1; ++v) {
        if (v == x) continue;
        while (res[iter] != -1) ++iter;
        res[iter] = v;
    }
    for (auto v : res) cout << v << endl;
}

int main() {
    int N, x;
    cin >> N >> x;
    solve(N, x);
}
    





Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    ll n,m;
    cin >> n >> m;
    Vi x(n),y(n),z(n);
    matrix option(8,Vi(n,0));
    rp(i,n) {
        cin >> x.at(i) >> y.at(i) >> z.at(i);
        rp(j,8){
            if(j&1) option[j][i]+=x[i];
            else option[j][i]-=x[i];
            if(j&2) option[j][i]+=y[i];
            else option[j][i]-=y[i];
            if(j&4) option[j][i]+=z[i];
            else option[j][i]-=z[i];
        }
    }
    rp(j,8){
        Sort(option[j]);
    }
    ll ans=0;
    rp(j,8){
        ll sum=0;
        rp(i,m){
            sum+=option[j][i];
        }
        chmax(ans,sum);
    }
    print(ans);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 384
while True:
    n=input()
    if n==0:break
    for i in range(n):
        pm,pe,pj=map(int,raw_input().split())
        ave=(pm+pe+pj)/3.0
        if (100 in (pm,pe,pj)) or ((pm+pe)/2>=90) or (ave>=80):
            print "A"
        elif (ave>=70) or ((ave>=50) and ((pm>=80) or (pe>=80))):
            print "B"
        else:
            print "C"

Measured memory_bytes: 4256
#include<iostream>
using namespace std;
#define ll long long
int main(){
  ll n,m,sum=0;
  cin>>n;
  ll a[n+1]={0};
  for(int i=0;i<n-1;i++){
    int p;
    cin>>p;
    a[p]++;
  }
  for(int i=1;i<=n;i++){
    cout<<a[i]<<"\n";
  }
  return 0;
}

Measured memory_bytes: 5156
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long int A,B,C=1;
	cin >> A >> B;
	if(A == 1){
		cout << B << endl;
		return 0;
	}
	for(long long int i=2; i*i <= B; i++)
		if(B % i == 0){
			int cnt = 0;
			while(B % i == 0)B /= i, cnt ++;
			cnt = (int)(cnt / A);
			while(cnt --)C *= i;
		}
	cout << C << endl;
	return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n + 2, 0);
  vector<int> b(n + 2, 0);
  vector<int> c(n + 2, 0);
  for (int i = 1; i <= n; i++)
    cin >> a[i];
  for (int i = 1; i <= n; i++)
    cin >> b[i];
  for (int i = 1; i <= n - 1; i++)
    cin >> c[i];
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += b[a[i]];
    if (a[i] > 1) {
      if (a[i] - 1 == a[i - 1]) {
        ans += c[a[i - 1]];
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 888
import heapq
N,M = map(int,input().split())
AB = []
for _ in range(N):
  A,B = map(int,input().split())
  heapq.heappush(AB, [A,B])
  
num = 0
ans = 0
while num < M:
  A,B = heapq.heappop(AB)
  if num + B <= M:
    ans += A*B
    num += B
  else:
    ans += A*(M-num)
    num += M-num
print(ans)

Measured memory_bytes: 19680
import java.util.*;
class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), m = sc.nextInt();
        int[] a = new int[m], b = new int[m];
        for(int i = 0; i < m; i++){
            a[i] = sc.nextInt() - 1;
            b[i] = sc.nextInt() - 1;
        }
        boolean[] aa = new boolean[n], bb = new boolean[n];
        Arrays.fill(aa, false);
        Arrays.fill(bb, false);
        for(int i = 0; i < m; i++){
            if(a[i] == 0) bb[b[i]] = true;
            if(b[i] == n-1) aa[a[i]] = true;
        }
        String ans = "IMPOSSIBLE";
        for(int i = 0; i < n; i++)
            if(aa[i] == true && bb[i] == true)
                ans = "POSSIBLE";
        System.out.println(ans);
    }
}


Measured memory_bytes: 95800
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
const int mod=1e9+7;
int n,a[200010];
long long ans,sum;
int main() {
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    for(int i=1;i<=n;i++) {
        ans+=sum*a[i]%mod;
        ans%=mod;
        sum+=a[i];
        sum%=mod;
    }
    printf("%lld\n",ans);
}

Measured memory_bytes: 4000
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <climits>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <map>
#include <tuple>
#include <iostream>
#include <deque>
#include <array>
#include <set>
#include <functional>
#include <memory>
#include <stack>
#include <numeric>
#include <climits>
#include <cfloat>
#include <bitset>

int main() {
	std::string a, b, c; std::cin >> a >> b >> c;
	if (a.back() == b.front() && b.back() == c.front()) std::cout << "YES\n";
	else std::cout << "NO\n";
}

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

int main(){
  int n,m,i,num[7368792];
  cin >> m;
  while(m!=0){
    cin>> n;
    for(i=0;i<7368792;i++)
      num[i]=1;
    num[0]=num[1]=0;
    for(int j=m;n>0;j++){
      if(num[j]==1){
        n--;
        for(int k=j;k<7368792;k+=j)
          num[k]=0;
      }
    }
    for(i=m;i<7368792;i++)
      if(num[i]==1){
        cout<<i<<endl;
        break;
      }
    cin >> m;
  }
}


Measured memory_bytes: 31852
#include <iostream>

using namespace std;

int main()
{
	int S[10005];
	int i, j, n, q, cnt = 0, t;
	cin >> n;
	for(i = 0; i < n; i++)
	{
		cin >> S[i];
	}
	cin >> q;
	for(j = 0; j < q; j++)
	{
		cin >> t;
		for(i = 0; i < n; i++)
		{
			if(t == S[i])
			{
				cnt++;
				break;
			}
		}
	}
	cout << cnt << endl;
	
	return 0;
}


Measured memory_bytes: 3120
#include<bits/stdc++.h>
#define ll  long long
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define pb push_back
#define Max(x,y,z) max(x,max(y,z))
#define f first
#define s second
#define lbd lower_bound
#define sz(x)       (ll)x.size()
#define pi 3.1415926536
#define mod 1000000007
using namespace std;
void solve()
{
    ll n,m,k,x,y=0,res=0,l,cnt=0,sum=0,z,sum1=0,cnt1=0,h,res1;
    cin>>n;
    ll pre[n],suf[n];
    ll ar[n];
    rep(i,0,n)
    cin>>ar[i];
    pre[0]=ar[0];suf[n-1]=ar[n-1];
    rep(i,1,n) pre[i]=__gcd(pre[i-1],ar[i]);
    for(ll i=n-2;i>=0;i--) suf[i]=__gcd(ar[i],suf[i+1]);
    ll ans=max(suf[1],pre[n-2]); // not taking the first and last element respectively
    rep(i,1,n)
    ans=max(ans,__gcd(pre[i-1],suf[i+1]));
    cout<<ans;

}
int main()
{
    ll t;
   // cin>>t;
    t=1;
    while(t--)
        solve();
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define f first
	#define s second
	
	using namespace std;
	int main()
	{
		std::ios::sync_with_stdio(false);
		int T;
		cin>>T;
		// cin.ignore(); must be there when using getline(cin, s)
		string s;
		cin >> s;

		int mid = T/2;
		if(T==1 || T%2!=0){
			cout << "No";
			return 0;
		}
		for(int i=0; i<T/2; i++){
			//cout << i << " " << mid << endl;
			if(s[i]!=s[mid]){
				cout << "No" << endl;
				return 0;
			}
			mid++;
		}

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


Measured memory_bytes: 256
### constant

MOD = 100000007

### subroutines

def distnum(n, c1, c2)
  if c1 > c2
    t = c1; c1 = c2; c2 = t
  end
  dc0 = c2 - c1
  dc1 = n - c2 + c1
  [(dc0 < dc1) ? dc0 : dc1, (dc0 == dc1) ? 2 : 1]
end

def mulmod(a, b)
  (a * b) % MOD
end

def powmod(a, n)
  pm = 1
  while n > 0
    pm = mulmod(pm, a) if (n & 1) == 1
    a = mulmod(a, a)
    n >>= 1
  end
  pm
end

def invmod(a)
  powmod(a, MOD - 2)
end

### main

r, c, a1, a2, b1, b2 = gets.split.map(&:to_i)

da, na = distnum(r, a1, b1)
db, nb = distnum(c, a2, b2)
#p [da, na, db, nb]

dab = da + db

fracs = [1]
invfs = [1]

for k in (1..dab)
  fracs[k] = (fracs[k - 1] * k) % MOD
  invfs[k] = invmod(fracs[k])
end

comb = mulmod(mulmod(fracs[dab], invfs[da]), invfs[db])
comb = mulmod(mulmod(comb, na), nb)

puts comb

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

int main(void){
    long int n, dis = 0, min;
    scanf("%ld", &n);
    min = n + 1;
    for(long int i = 1; i <= sqrt(n); i++){
        if(n % i == 0){
            if(i + n / i - 2 < min){
                min = i + n / i - 2;
            }
        }
    }
    printf("%ld\n", min);
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main{
	//?????°
	static int x;
	//????????????
	public static void solve(){
		Scanner sc = new Scanner(System.in);
		x = sc.nextInt();
		System.out.println(x*x*x);
	}
	public static void main(String[] args) {
		solve();
	}
}

Measured memory_bytes: 25968
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    int n, x;
    cin >> n >> x;
    int a[n];
    for(int i = 0; i< n; i++){
        cin >> a[i];
        x -= a[i];
    }
    int cnt = n;
    sort(a, a+n);
    for(int i = 0; ;i++){
        if(x - a[0] < 0){
            cout << cnt << endl;
            return 0;
        } else {
            x -= a[0];
            cnt++;
        }
    }
}


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

int main()
{
	long long n, ans, L1=1, L2=2, box;

	cin >> n;

	if (n == 0)
		ans = 2;
	else if (n == 1)
		ans = 1;
	else
	{
		for (int i = 0; i < n - 1; i++){
			box = L1 + L2;
			L2 = L1;
			L1 = box;
		}
		ans = box;
	}

	cout << ans;

	return 0;
}

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

using namespace std;

int main()
{
	std::ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    if(s=="Sunny") cout << "Cloudy" << endl;
    else if(s=="Cloudy") cout << "Rainy" << endl;
    else if(s=="Rainy") cout << "Sunny" << endl;
    
	return 0;
}


Measured memory_bytes: 256
d = int(input())
c = [int(i) for i in input().split()]
s = [[int(i) for i in input().split()] for j in range(d)]

#t = [int(input()) for i in range(d)]

ans = []
last = [[0 for i in range(26)] for j in range(27)]
tmp_ans = [0]*26

for i in range(1,d+1):
    tmp_num = 0
    for j in range(26):
        tmp_ans[j] += s[i-1][j]
        last[j+1][j] = i
        for k in range(26):
            tmp_ans[j] -= (i-last[j+1][k])*c[k]
    idx = tmp_ans.index(max(tmp_ans))
    for j in range(26):
        for k in range(26):
            if k == idx:
                continue
            last[k][j] = last[idx][j]
    print(idx+1)
    #print(tmp_ans)
#print(ans)
    """
            
    ans += s[i-1][t[i-1]-1]
    last[t[i-1]-1] = i
    for j in range(26):
        ans -= (i-last[j])*c[j]
    print(ans)
    """
    


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

#define LSOne(S) ((S) & (-S))

#define EPS 1e-6
#define MOD 1000000007

#define fi first
#define se second
#define pb push_back
#define ende '\n'

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mset(x, y) memset(&x, (y), sizeof(x))

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
	vi v;
	int n;
	cin >> n;
	int entra;
	while (cin >> entra)
		v.pb(entra);
	sort(all(v));
	cout << v[n/2]-v[n/2-1] << ende;
  return 0;
}


Measured memory_bytes: 892
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int[] a = new int[M];
    int[] b = new int[M];
    for (int i=0; i<M; i++) {
      a[i] = sc.nextInt();
      b[i] = sc.nextInt();
    }
    for (int i=1; i<N+1; i++) {
      int ans =0;
      for (int j=0; j<M; j++) {
        if (a[j] == i) ans++;
        if (b[j] == i) ans++;
      }
      System.out.println(ans);
    }
   }
}

Measured memory_bytes: 21076
N,*as=$<.read.split.map(&:to_i)
as.unshift(0)

cnt = 0
i = 1
chk = Array.new(N+1,false)
loop do
    cnt += 1
    if as[i] == 2
        puts cnt 
        exit 0
    elsif chk[as[i]]
        puts -1
        exit 0
    end

    chk[i] = true
    i = as[i]
end


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e5 + 5);

map<ll, unordered_map<ll, ll>> memo;

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

int n;
ll a[MAX_N];

ll ans;

ll forward_vec[MAX_N];
ll backward_vec[MAX_N];

int main(void) {
  // Here your code !
  scanf("%d", &n);

  for (int i = 0; i < n; ++i) {
    scanf("%lld", &(a[i]));
  }

  forward_vec[0] = a[0];
  for (int i = 1; i < n; ++i) {
    forward_vec[i] = gcd(forward_vec[i - 1], a[i]);
  }

  backward_vec[n - 1] = a[n - 1];
  for (int i = n - 2; i >= 0; --i) {
    backward_vec[i] = gcd(backward_vec[i + 1], a[i]);
  }

  ans = -1;

  for (int i = 0; i < n; ++i) {
    int left = i - 1;
    int right = i + 1;

    if (left < 0) {
      ans = max(ans, backward_vec[right]);
    }
    else if (right >= n) {
      ans = max(ans, forward_vec[left]);
    }
    else {
      ans = max(ans, gcd(forward_vec[left], backward_vec[right]));
    }
  }

  printf("%lld\n", ans);

  return 0;
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if(a == b && a != c) puts("Yes");
  else if(a == c && b != c) puts("Yes");
  else if(b == c && a != b) puts("Yes");
  else puts("No");
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
typedef long long ll;

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

  int ans = 0;
  int start = 0, end = S.length() - 1;

  while (start < end){
    if (S[start] == S[end]){
      start++; end--;
    }else if (S[start] == 'x'){
      ans++; start++;
    }else if(S[end] == 'x'){
      ans++; end--;
    }else{
      ans = -1; break;
    }
  }
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cstring>
#define N 15
using namespace std;
int main(){
	int n,a,b;
	cin>>n;
	if(n==1)
		cout<<"Hello World";
	if(n==2){
		cin>>a>>b;
		cout<<a+b;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define MOD 1000000007
#define fastio                    \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)

using namespace std;

int main()
{
    fastio;
    // ifstream f("f.txt");
    // ofstream g("out.txt");
    string n;
    cin>>n;
    LL sum=0;
    for(LL i=0;i<n.length();i++){
        sum+=(int)n[i] - 48;
    }
    if(sum%9==0){
        cout<<"Yes"<<"\n";
    }else
    {
        cout<<"No"<<"\n";
    }
    
    return 0;
}

Measured memory_bytes: 3744
var x = require('fs').readFileSync('/dev/stdin', 'utf8');

var input = x.split("\n");

var array = input[1].split(" ").map(Number);

max = Math.max.apply(null, array);
min = Math.min.apply(null, array);
sum = array.reduce(function(a, b){
        return a + b;
});

console.log(min + " " + max + " " +sum);



Measured memory_bytes: 18204
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<deque>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define ll long long
//#define __int64 long long

int n;
int a[233333];
int t[233333];
int bai[233333];


int main(void){
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    
    int kakutei=n/2+1;
    int cnt=0;
    
    for(int i=n;i>=1;i--){
       // cout<<i<<" "<<bai[i]<<endl;
        if(a[i]!=bai[i]%2){
            t[i]=1;
            cnt++;
            for(int j=1;j*j<=i;j++){
                if(i%j==0){
                    bai[j]++;
                    if(j!=i/j)bai[i/j]++;
                }
            }
            //end yakusu
        }
    }
    
    cout<<cnt<<endl;
    for(int i=1;i<=n;i++){
        if(t[i]==1)cout<<i<<endl;
    }
    
}


Measured memory_bytes: 3200
#include<stdio.h>

/* 値を入れ替える関数 */
void swap (int *x, int *y) {
  int temp;    // 値を一時保存する変数

  temp = *x;
  *x = *y;
  *y = temp;
}

/***
* pivotを決め、
* 全データをpivotを境目に振り分け、
* pivotの添え字を返す
***/
int partition (int H[], int left, int right) {
  int i, j, pivot;
  i = left;
  j = right + 1;
  pivot = left;   // 先頭要素をpivotとする

  do {
    do { i++; } while (H[i] < H[pivot]);
    do { j--; } while (H[pivot] < H[j]);
    // pivotより小さいものを左へ、大きいものを右へ
    if (i < j) { swap(&H[i], &H[j]); }
  } while (i < j);

  swap(&H[pivot], &H[j]);   //pivotを更新

  return j;
}

/* クイックソート */
void quick_sort (int H[], int left, int right) {
  int pivot;

  if (left < right) {
    pivot = partition(H, left, right);
    quick_sort(H, left, pivot-1);   // pivotを境に再帰的にクイックソート
    quick_sort(H, pivot+1, right);
  }
}


int main(void){
    long N,K,x,ans = 0;
    int n,i,j,k,tmp;
    scanf("%ld %ld",&N,&K);
    int H[N];
    for(n=0;n<N;n++){
        scanf("%d",&H[n]);
    }
    quick_sort(H, 0, N-1);

    if(N<=K){
        ans = 0;
    }else{
        x = N-K;
        for(k=0;k<x;k++){
            ans +=H[k];
        }
    }
    printf("%ld",ans);
    return 0;
}


Measured memory_bytes: 896
#pragma GCC optimize("O3", "unroll-loops")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

signed main() {
	int n; cin >> n;
	cout << (n - 1) / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector> 
#include <cstring>
#include <queue>
#include <stack>
#include <ctime>
#include <set>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;

const int maxN = 310; 
const int INF = 1000000000;

int a[maxN]; 
int c[maxN];
int f[maxN];
int n,G;
void init()
{
	for(int i=0;i<n;i++)
		f[i] = 0;
}
int main()
{

	scanf("%d %d",&n,&G);
	for(int i=0;i<n;i++)
	{
		scanf("%d %d",&a[i],&c[i]);
	}
	int minc = INF; 
	for(int i=0;i<((1<<n));i++)
	{
		int cnt = 0;
		int weg = 0;
		int g = G;
		init();
		for(int j = 0;j<n;j++)
		{
			int x = (i>>j)&1;
			if(x == 1)
			{
				weg += (c[j] + a[j] * (j*100 + 100));
				cnt += a[j];
				f[j] = 1; 
			}	
		}
		g = g-weg;
		if(g > 0)
		{			
			for(int j = n-1;j>=0;j--)
			{
				if(f[j]) continue;
				if(g > ((j+1)*100) * (a[j] - 1))
				{
					g -= ((j+1)*100) * (a[j] - 1);
					cnt += a[j] - 1;
				}
				else
				{
					int tmp = (g%((j+1)*100) == 0)? (g/((j+1)*100)) :  (g/((j+1)*100)) + 1;
					cnt += tmp;
					g -= (tmp * (j+1) * 100);
					break;
				}
			}
		}
		if(g > 0) continue;
		minc = min(minc,cnt);
	} 
	printf("%d\n",minc);
	return 0;
}

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

using namespace std;



int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);cout.tie(NULL);
   
   long long int n,cnt=1,min=0;
   cin>>n;
   long long int a[n],i;
   for(i=0;i<n;++i)
      cin>>a[i];
      
     min=a[0]; 
    for(i=1;i<n;++i)
     {
         if(min>a[i])
          {
              min=a[i];
              cnt++;
          }
           
    
     }
     cout<<cnt;
        
   
     return 0;
}


Measured memory_bytes: 5188
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		String a=sc.next();
		int flag=0;
		int ini=0;
		int fin=0;

		for(int i=0;i<a.length();i++){
			if(a.charAt(i)=='A' && flag==0){
				flag=1;
				ini=i;
			}else if(a.charAt(i)=='Z' && flag==1){
				fin=i;
			}
		}

		System.out.println(fin-ini+1);
	}
}

Measured memory_bytes: 26044
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 
int main() {
	ll n,d;
	cin>>n>>d;
	cout << (n+(2*d+1)-1)/(2*d+1);
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<cmath>

using namespace std;

int main()
{
    long long k,maxn=0,s,i,a,b,n;
    scanf("%lld %lld %lld",&a,&b,&n);
    i=b-1;
    if(i>n)
    {
        i=n;
    }
    s=(a*i)/b-a*(i/b);
    printf("%lld\n",s);
    //system("pause");
    return 0;
}

Measured memory_bytes: 3828
/**
   _           _
  / /         \ \
 / /  _   _  _ \ \
< < (_) (_) (_) > >
 \ \           / /
  \_\         /_/

Nerede Gitsen Çukur Orda
**/

#include<bits/stdc++.h>
#include<fstream>
///#include "windows.h"
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define fr first
#define sc second
#define Zohiri_dzd cout.tie(NULL);
#define Belafz cin.tie(NULL);
#define CODER ios_base::sync_with_stdio(0)  ;
#define p_b pop_back
#define p_f pop_front
#define quluq return 0;
using namespace std ;

    const ll N = 1e4 + 0.000001 ;

int main ()
{
    Zohiri_dzd
    Belafz
    CODER
    ///freopen("input.txt" , "r" , stdin );
    ///freopen("output.txt", "w" , stdout );
    ///Author of the greatest code :: Murtazoev Alijon
    ///4294967295
    char a ;
    cin >> a ;
    if (a >= 'A' and a <= 'Z')
        cout << 'A' ;
    else
        cout << "a" ;
}
///Mavl studios
///Eco students


Measured memory_bytes: 3644
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define ll long long
#define P std::pair<int, int>
vector<ll> a;
int ans;
int N;
ll x;
int main(){
	cin >> N >> x;
	for(int i = 0; i < N; i++){
		int tmp;
		cin >> tmp;
		a.push_back(tmp);
	}
	sort(a.begin(), a.end());
	for(auto u:a){
		if(x - u >= 0){
			ans++;
			x -= u;
		}
	}
	if(ans == N && x > 0) ans--;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
typedef long long int ll;
typedef long double ld;
#define PI 3.141592653589793
#define MOD 1000000007
#define ALL(obj) (obj).begin(),(obj).end()
template<class T>inline bool chmax(T& a,T b){if (a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if (a>b){a=b;return 1;}return 0;}
const ll INF = 1LL << 56;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
//四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct edge{//グラフに使うヤツ
    ll from,to,cost;
};

typedef vector<vector<edge> > G;
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

int main(){
    ll n;
    cin >> n;
    n--;
    vector<char> s;
    s.push_back('a'+(n%26));
    n/=26;
    while(n){
        n--;
        s.push_back('a'+(n%26));
        n/=26;
    }
    for (ll i=0;i<s.size();i++){
        cout << s[s.size()-1-i];
    }
    cout << endl;
    return 0;
}


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

const int RLEN=1<<18|1;
inline char nc() {
	static char ibuf[RLEN],*ib,*ob;
	(ib==ob) && (ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
	return (ib==ob) ? -1  : *ib++;
}
inline int rd() {
	char ch=nc(); int i=0,f=1;
	while(!isdigit(ch)) {if(ch=='-')f=-1; ch=nc();}
	while(isdigit(ch)) {i=(i<<1)+(i<<3)+ch-'0'; ch=nc();}
	return i*f;
}

const int N=2e5+50;
int n,m,a[N],b[N],c[N];
inline bool add(int p) {return (p>=1) ? (!b[p]++) : 0;}
inline bool dec(int p) {return (p>=1) ? (!--b[p]) : 0;}
int main() {
	n=rd(),m=rd(); int step=n;
	for(int i=1;i<=n;i++) a[i]=rd(), c[a[i]]++;
	for(int i=1;i<=n;i++) 
		for(int j=i-c[i]+1;j<=i;j++)
			if(add(j)) --step;
	for(int i=1;i<=m;i++) {
		int p=rd(), v=rd();
		if(dec(a[p]-c[a[p]]+1)) ++step;
		--c[a[p]]; a[p]=v; ++c[v];
		if(add(v-c[v]+1)) --step;
		printf("%d\n",step);
	}
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long int;
#define INF             1e14
#define dd              double
#define MOD             1000000007
#define my_sizeof(type) ((char *)(&type+1)-(char*)(&type)) 
#define nl              cout<<endl
#define fill(a,val)     memset(a,val,sizeof(a))
#define mp              make_pair
#define endl            "\n"
#define pb              push_back
#define ff              first    
#define ss              second
#define SIZE            200005
#define all(v)          v.begin(),v.end()
#define s(ar,n)         sort(ar,ar+n)
#define rs(ar,n)        sort(ar, ar+n, greater<ll>()) 
#define oa(a,n)         for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n)         for(ll i=0;i<n;i++)cin>>a[i];
#define maxa(ar,N)      *max_element(ar,ar+N)
#define mina(ar,N)      *min_element(ar,ar+N)
#define fastio()        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define printclock      cerr<<"Time : "<<1000*(long double)clock()/(long double)CLOCKS_PER_SEC<<"ms\n";
typedef tree<pair<ll,ll>, null_type, less<pair<ll,ll>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ll power(ll x, ll y){
    ll res=1;x=x;
    while(y>0){
        if(y&1)
            res = (res*x);
        y = y>>1;
        x = (x*x);
    }
    return res;
}  
ll logtwo(ll n){
    if(n==1)
        return 0;
    return logtwo(n/2)+1;
}
signed main()
{
	fastio();   
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
	int t=1;
	//cin>>t;
	while(t--)
	{
		ll N;
		cin>>N;
		ll ar[N];
		cn(ar,N);
		ll pro=1;
		for(ll i=0;i<N;i++)
		{
			if(ar[i]==0)
			{
				cout<<0<<endl;
				return 0;
			}
		}
		for(ll i=0;i<N;i++)
		{
			if(1000000000000000000/pro<ar[i])
			{
				cout<<-1<<endl;
				return 0;
			}
			pro*=ar[i];
		}
		cout<<pro<<endl;
	}
}

Measured memory_bytes: 4436
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;cin>>s;
  int ans=0,tmp=0;
  for(int i=0;i<3;i++){
    if(s.at(i)=='R')tmp++;
    else{ans=max(ans,tmp);tmp=0;}
    if(i==2)ans=max(ans,tmp);
  }
  cout<<ans<<endl;
}

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

int const N = 200000;
int n, m, sl;
char s[N + 1], t[N + 1];

bool solve(int x, int ln, char cl, char cr){
	int l = x, r = x;
	f(i, 0, sl){
		if (s[i] == cl)--l;
		else if (s[i] == cr)++r;
		if (r > ln || l == 0)return true;
		if (t[i] == cl)--r;
		else if (t[i] == cr)++l;
		l = min(l, ln);
		r = max(r, 1);
	}
	return false;
}

int main(){
	scanf("%d%d%d", &n, &m, &sl);
	int x, y;
	scanf("%d%d%s%s", &x, &y, s, t);
	printf("%s\n", solve(x, n, 'U', 'D') || solve(y, m, 'L', 'R') ? "NO" : "YES");
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define all(x) (x).begin(),(x).end()

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    ll N,K;
    cin >> N >> K;
    vector<ll> H(N);
    REP(i,N)cin >> H[i];
    sort(all(H),greater<ll>());
    REP(i,K){
        if(i == N)break;
        H[i] = 0;
    }
    ll answer = 0;
    REP(i,N)answer+=H[i];
    cout <<answer<< "\n";
}


Measured memory_bytes: 1792
S = list(input().strip())
ans = [0] * (len(S)+1)

for i in range(len(S)):
    if S[i] == "<":
        ans[i+1] = max(ans[i]+1, ans[i+1])

for i in range(len(S)-1, -1, -1):
    if S[i] == ">":
        ans[i] = max(ans[i], ans[i+1]+1)
print(sum(ans))

Measured memory_bytes: 92628
#include <iostream>
using namespace std;
int main()
{
    int N;
    long long a[3];
    a[0]=2;a[1]=1;
    cin>>N;
    for (int i=2;i<=N;i++)
    {
        a[i%3]=a[(i-1)%3]+a[(i-2)%3];
    }
    cout<<a[N%3]<<endl;
    system ("pause");
    return 0;
}


Measured memory_bytes: 504
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main()
{
  int n;
  cin>>n;
  vector<string> v;
  for(int i=0;i<n;i++)
  {
    string s;
    cin>>s;
    v.push_back(s);
  }
  int ac=0,wa=0,tle=0,re=0;
  for(int i=0;i<n;i++)
  {
    if(v[i]=="AC") {ac++;}
    if(v[i]=="WA") {wa++;}
    if(v[i]=="TLE"){tle++;}
    if(v[i]=="RE" ){re++;}
  }
  cout<<"AC "<<"x "<<ac<<endl;
  cout<<"WA "<<"x "<<wa<<endl;
  cout<<"TLE "<<"x "<<tle<<endl;
  cout<<"RE "<<"x "<<re<<endl;
}


Measured memory_bytes: 7460
#include <bits/stdc++.h>
using namespace std;
#define ll                  long long int
#define ull                 unsigned long long int
#define ld                  long double
#define fi                  first
#define se                  second
#define pb                  push_back
#define pbb                 pop_back
#define mp                  make_pair
#define pii     	        pair<int,int>
#define all(x)              x.begin(), x.end()
#define uniq(x)             x.erase(unique(x.begin(),x.end()),x.end())
#define mem(array, value)   memset(array, value, sizeof(array))
#define PI      	        2*acos(0.0)
#define EPS     	        1e-8
#define line                cout << "\n==========\n"
#define fastRead 	        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define trace(...)          __f( #__VA_ARGS__ , __VA_ARGS__ )
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << "\n";
}
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...);
}

const int INF = 1e9+9;

int ara[200];

int main ()
{
    #ifdef Lollipop
        //freopen ("input.txt", "r", stdin);
        //freopen ("output.txt", "w", stdout);
    #endif

    int n;
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> ara[i];
    }
    int ans = 0;
    for (int i = 1; i < n-1; i++){
        if (ara[i-1] > ara[i] && ara[i] > ara[i+1] || ara[i-1] < ara[i] && ara[i] < ara[i+1]){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
int main() {
    int a, b;
    cin >> a >> b;
    if(a < b) {
        for(int i = 0; i < b; i++) {
            cout << a;
        }
        cout << endl;
    } else {
        for(int i = 0; i < a; i++) {
            cout << b;
        }
        cout << endl;
    }
}

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

struct Dice {
  std::array<int, 7> num;

  void rotate(char n) {
    int tmp;
    switch (n) {
    case 'E':
      tmp = num[1];
      num[1] = num[4];
      num[4] = num[6];
      num[6] = num[3];
      num[3] = tmp;
      break;
    case 'N':
      tmp = num[1];
      num[1] = num[2];
      num[2] = num[6];
      num[6] = num[5];
      num[5] = tmp;
      break;
    case 'S':
      tmp = num[1];
      num[1] = num[5];
      num[5] = num[6];
      num[6] = num[2];
      num[2] = tmp;
      break;
    case 'W':
      tmp = num[1];
      num[1] = num[3];
      num[3] = num[6];
      num[6] = num[4];
      num[4] = tmp;
      break;
    default:
      throw;
    }
  }

  void print() {
    std::cout << "\t" << num[1] << std::endl;
    std::cout << num[4] << " " << num[2] << " " << num[3] << " " << num[5]
              << std::endl;
    std::cout << "\t" << num[6] << std::endl;
  }
};

int find3(Dice d, int u, int f) {
  for (int k = 0; k < 2; k++) {
    d.rotate('E');
    for (int i = 0; i < 4; i++) {
      d.rotate('N');
      for (int j = 0; j < 4; j++) {
        if (d.num[1] == u && d.num[2] == f) {
          return d.num[3];
        }
        d.rotate('E');
      }
    }
  }
  return -1;
}

int main() {
  std::array<int, 7> num;
  for (int i = 1; i <= 6; i++) {
    std::cin >> num[i];
  }

  Dice d = {num};
  // d.print();

  int n, u, f;
  std::cin >> n;
  while (std::cin >> u >> f) {
    std::cout << find3(d, u, f) << std::endl;
  }
}



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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz");
char s[101][101];
bool fl=true;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

      
      cin>>h>>w;
      rep(i,h)rep(j,w)cin>>s[i][j];
      rep(j,w+2)cout<<"#";
      cout<<"\n";
      rep(i,h){
        rep(j,w){
          if(j==0)cout<<"#";
          cout<<s[i][j];
          if(j==w-1)cout<<"#";
        }
        cout<<"\n";
      }
       rep(j,w+2)cout<<"#";
      cout<<"\n";
     

       
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    if (abs(a - b) % 2 == 1) {
        cout << "Borys" << endl;
    } else {
        cout << "Alice" << endl;
    }
}






Measured memory_bytes: 3620
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
	int N;
  	cin >> N;
	for(int a = 0; a * 4 <= N; ++a){
    	for(int b = 0; a * 4 + b * 7 <= N; ++b){
        	if(a * 4 + b * 7 == N){
              	cout << "Yes" << endl;
              	return 0;
            }
        }
    }
  	cout << "No" << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,a[2][100],i,j,sum,max=0;
    scanf("%d",&n);
    for(i=0;i<2;i++)
        for(j=0;j<n;j++)
        scanf("%d",&a[i][j]);
    for(i=0;i<n;i++)
    {
        sum=0;
        for(j=0;j<=i;j++)
            sum+=a[0][j];
        for(j=i;j<n;j++)
            sum+=a[1][j];
        if(max<sum)
            max=sum;
    }
    printf("%d\n",max);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 50+5;
const int dx[] = {-1,1,0,0,-1,-1,1,1};
const int dy[] = {0,0,-1,1,-1,1,-1,1};
using namespace std;

int a[N];
map<int,int> mp;
int main(){
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        int x;
        scanf("%d",&x);
        mp[x]++;
    }
    map<int,int>::iterator it;
    int res=0;
    for(it=mp.begin();it!=mp.end();it++){
        int num=it->first;
        int times=it->second;
        if(num>times)
            res+=times;
        else
            res+=(times-num);
    }
    printf("%d\n",res);
    return 0;
}


Measured memory_bytes: 4736
from math import ceil
h,w=map(int,input().split())
if h==1 or w==1:
  print(1)
else:
  if h%2:
    if w%2:
      print(ceil(h/2)*ceil(w/2)+(h//2)*(w//2))
    else:
      print(h*(w//2))
  else:
    print((h//2)*w)


Measured memory_bytes: 2940
import java.util.*;
class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long k = sc.nextLong();
    int next[]=new int[n];
    boolean flg[]=new boolean[n];
    for(int i=0;i<n;i++){
      next[i]=sc.nextInt()-1;
    }
    int now = 0;
    while(!flg[now]&&k>0){
      flg[now]=true;
      now = next[now];
      k--;
    }
    if(k!=0){
      ArrayList<Integer> list = new ArrayList<Integer>();
      int moto = now;
      list.add(now); now = next[now];
      while(now!=moto){
        list.add(now);
        now = next[now];
      }
      k = k%list.size();
      now = moto;
      for(long i=0;i<k;i++){
        now = next[now];
      }
    }
    now++;
    pl(now+"");

  }
  public static void pr(String str){
    System.out.print(str);
  }
  public static void pl(String str){
    System.out.println(str);
  }
}


Measured memory_bytes: 61468
# from math import factorial,sqrt,ceil #,gcd
# from itertools import permutations,combinations,combinations_with_replacement
# from collections import deque,Counter
# from bisect import bisect_left
# from heapq import heappush,heappop
# from numba import njit
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from fractions import gcd

# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np    # numpy.lcm()
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb,perm #permはnPk
# import networkx as nx
# G = Graph()

N,M,K = map(int,input().split())

for X in range(0,N+1):
    for L in range(0,M+1):
        if X*(M-L)+L*(N-X) == K:
            print("Yes")
            exit()

print("No")
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


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

int main() {
  int n, k; string s;
  cin >> n >> k >> s;
  for (int i = 0; i < n; i++) {
    if (i + 1 == k) cout << char(s.at(i) + ('a' - 'A'));
    else cout << s.at(i);
  }
}

Measured memory_bytes: 256