akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
int prime(int);
int p[1000001]={};
int main(){
	int n,x,v[30],i,j,o,a;
	while(1){
		memset(p,0,sizeof(p));
		memset(v,0,sizeof(v));
		scanf("%d %d",&n,&x);
		if(n==0&&x==0){
			break;
		}
		for(i=0;i<n;i++){
			scanf("%d",&v[i]);
			p[v[i]]=1;
		}
		for(i=0;i<=x;i++){
			if(p[i]){
				for(j=0;j<n;j++){
					if(i+v[j]<=x){
						p[i+v[j]]=1;
					}
				}
			}
		}
		o=0;
		for(i=x;i>=0;i--){
			if(p[i]){
				if(prime(i)){
					o=1;
					break;
				}
				
			}
		}
		if(o){
			printf("%d\n",i);
		}
		else{
			printf("NA\n");
		}
	}
	return 0;
}
int prime(int x){
	int i;
	if(x<2) return 0;
	else if(x==2) return 1;
	if(x%2==0) return 0;
	for(i=3;i*i<=x;i+=2){
		if(x%i==0) return 0;
	}
	return 1;
}

Measured memory_bytes: 6504
//binary trees
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
int n,par[30],sib[30],deg[30] = {},dep[30],hei[30],typ[30],chi[30][2];//root=1,internal node=2,leaf=3;//l/r
vector <int> leaf;

int depth(int now){
	if(dep[now] != -1)return dep[now];
	if(par[now] == -1)return 0;
	return dep[now] = depth(par[now])+1;
}
int height(int now){
	if(hei[now] != -1)return hei[now];
	if(deg[now] == 0)return 0;
	else if(chi[now][0] * chi[now][1] < 0){
		if(chi[now][0] != -1)return hei[now] = height(chi[now][0])+1;
		else return hei[now] = height(chi[now][1])+1;
	}
	else return hei[now] = max(height(chi[now][0])+1, height(chi[now][1])+1);
}
 
 
int main(){
	//input,clear
	cin >> n;//node
	for(int i=0; i<n; i++){
		par[i] = -1;
		dep[i] = -1;
		hei[i] = -1;
		chi[i][0] = -1;
		chi[i][1] = -1;
	}

	for(int i=0; i<n; i++){
		int id,le,ri;
		cin >> id >> le >> ri;
		if(le == -1 && ri == -1){
			typ[id] = 3;//no child>>leaf
			hei[id] = 0;
		}
		else{
			typ[id] = 2;
			//親に子のデータ  子に親のデータ
			
			if(le != -1){
				deg[id]++;
				chi[id][0] = le;
				par[le] = id;
				sib[le] = ri;
			}
			if(ri != -1){
				deg[id]++;
				chi[id][1] = ri;
				par[ri] = id;
			    sib[ri] = le;
			}
		}
	}
		//input end


	
	for(int i=0; i<n; i++){
		if(par[i] == -1) {
			typ[i] = 1;//root
			sib[i] = -1;
		}
		cout << "node " << i << ": ";
		cout << "parent = " << par[i] << ", ";
		cout << "sibling = " << sib[i] << ", ";
		cout << "degree = " << deg[i] << ", ";
		cout << "depth = " << depth(i) <<  ", ";
		cout << "height = " << height(i) << ", ";
		if(typ[i] == 1) cout  << "root";
		else if(typ[i] == 2) cout  << "internal node";
		else cout  << "leaf";
		cout << endl;
	}

    return 0;
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  ll n, a, b, c, d;
  string s;
  cin >> n >> a >> b >> c >> d >> s;
  a--; b--; c--; d--;

  bool f;
  // a < c < b < d or a < b < c < d
  if (c < d) {
    f = 1;
    rep(i, d-b) {
      if (s.substr(b+i, 2) == "##") {
        f = 0;
      }
    }
    rep(i, c-a) {
      if (s.substr(a+i, 2) == "##") {
        f = 0;
      }
    }
  // a < b < d < c
  } else {
    f = 0;
    for (ll i = b; i <= d; i++) {
      if (s.substr(i-1, 3) == "...") {
        f = 1;
      }
    }
  }

  if (f) {
    puts("Yes");
  } else {
    puts("No");
  }
}



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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define INF 999999999
#define MOD 1000000007

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};

ll h, w, dp[1001][1001];
string a[1001];

int main(){
	cin >> h >> w;
	for(int i=0;i<h;i++){
		cin >> a[i];
	}
	dp[0][0] = 1;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(a[i+1][j]=='.') dp[i+1][j] = (dp[i][j] + dp[i+1][j]) % MOD;
			if(a[i][j+1]=='.') dp[i][j+1] = (dp[i][j] + dp[i][j+1]) % MOD;
		}
	}
	cout << dp[h-1][w-1] << endl;
	return 0;
}

Measured memory_bytes: 9088
import java.util.*;

public class Main {

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

        double a = sc.nextInt();
        int b = sc.nextInt();
        int x = sc.nextInt();

        double radians;

        if (x > a * a * b / 2) {
            radians = Math.atan(((a * a * b - x) * 2) / Math.pow(a, 3));
        } else {
            radians = Math.atan(a * b * b / (2 * x));
        }

        System.out.println(radians * 180 / Math.PI);
    }
}

Measured memory_bytes: 21716
#include <stdio.h>

int main()
{
    int card13[16] ={0,14,2,3,4,5,6,7,8,9,10,11,12,13};
    int A,B;
    
    scanf("%d %d",&A,&B);
    if(card13[A] > card13[B])
        printf("Alice");
    if(card13[A] < card13[B])
        printf("Bob");
    if(card13[A] == card13[B])
        printf("Draw");
    return 0;
}


Measured memory_bytes: 128
n=int(input())
a=[0]*n
x=[[0]*n for i in range(n)]
y=[[0]*n for i in range(n)]

for i in range(n):
  a[i]=int(input())
  for j in range(a[i]):
    x[i][j],y[i][j]=map(int,input().split())
    x[i][j]-=1
    
