akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

const int INF = 100000000;
const int MAX_V = 101;

struct edge { int to,cost; };
typedef pair<int, int> P;

int n;
vector<edge> G[MAX_V];
int d[MAX_V];

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

int main() {
  int k; 
  while ( cin >> n >> k, n || k ) {
    for ( int i = 0; i < k; i++ ) {
      int order,a,b,c,d,e;
      cin >> order;
      if ( order == 0 ) {
	cin >> a >> b;
	a--; b--;
	int ans = dijkstra(a,b);
	if ( ans == INF ) cout << -1 << endl;
	else cout << ans << endl;
      } else if ( order == 1 ) {
	cin >> c >> d >> e;
	c--; d--;
	edge ed;
	ed.to = d;
	ed.cost = e;
	G[c].push_back(ed);
	ed.to = c;
	G[d].push_back(ed);
      }
    }
    for ( int i = 0; i < n; i++ ) G[i].clear();
  }
  return 0;
}

Measured memory_bytes: 1252
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <sstream>
#include <stack>
#include <queue>
#include <list>
#include <stdio.h>
#include <algorithm>
#define MAX 50000
#define INF 100000000
using namespace std;
typedef long long ll;
int t[MAX+1],c[21];
struct bags{
	int value;
	int weight;
};
vector<bags> B;
int dp[102][10002];
int main()
{	
	int n,m; 
	struct bags tian;
	cin>>n>>m;
	B.push_back(tian);
	for(int i=1;i<=n;i++)
	{
		struct bags tmp;
		cin>>tmp.value>>tmp.weight;
		B.push_back(tmp);
	}
	for(int i=1;i<=n;i++)
	{
		dp[i][0]=0;
		dp[0][i]=0;
	}
	dp[0][0]=0;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			if(j<B[i].weight)
				dp[i][j]=dp[i-1][j];
			else{
				dp[i][j]=max(dp[i-1][j],dp[i-1][j-B[i].weight]+B[i].value);
			}
		}
	cout<<dp[n][m]<<endl;
}


Measured memory_bytes: 7068
from collections import Counter

# Initializing variables
n = int(input())
s = [input() for i in range(n)]
c = Counter(s)  # This is a dictionary
max_ = max(c.values())  # print(max_) == prints max number of times sth that was said the most was in user input.

# Calculating...
c = sorted([k for k, v in c.items() if v == max_])
for j in c :
    print(j)





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

using namespace std;

int a[10010];
int g[110][110];

int main()
{
	int h , w;
	cin >> h >> w;
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i];
	}
	int x = 1;
	for(int i = 1; i <= h; i++)
	{
		if(i % 2 == 1)
		{
			for(int j = 1; j <= w; j++)
			{
				if(a[x] > 0)
				{
					g[i][j] = x;
					a[x]--;
				}
				else
				{
					x++;
					g[i][j] = x;
					a[x]--;
				}
			}
		}
		else
		{
			for(int j = w; j > 0; j--)
			{
				if(a[x] > 0)
				{
					g[i][j] = x;
					a[x]--;
				}
				else
				{
					x++;
					g[i][j] = x;
					a[x]--;
				}
			}
		}
	}
	for(int i = 1; i <= h; i++)
	{
		for(int j = 1; j <= w; j++)
		{
			cout << g[i][j] << " ";
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
#define rep(i,m,n) for(int i = (m);i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
#define Vec(a) vector <int> a
const int INF = 1 << 20;
const int MOD = 1e9+7;





int main(){
  int n;
  int res[200] = {};
  res[1] = 1;
  rep(i,2,200){
    res[i] = (res[i-1]*(i+2))/(i-1);
    //cout << i  << "  " << res[i] << endl;
  }
  
  //cout << (180/120*179*178*177*176)/(3*2*1) << endl;
  int dp[2000000] = {};
  int dps[2000000] = {};
  REP(i,1e6+1){
    dp[i] = 100;
    dps[i] = 10000000;
  }
  rep(i,1,181){
    dp[res[i]] = 1;
    if(res[i]%2 == 1){
      dps[res[i]] = 1;
    }
  }
  //cout << dps[5] << endl;
  REP(i,1e6+1){
    for(int j = 1;j < 181;j++){
      if(dp[i] != 0){
	dp[i+res[j]] = min(dp[i+res[j]],dp[i]+1);
	
      }
      if(dps[i] != 0){
	if(res[j]%2 == 1)
	  dps[i+res[j]] = min(dps[i+res[j]], dps[i]+1);
	
      }
      
    }
    
  }
  while(cin >> n, n){

    cout << dp[n] << " " << dps[n] << endl; 

  }
  return 0;
}



Measured memory_bytes: 18664
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws Exception {
    try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
      System.out.println(eval(reader.readLine()));
    }
  }

  public static int eval(String numbers) {
    if (numbers.contains("753")) return 0;
    int ans = -1;
    final int window = 3;
    for (int i = 0, length = numbers.length() - window; i <= length; ++i) {
      // variable "x"
      int generated = Integer.parseInt(numbers.substring(i, i + window));
      int d = Math.abs(753 - generated);
      if (ans == -1 || d < ans) {
        ans = d;
      }
    }
    if (ans == -1)
      throw new AssertionError("Unreachable");
    return ans;
  }

}


