akhauriyash/Code-Regression huggingface dataset:
/// wa ^3^

#pragma GCC optimize("O3")

#include<bits/stdc++.h>
                           
#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
 
using namespace std;
 
using ll = long long;
using pii = pair<int, int>;                                   

const int MOD = 1e9 + 7;
const int INF32 = 1e9 + 1e2;

template<typename T> istream 
&operator>>(istream &a, vector<T> &v) { 
for (auto& x : v) a >> x; return a; }

void stndrtn() {
#ifdef accepted
    freopen(".in", "r", stdin);
#endif        
}

const bool flag = 0;

void maincode() {
    ll n, a, b;
    cin >> n >> a >> b;
    ll len = b-a+1;
    if (len & 1) {
        cout << len/2;
    } else {
        cout << min((b-a)/2+a, n-b+len/2);
    }                                                                           
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr), stndrtn();
    int ts = 1;
    if (flag) 
        cin >> ts;
    while (ts--)
        maincode(); 
    return 0;
}



Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	public static void dame_mons(ArrayList<Integer> mons,int a_index,int b_index) {
		if(mons.size() < 2) {
			return;
		}
		int a = mons.get(a_index);
		int b = mons.get(b_index);
		mons.set(b_index, b % a);
		if(b % a == 0) {
			mons.remove(b_index);
			dame_mons(mons,0,1);
		}else {
			dame_mons(mons,b_index,a_index);
		}
		
	}
	public static int game_mons(ArrayList<Integer> mons) {
		mons.sort((a,b) -> Integer.compare(a, b));
		dame_mons(mons,0,1);
		
		return mons.get(0); 
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc  = new Scanner(System.in);
		int N = sc.nextInt();
		int result;
		ArrayList<Integer> mons = new ArrayList<Integer>();
		for(int i = 0; i < N; i++) {
			mons.add(sc.nextInt());
		}
		
		result = game_mons(mons);
		System.out.println(result);
		
		sc.close();
	}

}


Measured memory_bytes: 68412
#include<bits/stdc++.h>
using namespace std;
int a,b,N,A[10],B[10],cnt=0,temp[10],check[10]={0};
void permut(int depth)
{
  if(depth==N)
  {
  	cnt++;
    for(int i=0;i<N;i++)
    {
      if(A[i]!=temp[i])
      {
        break;
      }
      if(i==N-1)
      {
        a=cnt;
      }
    }
    for(int i=0;i<N;i++)
    {
      if(B[i]!=temp[i])
      {
        break;
      }
      if(i==N-1)
      {
        b=cnt;
      }
    }
  }
  else
  {
    for(int i=1;i<=N;i++)
    {
      if(check[i]==0)
      {
        check[i]=1;
        temp[depth]=i;
        permut(depth+1);
        check[i]=0;
      }
    }
  }
}
int main()
{
  cin>>N;
  for(int i=0;i<N;i++)cin>>A[i];
  for(int i=0;i<N;i++)cin>>B[i];
 
  permut(0);
  cout<<abs(a-b)<<endl;
}

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

int main(){
    int a, b;
    cin >> a >> b;
    int k = 0;
    int l = 0;
    for(int i = 0; i < b; i++){
        k += a * pow(10,i);
    }
    for(int i = 0; i < a; i++){
        l += b * pow(10,i);
    }
    if(a <= b){
        cout << k << endl;
    }else{
        cout << l << endl;
    }
}

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

int N;
vector<int> ans;

using Edge = pair<int, int>;
using Graph = vector<vector<Edge> >;
Graph G;

void dfs(int v, int p, int c ) {
  ans[v] = c;
  for (auto e: G[v]) {
    if ( e.first == p ) continue;
    if ( e.second & 1 ) dfs(e.first, v, 1-c);
    else dfs(e.first, v, c);
  }
}

int main() {
  cin >> N;
  G.assign(N, vector<Edge>());
  for ( int i = 0; i < N-1; i++ ) {
    int u,v,w; cin >> u >> v >> w;
    u--; v--;
    G[u].push_back(Edge(v,w));
    G[v].push_back(Edge(u,w));    
  }

  ans.assign(N, 0);
  dfs(0, -1, 0);
  for (auto a: ans) cout << a << endl;
  return 0;
}


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

int main(){
    int N,K,x,i;
    int result=0;

    cin >> N >> K;

    for(i=1;i<=N;i++){
        cin >> x;
        if((K-x)<x){
            result+=2*(K-x);
        }
        else{
            result+=2*x;
        }
    }
    cout << result << endl;
}

Measured memory_bytes: 256
#include<stdio.h>                                                                                                                                       

#define PASSED 'P'

int main(void) {
    int height, width, x, y;
    while(1) {
        scanf("%d %d", &height, &width);

        // The end of the input.
        if(height == 0 && width == 0) break;

        char tiles[height][width];
        char buf[width];
        for(y = 0; y < height; y++) {
            scanf("%s", buf);
            for(x = 0; x < width; x++) tiles[y][x] = buf[x];
        }

        char curr_tile = ' ';
        x = 0;
        y = 0;
        while(curr_tile != '.' && curr_tile != PASSED) {
            curr_tile = tiles[y][x];
            if(curr_tile == '>')         tiles[y][x++] = PASSED;
            else if(curr_tile == '<')    tiles[y][x--] = PASSED;
            else if(curr_tile == '^')    tiles[y--][x] = PASSED;
            else if(curr_tile == 'v')    tiles[y++][x] = PASSED;
            else if(curr_tile == '.')    printf("%d %d\n", x, y);
            else if(curr_tile == PASSED) printf("LOOP\n");
        }
    }

    return 0;
}