def check(honest):
  for i in range(n):
    if not honest[i]:
      continue
    for j in range(a[i]):
      if y[i][j]==1 and not honest[x[i][j]]:
        return False
      if y[i][j]==0 and honest[x[i][j]]:
        return False
  return True

def dfs(honest):
  if len(honest)==n:
    if check(honest):
      return sum(honest)
    else:
      return 0
  return max(dfs(honest + [1]),
             dfs(honest + [0]))
 
print(dfs([]))

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

bool uruu(int y) {
	return y % 3 == 0;
}

int main() {
	int n; cin >> n;
	int days[11] = {20, 19, 20, 19, 20, 19, 20, 19, 20, 19};
	int Days[11];
	for (int i = 0; i < 10; ++i) {
		Days[i] = days[i];
	}
	for (int i = 0; i < 10; ++i) {
		days[i+1] += days[i];
	}
	for (int t = 0; t < n; ++t) {
		int Y, M, D; cin >> Y >> M >> D;
		int ans = 0;
		if (Y < 1000) {
			if (uruu(Y)) {
				ans += 20 * (10-M);
				ans += 20 - D;
			}
			else {
				ans += days[10]-days[M-1];
				ans += Days[M-1] - D;
			}
		}
		while (++Y < 1000) {
			ans += uruu(Y) ? 20*10 : days[10];
		}
		cout << ans+1 << endl;
	}
}

Measured memory_bytes: 1160
import java.util.*;
class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] y = new long[5];
        Arrays.fill(y, 0);
        for(int i = 0; i < n; i++){
            char x = sc.next().charAt(0);
            switch(x){
                case 'M': y[0]++; break;
                case 'A': y[1]++; break;
                case 'R': y[2]++; break;
                case 'C': y[3]++; break;
                case 'H': y[4]++; break;
                default: break;
            }
        }
       long ans = 0;
        for(int i = 0; i < 3; i++)
            for(int j = i+1; j < 4; j++)
                for(int k = j+1; k < 5; k++)
                    ans += y[i] * y[j] * y[k];
        System.out.println(ans);
    }
}

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

using namespace std;

int main() {
    string s;
    cin >> s;
    string::size_type pos = s.find("hi");
    // while(pos != string::npos) {
    //     cout << pos << endl;
    //     pos = s.find("hi", pos+s.length());
    // }
    int flag = 0;
    if (s.length() % 2 == 0) {
        // cout << "even string" << endl;
        for(int i = 0; i < s.length(); i+=2) {
            // cout << s.substr(i,2) << endl;
            if(s.substr(i,2) != "hi") {
                flag = 1;
                break;
            }
        }
        if(flag == 0) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    } else {
        cout << "No" << endl;
    }

    // if(s.find("hi") != string::npos){
    //     cout << "Yes" << endl;
    // } else {
    //     cout << "No" << endl;
    // }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
const int INT_INF = 1001001001;
//stoi(s) : string→int stoll(s) :string→longlong  int→string to_string(i)
const double PI = acos(-1.0);
//小数点の表し方 cout << fixed << setprecision(5);
const ll LLINF = 1e18;

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    ll ans = 1;
    double p = 0;
    for(int i=0;i<n;i++){
        if(a[i] == 0){
            cout << 0 << endl;
            return 0;
        }
        ans *= a[i];
        if(a[i] != 0){p += log10(a[i]);}
    }
    if(p>18 || ans - 1000000000000000000 > 0){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }

}

Measured memory_bytes: 4108
#include <cstdio>

const int mod = 998244353;
const int MAXN = 2e6 + 5;

template<typename _T>
void read( _T &x )
{
	x = 0;char s = getchar();int f = 1;
	while( s > '9' || s < '0' ){if( s == '-' ) f = -1; s = getchar();}
	while( s >= '0' && s <= '9' ){x = ( x << 3 ) + ( x << 1 ) + ( s - '0' ), s = getchar();}
	x *= f;
}

template<typename _T>
void write( _T x )
{
	if( x < 0 ){ putchar( '-' ); x = ( ~ x ) + 1; }
	if( 9 < x ){ write( x / 10 ); }
	putchar( x % 10 + '0' );
}

template<typename _T>
void swapp( _T &x, _T &y )
{
	_T t = x; x = y, y = t;
}

int fac[MAXN], ifac[MAXN];
int N, M;

int qkpow( int, int );
int inv( const int a ) { return qkpow( a, mod - 2 ); }
void add( int &x, const int v ) { x = ( x + v >= mod ? x + v - mod : x + v ); }
int C( const int n, const int m ) { return 1ll * fac[n] * ifac[m] % mod * ifac[n - m] % mod; }
int invC( const int n, const int m ) { return 1ll * ifac[n] * fac[m] % mod * fac[n - m] % mod; }

int qkpow( int base, int indx )
{
	int ret = 1;
	while( indx )
	{
		if( indx & 1 ) ret = 1ll * ret * base % mod;
		base = 1ll * base * base % mod, indx >>= 1;
	}
	return ret;
}

void init( const int siz )
{
	fac[0] = ifac[0] = 1;
	for( int i = 1 ; i <= siz ; i ++ ) fac[i] = 1ll * fac[i - 1] * i % mod;
	ifac[siz] = inv( fac[siz] );
	for( int i = siz - 1 ; i ; i -- ) ifac[i] = 1ll * ifac[i + 1] * ( i + 1 ) % mod;
}

int main()
{
	read( N ), read( M );
	if( N < M ) swapp( N, M );
	init( N + M ); 
	
	int ans = 0, tmp = invC( N + M, N );
	for( int k = 1 ; k <= M ; k ++ )
		add( ans, 499122177ll * C( M - k + N - k, M - k ) % mod * C( 2 * k, k ) % mod * tmp % mod );
	add( ans, N ); write( ans ), putchar( '\n' );
	return 0;
}

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