Measured memory_bytes: 21076
N=int(input())
A=list((input().split()))
direction=0 #方向、上が1,下が-1
number=int(A[0])#初期値
count=0

for i in range (1, N):
    if direction==0:
        if int(A[i])>number:
            direction=1
        elif  int(A[i])<number:
            direction=-1
        else:
            direction=0
    elif direction==1:
        if int(A[i])<number:
            direction=0
            count+=1
    elif direction==-1:
        if int(A[i])>number:
            direction=0
            count+=1
    number=int(A[i])

count+=1
print(count)

Measured memory_bytes: 11100
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n, i;
int main()
{
	scanf("%d", &n);
	i = n%10;
	if(i == 3) printf("bon");
	else if(i==0 || i==1 || i==6 || i==8) printf("pon");
	else printf("hon");
	return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
int main(){
  int64_t W,H,x,y,A=0;
  cin>>W>>H>>x>>y;
  string S="";
  if(W==x*2&&H==y*2){
    A=1;
  }
  if((W*H)%2){
    S=".5";
  }
  cout<<(W*H)/2<<S<<" "<<A<<endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll n,k;
    cin>>n>>k;
    vector<ll> a(n);
    rep(i,n){
        cin>>a[i];
    }
    chmin(k,100ll);
    while(k--){
        vector<ll> na(n+1,0);
        rep(i,n){
            ll mi=max(0ll,i-a[i]);
            ll ma=min(n-1,i+a[i]);
            na[mi]++;
            na[ma+1]--;
        }
        FOR(i,1,n+1){
            na[i]+=na[i-1];
        }
        rep(i,n){
            a[i]=na[i];
        }
    }
    cout<<a<<endl;
}

Measured memory_bytes: 6340
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const ll mod = 1e9+7;

int main(void){
  int n;
  vector<int> a;
  cin >> n;
  for(int i = 0;i < n;++i){
    int tmp;
    cin >> tmp;
    a.push_back(tmp);
  }
  ll res = 1;
  ll rest = 0;
  for(int i = 0;i < n;++i){
    ++rest;
    if(a[i] < rest*2-1){
      res *= rest;
      res %= mod;
      --rest;
    }
  }
  for(int i = 1;i <= rest;++i){
    res *= i;
    res %= mod;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
#include <iomanip>
#include <iostream>
using namespace std;
using ll = long long;
ll INF = 9999999999999999;

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

int main(void){
    int A,B,C,X,Y; cin >> A >> B >> C >> X >> Y;
    int C2 = C*2;
    
    ll ans = 9999999999999999;
    for(int i = 0; i <= max(X,Y); i++){
        ll cost = C2*i + max((X-i)*A, 0) + max((Y-i)*B, 0);
        ans = min(ans, cost);
    }
    cout << ans << endl;
}


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

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll gcd(ll a,ll b){
  while(b!=0){
    a%=b;
    swap(a,b);
  }
  return a;
}

ll kaizyou(ll N){
  ll num=1;
  for(ll i=1;i<=N;i++){
  num*=i;
  }
  return num;
}

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

ll mod=1e9+7;

int main(){
  ll N,A,B;
  cin >> N >> A >> B;
  ll num=N/(A+B);
  ll ans=0;
  ans+=A*num;
  ll num2=N-((A+B)*num);
  if(num2>A){
    ans+=A;
  }
  else{
    ans+=num2;
  }
  cout << ans << endl;
}
      
  
  
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;
int divr[maxn];
/*ll modexpo(ll a,ll b)
{
     ll res=1LL;
     while(b>0)
     {
          if(b&1)res=(res*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return res;
}*/
void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
 
 
 
 
 














int main()
{
    int n;
    cin>>n;
    map<string,int> m;
    for(int i=0;i<n;i++){
         string t;
         cin>>t;
         m[t]++;
    }
    cout<<m.size();
}
























 
 
 
 
 

















Measured memory_bytes: 19236
from collections import defaultdict, deque
hwsss = [s.rstrip() for s in open(0)]
H,W = map(int, hwsss[0].split())
sss = [[int(c=='#') for c in list(l)] for l in hwsss[1:]]

dhw = [
    [0, 1],
    [1, 0],
    [0, -1],
    [-1, 0],
]

# h,w,dist
dq = deque([(0, 0, 0)])
# h,w
queued = {(0, 0)}

fdist = -1
while dq:
    h, w, dist = dq.popleft()
    
    if h == H - 1 and w == W - 1:
        fdist = dist
        break
        
    for dh, dw in dhw:
        nh = h + dh
        nw = w + dw
        ndist = dist + 1

        if (nh,nw) in queued:
            continue
        if not(0 <= nh < H) or not(0 <= nw < W):
            continue
        if sss[nh][nw]:
            continue

        dq.append((nh, nw, ndist))
        queued.add((nh, nw))

if fdist == -1:
    print(-1)
else:
    print(H * W - sum(sum(sss,[])) - fdist - 1)

Measured memory_bytes: 74680
import math
import copy
from copy import deepcopy
import sys
import fractions
import numpy as np
from functools import reduce
# import statistics
import heapq
sys.setrecursionlimit(3000)

# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

n, m = map(int, input().split())
data = list(map(int, input().split()))

data2 = getSomeInputListInt(m)

data2_sorted = sorted(data2, key=lambda x:x[1],reverse=True)

cnt = 0
for i in range(m):
    for j in range(data2_sorted[i][0]):
        data.append(data2_sorted[i][1])
        cnt += 1
        if cnt == n:
            break
    else:
        continue
    break

data.sort()
ans = sum(data[-n:])
print(ans)

Measured memory_bytes: 39280
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 400000;

vector<ll> A;
vector<ll> F;
int N;
ll K;

bool test(ll x) {
	ll s = 0;
	rep(i, N) {
		if (A[i] > x / F[N-1-i]) { s += A[i] - x / F[N-1-i]; }
	}

	
	return s <= K;
}



int main() {

	cin >> N >> K;

	rep(i, N) {
		ll a;
		cin >> a;
		A.push_back(a);
	}

	rep(i, N) {
		ll f;
		cin >> f;
		F.push_back(f);
	}

	sort(A.begin(), A.end());
	sort(F.begin(), F.end());
	
	ll f = -1;
	ll t = 1e18;

	while (t - f > 1) {
		if (test((t + f) / 2)) { t = (t + f) / 2; }
		else { f = (t + f) / 2; }
	}

	cout << t;

	system("PAUSE");

}

Measured memory_bytes: 4848
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;


int main() {
    

    ll n,m;
    cin >> n >> m;
    vector <ll> swi[11];
    ll amari[11] = {};
    for (ll i=1;i<=m;i++){
        ll k;
        cin >> k;
        for(ll j=0;j<k;j++){
            ll tmp;
            cin >> tmp;
            swi[tmp].push_back(i);
        }
    }
    for (ll i=1;i<=m;i++){
        ll tmp;
        cin >> tmp;
        amari[i] = tmp;
    }
//    for(ll i=1;i<=n;i++){
//        cout << i;
//        for(ll j=0;j<swi[i].size();j++){
//            cout << " " << swi[i][j];
//        }
//        cout << endl;
//    }
    ll onOff[11] = {};
    ll swiCount[11] = {};

    ll ans = 0;
    for(ll i=0;i<pow(2,n);i++){
        for (ll j=1;j<=m;j++){
            swiCount[j] = 0;
        }
        ll tmp = i;
        for (ll j=1;j<=n;j++){
            onOff[j] = tmp % 2;
            tmp /= 2;
            if(onOff[j] == 1) {
                for (ll k = 0; k < swi[j].size(); k++) {
                    swiCount[swi[j][k]]++;
                }
            }
        }
//        cout << i;
//        for (ll j=1;j<=n;j++){
//            cout << " " << onOff[j];
//        }
//        cout << endl;
        int flag = 1;
        for (ll j=1;j<=m;j++){
            if(swiCount[j] % 2 != amari[j]){
                flag = 0;
            }
        }
//        if(flag == 1){
//            for (ll j=1;j<=m;j++){
//                cout << swiCount[j] << " ";
//            }
//            cout << endl;
//        }
        ans += flag;
    }
    cout << ans << endl;


}

Measured memory_bytes: 256
#include<stdio.h>

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


    int count = 0;

    for(int i = 0; i < n; i++) {
        if(p[i] != i+1) {
            count++;
        }
    }


    if(count == 2 || count == 0) {
        puts("YES");
    } else {
        puts("NO");
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
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);
}
using P = pair<int, int>;
struct HashPair
{
    inline size_t operator()(const P &p) const
    {
        const auto h1 = hash<int>()(p.first);
        const auto h2 = hash<int>()(p.second);
        return h1 ^ (h2 << 1);
    }
};
int main()
{
    string s, t;
    cin >> s >> t;
    int N = s.size(), M = t.size();
    auto dp = make_v<int>(N + 1, M + 1); //dp[i][j] := s[0],...,s[i]までとt[0],...,t[j]まででできるLCS
    auto prev = make_v<P>(N + 1, M + 1);
    rep(i, N)
    {
        rep(j, M)
        {
            if (s[i] == t[j])
            {
                dp[i + 1][j + 1] = max({dp[i][j] + 1, dp[i + 1][j], dp[i][j + 1]});
            }
            else
            {
                dp[i + 1][j + 1] = max({dp[i + 1][j], dp[i][j + 1]});
            }
        }
    }
    P now = {N, M};
    string ans;
    while (dp[now.first][now.second] > 0)
    {
        auto val = dp[now.first][now.second];
        bool flag1 = false, flag2 = false;
        while (dp[now.first][now.second] == val and now.first > 0)
        {
            now.first--;
        }
        if (dp[now.first][now.second] != val)
        {
            flag1 = true;
            now.first++;
        }
        while (dp[now.first][now.second] == val and now.second >= 0)
        {
            now.second--;
        }
        if (dp[now.first][now.second] != val)
        {
            now.second++;
            flag2 = true;
        }
        ans.push_back(s[now.first - 1]);
        if (flag1)
        {
            now.first--;
        }
        if (flag2)
        {
            now.second--;
        }
    }
    reverse(all(ans));
    cout << ans;
    return 0;
}

Measured memory_bytes: 105984
#include <bits/stdc++.h>
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define mod (int)1e9+7
#define inf (int)1e16
#define rep(i,n) for (int i = 0; i < n; i++)
#define Rep(i,n) for (int i = n; i >= 0; i--)
#define all(vec) vec.begin(),vec.end()
#define vsort(vec) sort(all(vec))
#define vrever(vec) reverse(all(vec));
#define vunsort(vec) vsort(vec); vrever(vec);
#define cend cout<<endl;
#define P pair<int, int>
#define prique priority_queue<P, vector<P>, greater<P>>
using namespace std;
int k,t,ans=0;
int ma=0;
int a[114];
signed main() {
	cin>>k>>t;
	rep(i,t) {
		cin>>a[i];
		ma=max(a[i],ma);
	}
	cout<<max((int)0,ma-1-(k-ma))<<endl;
}


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

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		List<String> inputs = new ArrayList<>();

		while(true) {

			String input = sc.nextLine();
			if(input.equals("0")) break;

			inputs.add(input);

		}
		sc.close();

		for(String input : inputs) {

			int i = 0;

			if(input.charAt(0) == '-') i = 1;

			int ans = 0;
			for (; i < input.length(); i++) {
				ans += Character.getNumericValue(input.charAt(i));
			}

			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 26436
#include <bits/stdc++.h>
#define N 100010
#define pb push_back
#define fi first
#define se second
#define si size()
#define ll long long
#define mp make_pair
#define iter ::iterator
#define all(v) v.begin(), v.end()
#define pp pop_back
#define mapiter map<int, int>::iterator
#define forn(i, n) for(int i = 0; i < n; ++i)
#define forn1(i, n) for(int i = 1; i <= n; ++i)
#define forr(i, n)	for(int i = n - 1; i >= 0; --i)
#define forr1(i, n)	for(int i = n; i >= 1; --i)
#define r0 return 0
#define barnarnar ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define lld long double
#define elif else if
 
const ll inf = 1e12 + 7;
const lld EPS = 0.00000001;
const ll modw = 1e9 + 7;

using namespace std;

int dp[N];
ll a[N];

int main()
{
	barnarnar
	ll n, k;
	ll mn = inf;
	forn(i, N)	dp[i] = -1;
	cin >> n >> k;
	forn1(i, n)	cin >> a[i], mn = min(mn, a[i]);
	for(int i = 0; i < mn; i++)
	{
		dp[i] = 0;
	}
	for(int i = mn; i <= k; i++)
	{
		bool cl = 0;
		forn1(j, n)
		{
			if(i - a[j] >= 0)
			{
				if(!dp[i - a[j]])	cl = 1;
			}
		}
		dp[i] = cl;
	}
	if(dp[k])	cout << "First";
	else	cout << "Second";
	return 0;
}



Measured memory_bytes: 640
<?php
    $a = fgets(STDIN);
    $b = fgets(STDIN);
    $c = fgets(STDIN);
    $d = fgets(STDIN);
    $e = fgets(STDIN);
    $k = fgets(STDIN);
    if($e-$a>$k){
        echo ":(";
    }else{
        echo "Yay!";
    }
?>

Measured memory_bytes: 4604
import java.util.Scanner;

public class Main {

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

		long n = Long.parseLong(sc.next());

		int c = 'a';

		StringBuilder sb = new StringBuilder();
		while (true) {
			long remainder = (n - 1) % 26;
			sb.append((char) (c + remainder));

			n = (n - remainder + 1) / 26;
			if (n == 0)
				break;
		}

		System.out.println(sb.reverse());
	}

}


Measured memory_bytes: 35640
using System;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        new Program().SolveA();
        Console.ReadKey();
    }

    Scanner sc = new Scanner();
    void SolveA()
    {
        string s = sc.Next();

        Console.WriteLine(s.Replace(',', ' '));
    }

    void SolveB()
    {
        
    }

    void SolveC()
    {

    }

    void SolveD()
    {

    }

    // ------------------------------------- //
    int Max(int v1, int v2) { return Math.Max(v1, v2); }
    int Min(int v1, int v2) { return Math.Min(v1, v2); }
    int[][] CreateArray2D(int n1, int n2)
    {
        int[][] ary = new int[n1][];
        for (int i = 0; i < n1; i++) ary[i] = new int[n2];
        return ary;
    }
}
class Scanner
{
    public Scanner() { }
    private string[] buff = null;
    private int bIndex = 0;
    public string Next()
    {
        if (buff == null || bIndex >= buff.Length)
        {
            buff = Console.ReadLine().Split(' ');
            bIndex = 0;
        }
        return buff[bIndex++];
    }
    public int NextInt()
    {
        return int.Parse(Next());
    }
    public long NextLong()
    {
        return long.Parse(Next());
    }
}
class Pair<T, K>
{
    public Pair() { }
    public Pair(T f, K s)
    {
        first = f;
        second = s;
    }
    public T first {get; set;}
    public K second {get; set;}
}

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