Measured memory_bytes: 624
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int i,j,k;
  int x=0,kazu=0;
  vector<int> L(N+1);
  for(i=1;i<=N;i++) cin >> L[i];
  vector<int> LI(N+1);
  vector<int> LN(N+1);
  sort(L.begin(),L.end());
  for(i=1;i<=N;i++){
    if(i==1){
      kazu=1;
      LI[1]=L[1]; LN[1]=1;
    }else{
      if(LI[kazu]==L[i]){
        LN[kazu]++;
      }else{
        kazu++;
        LI[kazu]=L[i]; LN[kazu]=1;
      }
    }
  }
  for(i=1;i<=kazu-2;i++){
    for(j=i+1;j<=kazu-1;j++){
      for(k=j+1;k<=kazu;k++){
        if(LI[k]<LI[i]+LI[j]){
          x=x+LN[i]*LN[j]*LN[k];
        }
      }
    }
  }
  cout << x << endl;
  return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
using ll = long long;
using ld = long double;
using vvll = vector<ll, vector<ll> >;
using vll = vector<ll> ;
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define fastio(); ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);


int main() {
    fastio();

    int N;
    cin >> N;
    int arr[N];
    for(int i = 0;i < N;i ++) {
        cin >> arr[i];
    }
    int DP[N];
    DP[0] = 0;
    if(N > 1)
        DP[1] = abs(arr[1] - arr[0]);
    for(int i = 2;i < N;i ++) {
        DP[i] = min(DP[i-1] + abs(arr[i] - arr[i-1]), DP[i-2] + abs(arr[i-2] - arr[i]));
    }
    int ans = DP[N-1];
    cout << ans << "\n";
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mod 1000000007
int main(){
   ll n,k;
   cin>>n>>k;
   if(n==k)cout<<"0"<<endl;
   else if(n>k){
    cout<<min(n%k,abs(n%k - k))<<endl;
   }else{
    if(n<=k/2)cout<<n<<endl;
    else cout<<abs(n-k)<<endl;
   }
}


Measured memory_bytes: 256
n,t = map(int, input().split())
a = list(map(int,input().split()))
a.append(float("inf"))
ans = 0
for i in range(n):
  if a[i+1] - a[i] >= t:
    ans += t
  else:
    ans += a[i+1] - a[i]
print(ans)

Measured memory_bytes: 25200
import java.util.Scanner;

public class Main {
    static final Scanner sc = new Scanner(System.in);
    static final int MOD = (int) 1E9 + 7;
    
    public static void main(String[] args) {
        int A = nint();
        int B = nint();
        
        int tap = 1;
        int ans = 0;
        while (true) {
            if (tap >= B) {
                break;
            }
            ans++;
            tap--;
            tap+=A;
        }
        System.out.println(ans);
    }
    

    private static long nlong() {
        return sc.nextLong();
    }

    private static int nint() {
        return sc.nextInt();
    }

    private static String nstr() {
        return sc.next();
    }

    private static char[] nsToChars() {
        return sc.next().toCharArray();
    }

    private static long[] nlongs(int n) {
        return nlongs(n, 0, 0);
    }

    private static int[] nints(int n) {
        return nints(n, 0, 0);
    }

    private static int[] nints(int n, int padL, int padR) {
        int[] a = new int[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nint();
        return a;
    }

    private static long[] nlongs(int n, int padL, int padR) {
        long[] a = new long[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nlong();
        return a;
    }

    private static String[] nstrs(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = nstr();
        return a;
    }

    private static char[][] nsToChars2D(int h, int w) {
        return nsToChars2D(h, w, 0);
    }

    private static char[][] nsToChars2D(int h, int w, int pad) {
        char[][] a2 = new char[h + pad * 2][w + pad * 2];
        for (int i = 0; i < h; i++)
            System.arraycopy(nsToChars(), 0, a2[pad + i], pad, w);
        return a2;
    }
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
// const lint MOD = 998244353;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}

int gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

int main() {
	int n; cin >>n;
	vector<ll> v;
	rep(i,n){
		ll a; cin >> a;
		v.push_back(a);
	}
	v.push_back(0);
	sort(rall(v));
	vector<ll> ans;
	int index = 0;
	for(int i = 1; i <= n; i++){
		if (ans.size()==2) break;
		if (v[i]!=v[i-1]){
			if (i-index>=2){
				ans.push_back(v[i-1]);
			}
			index = i;
		}else {
			if (i-index==2){
				ans.push_back(v[i-1]);
				index = i;
			}
		}
	}
	if (ans.size() < 2){
		cout << 0 << endl;
	}else{
		cout << ans[0]*ans[1] << endl;
	}
}

Measured memory_bytes: 1400
N, S = map(int, input().split())
A = list(map(int, input().split()))
mod = 998244353
ans = 0
dp = [0]*S

for i, a in enumerate(A):
    dp[0] +=1
    if a > S:
        continue

    ans = (ans + dp[S-a]*(N-i)% mod) % mod

    for j, x in enumerate(dp[:S-a]):
        dp[j+a] += x
print(ans)


Measured memory_bytes: 3808
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    int h[100010];
    rep(i, N) cin >> h[i];
    int dp[100010];
    rep(i, 100010) dp[i] = INF;
    rep(i, K) dp[i + 1] = abs(h[i + 1] - h[0]);
    
    rep(i, N - K) {
        REP(d, 1, K) {
            int step = abs(h[i + K] - h[i + K - d]);
            dp[i + K] = min(dp[i + K], dp[i + K - d] + step);
            //cout << i + K << " " << i + K - d << " " << dp[i + K] << endl;
        }
    } 
    cout << dp[N - 1] << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <climits>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string.h>
#include <iomanip>
#include <ctype.h>

#define ll          long long int
#define ull         unsigned long long int
#define pb          push_back
#define pii         pair<int,int>
#define F         first
#define S          second
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define M_PI        3.14159265358979323846
#define mp          make_pair
#define sz(x)       (int)x.size()
#define hell        1000000007
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define eps 1e9
#define all(a)      (a).begin(),(a).end()
const long long INF = (long long) 1e9+1;


using namespace std;
void solve();

void fastIO() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}

int main(){
   fastIO();
    solve();
}
//void sieve();
ll pw(ll k,ll x);
ll gcd(ll x,ll y);


void solve(){

  int n;
  cin>>n;
  string s;
  cin>>s;
  char pre=s[0];
  int cnt=1;
  for(int i=1;i<n;i++){
    if(s[i]==pre)
    continue;
    else{
        pre=s[i];
        cnt++;
    }
  }
  cout<<cnt;
}


///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1

ll gcd(ll x,ll y){
  if(x==0)
  return y;
  else
  return gcd(y%x,x);
}


ll pw(ll k,ll x){
  if(x==0)
  return 1;
  if(x&1)
  return ((pw(k,x-1)%hell)*k%hell)%hell;
  else
  return ((pw(k,x/2)%hell)*(pw(k,x/2)%hell))%hell;
}

/*void sieve(){

  for(int i=2;i<=1000000;i++){
    if(prime[i]==true){
      for(int j=i*i;j<=1000000;j+=i)
      prime[j]=false;
    }
  }

}*/


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

using namespace std;

int main(void){
  int m[10];
  for(int i=0; i<10; i++){
    cin >> m[i];
  }
  sort(m, m+10);
  for(int i=0; i<3; i++)
    cout << m[9-i] << endl;
  return 0;
}

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

int main()
{
    int input;
    int a[4];
    cin>>input;
    
      a[0]= input/1000;
      a[1]=(input-a[0]*1000)/100;
      a[2]=(input-a[0]*1000-a[1]*100)/10;
      a[3]=input-a[0]*1000-a[1]*100-a[2]*10;
   
   

  
   for( int symbol=0; symbol<8 ; symbol++)
   {
       int sum = a[0];
       string s;
       s += to_string(a[0]);
       
        for(int i=0;i<3;i++)
        {
            if(symbol & (1<<i))
            {
            sum += a[i+1];
            s += "+";
            s += to_string(a[i+1]);
            }
            else
            {
            sum -= a[i+1];
            s += "-";
            s += to_string(a[i+1]);
            }
        }
     
      if(sum==7)
        {   
            s += "=7";
            cout<<s<<endl;
            break;
        }
     
     }
   
      
        return 0;
   }
    


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;

struct S {
    int x, y, c;
    S() {}
    S(int a, int b, int d) : x(a), y(b), c(d) {}
};

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

int W, H;

int wx[30][30], wy[30][30];

int solve() {
    queue<S> que;
    que.emplace(0, 0, 0);
    int ret = 0;

    int visited[30][30];
    for (int j = 0; j < H; j++) for (int k = 0; k < W; k++) visited[j][k] = 0;

    visited[0][0] = 1;
    while (!que.empty()) {
        S st = que.front(); que.pop();

        if (st.x == H-1 && st.y == W-1) {
            ret = st.c+1;
            break;
        }
        
        for (int d = 0; d < 4; d++) {
            int nx = st.x + dx[d], ny = st.y + dy[d];
            if (nx < 0 || nx >= H || ny < 0 || ny >= W || visited[nx][ny]) {
                continue;
            }
            if (d % 2 == 0) { // x
                int ix = (d == 0) ? st.x : nx;
                int iy = st.y;
                if (wx[ix][iy] == 0) {
                    visited[nx][ny] = 1;
                    que.emplace(nx, ny, st.c+1);
                }
            } else { // y
                int ix = st.x;
                int iy = (d == 1) ? st.y : ny;
                if (wy[ix][iy] == 0) {
                    visited[nx][ny] = 1;
                    que.emplace(nx, ny, st.c+1);
                }
            }
        }
    }

    return ret;
}

int main(){
    while(cin>>W>>H){
        if (W == 0 && H == 0) break;
        for (int j = 0; j < H; j++) {
            for (int k = 0; k < W-1; k++) {
                cin >> wy[j][k];
            }
            if (j < H-1) {
                for (int k = 0; k < W; k++) {
                    cin >> wx[j][k];
                }
            }
        }

        cout << solve() << endl;
    }
}

Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pop pop_back
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
//template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
signed main(){
  int a,b,f=0,h,m=0;
  cin>>a>>b;
  string c;
  cin>>c;
  vector<int> d;
  char e;
  for(int i=0;i<a;i=i){
    e=c[i];
    f=0;
    while(e==c[i]){
      f++;
      i++;
    }
    d.pb(f);
  }
  h=d.size();
  cout<<a-max<int>(1,h-2*b)<<endl;
}

Measured memory_bytes: 1528
#include <stdint.h>
#include <algorithm>
#include <bitset>
#include <functional>
#include <iostream>
#include <string>
#include <vector>

int main(int argc, char *argv[]) {
  int a, b, c;
  std::cin >> a >> b >> c;
  std::cout << (a ^ b ^ c) << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+9;
int n,k,c;int tot,tot1,ans,a[N],b[N],g[N]; int rest;
char s[N];
int main(){
	cin>>n>>k>>c>>s+1;
	rest=0;
	for(int i=1;i<=n;i++){
		if(s[i]=='o'&&rest<=0) a[++tot]=i,rest=c;
		else rest--;
	}
	rest=0;
	for(int i=n;i>=1;i--){
		if(s[i]=='o'&&rest<=0) b[++tot1]=i,rest=c;
		else rest--;
	}
	for(int i=1;i<=tot1/2;i++) swap(b[i],b[tot1-i+1]);
	//for(int i=1;i<=tot;i++) cout<<a[i]<<" ";
	for(int i=1;i<=min(tot,tot1);i++)
		if(a[i]==b[i]) g[++ans]=a[i];
	if(ans<=k) for(int i=1;i<=ans;i++) printf("%lld\n",g[i]);
	return 0;
}

Measured memory_bytes: 4096
#include <cstdio>
#include <vector>
#include <algorithm>
#include <sstream>
#define REP(i,n) for(int i = 0; i < (int)(n); i++)

using namespace std;

int main(){
  for(;;){
    int n, m;
    scanf("%d %d", &n, &m);
    if(!(n|m)) { break; }

    int count[100];
    REP(i, m) {count[i] = 0;}
    REP(i, n){
      for(int j = 0; j < m; j++){
	int tmp;
	scanf("%d", &tmp);
	count[j]+=tmp;
      }
    }
    vector<pair<int, int> > ranking;
    REP(i,m) ranking.push_back(make_pair(count[i],-(i+1)));
    sort(ranking.begin(), ranking.end());
    reverse(ranking.begin(), ranking.end());
    stringstream s;
    for(auto iter = ranking.begin(); iter < ranking.end(); iter++){
      printf("%d", -(*iter).second);
      printf(iter + 1 == ranking.end() ? "\n" : " ");
    }
  }
}

Measured memory_bytes: 1156
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;

//typedef modint998244353 mint;

const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;

const ll MAX = 1e9 + 5;

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> p(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	set<int> s;
	

	for (int i = 0; i < k; i++) {
		s.insert(p[i]);
	}

	int ans = 1;


	for (int i = 0; i + k < n; i++) {
		s.insert(p[i + k]);
		if (p[i] != *s.begin() || p[i + k] != *s.rbegin()) {
			ans++;
		}

		s.erase(p[i]);



	}
	//cout << ans << endl;
	int cnt = 0;
	bool canOriginal = false;
	p.emplace_back(-1);
	for (int i = 1; i <= n; i++) {
		if (p[i] > p[i - 1]) {
			cnt++;
		}
		else {
			//cout <<i<< " "<< cnt << endl;
			if (cnt >= k - 1) {
				if (canOriginal) {
					ans--;
				}
				canOriginal = true;
			}
			
			cnt = 0;
		}


	}

	cout << ans << endl;
}

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

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  if (n <= 2) {
    puts("No");
    return 0;
  }
  int dua = 1;
  while ((dua << 1) <= n+1) dua <<= 1;
  if (n == dua) {
    puts("No");
    return 0;
  }
  puts("Yes");
  for (int i = 1; i + 1 < dua; ++i) {
    printf("%d %d\n", i, i+1);
    printf("%d %d\n", n + i, n + i + 1);
  }
  printf("%d %d\n", dua-1, n+1);
  if (dua > n) {
    return 0;
  }
  int cnt = n - dua + 1;
  int k = n;
  if (cnt & 1)
    --k;
  for (int i = dua; i + 1 <= k; ++i) {
    printf("%d %d\n", i, i+1);
    printf("%d %d\n", n + i, n + i + 1);
  }
  int val = 0;
  for (int i = dua; i <= k; ++i)
    val ^= i;
  int last = val;
  if (val == 0) {
    printf("%d %d\n", k, 1);
    printf("%d %d\n", dua-1, n + dua);
    last = dua-1;
  }
  else {
    printf("%d %d\n", k, n + val);
    printf("%d %d\n", n + val, n + dua);
    last = n + val;
  }
  if (k < n) {
    printf("%d %d\n", n+dua, n);
    int cur = n^dua;
    int v = last;
    while (v <= 2*n) {
      int cost = v;
      if (cost > n)
        cost -= n;
      cur ^= cost;
      if (cur == 0)
        break;
      ++v;
      if (v == dua)
        v = n+1;
    }
    if (v > 2 * n) {
      cur = n^dua;
      v = last;
      while (v > 0) {
        int cost = v;
        if (cost > n)
          cost -= n;
        cur ^= cost;
        if (cur == 0)
          break;
        --v;
        if (v == n)
          v = dua-1;
      }
    }
    assert(cur == 0);
    printf("%d %d\n", v, 2 * n);
  }
  return 0;
}


Measured memory_bytes: 2816
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <chrono>
#include <vector>

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> p(N + 1);
    for (int i = 1; i <= N; i++)
    {
        cin >> p[i];
    }
    int pre_max = 0;
    int start = 0, end = 0;
    for (int i = 1; i <= N; i++)
    {
        if (i % 2 != p[i] % 2)
        {
            cout << "No" << endl;
            return 0;
        }
        pre_max = max(p[i], pre_max);
        if (pre_max == i)
        {
            end = i;
            if (end - start == 1)
            {
                continue;
            }
            else
            {
                for (int j = end - 1; j > start; j -= 2)
                {
                    if (p[j] != j)
                    {
                        cout << "No" << endl;
                        return 0;
                    }
                }

                int go_right_max = 0;
                int go_left_max = 0;
                int direction_flag = 0;
                for (int j = start + 1; j <= end; j += 2)
                {
                    if (j < p[j])
                    {
                        if (go_right_max > p[j] && direction_flag == 1)
                        {
                            cout << "No" << endl;
                            return 0;
                        }
                        go_left_max = 0;
                        go_right_max = p[j];
                        direction_flag = 1;
                    }
                    else if (j > p[j])
                    {
                        if ((go_left_max > p[j] && direction_flag == 2) || direction_flag == 0)
                        {
                            cout << "No" << endl;
                            return 0;
                        }
                        if (direction_flag == 1)
                        {
                            go_right_max = 0;
                            direction_flag = 2;
                        }
                        go_left_max = p[j];
                    }
                    else
                    {
                        if (direction_flag == 1)
                        {
                            cout << "No" << endl;
                            return 0;
                        }
                        direction_flag = 0;
                        go_left_max = 0;
                    }
                }
            }
            start = end;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

int main() {
    int k, s;
    cin >> k >> s;
    int ans = 0;
    
    rep(i, k + 1) {
        rep(ii, k + 1) {
            int v = (s - (i + ii));
            
            if ((v <= k) && (v >= 0)) {
                ans++;
            }
        }
    }
    
    cout << ans << endl;
    return 0;
}

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

#define mi           map<int,int>
#define pii          pair<int,int>
#define mpi          map<pii,int>
#define vi           vector<int>
#define vpi          vector<pii>
#define pb           push_back
#define mp           make_pair
#define x            first
#define y            second
#define all(a)       (a).begin(),(a).end()
#define fo(i,k,n)    for(int i=k;i<n;i++)
#define fod(i,k,n)   for(int i=k;i>=n;i--)
#define sz(x)        (int)x.size()

#define PI 3.141592653

typedef long long ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll> > vpl;
typedef pair<ll,ll> pll;

int main()
{
    std::ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int a,b;
    cin>>a>>b;
    if((a+b)%2==0) cout<<(a+b)/2;
    else cout<<"IMPOSSIBLE";
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        {
            //bool ret = false;
            var read = c2i(RL());
            //dflist = spr(RL()).Select(x => c2i(x)).ToList();
            var buy1000 = read / 500;
            var buy5 = (read % 500) / 5;
            int ret = buy1000 * 1000 + buy5 * 5;
            Console.WriteLine(ret);
            //Console.ReadLine();


        }
        static string RL() { return Console.ReadLine().Trim(); }
        static IEnumerable<string> spr(string s) { return s.Split(' '); }
        static int c2i(string c) { return int.Parse(c); }
        //static double c2d(string c) { return double.Parse(c); }
        static string bool2ret(bool b) { return b ? "Yes" : "No"; }
    }
}


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

char s[125];
int n;
int idx;

const int INF = 1000025;

struct EE{
  int id;
  int size;
  int mult;
  int csizesum;
  bool leaf;
  char c;
  vector<int> children;
};

EE E[125252];
int id;
int it;
void cl(int id){
  E[id].id = 0;
  E[id].size = 0;
  E[id].mult = 0;
  E[id].csizesum = 0;
  E[id].leaf = false;
  E[id].c = '\0';
  E[id].children.clear();
}

int dfs(){
  int nid = id++;
  cl(nid);
  E[nid].id = nid;
  if(isdigit(s[it])){
    // multiplier
    int mult = 0;
    while(isdigit(s[it])){
      mult *= 10;
      mult += s[it]-'0';
      it++;
    }
    E[nid].leaf = false;
    E[nid].mult = mult;
    if(s[it]=='('){
      it++;
      while(s[it] != ')'){
        int child = dfs();
        E[nid].children.push_back(child);
        E[nid].csizesum += E[child].size;
        if(E[nid].csizesum > INF)E[nid].csizesum = INF;
      }
      it++;
    }else{
      int child = dfs();
      E[nid].children.push_back(child);
      E[nid].csizesum += E[child].size;
      if(E[nid].csizesum > INF)E[nid].csizesum = INF;
    }
    E[nid].size = min(INF, E[nid].csizesum * mult);
    return nid;
  }else{
    E[nid].size = 1;
    E[nid].leaf = true;
    E[nid].c = s[it++];
    return nid;
  }
}

void debug(int root){
  if(E[root].leaf){
    printf("%c ",E[root].c);
  }else{
    printf("%dx [ ",E[root].mult);
    for(int c : E[root].children){
      debug(c);
    }
    printf("]");
  }
  return;
}

int main(){
  while(true){
    REP(i,125)s[i] = '\0';
    s[0] = '1';
    s[1] = '(';
    scanf("%s%d",s+2,&idx);
    n = strlen(s);
    s[n++] = ')';
    s[n] = '\0';
    if(n==4 && s[2]=='0' && idx==0)break;
    id = 0;
    it = 0;
    int root = dfs();
    if(E[root].size <= idx){
      puts("0");
      continue;
    }
    // debug(root);puts("");
    while(!E[root].leaf){
      int csizesum = E[root].csizesum;
      idx %= csizesum;
      int nxt = -1;
      for(int c : E[root].children){
        int sz = E[c].size;
        if(idx < sz){
          nxt = c;
          break;
        }
        idx -= sz;
      }
      root = nxt;
    }
    printf("%c\n",E[root].c);
  }
  return 0;
}


Measured memory_bytes: 9128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n,m;
    int i;
    int a[10000];
    int sum = 0;
    cin >> n >> m;
    for(i=0;i<m;i++){
        cin >> a[i];
        sum += a[i];
    }
    sum = n - sum;
    if(sum < 0){
        sum = -1;
    }
    cout << sum << endl;
}

Measured memory_bytes: 3616
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>


using namespace std;

int main() {

	int a, b;
	cin >> a >> b;
	if (a <= b) {
		for (int i = 0; i < b; i++) {
			cout << a;

		}
	}
	else {
		for (int i = 0; i < a; i++) {
			cout << b;
		}
	}
	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 a = n%1000;
    
    if(a==0) {
    System.out.println(a);
    }else{
    System.out.println(1000-a);
      }
}
}



Measured memory_bytes: 35628
package main

import(
	"bufio"
	"strconv"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readBigLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func min(x int, y int) int {
	if x > y {
		return y
	} else {
		return x
	}
}

func max(x int, y int) int {
	if x > y {
		return x
	} else {
		return y
	}
}

func main() {
	sc.Split(bufio.ScanWords)

	a := nextInt()

	ans := 1

	for i := 1; i <= a; i++ {
		ans *= i
		ans %= 1000000007
	}


	fmt.Println(ans)
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
typedef long long ll;
int cmpint(const void *x, const void *y) {
	return *(int *)x - *(int *)y;
}
int main() {
	int n, a[100000], b, dif[100000], cnt = 0;
	ll sum = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	for (int i = 0; i < n; i++) {
		scanf("%d", &b);
		dif[i] = a[i] - b;
	}
	qsort(dif, n, sizeof(int), cmpint);
	for (int i = 0; i < n; i++) {
		if (dif[i] >= 0) {
			break;
		}
		sum += dif[i];
		cnt++;
	}
	for (int i = n - 1; i >= 0; i--) {
		if (sum >= 0)
			break;
		if (dif[i] <= 0) {
			break;
		}
		sum += dif[i];
		cnt++;
	}
	printf("%d\n", sum >= 0 ? cnt : -1);
	return 0;
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
#define pb push_back
#define vi vector<int>
#define all(x) (x).begin(), (x).end()
#define pi pair<int, int>
using namespace std;

const int N = 3e5 + 5;
const int M = 7;

int n, a[N], b[N], k, v[N], need1[N], need3[N], l[N];
vector<pi> q1[N], q3[N];

bool cmp(pi a, pi b) {
    return a.second < b.second;
}

void dfs(int v) {
    if (need1[v]) {
        q1[v].pb({0, 0});
        int vv = v;
        for (int i = 0; i < M + 1 && vv != 0; i++) {
            int sz = q1[v].size();
            for (int j = 0; j < sz; j++)
                q1[v].pb({q1[v][j].first + a[vv], q1[v][j].second + b[vv]});
            vv /= 2;
        }
        sort(q1[v].begin(), q1[v].end(), cmp);
    }
    if (need3[v]) {
        q3[v].pb({0, 0});
        int vv = v;
        for (int i = 0; i < M + 3 && vv != 0; i++) {
            int sz = q3[v].size();
            for (int j = 0; j < sz; j++)
                q3[v].pb({q3[v][j].first + a[vv], q3[v][j].second + b[vv]});
            vv /= 2;
        }
        sort(q3[v].begin(), q3[v].end(), cmp);
    }
    if (v + v <= n)
        dfs(v + v);
    if (v + v + 1 <= n)
        dfs(v + v + 1);
}

signed main()
{

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> a[i] >> b[i];
    cin >> k;
    for (int i = 1; i <= k; i++) {
        cin >> v[i] >> l[i];
        need1[v[i]] = 1;
        int q = v[i];
        for (int j = 0; j < M + 1; j++)
            q /= 2;
        need3[q] = 3;
    }
    q1[0].pb({0, 0});
    q3[0].pb({0, 0});

    dfs(1);
    for (int y = 1; y <= k; y++) {
        int u = v[y];
        int v = u;
        for (int i = 0; i < M + 1; i++)
            v /= 2;
        int ans = 0;
        vector<int> mx_pref(q1[u].size(), q1[u][0].first);
        for (int i = 1; i < q1[u].size(); i++)
            mx_pref[i] = max(mx_pref[i - 1], q1[u][i].first);
        int r = q1[u].size() - 1;
        for (int i = 0; i < q3[v].size(); i++) {
            if (q3[v][i].second > l[y])
                break;
            while (q3[v][i].second + q1[u][r].second > l[y])
                r--;
            ans = max(ans, q3[v][i].first + mx_pref[r]);
        }
        cout << ans << "\n";
    }
    return 0;
}


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

using namespace std;

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

using ll = long long;
using pint = pair<int, int>;
using mint = map<int, int>;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	int len = v.size();
    s << '[';
	for (int i = 0; i < len; ++i) {
		s << v[i]; if (i < len-1) s << ", ";
	}
    s << ']';
	return s;
}

int grid[1001][1001];
queue<int> q;
int h, w;

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
	cin >> h >> w;
	fill_n(*grid, 1001*1001, MOD);
	rep(i, h){
		string s;
        cin >> s;
		rep(j, w){
			if(s[j] == '#') {
				q.push(j*1000+i);
				grid[i][j] = 0;
			}
		}
	}

    while(!q.empty()){
        int tmp = q.front(); q.pop();
        int x = tmp/1000;
		int y = tmp%1000;
	    rep(i, 4){
			int xx = x+dx[i], yy = y+dy[i];
			if(grid[yy][xx] != MOD) continue;
			if(xx < 0 or w <= xx or yy < 0 or h <= yy) continue;
			grid[yy][xx] = min(grid[yy][xx], grid[y][x]+1);
			q.push(xx*1000+yy);
        }
    }

	int ans = 0;
	rep(i, h){
		rep(j, w){
			ans = max(ans, grid[i][j]);
		}
	}
	ppp(ans);

    return 0;
}


Measured memory_bytes: 8320
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

vector<vector<int>> inp;
int n, m, q, ans = 0;

// void dfs(vector<int> a) {
//   if (a.size() == n + 1) {
//     int now = 0;
//     rep(i, 0, q) {
//       if (a[inp[i][1]] - a[inp[i][0]] == inp[i][2])
//         now += inp[i][3];
//       chmax(ans, now);
//     }
//     return;
//   }
//   a.push_back(a.back());
//   while (a.back() <= m) {
//     dfs(a);
//     a.back()++;
//   }
// }

void dfs(int i, int p, vector<int> v) {
  if (i == n) {
    int s = 0;
    for (int j = 0; j < q; j++) {
      if (v[inp[j][1]] - v[inp[j][0]] == inp[j][2]) {
        s += inp[j][3];
      }
    }
    chmax(ans, s);
    return;
  }

  rep(j, p, m + 1) {
    vector<int> nv = v;
    nv.push_back(j);
    dfs(i + 1, j, nv);
  }
}

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

  cin >> n >> m >> q;
  inp.resize(q, vector<int>(4));
  rep(i, 0, q) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    a--, b--;
    inp[i][0] = a;
    inp[i][1] = b;
    inp[i][2] = c;
    inp[i][3] = d;
  }
  // dfs(vector<int>(1, 1));
  dfs(0, 1, vector<int>());
  cout << ans << endl;
}


Measured memory_bytes: 3648
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0
for i in range(N):
    ans += min(B[i], A[i]+A[i+1])
    A[i+1] = max(0, A[i+1] - max(0, (B[i]-A[i])))
print(ans)

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

int main(void){
    int N, M, K, Abuf, Bbuf;
    cin >> N >> M >> K;
    vector<vector<int>> Friend(N);
    vector<vector<int>> Block(N);
    vector<int> numCandidate(N, -1);

    for(int i=0; i<M; i++){
        cin >> Abuf >> Bbuf;
        Abuf--;
        Bbuf--;
        Friend[Abuf].push_back(Bbuf);
        Friend[Bbuf].push_back(Abuf);
    }
    for(int i=0; i<K; i++){
        cin >> Abuf >> Bbuf;
        Abuf--;
        Bbuf--;
        Block[Abuf].push_back(Bbuf);
        Block[Bbuf].push_back(Abuf);
    }

    vector<int> maxCandidate(N, 0);
    for(int i=0; i<N; i++){
        if(numCandidate[i] != -1)continue;
        queue<int> que;

        que.push(i);
        numCandidate[i] = i;
        while(!que.empty()){
            int curMember = que.front();
            que.pop();
            maxCandidate[i]++;
            for(int cldMember: Friend[curMember]){
                if(numCandidate[cldMember] != -1) continue;
                numCandidate[cldMember] = i;
                que.push(cldMember);
            }
        }
    }

    vector<int> effectiveblock(N, 0);
    for(int i=0; i<N; i++){
        for(int j: Block[i]){
            if(numCandidate[i] == numCandidate[j])effectiveblock[i]++;
        }
    }

    bool firstoutput = true;
    for(int i=0; i<N; i++){
        if(firstoutput){
            firstoutput = false;
        }else{
            cout << " ";
        }
        cout << maxCandidate[numCandidate[i]] - Friend[i].size() - effectiveblock[i] - 1;
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 13048
#include <stdio.h>

void trace(int a[],int n)
{
	int i;
	for(i=0;i<n;i++)
	{
		if(i>0)printf(" ");
		printf("%d",a[i]);
	}
	printf("\n");
 } 
 void insert(int a[],int n)
 {
 	int i,j,v;
 	for(i=1;i<n;i++)
 	{
 		v=a[i];
 		j=i-1;
 		while(j>=0&&a[j]>v)
 		{
 			a[j+1]=a[j];
 			j--;
		 }
		 a[j+1]=v;
		 trace(a,n);
	 }
 }
 
 int main()
 {
 	int n,j,i;
 	int a[100];
 	scanf("%d",&n);
 	for(i=0;i<n;i++)
 	scanf("%d",&a[i]);
 	trace(a,n);
 	insert(a,n);
 	return 0;
 }


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

int main() { int N; string S; cin >> N >> S;
vector<int> Wsum(N);
int cnt = 0;
for(int i = 0; i < N; i++){//累積和
  if(S.at(i) == 'W') cnt++;
    Wsum.at(i) = cnt;
}
vector<int> dp(N + 5);
int INF = 1e5;
dp.at(0) = INF; dp.at(1) = 0;

for(int i = 1; i < N; i++){
  if(S.at(i) == 'W') dp.at(i + 1) = dp.at(i);
  else{
    dp.at(i + 1) = min(dp.at(i) + 1, Wsum.at(i - 1));
  }
}




// cout << Wsum.at(4) << endl;
cout << dp.at(N) << endl;
  return 0;
 
}
   

Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)

#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))

#define endl "\n"
#define pb push_back
#define rtn return
#define elif else if

#define MOD 1000000007
 
const int dx_4[]={1,0,-1,0}, dy_4[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};

typedef long long ll;
typedef unsigned long long ull;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	int N, W, v[108], w[108];
	int dp[128][10240] = {0};

	cin >> N >> W;
	REP(i, N) cin >> v[i] >> w[i];

	REP(i, N){
		REP(j, W+1){
			if(j < w[i]) dp[i+1][j] = dp[i][j];
			else dp[i+1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
		}
	}
	cout << dp[N][W] << endl;

	rtn 0;
}


Measured memory_bytes: 8352
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
typedef long long ll;
int main()
{
	vector<string> v;
	ll n,m;
	cin>>n>>m;
	for(ll i=0;i<n;i++)
	{
		string s;
		cin>>s;
		v.push_back(s);
	}
	
	ll dp[n][m];
	dp[0][0]=0;
	ll j=0;
	while(j+1<m && v[0][j+1]=='.')
	{
		dp[0][j+1]=1;
		j++;
	}
	j++;
	while(j<m)
	{
		
		dp[0][j]=0;
		j++;
	}
	
	ll i=0;
	while(i+1<n && v[i+1][0]=='.')
	{
		dp[i+1][0]=1;
		i++;
	}
	i++;
	while(i<n)
	{
		dp[i][0]=0;
		i++;
	}
	
	
	for(ll i=1;i<n;i++)
	{
		for(ll j=1;j<m;j++)
		{
			if(v[i][j]=='#')
			dp[i][j]=0;
			else
			dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
		}
	}
	

	cout<<dp[n-1][m-1];
	
	
}


Measured memory_bytes: 12464
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int64_t n,a,m;
  cin>>n;
  a=0;
  m=0;
  vector<string> vec(n);
  for(int64_t i=0;i<n;i++){
  cin>>vec.at(i);
  }
  sort(vec.begin(), vec.end());
  for(int64_t i=0;i<n-1;i++){
  if(vec.at(i)==vec.at(i+1)){a++;
                            m=max(m,a);}
    else{a=0;}
  }
  if(a!=0){a=0;
  for(int64_t i=0;i<n-1;i++){
  if(vec.at(i)==vec.at(i+1)){a++;
                            if(m==a){cout<<vec.at(i)<<endl;};}
    else{a=0;
         }
  }}
  else{for(int64_t i=0;i<n;i++){
  cout<<vec.at(i)<<endl;
  }}
 }

Measured memory_bytes: 9596
#include<stdio.h>

int main(void){
        char str[11];
        int n,i;
        while(1){
                scanf("%d",&n);
                if(n==0)break;
                sprintf(str,"%o",n);
                for(i=0;str[i]!='\0';i++){
                        str[i]+=(str[i]>='4')+(str[i]>='5');
                }
                printf("%s\n",str);
        }
        return 0;
}


Measured memory_bytes: 2100
#include<stdio.h>
     
     
    int main(){
        int N,i,b[50]={0},k=0;
        scanf("%d",&N);
     
        int p[N];
        for(i=0;i<N;i++){
            scanf("%d",&p[i]);
        }
        for(i=0;i<N;i++){
            if(p[i]!=i+1){
                b[i]=1;
            }
            if(b[i]==1){
                k++;
            }
        }
        if(k<3){
            printf("YES\n");
        }else{
            printf("NO\n");
        }
    }

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

int main(){
  int64_t h;
  cin>> h;
  
  int64_t n=1,count=0;
  while(h>1){
    count+=n;
    h/=2;
    n*=2;
  }
  cout<< n+count << endl;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
typedef long long ll;

int main(){
  vector<bool> ert(100005,1);
  ert[0] = 0;
  ert[1] = 0;
  rep(i,100005){
    if(!ert[i]) continue;
    for(int j=i+i;j<100005;j += i){
      ert[j] = 0;
    }
  }
  vector<int> sum(100005,0);
  for(int i=1;i<100005;i++){
    sum[i] = sum[i-1];
    if(i%2) sum[i] += ert[i] * ert[(i+1)/2];
  }
  int q;
  cin >> q;
  rep(i,q){
    int l,r;
    cin >> l >> r;
    cout << sum[r] - sum[l-1] << endl;
  }
}

Measured memory_bytes: 3652
n = int(input())
a = list(map(int, input().split()))
a.sort()
a.reverse()
ans = 0
if n%2==0:
	for i in range(int(n/2)):
		ans +=a[i]
	ans*=2
	ans-=a[0]
else:
	k = int((n-1)/2)
	for i in range(k):
		ans+=a[i]
	ans*=2
	ans-=a[0]
	ans+=a[k]
print(ans)

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

#ifdef DEBUG
    #include "debug.h"
    #define dump(...)                                                              \
        DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
                << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
                << endl                                                            \
                << "    ",                                                         \
            dump_func(__VA_ARGS__)
#else
    #define dump(...)
#endif


// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

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

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//////////////////

#define int long long
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
#define ALL(v) (v).begin(), (v).end()
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
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 (a>b) { a=b; return 1; } return 0; }

//*
#define mod 1000000007 /*/
#define mod 998244353 //*/

typedef pair<int, int> P;
#define INF (1LL<<60)


void solve(){
    int N;
    cin >> N;
    int ans = 0;
    for(int i=1; i<=N; i++){
        int a; cin >> a;
        if(i%2==1 && a%2==1) ans++;
    }
    cout << ans << endl;

}


signed main(){
    cout << fixed << setprecision(18);
    cerr << fixed << setprecision(18);
    solve();
}


Measured memory_bytes: 3644