akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define x first
#define y second

using namespace std;

typedef long long ll;

int digit(int x)
{
    int ans = 0;
    while (x > 0)
    {
        ans += x % 10;
        x /= 10;
    }
    return ans;
}

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n, ans = 100;
    cin >> n;
    for (int i = 1; i < n; i++)
        ans = min(ans, digit(i) + digit(n - i));
    cout << ans;
    return 0;
}


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

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

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

  if (a + b + c >= 22) {
    cout << "bust" << endl;
  } else {
    cout << "win" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>
#include <iomanip>

using namespace std;

#define PI 3.14159265358979323846
#define INF 1e+9
#define DIV_NUM (1000000007)



int main() {

	int N, K;
	cin >> N >> K;
	vector<int> inputs;
	vector<double> sums;
	for (int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		inputs.push_back(tmp);
		if(i==0){
			sums.push_back((double)(inputs[i]+1)/2.0);
		}
		else {
			sums.push_back((double)(inputs[i]+1)/2.0+sums[i-1]);

		}
	}

	vector<double> K_sums;
	for (int i = 0; i < N - K + 1; i++) {
		if (i == 0) {
			K_sums.push_back(sums[K - 1 + i]);
		}
		else {
			K_sums.push_back(sums[K - 1 + i] - sums[i-1]);
		}
	}

	sort(K_sums.begin(), K_sums.end(), greater<double>());

	cout << setprecision(20) << K_sums[0] << endl;

	return 0;
}


Measured memory_bytes: 5736
/**
 *    author:  tourist
 *    created: 30.09.2017 15:59:34       
**/
#include <bits/stdc++.h>

using namespace std;

inline void add(int &a, int b, int md) {
  a += b;
  if (a >= md) a -= md;
}

inline void sub(int &a, int b, int md) {
  a -= b;
  if (a < 0) a += md;
}

inline int mul(int a, int b, int md) {
#if !defined(_WIN32) || defined(_WIN64)
  return (long long) a * b % md;
#endif
  unsigned long long x = (long long) a * b;
  unsigned xh = (unsigned) (x >> 32), xl = (unsigned) x, d, m;
  asm(
    "divl %4; \n\t"
    : "=a" (d), "=d" (m)
    : "d" (xh), "a" (xl), "r" (md)
  );
  return m;
}

inline int power(int a, long long b, int md) {
  int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a, md);
    }
    a = mul(a, a, md);
    b >>= 1;
  }
  return res;
}