int N, U[2], M, A[2][500][500];
bool flag[2][500][500] = {{}};
map< int, vector< tuple< int, int, int > > > memo;
int main()
{
  
  scanf("%d %d %d %d", &N, &U[0], &U[1], &M);

  for(int k = 0; k < 2; k++) {
    for(int i = 0; i < N; i++) {
      for(int j = 0; j < N; j++) {
        scanf("%d", &A[k][i][j]);
        memo[A[k][i][j]].emplace_back(k, i, j);
      }
    }
  }
  
  while(M--) {
    int num;
    scanf("%d", &num);
    for(auto& d : memo[num]) {
      int k, i, j;
      tie(k, i, j) = d;
      
      flag[k][i][j] = true;
      bool f1 = true, f2 = true;
      bool f3 = i == j;
      bool f4 = j == N - i - 1;
      for(int l = 0; l < N; l++) {
        f1 &= flag[k][i][l];
        f2 &= flag[k][l][j];
        f3 &= flag[k][l][l];
        f4 &= flag[k][l][N - l - 1];
      }
      U[k] -= f1;
      if(N > 1) {
        U[k] -= f2;
        U[k] -= f3;
        U[k] -= f4;
      }
    }
    if(U[0] <= 0 || U[1] <= 0) {
      if(U[0] <= 0 && U[1] <= 0) break;
      puts(U[1] <= 0 ? "NEKO" : "USAGI");
      exit(0);
    }
  }
  puts("DRAW");
}

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