public class Main{
	public static void main(String[] args){
		Scanner stdIn = null;
		
		try{
			stdIn = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
			while( stdIn.hasNext() ){
				List<String> list = new ArrayList<String>();
				String str = stdIn.nextLine();
				String[] s1 = str.split(" ");				
			outer:	for(String s_1 : s1){
					String[] s2 = s_1.split(",");
					for(String s_2 : s2){
						String[] s3 = s_2.split("\\.");
						for(String s : s3){
							if( s.length() >= 3 && s.length() <= 6 ){							
								list.add(s);
							}
						}
					}
				}
				for(int i = 0; i < list.size()-1; i++){
					System.out.print(list.get(i) + " ");
				}
				System.out.println(list.get(list.size()-1));
			}
		} finally {
			if( stdIn != null){
				stdIn.close();
			}
		}
	}
}

Measured memory_bytes: 12000
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.function.LongSupplier;

public class Main{ // 

	static class ConsoleScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			try {
				while (!st.hasMoreElements())
					st = new StringTokenizer(br.readLine());
				return st.nextToken();
			} catch (IOException e) {
				throw new AssertionError(e);
			}
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}
	}

	static LongSupplier now = new LongSupplier() {
		private long t = System.currentTimeMillis();

		@Override
		public long getAsLong() {
			long a = t;
			t = System.currentTimeMillis();
			long ans = t - a;
			return ans;
		}
	};

	public static void main(String args[]) {
		ConsoleScanner cin = new ConsoleScanner();
		PrintWriter cout = new PrintWriter(System.out);
		solve(cin, cout);
		cout.flush();
	}

	static int tr(Object... objects) {
		System.out.println("tr:" + Arrays.deepToString(objects));
		return 0;
	}

	private static void solve(ConsoleScanner cin, PrintWriter cout) {
		// assert solve(1) == 1;

		int n = cin.nextInt();

		int[] a = new int[n];
		for (int i = 0; i < a.length; i++)
			a[i] = cin.nextInt();

		now.getAsLong();

		int ans = solve(n, a);
		cout.println(ans);

		assert 0 == tr("elapsed", now.getAsLong());
	}

	private static int solve(int n, int[] a) {
		int ans = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] != i + 1)
				continue;
			ans += 1;
			if (i == n - 1)
				continue;
			if (a[i + 1] == i + 2)
				i += 1;
		}
		return ans;
	}

}


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