inline int inv(int a, int md) {
  a %= md;
  if (a < 0) a += md;
  int b = md, u = 0, v = 1;
  while (a) {
    int t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}

template<typename T>
T extgcd(T a, T b, T &x, T &y) {
/*  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  T p = b / a;
  T g = extgcd(b - p * a, a, y, x);
  x -= p * y;
  return g;*/
  x = 0, y = 1;
  while (a) {
    T t = b / a;
    b -= t * a; swap(a, b);
    x -= t * y; swap(x, y);
  }
  return b;
}

template<typename T>
bool diophantine(T a, T b, T c, T &x, T &y, T &g) {
  if (a == 0 && b == 0) {
    if (c == 0) {
      x = y = g = 0;
      return true;
    }
    return false;
  }
  if (a == 0) {
    if (c % b == 0) {
      x = 0;
      y = c / b;
      g = abs(b);
      return true;
    }
    return false;
  }
  if (b == 0) {
    if (c % a == 0) {
      x = c / a;
      y = 0;
      g = abs(a);
      return true;
    }
    return false;
  }
  g = extgcd(a, b, x, y);
  if (c % g != 0) {
    return false;
  }
  T dx = c / a;
  c -= dx * a;
  T dy = c / b;
  c -= dy * b;
  x = dx + (T) ((__int128) x * (c / g) % b);
  y = dy + (T) ((__int128) y * (c / g) % a);
  g = abs(g);
  return true;
}

int get_phi(int m) {
  int phi = m;
  int tmp = m;
  for (int i = 2; i * i <= tmp; i++) {
    if (tmp % i == 0) {
      phi /= i;
      phi *= (i - 1);
      while (tmp % i == 0) {
        tmp /= i;
      }
    }
  }
  if (tmp > 1) {
    phi /= tmp;
    phi *= tmp - 1;
  }
  return phi;
}

long long solve(int a, int m) {
  if (m == 1) {
    return 30;
  }
  int phi = get_phi(m);
  int g = __gcd(m, phi);
  long long k = solve(a, g);
  int value = power(a, k, m);
  k %= phi;
  // res = value (mod m)
  // res = k (mod phi)
  // res = m * x + value = phi * y + k
  int x, y;
  assert(diophantine(m, -phi, (int) (k - value), x, y, g));
  long long res = (long long) m * x + value;
  while (res < 30) {
    res += (long long) m / g * phi;
  }
  return res;
}

int main() {
  int tt;
  scanf("%d", &tt);
  while (tt--) {
    int a, m;
    scanf("%d %d", &a, &m);
    long long k = solve(a, m);
    cout << k << endl;
    assert(power(a, k, m) == k % m);
  }
  return 0;
}


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

using namespace std;
using ll=long long int;

class UnionFind {
public:
    UnionFind(int n) : parent(n, -1), rank(n) {}

    int find(int x) {
        if (parent[x] < 0) {
            return x;
        } else {
            return parent[x] = find(parent[x]);
        }
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;

        if (rank[x] < rank[y]) {
            parent[y] += parent[x];
            parent[x] = y;
        } else {
            parent[x] += parent[y];
            parent[y] = x;
            if (rank[x] == rank[y]) rank[x]++;
        }
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    int size(int x) {
        return -parent[find(x)];
    }

private:
    vector<int> parent;
    vector<int> rank;
};

int main() {
    ll n, m;
    cin >> n >> m;
    vector<pair<int, int>> br(m);
    for (auto &e: br) cin >> e.first >> e.second;

    reverse(br.begin(), br.end());
    vector<ll> ans(m);
    ans[0] = n * (n-1) / 2;

    UnionFind uf(n+1);
    for (int i = 0; i < m-1; ++i) {
        if (uf.same(br[i].first, br[i].second)) {
            ans[i+1] = ans[i];
            continue;
        }
        ans[i+1] = ans[i] - (ll)uf.size(br[i].first) * uf.size(br[i].second);
        uf.unite(br[i].first, br[i].second);
    }

    for (auto it = ans.rbegin(); it != ans.rend(); ++it) {
        cout << *it << endl;
    }

    return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
using namespace std;

int main(){
	int n, x, m, sum = 0, mn = 1000;
	cin >> n >> x;
	for (int i = 0; i < n; ++i) {
		cin >> m;
		sum += m;
		mn = min(mn, m);
	}
	cout << n + ((x - sum) / mn) << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int h=0,w=0;
    while((h = sc.nextInt()) != 0 | (w = sc.nextInt()) != 0){
      for(int i = 1;i <= h;i++){
        for(int j = 1;j <= w;j++){
          if((j % 2) == (i % 2)){
              System.out.print("#");
          }else{
              System.out.print(".");
          }
        }
        System.out.println("");
      }
      System.out.println("");
    }
  }
}



Measured memory_bytes: 32760
s = list(input())
n = len(s)

if s != list(reversed(s)):
    print("No")
    exit()

seq = s[0:int(((n-1)/2))]
#print(seq)
if seq != list(reversed(seq)):
    print("No")
    exit()


seq = s[int(((n+3)/2))-1:]
#print(seq)
if seq != list(reversed(seq)):
    print("No")
    exit()

print("Yes")

Measured memory_bytes: 38512
<?php

$n = trim(fgets(STDIN));
for($i = 1; $i <= $n; $i++){
    $l = explode(" ", trim(fgets(STDIN)));
    $r[$l[0]][$i] = $l[1];
}
ksort($r);

$nn = 1;
foreach($r as $n => $p){
  $t = $p;
  arsort($t);
  foreach($t as $k => $v){
    if($nn == 0) echo "\n";
    echo $k;
    if($nn !== 0) $nn = 0;
  }
}

?>

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

using namespace std;

int main()
{
  int s;
  cin >> s;
  int ans = 1;
  map<int, bool> m;
  while (!m[s])
  {
    m[s] = true;
    if (s % 2 == 0)
      s /= 2;
    else
      s = 3 * s + 1;
    ans++;
  }
  cout << ans << endl;

  return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N,D;

int cnt[1111][1111];
int acc[2222][2222];
int uku[111111];

signed main(){
	for(int i=1;i<111111;i++){
		uku[i]=uku[i-1];
		if(uku[i]*uku[i]<i)uku[i]++;
	}

	cin>>N>>D;

	int L=0;
	rep(i,N){
		int x,y;
		cin>>x>>y;
		x%=D;y%=D;
		cnt[y][x]++;
		chmax(L,uku[cnt[y][x]]);		
	}

	vpint f,h;
	rep(i,D)rep(j,D){
		if((L-1)*(L-1)>=cnt[i][j])continue;
		if(L*(L-1)>=cnt[i][j])h.pb({i,j});
		else f.pb({i,j});
	}

	int lb=0,ub=D;
	while(ub-lb>1){
		int mid=(lb+ub)/2;

		memset(acc,0,sizeof(acc));
		for(auto &p:f){
			int y,x;
			tie(y,x)=p;
			acc[y][x]++;
			acc[y+mid][x]--;
			acc[y][x+mid]--;
			acc[y+mid][x+mid]++;
		}
		for(auto &p:h){
			int y,x;
			tie(y,x)=p;

			acc[y][x]++;
			acc[y+mid][x]--;
			acc[y][x+D]--;
			acc[y+mid][x+D]++;

			acc[y][x]++;
			acc[y+D][x]--;
			acc[y][x+mid]--;
			acc[y+D][x+mid]++;

			acc[y][x]--;
			acc[y+mid][x]++;
			acc[y][x+mid]++;
			acc[y+mid][x+mid]--;			
		}
		rep(i,D*2)rep(j,D*2){
			acc[i+1][j]+=acc[i][j];
			acc[i][j+1]+=acc[i][j];
			acc[i+1][j+1]-=acc[i][j];
		}
		bool ok=false;
		rep(i,D)rep(j,D)if(acc[i][j]+acc[i+D][j]+acc[i][j+D]+acc[i+D][j+D]==h.size()+f.size())ok=true;
		if(ok)ub=mid;
		else lb=mid;
	}

	cout<<(L-1)*D+ub-1<<endl;
	return 0;
}

Measured memory_bytes: 50032
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int par[1001],rank[1001];
void init(int n){
  for(int i=0;i<n;i++){
    par[i]=i;
    rank[i]=1;
  }
}
int find(int x){
  if(par[x]==x){
    return x;
  }else{
    return par[x]=find(par[x]);
  }
}
void unit(int x,int y){
  x=find(x);
  y=find(y);
  if(x==y)return;
  if(rank[x]<rank[y]){
    par[x]=y;
  }else{
    par[y]=x;
    if(rank[x]==rank[y])rank[x]++;
  }
}
bool same(int x,int y){
  return find(x)==find(y);
}
struct edge{int u,v,cost;};
bool comp(const edge& e1,const edge& e2){
  return e1.cost<e2.cost;
}
edge es[10001];
int V,E;
int kruskal(){
  sort(es,es+E,comp);
  init(V);
  int c=0;
  for(int i=0;i<E;i++){
    edge e=es[i];
    if(!same(e.u,e.v)){
      unit(e.u,e.v);
      if(c++==((V-1)/2))return e.cost;
    }
  }
}
main(){
    while(cin>>V>>E,V){
        init(V);
        r(i,E)cin>>es[i].u>>es[i].v>>es[i].cost;
        cout<<kruskal()<<endl;
    }
}

Measured memory_bytes: 3264
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)

ll cnt;
ll ans[300010];

int main(){
	ll k,n;
	scanf("%lld%lld",&k,&n);
	if(k%2==0){
		printf("%lld ",k/2);
		rep(i,1,n)printf("%lld ",k);
		return 0;
	}
	rep(i,0,n)ans[i]=(k+1)/2;
	cnt=n;
	rep(xx,0,n/2){
		ans[cnt-1]--;
		if(ans[cnt-1]){
			rep(j,cnt,n)ans[j]=k;
			cnt=n;
		}else cnt--;
	}
	for(int i=0;ans[i];i++)printf("%lld ",ans[i]);
}

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

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()

int main(){
  int n;cin>>n;
  vector<ll> a(n);
  rep(i,n){
    cin>>a[i];
  }
  sort(all(a),greater<int>());
  int alice=0,bob=0;
  rep(i,n){
    if(i%2==0){
      alice+=a[i];
    }else{
      bob+=a[i];
    }
  }
  cout<<alice-bob<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
struct fastio { fastio() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); } } _fastio_;
template<class T> bool chmin (T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> bool chmax (T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }

int main() {
	std::string s;
	std::cin >> s;
	long long sum = 0;
	for (const char &c : s) {
		sum += (c - '0');
	}
	
	std::cout << (sum % 9 == 0 ? "Yes" : "No") << '\n';
	
	return 0;
}

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

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

vector <int> a,b,o;


int main(void){
	int N;
	cin >> N;
	REP(i,N){
		int x;
		cin >> x;
		a.push_back(x);
	}
	REP(i,N){
		int x;
		cin >> x;
		b.push_back(x);
	}
	REP(i,N)
		o.push_back(i+1);
	int ans1 = 0,ans2 = 0,sum = 1;
	do{
		if(o == a) ans1 = sum;
		if(o == b) ans2 = sum;
		sum++;
	}while(next_permutation(o.begin(),o.end()));
	cout << abs(ans1-ans2) << endl;
	return 0;
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);  
	
	int n, ma, mb;
	cin >> n >> ma >> mb;
	int mx = 450, inf = 1 << 30;
	vector<vector<int>> dp(mx, vector<int>(mx, inf));
	dp[0][0] = 0;
	while(n--) {
		int a, b, c;
		cin >> a >> b >> c;
		for(int i = mx - 1 - a; i >= 0; i--) {
			for(int j = mx - 1 - b; j >= 0; j--) {
				dp[i + a][j + b] = min(dp[i + a][j + b], dp[i][j] + c);
			}
		}
	}
	int ans = 1 << 30;
	for(int i = 1; i < mx; i++) {
		for(int j = 1; j < mx; j++) {
			if(i * mb == j * ma) {
				ans = min(dp[i][j], ans);
			}
		}
	}
	cout << (ans == 1 << 30 ? -1 : ans) << endl;
	return 0;	
}

Measured memory_bytes: 1024
import time
K=int(input())
mod=7%K

if 7%K==0:
  print(1)
  exit()
ans=1
now=time.time()
while 1:
  ans+=1
  mod=(mod*10+7)%K
  if mod==0:
    print(ans)
    break
  if time.time()-now>=1.8:
    print(-1)
    break
  



Measured memory_bytes: 63664
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int dp[2][10005];
const int INF = 1e9;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h, n;
	cin >> h >> n;
	rep(i,2)rep(j,10005) dp[i][j] = INF;
	dp[0][0] = 0;
	rep(i,n){
		int a, b;
		cin >> a >> b;
		rep(j,h+1){
			chmin(dp[(i+1)%2][j], dp[i%2][j]);
			chmin(dp[i%2][min(j+a, h)], dp[i%2][j] + b);
		}
	}
	cout << dp[n%2][h] << endl;
	return 0;
}