int main() {
    string s;
    cin>>s;
    int n = s.size();
    int judge = 0;
    rep(i,n/2){
        if(s[i] != s[n-1-i]){
            judge = 1;
        }
    }
    rep(i,n/4){
        if(s[i] != s[n/2-1-i]){
            judge = 1;
        }
    }
    for(int i = (n+3)/2-1;i<n;i++){
        if(s[i] != s[n+(n+3)/2-2-i]){
            judge = 1;
        }
    }
    if(judge == 0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
n = int(input())
a = []
b = []
for _ in range(n):
    a_i, b_i = map(int, input().split())
    a.append(a_i)
    b.append(b_i)
a.sort()
b.sort()


def odd():
    left = a[n//2]
    right = b[-(1 + n//2)]
    return right - left + 1


def even():
    left_x = a[(n//2) - 1]
    right_x = b[-(n//2 + 1)]
    left_y = a[n//2]
    right_y = b[-n//2]
    x_range = right_x - left_x + 1
    y_range = right_y - left_y + 1
    return x_range + y_range - 1


def solve():
    if n % 2 == 1:
        return odd()
    return even()

print(solve())


Measured memory_bytes: 25556
/*
    --------------              |   /
          |                     |  /
          |                     | /
          |             *       |/          |    |         ------            *
          |                     |           |    |        /      \
          |             |       |\          |    |       |       |\          |
       \  |             |       | \         |    |       |       | \         |
        \ |             |       |  \        |    |        \     /   \        |
         V              |       |   \        \__/|         -----     \       |
    */
    #include <bits/stdc++.h>
    using namespace std;
     
    #define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(NULL);
    #define endl '\n'
    #define mem(i,j) memset(i,j,sizeof (i));
    #define F first
    #define S second
    #define pb push_back
    #define mp make_pair
    #define all(a) (a).begin(), (a).end()
    #define bit(s,i) (((s)>>(i))&1LL)
    #define lowbit(x) ((x)&(-(x)))
    #define siz(v) (long long)(v).size()
    typedef int64_t ll;
    typedef uint64_t ull;
    typedef pair<int,int> pii;
    typedef pair<ll, ll> pll;
    const double EPS  = 1e-8;
    const int INF     = 0x3F3F3F3F;
    const int MOD     = 1e9+7;
    const int MAXN    = 2e5+9;
    /*-----------------------------------------------------------------------------------------------------*/
     
    int arr[3][3], has[3][3];
    signed main() {
    	EmiliaMyWife
     
    	for(int i = 0; i < 3; i++) for(int j = 0; j < 3; j++) cin >> arr[i][j];
    	int n, a;
    	cin >> n;
    	while(n--) {
    		cin >> a;
    		for(int i = 0; i < 3; i++) for(int j = 0; j < 3; j++) if(arr[i][j]==a) has[i][j]=1;
    	}
    	bool ans = false;
    	for(int i = 0; i < 3; i++) {
    		bool cur=true;
    		for(int j = 0; j < 3; j++) {
    			cur&=has[i][j];
    		}
    		ans|=cur;
    	}
    	for(int i = 0; i < 3; i++) {
    		bool cur = true;
    		for(int j = 0; j < 3; j++) {
    			cur&=has[j][i];
    		}
    		ans|=cur;
    	}
    	bool cur=true;
    	for(int i = 0; i < 3; i++) {
    		cur&=has[i][i];
    	}
    	ans|=cur;
    	cur=true;
    	for(int i = 0; i < 3; i++) {
    		cur&=has[i][2-i];
    	}
    	ans|=cur;
    	cout << (ans?"Yes":"No");
     
    	return 0;
    }

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int data[105],d,max,i;
	for(i=0;i<=100;i++)data[i]=0;
	max=0;
	while(scanf("%d",&d)!=EOF){
		data[d]++;
		if(max<data[d]){max=data[d];}
	}
	for(i=1;i<=100;i++){
		if(data[i]==max){printf("%d\n",i);}
	}
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h> 
using namespace std;
#define N 100001
const int mod=1e9+7;
int a[N],inv[N];
int Pow(int p,int q){
    int s=1;
    for(;q;q>>=1,p=1LL*p*p%mod){
    	if(q&1){
    		s=1LL*s*p%mod;
		}
	}
    return s;
}
int main(){
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;++i){
    	cin>>a[i];
	}
    sort(a+1,a+n+1);
    for(int i=1;i<=n;++i){
    	inv[i]=Pow(i,mod-2); 
	}
    long long p=1,ans=a[k];
    for(int i=k+1;i<=n;++i){
         p=p*(i-1)%mod;
         p=p*inv[i-k]%mod;
         ans=(ans+a[i]*p%mod)%mod;
    }
    ans-=a[n-k+1];
    p=1;
    for(int i=k+1;i<=n;++i){
         p=p*(i-1)%mod;
         p=p*inv[i-k]%mod;
         ans=(ans-a[n-i+1]*p%mod)%mod;
    }
    if(ans<0){
    	ans+=mod;
	}
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

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

	//sort(a.begin(),a.end());
	//sort(b.begin(),b.end());
	/*
	5
3 1. 4 1 5
2 7. 1 8 2

3 7 4 7 5
3 7 3 9 3
	*/
	ll sum[2]={};
	for(int i = 0;i<n;i++)
	{
		sum[0] += a[i];
		sum[1] += b[i];
	}
	ll da = sum[1]-sum[0];//足せる回数
	ll db = da;

	for (int i = 0; i < n; ++i)
	{
		if(b[i]-a[i]>0)
		{
			ll d = b[i] - a[i];
			if(d<=0)continue;
			d = (d+1)/2;
			a[i] += d*2;
			da -= d;
		}
	}
	for(int i = 0;i<n;i++)
	{
		ll d = a[i]-b[i];
		b[i] = a[i];
		db -= d;
	}
	//for(int i = 0 ;i<n;++i){cout<<a[i]<<';'<<b[i]<<endl;}cout<<da<<';'<<db<<endl;
	if(da>=0&&db>=0&&da*2==db)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	


	return 0;
}

Measured memory_bytes: 384
# coding=utf-8

import sys
stdin = sys.stdin
def na(): return map(int, stdin.readline().split())
def ns(): return stdin.readline().strip()

def main():
    n,m = na()
    g = []
    for i in range(n):
        g.append([99999999]*n)
    for i in range(n):
        g[i][i] = 0
    es = []
    for i in range(m):
        a,b,c = na()
        es.append((a-1,b-1,c))
        g[a-1][b-1] = c
        g[b - 1][a - 1] = c

    for k in range(n):
        for i in range(n):
            for j in range(n):
                g[i][j] = min(g[i][j], g[i][k] + g[k][j])
    ct = 0
    for e in es:
        if g[e[0]][e[1]] != e[2]:
            ct += 1
    print(ct)
    pass


if __name__ == '__main__':
    main()

Measured memory_bytes: 3444
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int main(){
  string s;
  cin >> s;
  sort(s.begin(), s.end());
  string t;
  cin >> t;
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());
  
  if (s < t) puts("Yes");
  else puts("No");
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
class Main
{

	public static void main(String args[])throws IOException
	{
		int n,count=0 ;
		Scanner sc=new Scanner(System.in);
		n=sc.nextInt();
		int p[]=new int[n];
		int p1[]=new int[n];
      	for(int i=0;i<n;i++)
      	{
      		p[i]=sc.nextInt();
      		p1[i]=p[i];
      	}
      	for (int i = 0; i < n-1; i++) 
            for (int j = 0; j < n-i-1; j++) 
                if (p1[j] > p1[j+1]) 
                { 
                    int temp = p1[j]; 
                    p1[j] = p1[j+1]; 
                    p1[j+1] = temp; 
                } 
		for(int i=0;i<n;i++)
		{
			if(p1[i]!=p[i])
				count++;
			if(count>=3)
				break;
		}
		if(count<=2)
			System.out.println("YES");
		else
			System.out.println("NO");
	}
}

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

int main() {
    int a, b;
    cin >> a >> b;
    int x = 0;
    if ((a + b) % 2 == 0) {
        x = (a + b) / 2;
    } else {
        x = (a + b) / 2 + 1;
    }
    cout << x << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
const int N=10050;
char s[N];
int main()
{
	int n,k;
	scanf("%s %i",s+1,&k);
	n=strlen(s+1);
	vector<int> ds;
	for(int i=1,j;i<=n;i=j)
	{
		for(j=i;j<=n && s[i]==s[j];j++);
		ds.pb(j-i);
	}
	ll ans=0;
	if(ds.size()==1)
	{
		ans=(ll)n*k/2;
	}
	else if(s[1]==s[n])
	{
		int mrg=ds.front()+ds.back();
		ans=(ll)(mrg/2)*(k-1);
		for(int i=1;i+1<ds.size();i++) ans+=(ll)(ds[i]/2)*k;
		ans+=ds[0]/2;
		ans+=ds.back()/2;
	}
	else
	{
		for(int i=0;i<ds.size();i++) ans+=(ll)(ds[i]/2)*k;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k, x, y;
	cin >> n >> k >> x >> y;
	int ans = x * min(n, k) + y * max(0, n - k);
	dunk(ans);
	return 0;
}

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

public class Main 
{
	static class Node
	{
		int i;
		int mark = -999;
		int run = -999;
		HashSet<Node> e = new HashSet<Node>();
		
		public Node(int id)
		{
			i = id;
		}
	}
	
	static int best = -1;
	static int run;
	static int cur = 0;
	static boolean quit = false;


	static Node[] nd;
	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		nd = new Node[n];
		
		for(int i = 0; i<n;i++)
		{
			nd[i]=new Node(i);
		}
		for(int i = 0; i < n; i++)
		{
			String s = sc.next();
			for(int j = 0; j < n; j++)
			{
				if(s.charAt(j) == '1')
					nd[i].e.add(nd[j]);
			}
		}
		
		for(run = 0; run < n; run++)
		{
			quit = false;
//			System.out.println("run " + run);
			
			int pos = run;
			
			LinkedList<Node> q = new LinkedList<>();
			
			q.add(nd[run]);
			nd[run].mark = 1;
			cur = 1;
			nd[run].run = run;
			
			boolean[] listed = new boolean[n];
			listed[run]=true;
			while(!q.isEmpty())
			{
				Node x = q.pollFirst();
//				System.out.println("do " + x.i);
				
				int minad = 99999999;
				int maxad = -99999999;
				int a = 0;
				int b = 0;
				x.run = run;
				for(Node e : x.e)
				{
					if(e.run != run)
					{
						if(!listed[e.i])
						{
							q.add(e);
							listed[e.i]=true;
						}
					}
					else
					{
//						System.out.println("adj with " + e.i);
						minad = Math.min(minad, e.mark);
						maxad = Math.max(maxad, e.mark);
					}
				}
				
				if(minad == maxad || maxad - minad == 2 || minad == 99999999)
				{
					if(minad==99999999)minad=0;
					x.mark = minad+1;
					cur=Math.max(cur, x.mark);
				}
				else
				{
//					System.out.println("quit " + x.i + " " + minad + " " + maxad);
					quit = true;
					break;
				}
			}
			
			if(!quit)best = Math.max(best, cur);
		}
		
		System.out.println(best);
	}

}


Measured memory_bytes: 29352
#include <bits/stdc++.h>
#define N 2020
#define mod 1000000007
#define ll long long
using namespace std;
inline int read(){
  int x=0,f=1;char ch=getchar();
  while(ch>'9'||ch<'0')ch=='-'&&(f=0)||(ch=getchar());
  while(ch<='9'&&ch>='0')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
  return f?x:-x;
}
ll frac[N*N];
ll fast_pow(ll x, ll y) {
  ll z = 1;
  for (; y; y >>= 1, x = x * x % mod) {
    if (y & 1) {
      z = z * x % mod;
    }
  }
  return z;
}
ll inv(ll x) {
  return fast_pow(x, mod - 2);
}
ll C(ll m, ll n) {
  return frac[m] * inv(frac[n]) % mod * inv(frac[m - n]) % mod;
}
int f[N][N];
int main(int argc, char const *argv[]) {

  frac[0] = 1;
  for (int i = 1; i <= 4000000; ++ i) {
    frac[i] = frac[i - 1] * i % mod;
  }

  int n = read(), k = read();

  if (k == 1) {
    return puts("1"), 0;
  }

  f[0][1] = 1;
  for (int j = 1; j <= n; ++ j) {
    for (int i = 0; i <= j; ++ i) {
      if (i < j) f[i + 1][j] = (f[i + 1][j] + f[i][j]) % mod;
      if (j < n) f[i][j + 1] = (f[i][j + 1] + f[i][j] * C(i + (j + 1) * (k - 1) - 1, k - 2) % mod) % mod;
    }
  }
  printf("%lld\n", f[n][n] * frac[n] % mod);
  return 0;
}
/*
问题转化为拓扑计数问题

颜色顺序最后乘一个阶乘即可，现在要计算的是如下图的拓扑方案数。

| (0)->(0)->(0)->(0)->(0)
|  |    |    |    |    |
|  v    v    v    v    v
| (1)->(2)->(3)->(4)->(5)
|  |    |    |    |    |
|  v    v    v    v    v
| (1)  (2)  (3)  (4)  (5)
|  |    |    |    |    |
|  v    v    v    v    v
| (1)  (2)  (3)  (4)  (5)
|  |    |    |    |    |
|  v    v    v    v    v
| (1)  (2)  (3)  (4)  (5)

只需按照前两行从后往前转移即可。

f[i][j] 表示选了 i 个 0, j 种颜色的方案数。

每次转移相当于加入一个 0 或者加入一列。

|               .-- i ---.
|                (0)->(0)
|                 |    |
|                 v    v
|      (2)->(3)->(4)->(5)
|       |    |    |    |
|       v    v    v    v
|      (2)  (3)  (4)  (5)
|       |    |    |    |
|       v    v    v    v
|      (2)  (3)  (4)  (5)
|       |    |    |    |
|       v    v    v    v
|      (2)  (3)  (4)  (5)
|     `-------- j -------'

f[i+1][j] += f[i][j]
f[i][j+1] += f[i][j] * C(i+j*(k-1)+k-2, k-2)

ans = f[n][n] * n!

*/

Measured memory_bytes: 47488
#include "bits/stdc++.h"
using namespace std;

/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	long long int N, K, Q;
	cin >> N >> K >> Q;
	long long int s[100030] = {0};
	for (int i = 0; i < N; i++) {
		s[i] = K;
	}

	for (int i = 0; i < Q; i++) {
		int a;
		cin >> a;
		s[a-1] = s[a-1] + 1;
	}
	for (int i = 0; i < N; i++) {
		if (s[i] - Q > 0) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
}

Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <stack>
#include <iomanip>
#include <numeric>
#include <bitset>

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

using namespace std;

typedef long long ll;

int h, w;
char maze[30][30];

int bfs(int sx, int sy) {
  int dx[] = {-1, 0, 0, 1};
  int dy[] = {0, -1, 1, 0};

  int dist[30][30];
  rep(i, 30) rep(j, 30) dist[i][j] = -1;

  queue<pair<int, int> > q;
  q.push( make_pair(sx, sy) );
  dist[sy][sx] = 0;

  while (!q.empty()) {
    auto cur = q.front();
    int x = cur.first;
    int y = cur.second;
    q.pop();
    rep(i, 4) {
      int nx = x + dx[i];
      int ny = y + dy[i];
      if (nx < 0 || nx >= w || ny < 0 || ny >= h) {
        continue;
      }
      if ( maze[ny][nx] == '#' ) { continue; }
      if ( dist[ny][nx] != -1  ) { continue; }
      dist[ny][nx] = dist[y][x] + 1;
      q.push( make_pair(nx, ny) );
    }
  }
  int res = -1;
  rep(x, w) {
    rep(y, h) {
      res = max(res, dist[y][x]);
    }
  }
  return res;
}

int main () {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << fixed;

  cin >> h >> w;

  rep(i, h) {
    cin >> maze[i];
  }
  
  int ans = 0;
  rep(sx, w) {
    rep(sy, h) {
      if (maze[sy][sx] != '.') {
        continue;
      }
      int t = bfs(sx, sy);
      ans = max(ans, t);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    a=sort(parseMap(split(readline())))
    ans=0
    if a[1]%2==a[3]%2
        ans+=div(a[3]-a[1],2)
        a[1]=a[3]
    else
        ans+=div(a[3]-a[1]-1,2)
        a[1]=a[3]-1
    end
    if a[2]%2==a[3]%2
        ans+=div(a[3]-a[2],2)
        a[2]=a[3]
    else
        ans+=div(a[3]-a[2]-1,2)
        a[2]=a[3]-1
    end
    sort!(a)
    if a[1]<a[3] && a[2]==a[3]
        ans+=2
    elseif a[1]<a[3] && a[2]<a[3]
        ans+=1
    end
    println(ans)
end
main()

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


int main(){
  string S;
  cin >> S;
  char pre = ' ';
  for(auto& s : S){
    if(s==pre){
      cout << "Bad" << endl;
      return 0;
    }
    pre = s;
  }
  cout << "Good" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int n,W;
ll w[100];
ll v[100];
ll dp[101][10001];

int main(){
	cin >> n >> W;
	rep(i,n)cin >> v[i] >> w[i];
	rep(i,n){
		rep(j,10001){
			if(j - w[i] >= 0)dp[i+1][j] = max(dp[i][j - w[i]] + v[i],dp[i][j]);
			dp[i+1][j] = max(dp[i][j],dp[i+1][j]);
		}
	}
	cout << dp[n][W] << endl;
}




Measured memory_bytes: 10916
N,M = input().split()
N = int(N)
M = int(M)

o_height = input().split()
result = []
for i in range(N):
    result.append(True)

while(M):
    road = input().split()
    if int(o_height[int(road[0])-1]) < int(o_height[int(road[1])-1]):
        result[int(road[0])-1] = False
    elif int(o_height[int(road[0])-1]) == int(o_height[int(road[1])-1]):
        result[int(road[0])-1] = False
        result[int(road[1])-1] = False
    else:
        result[int(road[1])-1] = False
    M-=1



count = 0 
for i in range(len(result)):
    if result[i] == True:
        count+=1
print(count)

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

signed main() {
	int n;
	cin >> n;
	int ans = 0;
	for(int i = 1; i <= n; i+=2){
		int cou = 0;
		for(int j = 1; j <=i; j++){
			if(i%j == 0) cou++;
		}
		if(cou == 8) {
			ans++;
		}
	}
	
	cout << ans << endl;
	return 0;			
}


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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

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

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    double a, b; cin >> a >> b;
    double amin = a / 0.08;
    double amax = (a + 1) / 0.08;
    double bmin = b / 0.1;
    double bmax = (b + 1) / 0.1;
    if(amax <= bmin || bmax <= amin){
        cout << -1 << endl;
    }else if(amin <= bmin){
        if(ceil(bmin) < min(amax, bmax)){
            cout << ceil(bmin) << endl;
        }else{
            cout << -1 << endl;
        }
    }else if(bmin <= amin){
        if(ceil(amin) < min(amax, bmax)){
            cout << ceil(amin) << endl;
        }else{
            cout << -1 << endl;
        }
    }
}

Measured memory_bytes: 256
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N = get_int

if N % 2 == 0
  puts N
else
  puts N * 2
end


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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n; cin >> n;
  vi a(n), b(n), c(n);
  for(int i=0;i<n;++i) {
    cin >> a[i];
    a[i]--;
  }
  for(int i=0;i<n;++i) {
    cin >> b[i];
  }
  for(int i=0;i<n-1;++i) {
    cin >> c[i];
  }

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


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

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int main(){
  string s;
  cin >> s;
  for (int i = 0; i < 3; i++){
    if (s[i] == '1'){
      s[i] = '9';
    }
    else if (s[i] == '9'){
      s[i] = '1';
    }
  }
  cout << s << '\n';
  return 0;
}

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

using namespace std ;

/*ifstream cin ("input") ;
ofstream cout ("output") ;
*/
int main(int argc, char const *argv[])
{
	int n ;
	cin >> n ; 
	int minim = 1 << 30 ; 
	int maxim = 0 ; 
	for (int i = 1 ; i <= n ; ++ i) {
		int x ; 
		cin >> x ;
		minim = min (minim, x) ;
		maxim = max (maxim, x) ; 
	}
	cout << maxim - minim ; 
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

/**
 * A
 */
public class Main {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int[] A = new int[H];

        for(int i=0; i<H; i++) {
            A[i] = sc.nextInt();
        }

        sc.close();

        for (int i = 1; i <= H; i++) {

            StringBuilder sb = new StringBuilder();
            sb.append("node ").append(i).append(": key = ").append(A[i-1]).append(", ");

            if(i != 1) {
                sb.append("parent key = ").append(A[i/2-1]).append(", ");
            }

            if(i*2 <= H) {
                sb.append("left key = ").append(A[i*2-1]).append(", ");
            }

            if(i*2+1 <= H) {
                sb.append("right key = ").append(A[i*2]).append(", ");
            }

            System.out.println(sb);

        }

    }
}


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

class unionfind {
  vector<int> v;

  int size(int n) {
    return -v[root(n)];
  }

  int parent(int n) {
    return v[n] < 0 ? n : v[n];
  }

  int root(int n) {
    return parent(n) == n ? n : v[n] = root(parent(n));
  }

public:
  int component_count;

  unionfind(int n) {
    v.resize(n, -1);
    component_count = n;
  }

  int unite(int a, int b) {
    int ra = root(a);
    int rb = root(b);
    if (ra == rb) return size(ra);
    component_count--;
    if (size(ra) >= size(rb)) {
      v[ra] += v[rb];
      v[rb] = ra;
      return size(ra);
    } else {
      v[rb] += v[ra];
      v[ra] = rb;
      return size(rb);
    }
  }
};

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

  unionfind uf(n);

  for (int i = 0; i < m; i++) {
    int x, y, z;
    cin >> x >> y >> z;
    x--;
    y--;
    uf.unite(x, y);
  }
  cout << uf.component_count << endl;
}


Measured memory_bytes: 640
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <unordered_map>
#define rep(i,a,b) for(auto i=(a);i<(b);i++)
#define per(i,a,b) for(auto i=(a);i>=(b);i--)
#define Min(a,b) ((a) < (b) ? (a) : (b))
#define Max(a,b) ((a) > (b) ? (a) : (b))
#define int_inf 0x3f3f3f3f
#define int_max 2147483647
#define ll_max 9223372036854775807
#define ull_max 18446744073709551615
#define ll_inf 0x7f7f7f7f7f7f7f7f
#define lowbit(x) (x)&(-x)
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define eps 1e-8
#define all(v) (v.begin(),v.end())
#define db double
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const ll mod = 1e9 + 7;
const double pi = acos(-1.0);
const double inf = 1e100;
template<class T>
inline T read()
{
	T x = 0, f = 1; char s = getchar();
	while (s < '0' || s > '9') {if (s == '-')f = -1; s = getchar();};
	while (s >= '0' && s <= '9') {x = (x << 3) + (x << 1) + s - 48; s = getchar();};
	return x * f;
}
template<typename T>
inline void wri(T x)
{
	if (x < 0) {x = -x; putchar('-');};
	if (x / 10) wri(x / 10);
	putchar(x % 10 + 48);
}
template<typename T>
inline void print(T x, char s)
{
	wri(x);
	putchar(s);
}
template<typename T>
T gcd(T a, T b)
{
	return b == 0 ? a : gcd(b, a % b);
}
const int maxn = 5e5;
//关闭流同步就不能手写读入优化啦
ll inv[maxn + 1], f[maxn + 1];
int n, m;
ll quick_pow(ll r, ll k) {
	ll ret = 1;
	while (k) {
		if (k & 1) ret = (ret * r) % mod;
		r = (r * r) % mod;
		k >>= 1;
	}
	return ret;
}
void init() {
	f[0] = 1, f[1] = 1;
	for (int i = 2; i <= maxn; i++) {
		f[i] = (1ll * f[i - 1] * i) % mod;
	}
	for (int i = 2; i <= maxn; i++) {
		inv[i] = quick_pow(f[i], mod - 2);
	}
}
ll A(int n, int m) {
	return f[m] * quick_pow(f[m - n] % mod, mod - 2) % mod;
}
ll C(int n, int m) {
	return f[m] * quick_pow((f[n] * f[m - n]) % mod, mod - 2) % mod;
}
ll cal() {
	ll ans = 0;
	ll mul = 1;
	for (int i = 0; i <= n; i++) {
		ll cur = mul * C(i, n) * C(n - i, m - i) % mod * f[n - i] % mod;
		ans = (ans + cur + mod) % mod;
		mul *= (-1);
	}
	return ans * A(n, m) % mod;
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	init();
	cin >> n >> m;
	cout << cal();
	return 0;
}



Measured memory_bytes: 11468
#include<bits/stdc++.h>
using namespace std;
# define ld long double
int main()
{

	int n,m,s=0;
	cin>>n>>m;
	
	vector<int >v(n);
	
	for(auto &x:v)cin>>x,s+=x;
	
		ld t=(ld)s/(ld)(4*m);
		
		int ans=0;
		for(auto x:v)
		{
			if(x>=t)ans++;
		}
		
		if(ans>=m)cout<<"Yes";
		else
		cout<<"No";


	return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
typedef long long ll;
#define  rep(i,a,b)for(long long i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
const ll INF=1000000000000LL;
const ll r197=1000000007;
typedef pair<int,int>P;
typedef pair<int,P>Pa;
bool Inframe(int a,int b,int c,int d,int h,int w){
	if(a+b>=0&&a+b<h&&c+d>=0&&c+d<w)return true;
	return false;
}

int n,k,p[200005],ans=0;
string str;
priority_queue<long long ,vector<long long> > que;
set<int> st;
bool a=0;
int main() {
	cin>>n>>k;
	int h;
	for(int i=0;i<n;++i){
		cin>>h;
		if(h>=k)++ans;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a, b, c;
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	cin >> a >> b >> c;
	ll x = c - a - b;
	if (x < 0) cout << "No\n";
	else if (4 * a * b < x * x) cout << "Yes\n";
	else cout << "No\n";

	return 0;
}

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

int main()
{
	int a[100000+1],b[100000+1],s[100000+1];
	
	a[0]=0;a[1]=0;s[0]=0;s[1]=0;
	for(int i=2;i<=100000;i++){
		a[i]=1;
		s[i]=0;
	}
	for(int i=2;i<=sqrt(100000);i++){
		if (a[i]==1){
			for(int j=2*i;j<=100000;j+=i) a[j]=0;
		}
	}
	b[0]=0;
	for(int i=1;i<=100000;i++){
		if (i%2==0) b[i]=0;
		else 
			if (a[i]==1 && a[(i+1)/2]==1) b[i]=1;
			else b[i]=0;
		s[i]=s[i-1]+b[i];
	}
	int q,l,r,t;
	cin>>q;
	for(int i=1;i<=q;i++){
		cin>>l>>r;
		t=s[r]-s[l-1];
		cout<<t<<endl;
	}
	return 0;
}

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

int main(){
    string s;
    cin >> s;
    int n = s.size();
    rep(i,n){
        rep(j,n){
            if (i != j && s[i] == s[j]){
                cout << "no" << endl;
                exit(0);
            }
        }
    }
    cout << "yes" << "\n";
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

ll N;

int Solve(int turn){
  string ans = "";
  for (int i = 0; i < turn; i++){
    int now = N % 26;
    char next = now + 'a';
    ans = next + ans;
    N /= 26;
  }
  cout << ans << endl;

  return 0;
}

int main(){
  cin >> N; 
  ll num = 26, turn = 1;
  while (N - num > 0){
    N -= num; num *= 26;
    turn++;
  }
  N--;

  Solve(turn);
  return 0;
}


Measured memory_bytes: 3632
from heapq import heappush, heappop
 
INT_MAX = 10 ** 9
 
 
def main():
  n, m = map(int, input().split())
  ab = (map(int, input().split()) for i in range(m))
  
  g = [[] for i in range(n+1)]
  gp = [INT_MAX] * (n+1)
  gf = [0] * (n+1)
  
  for a, b in ab:
    g[a].append(b)
    g[b].append(a)
  
  h = [(0, 1, 1)]
  
  while h:
    p, a, f = heappop(h)
    if p < gp[a]:
      gp[a] = p
      gf[a] = f
    else:
      continue
    for b in g[a]:
      heappush(h, (p + 1, b, a))
  
  r = gf[2:]
  s = 'Yes' if all(0 < i < INT_MAX for i in r) else 'No'
  print(s)
  if s == 'Yes':
    for i in r:
      print(i)
  
if __name__ == '__main__':
  main()

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

int main(){
    int n;
    cin >> n;
    cout << (n+1)/2 << endl;

    return 0;
}

Measured memory_bytes: 256
function main(input) {
    const args = input.split('\n');
    
    const N = args[0].split('').join(''),
          S = args[1].split('').join('');

    let ans = 1;
    for(let i=1;i<N;i++){
        if(S.charAt(i-1)!==S.charAt(i)) ans++;
    }

    console.log(ans);
}

// 下記必須
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 36224
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
	vector<char> s(10);
	rep(i, 10) {
		cin >> s[i];
	}
	s[3] = '8';
	rep(i, 10) {
		cout << s[i];
	}
	cout << endl;
}	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int x,n;
    cin >> x >> n;
    map<int,int> p;
    for(int i=0;i<n;i++){
        int a;  cin >> a;
        p[a]++;
    }
    
    if(p[x]==0){
        cout << x << endl;
        return 0;
    }
    
    for(int i=0;i<102;i++){
        if(x-i>-1){
            if(p[x-i]==0){
                cout << x-i << endl;
                return 0;
            }
        }
        if(x+i<103){
            if(p[x+i]==0){
                cout << x+i << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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;}

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  int N; cin >> N;
  if (N / 100 == N % 10) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
typedef long long ll;

using namespace std;

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

  if (a > b)
  {
    cout << "a > b" << "\n";
  } else if (a < b)
  {
    cout << "a < b" << "\n";
  } else
  {
    cout << "a == b" << "\n";
  }

  return(0);
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
typedef pair<int,int> par;
int a[300000],n,k;
pair<par,par> dp[300000];
int main()
{
	cin>>n;
	for(int i=0;i<(1<<n);i++) cin>>a[i],dp[i]=mp(mp(a[i],i),mp(-1,-1));
	for(int i=1;i<(1<<n);i++)
	{
		for(int j=0;j<n;j++)
		{
			if(i&(1<<j))
			{
				if((i^(1<<j))==0)
				{
					if(dp[i].fi.fi>=dp[0].fi.fi)
					{
						dp[i].se.fi=dp[0].fi.fi;
						dp[i].se.se=0;
					}
					else
					{
						dp[i].se.fi=dp[i].fi.fi;
						dp[i].se.se=dp[i].fi.se;
						dp[i].fi.fi=dp[0].fi.fi;
						dp[i].fi.se=0;
					}
					continue;
				}
				if(dp[i].fi.fi==dp[i^(1<<j)].fi.fi&&dp[i].fi.se==dp[i^(1<<j)].fi.se) continue;
				if(dp[i].fi.fi<=dp[i^(1<<j)].fi.fi&&dp[i].fi.se!=dp[i^(1<<j)].fi.se)
				{				
					dp[i].se.fi=dp[i].fi.fi;
					dp[i].se.se=dp[i].fi.se;
					dp[i].fi.fi=dp[i^(1<<j)].fi.fi;
					dp[i].fi.se=dp[i^(1<<j)].fi.se;
					if(dp[i].se.fi==dp[i^(1<<j)].se.fi&&dp[i].se.se==dp[i^(1<<j)].se.se) continue;
					if(dp[i].se.fi<=dp[i^(1<<j)].se.fi&&dp[i].se.se!=dp[i^(1<<j)].se.se)
					{
						dp[i].se.fi=dp[i^(1<<j)].se.fi;
						dp[i].se.se=dp[i^(1<<j)].se.se;
					}
					continue;
				}
				else if(dp[i].se.fi==dp[i^(1<<j)].fi.fi&&dp[i].se.se==dp[i^(1<<j)].fi.se) continue;
				if(dp[i].se.fi<=dp[i^(1<<j)].fi.fi&&dp[i].se.se!=dp[i^(1<<j)].fi.se)
				{
					dp[i].se.fi=dp[i^(1<<j)].fi.fi;
					dp[i].se.se=dp[i^(1<<j)].fi.se;
				}
			}
		}
	}
	int mx=0;
	for(int i=1;i<(1<<n);i++)
	{
		mx=max(mx,dp[i].fi.fi+dp[i].se.fi);
		cout<<mx<<endl;
	}
}

Measured memory_bytes: 8724
#include <iostream>
#include <vector>
using ll = long long;
using namespace std;

struct Union_find
{
    vector<int> par;
    vector<int> rank;

    Union_find(int n) : par(n), rank(n)
    {
        for (int i = 0; i < n; i++)
        {
            par[i] = i;
            rank[i] = 0;
        }
    }

    int root(int x)
    {
        return par[x] == x ? x : par[x] = root(par[x]);
    }

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

    void unite(int x, int y)
    {
        x = root(x);
        y = root(y);
        //根にのみランクが保持されればいい
        if (rank[x] < rank[y])
            par[x] = y;
        else
        {
            par[y] = x;
            if (rank[x] == rank[y])
                rank[x]++;
        }
        return;
    }
};

int main(){
    int n, q;
    cin >> n >> q;
    Union_find uf(n);
    int com, x, y;
    for (int i = 0; i < q; i++){
        cin >> com >> x >> y;
        if (com)
            cout << uf.same(x, y) << endl;
        else
            uf.unite(x, y);
    }
}


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

using namespace std;

int main(){

  int n, idx;
  string s;

  cin >> n;
  cin.ignore();

  while(n--){

    getline(cin, s);

    while((idx = s.find("Hoshino", 0)) != string::npos){

      s[idx + 6] = 'a';

    }

    cout << s << endl;

  }

}

Measured memory_bytes: 1204