using namespace std;

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

  int count = 0;
  for(int i = 0; i < n; i++) {
    while(a[i] % 2 == 0) {
      a[i] /= 2;
      count++;
    }
  }

  cout << count << endl;
}

Measured memory_bytes: 892
#include <iostream>
using namespace std;
int main(){
  long long int N, A, B;
  cin >> N >> A >> B;
  if (N == 1){
    if (A == B) cout << 1 << endl;
    else cout << 0 << endl;
  }else{
    cout << max((N-2)*(B-A) + 1,0ll) << endl;
  }
  return 0;
}


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

int main()
{
     char A[3][3],i,j;
     for(i=0;i<3;i++)
     {
          for(j=0;j<3;j++)
          {
               cin>>A[i][j];
          }
     }

     for(i=0;i<3;i++)
     {
          for(j=0;j<3;j++)
          {
               if(i==j)
               {
                    cout<<A[i][j];
               }
          }
     }

     cout<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;

class dice
{
    public:
    int num[6], new_num[6];
    void refresh();
    void turnN();
    void turnS();
    void turnE();
    void turnW();
};

void dice::refresh(){
    for(int i=0;i<6;i++){
        num[i] = new_num[i];
    }
}

void dice::turnN(){
    new_num[0] = num[1];
    new_num[1] = num[5];
    new_num[2] = num[2];
    new_num[3] = num[3];
    new_num[4] = num[0];
    new_num[5] = num[4];
    
}

void dice::turnS(){
    new_num[0] = num[4];
    new_num[1] = num[0];
    new_num[2] = num[2];
    new_num[3] = num[3];
    new_num[4] = num[5];
    new_num[5] = num[1];
}

void dice::turnE(){
    new_num[0] = num[3];
    new_num[1] = num[1];
    new_num[2] = num[0];
    new_num[3] = num[5];
    new_num[4] = num[4];
    new_num[5] = num[2];
}

void dice::turnW(){
    new_num[0] = num[2];
    new_num[1] = num[1];
    new_num[2] = num[5];
    new_num[3] = num[0];
    new_num[4] = num[4];
    new_num[5] = num[3];
}



int main(){
    dice a;
    
    for(int i=0;i<6;i++){
        cin >> a.num[i];
    }
    char dir;
    while(scanf("%c", &dir) != EOF){
        if(dir == 'N'){
            a.turnN();
            a.refresh();
        }else if(dir == 'S'){
            a.turnS();
            a.refresh();
        }else if(dir == 'E'){
            a.turnE();
            a.refresh();
        }else if(dir == 'W'){
            a.turnW();
            a.refresh();
        }
    }
    
    cout << a.num[0] << endl;
    
    return 0;
}


Measured memory_bytes: 3160
n,m = map(int,input().split())
ks = [list(map(int,input().split())) for x in range(m)]
plis = list(map(int,input().split()))
ans = 0
llis=[]
for x in range(2**n):
    sw_lis = [0]*n
    for y in range(n):
        if ((x >> y)&1):
            sw_lis[y] = 1
    llis.append(sw_lis)
for sw in llis:
    on = 0
    for x in range(m):
        judge = 0
        for i in ks[x][1:]:
            judge += sw[i-1]
        if judge%2 == plis[x]:
            on += 1    
    if on == m:
        ans += 1
print(ans)


Measured memory_bytes: 3188
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
typedef pair<pii, ll>pi3;
ll mod = 1000000007;
int main()
{
	int a, b;
	cin >> a >> b;
	//cout << r << endl;
	printf((a*b%2==0) ? "Even\n" : "Odd\n");
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		String weather = sc.next();
		
		if(weather.equals("SSS")) {
			System.out.println(0);
			return;
		}
		
		if(weather.equals("RRR")) {
			System.out.println(3);
			return;
		}
		
		if(weather.equals("RRS")||weather.equals("SRR")) {
			System.out.println(2);
			return;
		}
		
		System.out.println(1);


		
	}
}