Measured memory_bytes: 3724
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define EQ(a,b) abs((a)-(b))<EPS
using namespace std;
typedef double D;
const D EPS = 1e-8;

int n,b;
D d,p[11],h[11];

bool check(D H, D W){
  D a = -4*H/W/W;
  rep(i,n){
    D x = p[i];
    while(x+EPS>W)x -= W;
    if(EQ(x,0))return false;
    if(a*(x-W/2)*(x-W/2)+H +EPS < h[i])return false;
  }
  return true;
}

int main(){
  cin >> d >> n >> b;
  rep(i,n)cin >> p[i] >> h[i];

  D res = 1e12;
  rep(i,b+1){
    D w = d/(i+1);
    D l = w/4, r = 1e12;
    rep(azu,99){
      D mid = (l+r)/2;
      if(check(mid,w))r = mid;
      else l = mid;
    }
    D vy = sqrt(2*l), vx = w/2/vy;
    res = min(res, sqrt(vy*vy + vx*vx));
  }
  cout << fixed << setprecision(5) << res << endl;
}

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

const int MAX_N = 100010;
vector<int> G[MAX_N];

int main()
{
    int N;
    int M;
    cin >> N >> M;

    vector<int> in(N, 0);

    for(int i = 0; i < M; i++)
    {
        int x;
        int y;
        cin >> x >> y;
        x--;
        y--;
        G[x].push_back(y);
        in[y]++;
    }

    queue<int> st;
    for(int i = 0; i < N; i++) if(in[i] == 0) st.push(i);

    vector<int> dp(N, 0);

    while(st.size())
    {
        int v = st.front();
        st.pop();
        for(int i = 0; i < G[v].size(); i++)
        {   
            int to = G[v][i];
            in[to]--;
            if (in[to] == 0)
            {
                st.push(to);
                dp[to] = max(dp[to], dp[v] + 1);
            }
        }
    }

    cout << *max_element(dp.begin(), dp.end()) << endl;
}

Measured memory_bytes: 6528
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int dp[1100000][2];
int main()
{
  string s;
  cin >> s;
  int inf = 1e+9;
  reverse(s.begin(), s.end());
  s.push_back('0');
  
  int n = s.size();
  rep(i,n+1) rep(f,2) dp[i][f] = inf;
  dp[0][0]=0;
  
  rep(i,n+1){
    int d = (int)s[i]-'0';
    rep(j,10){
      rep(f,2){
	int k = j;
	if(f) k--;
	if(k>=d) dp[i+1][0] = min(dp[i+1][0],dp[i][f]+j+k-d);
	else dp[i+1][1] = min(dp[i+1][1],dp[i][f]+j+k-d+10);
      }
    }
  }


  cout << dp[n][0] << "\n";


  return 0;
}


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

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

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

template <class T>
T Sq(const T &t) {
  return t * t;
}

const int mod = 1e9 + 7;

signed main() {
  int s = read(), ans = 0;
  set<int> a;
  while (!a.count(s)) {
    a.insert(s);
    ans++;
    if (s % 2 == 0)
      s = s / 2;
    else
      s = 3 * s + 1;
  }
  ans++;
  print(ans);
}


Measured memory_bytes: 256
S=input()
if S=="SUN" :
	print(7)
if S=="MON" :
	print(6)
if S=="TUE" :
	print(5)
if S=="WED" :
	print(4)
if S=="THU" :
	print(3)
if S=="FRI" :
	print(2)
if S=="SAT" :
	print(1)