Measured memory_bytes: 35564
#include <bits/stdc++.h>
using namespace std;
int mp[5][5],a[5][5];
int n,score[5],ans;
int dx[]={0,0,-1,1},dy[]={1,-1,0,0};


int mark(int x,int y,int dep,int i){
  int res=dep;
  int nx=x+dx[i],ny=y+dy[i];
  if(dep>=3)mp[y][x]=-1;
  if(nx<0||ny<0||nx>=5||ny>=5||a[ny][nx]!=a[y][x])return res;
  res=mark(nx,ny,dep+1,i);
  if(3<=res) mp[y][x]=-1;
  return res;
}

void erase(){
  int f=1;
  while(f){
    f=0;
    for(int i=1;i<5;i++)
      for(int j=0;j<5;j++)
	if(mp[i][j]==-1&&mp[i-1][j]!=-1)f=1, swap(mp[i][j],mp[i-1][j]);
  }
}


int cal(){
  int tmp[5][5];
  for(int i=0;i<5;i++)for(int j=0;j<5;j++)tmp[i][j]=mp[i][j];
  int b=1,res=0;

  while(1){
    int cnt=0,f=1;
    for(int i=0;i<5;i++)
      for(int j=0;j<5;j++) a[i][j]=mp[i][j]; 

    for(int i=0;i<5;i++)
      for(int j=0;j<5;j++)
	for(int k=0;k<4&&a[i][j]!=-1;k++)
	  if(mark(j,i,1,k)>=3)mp[i][j]=-1,f=0;
	
    int used[5]={};
    for(int i=0;i<5;i++)
      for(int j=0;j<5;j++)used[a[i][j]-1]+=a[i][j]!=mp[i][j];
   
    for(int i=0;i<5;i++) res+=used[i]*score[i]*b;
    b++;
    erase();
    if(f)break;
  }
  for(int i=0;i<5;i++)
    for(int j=0;j<5;j++) mp[i][j]=tmp[i][j];
  return res;
}

void saiki(int x,int y,int dep){
  ans=max(ans,cal());
  if(dep==n)return ;  
  for(int i=0;i<4;i++){
    int nx=x+dx[i],ny=y+dy[i];
    if(nx<0||ny<0||nx>=5||ny>=5)continue;
    swap(mp[y][x],mp[ny][nx]);
    saiki(nx,ny,dep+1);
    swap(mp[y][x],mp[ny][nx]);
  }
}

int main(){

  while(1){
    cin>>n;
    if(n==-1)break;
    for(int i=0;i<5;i++)for(int j=0;j<5;j++) cin>>mp[i][j];
    for(int i=0;i<5;i++)cin>>score[i];
    ans=0;
    for(int i=0;i<5;i++)
      for(int j=0;j<5;j++)saiki(i,j,0);

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

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

public class Main {

  void solve(InputReader in, PrintWriter out) {
    out.println(in.nextInt() == in.nextInt() ? "Yes" : "No");
  }

  public static void main(String[] args) throws Exception {
    InputReader in = new InputReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    Main solver = new Main();
    solver.solve(in, out);
    out.close();
  }

  static class InputReader {
    BufferedReader in;
    StringTokenizer st;

    public InputReader(InputStream is) {
      in = new BufferedReader(new InputStreamReader(is));
    }

    public String next() {
      try {
        while (st == null || !st.hasMoreTokens()) {
          st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public long nextLong() {
      return Long.parseLong(next());
    }
  }
}


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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

#define MAX 105

int n[MAX], dp[MAX][4][2];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    string s;
    int k;
    cin >> s >> k;

    for (int i=1; i<=s.length(); i++)
        n[MAX-i] = s[s.length()-i] - '0';

    dp[0][0][1] = 1;
    for (int i=1; i<MAX; i++)
        for (int j=0; j<=k; j++) {
            if (j > 0) {
                dp[i][j][0] += dp[i-1][j-1][0] * 9 + (n[i] > 0 ? dp[i-1][j-1][1] * (n[i] - 1) : 0);
                dp[i][j][1] += (n[i] > 0 ? dp[i-1][j-1][1] : 0);
            }
            dp[i][j][0] += dp[i-1][j][0];
            dp[i][j][n[i] == 0] += dp[i-1][j][1];
        }

    cout << dp[MAX-1][k][0] + dp[MAX-1][k][1] << "\n";

    return 0;
}


Measured memory_bytes: 3608
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


fn main() {
    let u: u32 = read();
    if u == 3 || u == 5 || u == 7 {
        println!("YES");
    } else {
        println!("NO");
    }
}

Measured memory_bytes: 4352
#pragma GCC optimize("-O3")

#include <bits/stdc++.h>

#define ll long long

const ll mod = (ll)1e9 + 7;

using namespace std;

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

	if (b == 0) {
		cout << 0 << endl;
	}
	else if ((b - 1) % (a - 1) == 0) {
		cout << (b - 1) / (a - 1) << endl;
	}
	else {
		cout << (b - 1) / (a - 1) + 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import sys

MAX = 1000000


def digit_sum(n, b):
    if n == 0:
        return 0
    else:
        return digit_sum(n // b, b) + n % b


if __name__ == '__main__':
    n = int(input())
    s = int(input())

    if n < s:
        print(-1)
        sys.exit()

    ans = -1

    for b in range(2, min(n + 1, MAX) + 1):
        sm = digit_sum(n, b)
        if sm == s:
            ans = b
            break

    if ans != -1:
        print(ans)
        sys.exit()

    if n + 1 <= MAX:
        print(-1)
        sys.exit()

    for p in reversed(range(1, MAX)):
        if (n - s) % p != 0:
            continue
        b = (n - s) // p + 1
        if b < 2:
            continue
        sm = digit_sum(n, b)
        if sm == s:
            ans = b
            break

    if ans != -1:
        print(ans)
        sys.exit()

    if n == s:
        print(n + 1)
        sys.exit()

    print(-1)


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

int main()
{
    char s ;
    cin >> s ;
    if(isupper(s))
    {
        cout << 'A' << endl ;
    }
    else
    {
        cout << 'a' <<  endl ;
    }
    
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

vector<int> par;
vector<int> rnk;

void init(int N){
  par.resize(N, 0);
  rnk.resize(N, 0);
  REP(i, N){
    par[i] = i;
  }
}

int find(int X){
  if(par[X] == X){
    return X;
  }else{
    return par[X] = find(par[X]);
  }
}

void unite(int X, int Y){
  X = find(X); Y = find(Y);
  if(X == Y) return;
  if(rnk[X] < rnk[Y]){
    par[X] = Y;
  }else{
    par[Y] = X;
    if(rnk[X] == rnk[Y]) rnk[X]++;
  }
}

bool same(int X, int Y){
  return find(X) == find(Y);
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M; cin >> N >> M;
  vector<int> p(N, 0);
  REP(i, N){
    int tmp; cin >> tmp; tmp--;
    p[i] = tmp;
  }
  init(N);
  REP(i, M){
    int x, y; cin >> x >> y; x--; y--;
    unite(x, y);
  }
  int ans = 0;
  REP(i, N){
    if(same(p[i], i)) ans++; // p[i]:行きたい場所、i:今いる場所
  }
  cout << ans << endl;
}

Measured memory_bytes: 1408
#if 0
#endif
#include <cstdio>
#include <algorithm>

inline int input() { int x; scanf("%d", &x); return x; }

const int maxn = 3030;
int head[maxn], nxt[maxn << 1], to[maxn << 1], hp;
bool vis[maxn], win[maxn];
int a[maxn];

inline void add(int u, int v) {
	nxt[++ hp] = head[u];
	head[u] = hp;
	to[hp] = v;
}

void dfs(int u) {
	vis[u] = true;
	for(int i = head[u]; i; i = nxt[i]) {
		if(not vis[to[i]])
			dfs(to[i]);
		if(not win[to[i]])
			win[u] = true;
	}
}

int main() {
	int n = input();
	for(int i = 1; i <= n; i ++)
		a[i] = input();
	for(int i = 1; i < n; i ++) {
		int u = input(), v = input();
		if(a[u] > a[v])
			add(u, v);
		else if(a[u] < a[v])
			add(v, u);
	}
	for(int u = 1; u <= n; u ++)
		if(not vis[u])
			dfs(u);
	for(int u = 1; u <= n; u ++)
		if(win[u])
			printf("%d ", u);
	puts("");
}

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

typedef long long ll;

int N;
string S;

int wt, eA, sB, bt;

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cout.sync_with_stdio(0); cout.tie(0);

	cin >> N;

	for (int i = 0; i < N; ++i) {
		cin >> S;
		int len = S.length();
		if (S[len-1] == 'A') eA++;
		if (S[0] == 'B') sB++;
		if (S[len-1] == 'A' && S[0] == 'B') bt++, eA--, sB--;

		for (int i = 0; i < len-1; ++i) {
			if (S[i] == 'A' && S[i+1] == 'B') wt++;
		}
	}

	if (eA + sB && bt) wt += bt, bt = 0;
	if (bt) wt += bt - 1, bt = 1;
	wt += min(eA, sB);

	cout << wt << endl;
}


Measured memory_bytes: 256
// organize and work - Abhinav IIITA
#include <bits/stdc++.h>
using namespace std;
#define int long long 
void q1(){
	int n;
	cin>>n;
	double even=n/2;
	double odd=n-even;
	double ans=odd/n;
	cout << fixed << setprecision(6) << ans <<endl; 
}
void q2(){
	int n,k,c=0;
	cin>>n>>k;
	while(n--){
	int t; cin>>t;
	if(t>=k)
	c++;
	}
	cout<<c<<endl;
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	t=1;
	while(t--)
	q2();
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAXN	5005
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;
}
int n, m, ind[MAXN], outd[MAXN];
int tot, cnt, home[MAXN];
vector <int> A[MAXN];
bool visited[MAXN];
void work(int pos) {
	if (visited[pos]) return;
	visited[pos] = true;
	home[++tot] = pos;
	cnt += A[pos].size();
	for (unsigned i = 0; i < A[pos].size(); i++)
		work(A[pos][i]);
}
int main() {
	read(n), read(m);
	for (int i = 1; i <= n; i++) {
		int a, b, c, d, inp, outp;
		read(a), read(b), read(c), read(d);
		if (c == 0) inp = a;
		else inp = m + c;
		if (d == 0) outp = m + b;
		else outp = d;
		outd[inp]++; ind[outp]++;
		A[inp].push_back(outp);
		A[outp].push_back(inp);
	}
	for (int i = 1; i <= 2 * m; i++) {
		tot = 0; cnt = 0; work(i);
		if (tot == 0 || cnt == 0) continue;
		bool flg = true;
		for (int i = 1; i <= tot; i++) {
			if (home[i] <= m && ind[home[i]] > outd[home[i]]) {
				printf("NO\n");
				return 0;
			}
			if (home[i] > m && ind[home[i]] < outd[home[i]]) {
				printf("NO\n");
				return 0;
			}
			if (ind[home[i]] != outd[home[i]]) flg = false;
		}
		if (flg) {
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	return 0;
}

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

int main() {
  int n;
  double ans;
  cin >> n;
  vector<double> u(n);
  for(int i=0;i<n;i++) {
    cin >> u.at(i);
  };
  sort(u.begin(),u.end());
  ans=(u.at(0)+u.at(1))/2;
  for(int i=0;i<n-2;i++) {
    ans=(ans+u.at(i+2))/2;
  };
  cout << fixed << setprecision(6);
  cout << ans << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

def main():
    K = int(input())
    A, B = map(int, input().split())
    for i in range(A,B+1):
        if i % K == 0:
            print('OK')
            exit()
    print('NG')


if __name__ == '__main__':
    main()


Measured memory_bytes: 9168
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef long long ll;
struct edge { ll s, t, x; };
typedef pair<int, int> P;
typedef pair<ll,P> event;
const ll MAX = 510000;
const ll MOD = 1000000007;
#define INF (ll)1000000000000

int main() {
  ll dp[1010][10000];
  rep(i,1010){rep(j,10000){dp[i][j]=INF;}}
  int N,M;
  cin>>N>>M;
  vector<ll>key(M);
  vector<ll>money(M);
  rep(i,M){key[i]=0ll;money[i]=0ll;}
  rep(i,M){
    int a,b;
    cin>>a>>b;
    money[i]=a;
    rep(j,b){
      ll c;
      cin>>c;
      c--;
      key[i]+=(1<<c);
    }
  }
  dp[0][0]=0ll;
  ll max=(1<<N);
  rep(i,M){
    rep(j,max){
      dp[i+1][j]=min(dp[i][j],dp[i+1][j]);
      dp[i+1][j|key[i]]=min(dp[i+1][j|key[i]],dp[i][j]+money[i]);
    }
  }
  if(dp[M][max-1]!=INF){
    cout<<dp[M][max-1];
  }
  else{cout<<-1;}
}



Measured memory_bytes: 82560
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

    Int A, B; cin >> A >> B;
    if (B%A == 0) cout << A+B << endl;
    else cout << B-A << endl;
}


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

typedef long long LL;

LL memo[100005];
LL h[100005];
int k = 2;
int n;

LL dp(int idx){
   if(idx == n) return 0LL;
   LL &ret = memo[idx];
   if(ret!=-1) return ret;
   ret = 1e17;
   for(int i=1;i<=k;i++){
      if(idx+i>n) break;
      ret = min(ret,dp(idx+i) + abs(h[idx] - h[idx+i]));
   }
   return ret;
}

int main(){
   memset(memo,-1,sizeof(memo));
   scanf("%d",&n);
   for(int i=1;i<=n;i++) scanf("%lld",&h[i]);
   LL ans = dp(1);
   printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 4992
use std::io;
use std::collections::HashMap;


/// https://beta.atcoder.jp/contests/arc087/tasks/arc087_a
/// **only remove**
fn main() {
    let _ = read_one::<usize>();
    let an = read::<isize>();
    let mut cnt = 0;
    let mut hm = HashMap::new();
    for a in an {
        *hm.entry(a).or_insert(0) += 1;
    }

    for a in hm.keys() {
        let &v = hm.get(a).unwrap();
        cnt += if v < *a { v } else { v - *a };
    }
    println!("{}", cnt);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 12540
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin >> a >> b;
    int arr[3];
    int i;
    int j;
    int ma  = INT_MIN;
    arr[0] = a + a - 1;
    arr[1] = b + b - 1;
    arr[2] = a + b;
    for(i=0;i<3;i++)
    {
        j = arr[i];
        ma = max(ma,j);
    }
    cout << ma;
}

Measured memory_bytes: 3580