Measured memory_bytes: 3060
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=5e18;
using P=pair<int,int>;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,k,a[100005]={},ans=inf;
  cin >> n >> k;
  for(int i=0; i<n; i++) {
    cin >> a[i];
  }
  for(int i=0; i<n-k+1; i++) {
    if(a[i+k-1]<=0) {
      ans=min(ans,abs(a[i]));
    }
    else if(a[i]>=0) {
      ans=min(ans,a[i+k-1]);
    }
    else {
      ans=min({ans,abs(a[i])*2+a[i+k-1],abs(a[i])+a[i+k-1]*2});
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 768
#include <stdio.h>
#define size 50
int main()
{
    int ar[size];
    int n,i,count=0;
    scanf("%d",&n);
    for (i=1; i<=n; i++)
    {
        scanf("%d",&ar[i]);
    }
    for(i=1;i<=n;i++)
    {
        if(ar[i]!=i)
            count++;
    }
    if(count>2)
        printf("NO");
    else
        printf("YES");
    return 0;
    
}


Measured memory_bytes: 2128
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int main() {
	int x, y, z;
	read(x), read(y), read(z);
	if (x == y && x == z) puts("Yes");
	else puts("No");
	return 0;
}

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

#define ll long long
#define ld long double
 
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
 
#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)    A.rbegin(),A.rend()
#define ft first
#define sd second
 
#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V>
#define Vpll vector<pll>
 
#define endl "\n"

const ll logN = 20;
const ll M = 1000000007;
const ll INF = 1e12;
#define PI 3.14159265
 
const ll N = 200005;

ll A[N];
V adj[N];
ll B[N];
V lis;

void dfs(ll n, ll p, ll ans){
	ll pos = upper_bound(lis.begin(), lis.end(), A[n]) - lis.begin();
	ll tmp = lis[pos];
	if(lis[pos-1] < A[n] and A[n] < lis[pos]){
		lis[pos] = A[n];
		ans = max(ans, pos);	
	}
	// err3(n, pos, ans);
	// errA(lis);
	B[n] = ans;
	for(auto i:adj[n]){
		if(i!=p){
			dfs(i, n, ans);
		}
	}
	lis[pos] = tmp;
}

void solve(){
	ll n;
	cin>>n;
	rep(i,1,n+1)	cin>>A[i];
	rep(i,0,n-1){
		ll u,v;
		cin>>u>>v;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	rep(i,0,n+1)	lis.pb(INF);
	lis[0] = -INF;
	dfs(1, 0, 0);
	rep(i,1,n+1)	cout<<B[i]<<endl;
	return;
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll no;
	// cin>>no;
	no = 1;
	while(no--){
		solve();
	}
    return 0;
}

Measured memory_bytes: 33260
#include<stdio.h>
int main(void){
	int h=1, w=1, cow, coh;
	while (h != 0 && w != 0){
		scanf("%d", &h);
		scanf("%d", &w);
		if (w != 0 && h != 0){
			for (cow = 1; cow <= w; cow++){
				printf("#");
			}
			printf("\n");

			for (coh = 1; coh <= h - 2; coh++){
				printf("#");
				for (cow = 1; cow <= w - 2; cow++){
					printf(".");
				}
				printf("#");
				printf("\n");
			}
			for (cow = 1; cow <= w; cow++){
				printf("#");
			}
			printf("\n\n");
		}
	}
	return 0;
}

Measured memory_bytes: 588
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=1e5+5;
int p[N][2];
int t[N];
int Abs(int x){
	return x>0?x:-x;
}
int main()
{
    int m;
    scanf("%d",&m);
    for(int i=1;i<=m;i++){
        scanf("%d%d%d",&t[i],&p[i][0],&p[i][1]);
        int x=(p[i][0]-p[i-1][0]+p[i][1]-p[i-1][1])%2;
        x=(x+2)%2;
        if(t[i]-t[i-1]<Abs(p[i][0]-p[i-1][0]+p[i][1]-p[i-1][1])||(t[i]-t[i-1])%2!=x){
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
}


Measured memory_bytes: 1280
#include<iostream>

using namespace std;
typedef long long ll;
int main(){
	int l, r;
	cin >> l >> r;

	ll min = 2019;

	if(r-l >= 2019){
		min = 0;
	}else{
		for(ll i = l; i <= r; ++i){
			for(ll j = l; j <= r; ++j){
				if((i!=j)&&(min>((i*j)%2019))){
					min=(i*j)%2019;
				}
			}
		}
	}

	cout << min << endl;
	
	return 0;
}


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

long long n, p;
string s;
map<long long, long long> mp;

long long solve();

int main() {
  cin >> n >> p >> s;
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long res = 0, sum = 0, ten = 1;
  if(p == 2) {
    for(int i = 0; i < n; ++i)
      if((s[i] - '0') % 2 == 0) res += i + 1;
    return res;
  }
  if(p == 5) {
    for(int i = 0; i < n; ++i)
      if(s[i] == '0' || s[i] == '5') res += i + 1;
    return res;
  }
  reverse(s.begin(), s.end());
  mp[0] = 1;
  for(int i = 0; i < n; ++i) {
    (ten *= 10) %= p;
    (sum += ten * (s[i] - '0') % p) %= p;
    res += mp[sum];
    ++mp[sum];
  }
  return res;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int k,s,x,y,z,ans=0;
  cin >> k >>s;
  for(x=0;x<=k;x++){
    for(y=0;y<=k;y++){
      if((s-x-y)<=k && (s-x-y>=0)) ans++;
    }
  }
  cout <<ans <<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int i, max, min, size;
    double sum=0;
    scanf("%d", &size);
    int arr[size];

    for(i=0; i<size; i++)
    {
        scanf("%d", &arr[i]);
    }

    max = -9999999999;
    min=9999999999;

    for(i=0; i<size; i++)
    {
        if(arr[i] > max)
        {
            max = arr[i];
        }

        if(arr[i] < min)
        {
            min = arr[i];
        }
        sum=sum+arr[i];
    }

    printf("%d %d %.0lf\n",min,max,sum);

    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;

const ll MOD=1000000007;
ll factorial[200000], factorial_inv[200000];

ll mpow(ll x, ll y){
    if(y==0) return 1LL;
    if(y==1) return x%MOD;
    return mpow(x*x%MOD,y/2)*(y%2==0?1LL:x%MOD)%MOD;
}

ll comb(ll n, ll r){
    if(n<r) return 0;
    return factorial[n]*factorial_inv[r]%MOD*factorial_inv[n-r]%MOD;
}

int main(){
    vector<ll> primes;
    bool canPrime[100001];
    for(int i=0;i<=100000;i++) canPrime[i]=(i>=2);
    for(int i=0;i<=100000;i++){
        if(!canPrime[i]) continue;
        primes.push_back(i);
        for(int j=2;j*i<=100000;j++) canPrime[j*i]=false;
    }

    factorial[0]=factorial_inv[0]=1;
    for(ll i=1;i<2e5;i++) factorial[i]=factorial[i-1]*i%MOD;
    for(ll i=1;i<2e5;i++) factorial_inv[i]=mpow(factorial[i],MOD-2);

    ll M,N;
    cin >> N >> M;

    vector<ll> fact;
    for(ll p:primes){
        ll cnt=0;
        for(cnt=0;M%p==0;cnt++) M/=p;
        fact.push_back(cnt);
    }
    if(M!=1) fact.push_back(1);

    ll ans=1;
    for(ll f:fact){
        ans=ans*comb(f+N-1,f)%MOD;
    }

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

Measured memory_bytes: 3712
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    ll x,y,now=0,z=0;
    bool A[4010][20000],B[4010][20000];
  	rep(i,4010)rep(j,20000){
      A[i][j]=0;B[i][j]=0;
    }
    A[0][10000]=1;B[0][10000]=1;
    vector<ll> a,b;
    cin>>s>>x>>y;
    rep(i,(ll)s.size()){
        if(s[i]=='F') now++;
        if(s[i]=='F' && i==(ll)s.size()-1){
            if(z==0){
                a.pb(now);
            } else{
                b.pb(now);
            }
        }
        if(s[i]=='T'){
            if(z==0){
                a.pb(now);
                now=0;
                z=1;
            }
            else{
                b.pb(now);
                now=0;
                z=0;
            }
        }
    }
  	/*
    rep(i,(ll)a.size()){
        cout<<a[i]<<endl;
    }
    cout<<endl;
    rep(i,(ll)b.size()){
        cout<<b[i]<<endl;
    }
    */
    rep(i,(ll)a.size()){
        if(i==0 && s[0]=='F'){
            A[1][a[0]+10000]=1;
          	continue;
        }
        rep(j,20000){
            if(A[i][j]==1){
                A[i+1][j+a[i]]=1;
                A[i+1][j-a[i]]=1;
            }
        }
    }
    rep(i,(ll)b.size()){
        rep(j,20000){
            if(B[i][j]==1){
                B[i+1][j+b[i]]=1;
                B[i+1][j-b[i]]=1;
            }
        }
    }
  	//cout<<A[a.size()][10000+x] <<B[b.size()][10000+y] <<endl;
    if(A[a.size()][10000+x]==1 && B[b.size()][10000+y]==1){
        cout<<"Yes"<<endl;
    } else{
        cout<<"No"<<endl;
    }
    return 0;
}

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

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

  vector<set<int>> sl(m);
  int s, k;
  rep(i, m) {
    cin >> k;
    rep(j, k) {
      cin >> s;
      sl[i].insert(s - 1);
    }
  }
  vector<int> p(m);
  rep(i, m) cin >> p[i];

  int ans = 0;
  rep(i, (1 << n)) {
    vector<int> sw(n);
    rep(j, n) if (i >> j & 1) sw[j] = 1;

    bool ok = true;
    rep(j, m) {
      int on = 0;
      for (auto c : sl[j]) {
        if (sw[c] == 1) on++;
      }

      if (on % 2 != p[j]) ok = false;
    }
    if (ok) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3596
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair <int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int mod = 1e9 + 7;
const char nl = '\n';

void solve() {
    int x;
    cin >> x;
    int n;
    cin >> n;
    set <int> s;
    for(int i = 0; i < n; ++i){
        int curr;
        cin >> curr;
        s.insert(curr);
    }
    int diff = 0;
    while (1){
        if(s.count(x - diff) == 0){
            cout << x - diff;
            return;
        }
        if(s.count(x + diff) == 0){
            cout << x + diff;
            return;
        }
        ++diff;
    }
}

int main() {
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    solve();
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
int main(){
    string s;
    cin>>s;
    int i;
    i=10000000*(s[0]-'0')+1000000*(s[1]-'0')+100000*(s[2]-'0')+10000*(s[3]-'0')+1000*(s[5]-'0')+100*(s[6]-'0')+10*(s[8]-'0')+(s[9]-'0');
    if(i<=20190430){
        cout<<"Heisei";
    }else{
        cout<<"TBD";
    }
    return 0;
}

Measured memory_bytes: 256
Module Module1

    Sub Main()
        Dim ans As String = ""

        Dim value As String = Console.ReadLine

        If Not (value.Substring(0, 1) = value.Substring(1, 1) AndAlso value.Substring(1, 1) = value.Substring(2, 1)) Then
            ans = "Yes"
        Else
            ans = "No"
        End If




        Console.WriteLine(ans)
        Console.ReadKey()








    End Sub




End Module


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

long long n,i,j,k,a[100005],cnt;

int main(){
	cin >> n;
	for(i=0; i<n; i++){
		cin >> a[i];
	}
	sort(a,a+n);
	
	for(i=0; i<n-2; i++){
		for(j=i+1; j<n-1; j++){
			if(a[j]==a[i]){
				continue;
			}
			for(k=j+1; k<n; k++){
				if(a[k]==a[j]){
					continue;
				}
				if(a[k]<(a[i]+a[j])){
					if(a[i]<(a[k]+a[j])){
						if (a[j]<(a[i]+a[k])){
							cnt++;
						}
					}
				}
			}
		}
	}
	if(n<3){
		cout << 0 << endl;
	}else {
		cout << cnt << endl;
	}
}

Measured memory_bytes: 3644
MOD=10**9+7
N=int(input())
x=list(map(int, input().split()))
y=[x[i+1]-x[i] for i in range(N-1)]
 
upp=[1]*(N+1)
for i in range(2, N+1):
  upp[i]=upp[i-1]*i
  upp[i]%=MOD
  
a=[0]*(N-1)
a[0]=upp[N-1]
for i in range(1, N-1):
  a[i]=a[0]*pow(i+1, MOD-2, MOD)
  a[i]%=MOD

b=[0]*(N-1)
b[0]=a[0]
for i in range(1, N-1):
  b[i]=b[i-1]+a[i]
  b[i]%=MOD
  
def moddot(v1, v2):
  n=len(v1)
  out=0
  for i in range(n):
    out+=v1[i]*v2[i]%MOD
    out%=MOD
  return out
 
ex=moddot(b, y)
print(ex)

Measured memory_bytes: 23120
#include <bits/stdc++.h>
using namespace std;
typedef int ll;
typedef pair<ll, ll> pii;
typedef pair<double,double> pdd;
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) ll(i.size())
#define FOR(i, j, k, in) for (ll i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (ll i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,deque<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif

const ll MOD = 1000000007;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll MAXN = 10003;


struct st {
    ll cnt[20],sz;
    bool sol;
    st(){
        MEM(cnt,0);
        sz = 0;
        sol = false;
    }
    bool operator > (const st &c) {
        if (sz != c.sz) {
            return sz > c.sz;
        } else {
            for (ll i=9;i>=1;i--) {
                if (cnt[i] != c.cnt[i]) {
                    return cnt[i] > c.cnt[i];
                }
            }
        }
        return false;
    }
};
st dp[MAXN];

ll n,m;
ll a[10],mat[] = {0,2,5,5,4,5,6,3,7,6};


/********** Good Luck :) **********/
int main()
{
    IOS();
    cin >> n >> m;
    REP (i,m) {
        cin >> a[i];
    }
    dp[0].sol = true;
    
    REP1 (x,n) {
        st bst;
        REP (i,m) {
            if (x >= mat[a[i]]) {
                st tmp = dp[x-mat[a[i]]];
                if (tmp.sol) {
                    tmp.cnt[a[i]]++;
                    tmp.sz++;
                    if (tmp > bst) {
                        bst = tmp;
                    }
                }
            }
        }
        dp[x] = bst;
    }
    for (ll i=9;i>=1;i--) {
        REP (j,dp[n].cnt[i]) {
            cout << i;
        }
    }
    cout << endl;
    return 0;
}


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

int main(){
 
  int i,l,a[3];
  int second;
  int third;
  
  while(cin>>l){
  	a[i]=l;
    i++;
  }
    
  string yes="YES";
  string no="NO";
  int cnt5=0;
  int cnt7=0;
  int cnt_else=0;
  for(int j=0;j<3;j++){
  	  if(5==a[j]){
      	cnt5++;
      }else if(7==a[j]){
      	cnt7++;
      }else{
        cnt_else;
      }
  }  
  if(cnt5==2&cnt7==1&cnt_else==0){
  	cout<<yes;
  }else{
  	cout<<no;
  }
  return 0;
}

Measured memory_bytes: 256
import java.io.*;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb=new StringBuilder();
		String[] a=null;
		int n=0,x=0,count=0;
        while(true){
        	a=br.readLine().split(" ");
            n=Integer.parseInt(a[0]);
            x=Integer.parseInt(a[1]);
            if(n==0&&x==0) break;
            count=0;
        	for(int i=n;i>0;i--){
            	for(int j=i-1;j>0;j--){
            		int k=x-i-j;
            		if(k<=n && k!=i && k!=j && 0<k && k<j) count++;
            	}
        	}
        	sb.append(count+"\n");
        }
    	System.out.print(sb);
	}
}

Measured memory_bytes: 24548
#include<cstdio>
int n;
int main(){
	scanf("%d",&n);
	for(register int i=1;i<=9;i++){
		for(register int j=1;j<=9;j++){
			if(i*j==n){
				printf("Yes");
				return 0;
			}
		}
	}
	printf("No");
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define MAX(X, Y) (((X) > (Y))? (X) : (Y))
#define MIN(X, Y) (((X) < (Y))? (X) : (Y))
int compare_int(const void *a, const void *b){
  return *(long int*)b - *(long int*)a; // 大きい順
}
// 公約数
long int gcd(long int a, long int b){
  if(b == 0){
    return a;
  }else{
    return gcd(b, a % b);
  }
}
// 最小公倍数 = a * b / 最大公約数
// 公倍数
long int lcm(long int a, long int b){
  return a * b / gcd(a, b);
}



// min
int main(void){

  long int n;
  int k;
  int h[100001];
  long int ans = 0;;

  scanf("%ld%d", &n, &k);
  
  for(long int i = 0; i < n; i++){
    scanf("%d", &h[i]);
    if(h[i] >= k){
      ans++;
    }
  }

  //  fprintf(stderr, "n / 2 = %f\n", 3.0/5.0);
  printf("%ld\n", ans);
  
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using LL = long long;

int main(){
    LL q, h, s, d, N;
    cin >> q >> h >> s >> d >> N;
    LL oneL = min(4*q, 2*q+h);
    oneL = min(oneL, s);
    oneL = min(oneL, 2*h);
    LL twoL = min(oneL*2, d);
    cout << twoL*(N/2)+oneL*(N&1) << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
using namespace std;

int main() {

	double ztmp[3] = {}, n, x[100], y[100], d[4] = {}, atmp[100] = {};
	cin >> n;

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

	for (double p = 1; p < 4; p++) {
		for (int i = 0; i < n; i++){
			ztmp[int(p - 1)] += pow(fabs(x[i] - y[i]), p);
			atmp[i] = fabs(x[i] - y[i]);
		}
		d[int(p - 1)] = pow(ztmp[int(p - 1)], 1.0 / p);
	}

	sort(atmp, atmp + int(n));
	d[3] = atmp[int(n) - 1];

	for (int i = 0; i < 4; i++){
		cout << setprecision(10) << d[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 3476
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll, vl/*, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll &b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll &b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
ll num, ans=0, count=0, sum=0;

int main() {
  ll X, Y, Z;
  cin >> X >> Y >> Z;
  cout << Z << " " << X << " " << Y << endl;
  return 0;
}

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

using namespace std;

#define REP(var, count) for(int var=0; var<count; var++)

struct unionf {
	
	vector<int> data;
	
	unionf(int n) {
		REP(i, n+1) { data.push_back(i); }
	}
	
	int root(int a) {
		if(data[a] == a) { return a; }
		return (data[a] = root(data[a]));
	}
	
	bool issame(int a, int b) {
		return root(a) == root(b);
	}
	
	void unite(int a, int b) {
		data[root(a)] = root(b);
	}

};

int main(void) {
	int N;
	cin >> N;
	
	vector<pair<int, pair<int, int> > > edge;
	
	REP(x, N) {
		REP(y, N) {
			int c;
			cin >> c;
			if ( x <= y ) { continue; }
			if ( c == -1 ) { continue; }
			edge.push_back( make_pair(c, make_pair(x,y)) );
		}
	}
	
	sort(edge.begin(), edge.end());
	
	unionf uf(N);
	
	int cnt = 0;
	int ret = 0;
	
	REP(i, edge.size() ) {
		
		pair<int, int> sd = edge[i].second;
		if ( ! uf.issame( sd.first, sd.second ) ) {
			cnt ++;
			ret += edge[i].first;
			uf.unite(sd.first, sd.second);
			//cout << "joint " << sd.first << " " << sd.second << " -> " << edge[i].first << endl;
		}
		
		if ( cnt == N-1 ) { break; }
	}
	
	cout << ret << endl;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

//制約により、Sに0は含まれない
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    string s;
    cin>>s;

    ll ten=1;
    ll n = 0;
    unordered_map<ll, ll> mp;
    mp[0] = 1;
    FORR(i,0,s.size()){
        n = (n + ((s[i]-'0') * ten)) % 2019;
        ten *= 10;
        ten %= 2019;
        mp[n]++;
    }

    ll ans=0;
    for(auto& p : mp){
        //DEBUG2(p.first, p.second);
        ans += p.second * (p.second-1) / 2;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3748
#include <stdio.h>
int main(void){
    // Your code here!
    int n,i,j;
    while (scanf("%d", &n) != EOF){
        int a[n], sum=0;
        a[0]=0;
        for(i=1;i<n;i++){
            a[i]=1;
        }
        for(i=1;i<n;i++){
            if(a[i-1]==1){
                    for(j=2;i<i;j+=i){
                        if(i %j==0){
                            a[i-1]=0;
                            break;
                        }
                }
                for(j=i*2; j<=n; j+=i){
                    a[j-1]=0;
                }
            }
            if(a[i]){
                sum++;
            }
        }
        printf("%d\n",sum);
        
    }
    return 0;
}



Measured memory_bytes: 5620
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String s =sc.next();
		for(int i = 0;i < s.length();i++) {
			if(s.charAt(i) == 'R') {
				if((i+1) % 2 == 0) {
					System.out.println("No");
					System.exit(0);
				}
			}
			if(s.charAt(i) == 'L') {
				if((i+1) % 2 == 1) {
					System.out.println("No");
					System.exit(0);
				}
			}
		}
		System.out.println("Yes");
		
	}

}


Measured memory_bytes: 21716
S = input()
N = len(S)
aL = [0] * N
l = 0
for i in range(N):
    if S[i] == 'L':
        l += 1
        aL[i] = l
    else:
        l = 0
aR = [0] * N
r = 0
for i in range(N - 1, -1, -1):
    if S[i] == 'R':
        r += 1
        aR[i] = r
    else:
        r = 0
ans = [0] * N
for i in range(N):
    if S[i] == 'R':
        ans[i + 2 * (aR[i] // 2)] += 1
    else:
        ans[i - 2 * (aL[i] // 2)] += 1
print(*ans)
#RRRLLRLLRRRLLLLL
#3210010032100000
#0001201200012345


Measured memory_bytes: 11120
s = list(input())
count = 0
n = len(s)
if n % 2 == 0:
    for i in range(0,int(n/2)):
        if s[(2*i)+1] == "0":
            count = count + 1
    for j in range(0,int(n/2)):
        if s[2*j] == "1":
            count = count + 1
else:
    for i in range(0,int((n-1)/2)+1):
        if s[2*i] == "0":
            count = count + 1
    for j in range(0,int(((n-1)/2))):
        if s[2*j + 1] == "1":
            count = count + 1
count2 = n - count
print(min(count,count2))

Measured memory_bytes: 3956
#include <cstdio>

int N, S;

int main() {
	scanf("%d", &N);
	S = N & 1 ? N : N + 1;
	printf("%d\n", N * (N - 1) / 2 - N / 2);
	for (int i = 1; i < N; ++i)
		for (int j = i + 1; j <= N; ++j)
			if (i + j != S) printf("%d %d\n", i, j);
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> L(2*N);
  for(int i = 0; i < 2 * N; i++){
    cin >> L[i];
  }
  sort(L.begin(),L.end());
  int ans=0;
  for(int i = 0; i < 2 * N; i +=2){
    ans += L[i];
  }
  cout << ans << endl;
}


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
const int MOD=1000000007;
const int INF=LLONG_MAX/2;

signed main() {cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    int n;
    cin>>n;
    Vi a(n);
    REP(i,0,n) cin>>a[i];
    
    int count=0;
    REP(i,0,n){
        if(a[i]!=i+1) count++;
    }
    if(count<=2) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

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

int main() {
  string S;
  cin >> S ;
 
 if(S == "Sunny" ){
  cout << "Cloudy" << endl;
}else  if(S == "Cloudy" ){
  cout << "Rainy" << endl;
}else if(S == "Rainy" ){
  cout << "Sunny" << endl;
}
}


Measured memory_bytes: 256