akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////
int N;

vector<bool> seen,finished;
vector<int> d;

int dfs (const vector<vector<int>> &G,int v) {
  int y = 0;
  seen[v] = true;
  for (auto nv : G[v]) {
    if (finished[nv]) {
      chmax(y,d[nv]);
      continue;
    }
    if (seen[nv] && !finished[nv]) {
      y = INF;
      continue;
    }
    chmax(y,dfs(G,nv));
  }
  finished[v] = true;
  d[v] = y + 1;
  return y + 1;
}

int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr); //入出力高速化
  cin >> N;
  map<pair<int, int>, int> dic;
  int k = 0;
  rep(i,N-1) {
    for (int j = i+1; j < N; j++) {
      dic.emplace(make_pair(i,j),k);
      k++;
    }
  }

  vector<vector<int>> G(k);
  rep(i,N) {
    int a;
    rep(j,N-1) {
      if (j == 0) {
        cin >> a;
        a--;
      }
      else {
        int b; cin >> b; 
        b--;
        G[dic[minmax(i,a)]].emplace_back(dic[minmax(i,b)]);
        a = b;
      }
    }
  }

  seen.resize(k,false); finished.resize(k,false); d.resize(k);
  int ans = 0;
  rep(i,k) {
    if(finished[i]) continue;
    chmax(ans,dfs(G,i));
  }

  if (ans >= INF) cout << -1 << endl;
  else cout << ans << endl;  
}

Measured memory_bytes: 61056
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		long mod = (long)(1e9+7);
		Scanner input = new Scanner(System.in);
		int N = input.nextInt();
		int K = input.nextInt();
		boolean[] vis = new boolean[N+1];
		int answer = N;
		for (int i = 0; i < K; i++) {
			int num = input.nextInt();
			for (int j = 0; j < num; j++) {
				int snuke = input.nextInt();
				if (!vis[snuke]) {
					answer--;
					vis[snuke]=true;
				}
			}
		}
		System.out.println(answer);
	}
}

Measured memory_bytes: 37324
#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
using namespace std;

template <typename T> bool next_combination(const T first, const T last, int k) {
    const T subset = first + k;
    // empty container | k = 0 | k == n 
    if (first == last || first == subset || last == subset) {
        return false;
    }
    T src = subset;
    while (first != src) {
        src--;
        if (*src < *(last - 1)) {
            T dest = subset;
            while (*src >= *dest) {
                dest++;
            }
            iter_swap(src, dest);
            rotate(src + 1, dest + 1, last);
            rotate(subset, subset + (last - dest) - 1, last);
            return true;
        }
    }
    // restore
    rotate(first, subset, last);
    return false;
}

int main() {
	int N, M, Q;
	cin >> N >> M >> Q;
	vector<tuple<int, int, int, int>> X(Q);
	for (int i = 0; i < Q; i++) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		X.at(i) = make_tuple(d, a, b, c);
	}

	vector<int> A;
	for (int i = 0; i < M; i++) {
		for (int j = 0; j < N; j++){
			A.push_back(i + 1);
		}
	}
	long long max_ans = 0;

	do {
		long long tmp = 0;
		for (int i = 0; i < Q; i++) {
			int score, a, b, c;
			tie(score, a, b, c) = X.at(i);
			if (A.at(b - 1) - A.at(a - 1) == c) {
				tmp += score;
			}
		}
		if (max_ans < tmp) max_ans = tmp;
	} while (next_combination(A.begin(), A.end(), N));

	cout << max_ans << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;
#define PI 3.14159265358979323846264338327950L
void test_case(){
	int a,b,h,m; cin >> a >> b >> h >> m;
	long double rad = PI*2*((long double)h/12.0+((long double)m/60.0)/12.0-(long double)m/60.0);
	long double rsq = (long double)(a*a+b*b)-(long double)(2*a*b)*cos(rad);
	cout<<setprecision(20)<<sqrt(rsq);
}
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int T=1;
	//~ cin >> T;
	while(T--){
		test_case();
	}
	return 0;
}


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

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define read()          freopen("fibsubseq.in","r",stdin)
#define write()         freopen("fibsubseq.out","w",stdout)
#define sf(n)           scanf("%d",&n)
#define sfd(n)          scanf("%lf",&n)
#define sl(x)           scanf("%I64d",&x)
#define sfl(n)          scanf("%lld", &n)
#define sfc(n)          scanf(" %c",&n)
#define sful(n)         scanf("%llu",&n)
#define ull             unsigned long long int
#define endll           pf("\n")
#define pf              printf
#define pi              acos(-1.0)
#define eps             1e-10
#define mem(a,b)        memset(a,b,sizeof(a))
#define pb              push_back
#define xx              first
#define yy              second
#define pii             pair<int, int>
#define pll             pair<ll, ll>
#define MP make_pair
#define ll              long long
#define uniq(a)      a.erase(unique(a.begin(), a.end()), a.end())

bool Check(unsigned int  N,int pos){return (bool)(N & (1LL<<pos));}
ll  Set(unsigned int N,int pos){    return N=N | (1LL<<pos);}
#define cnd tree[idx]
#define lnd tree[idx<<1]
#define rnd tree[(idx<<1)+1]
#define lndp (idx<<1),(b),((b+e)>>1)
#define rndp ((idx<<1)+1),(((b+e)>>1)+1),(e)
#define inf 1999999999
#define MX 100005
#define mod  1000000007
#define mod1 1000000009
#define var    int ii,i,j,n,k,m,z=0,c=0,t,x,y,l,r,mid
//int dx[8]={0,0,1,1,-1,-1,1,-1};  //8 direction
//int dy[8]={1,-1,1,-1,1,-1,0,0};
//int dx[4]={1,-1,0,0};  //4 direction
//int dy[4]={0,0,1,-1};
ll int a[1000006];
int main()
{
    ll var;
    sfl(n);sfl(l);sfl(r);
    c=100000000;m=0;
    while(n%2==0 && l%2==0 && r%2==0 && c>0)
    {
        n/=2;l/=2;r/=2;
        x=l+r,y=n+r,z=n+l;
        n=x,l=y,r=z;
        m++;
        c--;
    }
    if(c>0)
    {
        cout<<m<<endl;
    }
    else cout<<-1<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<string>
#include<iomanip>
#include<cstdio>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MOD 1000000007
#define MAXS(x,y) (x = max(x,y))
#define MINS(x,y) (x = min(x,y))

using namespace std;

typedef long long int ll;

const ll INF=(ll)1e18;


int N;
vector<vector<int> > a;
vector<bool> visited;

vector<vector<ll> > memo;

ll dp(int n, char c, int parent){
  if(c == 'W' && memo[n][0] != 0){
    return memo[n][0];
  }else if(c == 'B' && memo[n][1] != 0){
    return memo[n][1];
  }

  ll ret = 1;
  REP(i,a[n].size()){
    if(a[n][i] == parent)continue;
    if(c == 'W'){
      ret *= (dp(a[n][i], 'B', n) + dp(a[n][i], 'W', n));
      ret %= MOD;
    }else{
      ret *= dp(a[n][i], 'W', n);
      ret %= MOD;
    }
  }

  if(c == 'W'){
    return memo[n][0] = ret;
  }else{
    return memo[n][1] = ret;
  }

}

int main(){
  cin >> N;

  a.resize(N+1);

  memo.resize(N+1);
  FOR(i,1,N+1)memo[i].resize(2);

  visited.resize(N+1);
  FOR(i,1,N+1)visited[i] = false;

  REP(i,N-1){
    int x,y;
    cin >> x >> y;
    a[x].push_back(y);
    a[y].push_back(x);
  }

  ll ans = 0;
  ans += dp(1, 'B', 0);
  ans += dp(1, 'W', 0);

  cout << ans % MOD << endl;

}

Measured memory_bytes: 18176
from collections import deque
h,w=map(int,input().split())
s=[list(input()) for i in range(h)]
def bfs():
    d=[[float("inf")]*w for i in range(h)]
    dx=[1,0,-1,0]
    dy=[0,1,0,-1]
    que=deque([])
    que.append((0,0))
    d[0][0]=0
    while que:
        p=que.popleft()
        if p[0]==h-1 and p[1]==w-1:
            break
        for i in range(4):
            nx=p[0]+dx[i]
            ny=p[1]+dy[i]
            if 0<=nx<h and 0<=ny<w and s[nx][ny]!="#" and d[nx][ny]==float("inf"):
                d[nx][ny]=d[p[0]][p[1]]+1
                que.append((nx,ny))
    return d[h-1][w-1]
ans=h*w
for i in range(h):
    for j in range(w):
        if s[i][j]=="#":
            ans-=1
if 0<bfs()<float("inf"):
    print(ans-bfs()-1)
else:
    print(-1)


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

int main(){
    int m,d;
    cin >> m >> d;
    int ans = 0;
    for(int i = 1; i <= m; i++){
        for(int j = 22; j <= d; j++){
            if(j%10 < 2) continue;
            if(j/10 < 2) continue;
            if((j%10)*(j/10) == i) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    a = list(map(int, readline().split()))
    ans = []
    for i, v in enumerate(a):
        ans.append([i, v])
    ans.sort(key=lambda x: x[1])
    ls = []
    for i in range(n):
        ls.append(ans[i][0] + 1)
    print(*ls)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 67960
#include <iostream>
#include <fstream>
#include <climits>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <cstdio>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <list>
#include <ctime>

#define FOR(i , n)      for(int i = 0 ; i < n ; i++)
#define FORmn(i,m,n)	for(int i = m ; i < n ; i++)
#define FORrev(i,n,m)	for(int i = n - 1 ; i >= m ; i--)
#define ALL(a)			a.begin(),a.end()
#define pii				pair<long long int , long long int>
#define mp(a , b)		make_pair(a , b)

typedef long long int ll; 

using namespace std;

int main() {
	int s , w;
	cin>>s>>w;
	cout<< ((w >= s) ?  "unsafe" : "safe");
	return 0; 
}

Measured memory_bytes: 3592
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
ll p=pow(10,9)+7;
//行列のサイズ
int m;

//DPの更新
vec matmul(vec& dp,mat& mt){
    vec ret(m,0);
    for(int i=0;i<m;i++){
        for(int j=0;j<m;j++)
            ret[i]+=(mt[i][j]*dp[j])%p;
    }
    return ret;
}

//遷移行列の更新
mat update(mat& mt){
    mat ret(m,vec(m,0));
    for(int i=0;i<m;i++){
        for(int j=0;j<m;j++){
            for(int k=0;k<m;k++)
                ret[i][j]+=(mt[i][k]*mt[k][j])%p;
        }
    }
    return ret;
}

//累乗
void matpow(vec& dp,mat& mt,int k){
    m=dp.size();
    while(k>0){
        if(k & 1)dp=matmul(dp,mt);
        mt=update(mt);
        k/=2;
    }
}

vec n(100010),n_rev(100010);

void fuct(int N){
    n[0]=1;int i=1;
    while(i<=N){
        n[i]=((ll)i*n[i-1])%p;
        i++;
    }
}
void fuct_rev(int N){
    n_rev[1]=1;
    vec dp(1);mat mt(1,vec(1));
    for(int i=2;i<=N;i++){
        dp[0]=1;
        mt[0][0]=n[i];
        matpow(dp,mt,p-2);
        n_rev[i]=dp[0];
    }
}

int comb(int N,int r){
    if(r==0 || N==r)return 1;
    return (((n[N]*n_rev[r])%p)*n_rev[N-r])%p;
}

int main(){
    int N;cin>>N;
    fuct(N+1);fuct_rev(N+1);
    int a,R;
    map<int,int> mp;
    for(int i=1;i<=N+1;i++){
        cin>>a;
        if(mp[a]!=0)R=N+mp[a]-i;
        else mp[a]=i;
    }
    for(int i=1;i<=N+1;i++){
        int X=comb(N+1,i);
        int Y;
        if(R>0){
            if(i-1<=R)Y=comb(R,i-1);
            else Y=0;
        }
        else{
            if(i==1)Y=1;
            else Y=0;
        }
        cout<<(X-Y+p)%p<<endl;
    }
    return 0;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 n;
  cin >> n;
  vector<vector<int32>> adj(n);
  REP(i,n-1){
    int32 a,b;
    cin >> a >> b;
    a--;b--;
    adj[a].pb(b);
    adj[b].pb(a);
  }
  vector<int32> dist(n,INF);
  dist[0] = 0;
  queue<int32> que;
  que.push(0);
  while(!que.empty()){
    int32 x = que.front();que.pop();
    for(int32 y : adj[x]){
      if(dist[y] == INF){
        dist[y] = dist[x] + 1;
        que.push(y);
      }
    }
  }
  // REP(i,n)cout << i << " " << dist[i] << endl;
  vector<int32> color(n,-1);
  int32 x = n-1;
  color[n-1] = 1;
  que.push(n-1);
  while(x != 0){
    for(int32 y : adj[x]){
      if(dist[y] < dist[x]){
        x = y;
        break;
      }
    }
    // cout << x << endl;
    que.push(x);
    if(dist[x] <= dist[n-1] / 2){
      color[x] = 0;
    }else{
      color[x] = 1;
    }
  }
  // REP(i,n)cout << i << " " << color[i] << endl;
  while(!que.empty()){
    x = que.front();que.pop();
    for(int32 y : adj[x]){
      if(color[y] == -1){
        color[y] = color[x];
        que.push(y);
      }
    }
  }
  int32 colorCnt[2] = {0,0};
  REP(i,n)colorCnt[color[i]]++;
  // REP(i,n)cout << i << " " << color[i] << endl;
  if(colorCnt[0] > colorCnt[1]){
    cout << "Fennec\n";
  }else{
    cout << "Snuke\n";
  }
  return 0;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define mod 1000000007LL
#define eps 1e-13
// #define PI 3.141592653589793238L
#define INF 1000000011
#define INFLL 1000000000000000011LL
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define fo(i,a,n) for(i = (a); i < (n); i++)
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define sws ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)((a).size())
#define io_file freopen("D:/Coding Problems/Contest/input_file.in", "r", stdin); freopen("D:/Coding Problems/Contest/output_file.out", "w", stdout)

ll modx(ll Base, ll exponent)
{
	ll ans = 1;
	if(Base == 1)
		return Base;
	while(exponent)
	{
		if(exponent & 1)
			ans = (ans * Base)%mod;
		Base = (Base * Base)%mod;
		exponent = exponent >> 1;
	}
	return ans;
}

ll inmodx(ll num)
{
	return (modx(num, mod-2LL));
}

bool cmp(pair < pii, int > a, pair < pii, int > b)//true for a before b
{
	if(a.F.F/300 < b.F.F/300)
		return 1;
	if(a.F.F/300 > b.F.F/300)
		return 0;
	if(a.F.S < b.F.S)
		return 1;
	if(a.F.S > b.F.S)
		return 0;
	if(a.F <= b.F)
		return 1;
	return 0;
}

const int N = (2e5) + 9;
const int M = (N<<2) + 9;
const int LOGN = ((int)log2(N)) + 3;
const int LOGM = ((int)log2(M)) + 3;
const int BUCK = 2*550;
const int SQRT = BUCK+9;

vll dig, temp;

ll digsum(ll n)
{
	ll ans = 0;
	while(n > 0LL)
	{
		ans += (n%10LL);
		dig.pb(n%10LL);
		n /= 10LL;
	}
	reverse(all(dig));
	return ans;
}

void solve()
{
	int i;
	ll n, ans, val;
	cin >> n;
	ans = digsum(n);
	temp = dig;
	temp[0]--;
	fo(i,1,sz(temp))
		temp[i] = 9LL;
	val = 0;
	for(auto x : temp)
		val += x;
	ans = max(ans, val);
	cout << ans << '\n';
	return;
}

int main()
{
	sws;
	clock_t clk;
	clk = clock();
	// io_file;
	// srand (time(NULL));

	//Code heresfhof
	int t = 1, cs;
	cout << fixed << setprecision(9);
	// cin >> t;
	fo(cs,1,t+1)
	{
		// cout << "Case #" << cs << ": ";
		solve();
	}
	// Code ends here

	clk = clock() - clk;
	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
	return 0;
}

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

int main()
{
	int n; cin >> n;
	
	vector<long long> num(5,0);

	for (int i = 0; i < n; i++) {		
		
		string tmp_s;
		cin >> tmp_s;
		if (tmp_s.at(0) == 'M' || tmp_s.at(0) == 'A' || tmp_s.at(0) == 'R' || tmp_s.at(0) == 'C' || tmp_s.at(0) == 'H') {
	
			if (tmp_s.at(0) == 'M') num[0]++;
			else if (tmp_s.at(0) == 'A') num[1]++;
			else if (tmp_s.at(0) == 'R') num[2]++;
			else if (tmp_s.at(0) == 'C') num[3]++;
			else if (tmp_s.at(0) == 'H') num[4]++;
		
		}
	
	}
	
	long long ans = 0;

	ans += num[0] * num[1] * num[2] * 1      * 1;
	ans += num[0] * num[1] * 1      * num[3] * 1;
	ans += num[0] * 1      * num[2] * num[3] * 1;
	ans += 1      * num[1] * num[2] * num[3] * 1;
	ans += num[0] * num[1] * 1      * 1      * num[4];
	ans += num[0] * 1      * num[2] * 1      * num[4];
	ans += 1      * num[1] * num[2] * 1      * num[4];
	ans += num[0] * 1      * 1      * num[3] * num[4];
	ans += 1      * num[1] * 1      * num[3] * num[4];
	ans += 1      * 1      * num[2] * num[3] * num[4];
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
n,q=map(int,input().split())
graph=[[] for i in range(n)]
visited=[False]*n
visited[0]=True
from collections import deque
for i in range(n-1):
    a,b=map(int,input().split())
    a-=1;b-=1
    graph[a].append(b)
    graph[b].append(a)

s=[0]*n
for i in range(q):
    p,x=map(int,input().split())
    s[p-1]+=x
quest=deque([0])#はじめどうせ見るし入れとく
while len(quest)!=0:
    see=quest.popleft()
    for i in graph[see]:
        if visited[i]==True:
            continue
        quest.append(i)
        visited[i]=True
        s[i]+=s[see]
#for i in range(n):
    #print(s[i],end=" ")
print(*s)

Measured memory_bytes: 56112
from collections import deque

n = int(input())
tree = [[] for i in range(n+1)]

for i in range(1,n):
    a, b = map(int, input().split())
    tree[a].append(b)
    tree[b].append(a)

c = list(map(int,input().split()))
#print(c)
#cs = sorted(c, reverse=True)
#print(cs)
cs = sorted(c)
#print(cs)

ansd=[0]*(n)
score=0

stack = deque()
stack.append(1)
ansd[0]=cs.pop()
visitted=[]

while stack:
    cur = stack.popleft()
    visitted.append(cur)
    for v in tree[cur]:
        if v in visitted:
            continue
        stack.append(v)
        ansd[v-1]=cs.pop()
        score += min(ansd[cur-1], ansd[v-1])

print(score)
print(*ansd, sep=' ')
#print(visitted)


Measured memory_bytes: 6168
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

let nk=readInts()
let n=nk[0]
let k=nk[1]
let h=readInts()
var ans=0

for i in h{
  if i>=k {ans+=1}
}

print(ans)

Measured memory_bytes: 17844
#include <vector>
#include <iostream>
using namespace std;
int main() {
	int N, M, C;
	cin >> N >> M >> C;
	vector<int> B(M);
	for (int i = 0; i < M; ++i) {
		cin >> B[i];
	}
	int ans = 0;
	for (int i = 0; i < N; ++i) {
		int val = C;
		for (int j = 0; j < M; ++j) {
			int x;
			cin >> x;
			val += x * B[j];
		}
		ans += (val > 0);
	}
	cout << ans << endl;
	return 0;
}

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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pop pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define b begin()
#define e end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];

	cin>>s;

	f(i,0,strlen(s)-1){
        if(s[i]=='+') count++;
        else if(s[i]=='-') count--;
	}

	cout<<count<<endl;



}


Measured memory_bytes: 256
def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    return gcd(b, a % b)
def resolve():
    a, b, c, d = list(map(int, input().split()))
    lcm = int(c * d / gcd(c, d))
    c_b = b - (b//c + b//d - b//(lcm))
    c_a = (a-1) - ((a-1)//c + (a-1)//d - (a-1)//(lcm))
    print(c_b - c_a)
    
resolve()

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

int main() {
    string s;
    string flag = "No";
    cin >> s;
    if (s.at(0)==s.at(1) && s.at(2)==s.at(3) && s.at(0) != s.at(2)){
        flag = "Yes";
    }
    if (s.at(0)==s.at(2) && s.at(1)==s.at(3) && s.at(0) != s.at(1)){
        flag = "Yes";
    }
    if (s.at(0)==s.at(3) && s.at(1)==s.at(2) && s.at(0) != s.at(1)){
        flag = "Yes";
    }
    cout << flag;
}

Measured memory_bytes: 256
#include <cstdio>
long long num[300005], he[300005];
int main() {
    long long n = 0;
    scanf("%lld", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%lld", &num[i]);
    }
    for (int i = n; i >= 1; i--) {
        he[i] = (he[i + 1] + num[i]) % 1000000007;
    }
    long long ans = 0;
    for (int i = 1; i <= n; i++) {
        //printf("%lld * %lld\n", he[i + 1], num[i]);
        ans = (ans + he[i + 1] * num[i]) % 1000000007;
    }
    printf("%lld\n", ans);
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    if(n == 1) cout << "Hello World" << endl;
    else {
        int a,b;
        cin >> a >> b;
        cout << a+b << endl;
    }
}

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

int c[27], s[366][27], t[366], last[27];
int main()
{
    int D; cin>>D;
    for(int i=1; i<=26; ++i) cin>>c[i];
    for(int i=1; i<=D; ++i)
        for(int j=1; j<=26; ++j)
            cin>>s[i][j];

    auto calc_score=[&](){
        long score=0;
        for(int i=1; i<=26; ++i) last[i]=0;
        for(int d=1; d<=D; ++d) {
            score+=s[d][t[d]];
            last[t[d]]=d;
            for(int i=1; i<=26; ++i) score-=c[i]*(d-last[i]);
        }
        return score;
    };

    for(int i=1; i<=D; ++i) {
        long bestscore=-(1L<<60), typ=1;
        for(int j=1; j<=26; ++j) {
            t[i]=j;
            auto score=calc_score();
            t[i]=0;
            if (bestscore<score) {
                bestscore=score;
                typ=j;
            }
        }
        t[i]=typ;
    }

    for(int i=1; i<=D; ++i) cout<<t[i]<<endl;
}


Measured memory_bytes: 3596
#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++)
int main()
{
    int D;
    cin >>D;

    cout << "Christmas";

    if(D!=25){
        REP(i, 25-D) cout << " Eve" << endl;
    }
    cout << endl;

   return 0;
}

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

using ll = long long;
const ll MOD = 1e9 + 7;

ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    ll N, ans = 0, p, q = 0;
    cin >> N;
    vector<ll> C(N);
    rep(i, N) cin >> C[i];
    if (N == 1) {
        cout << (C[0] * 2) % MOD << endl;
        return 0;
    }
    q = mod_pow(2, N - 2, MOD);
    p = mod_pow(2, N - 1, MOD);
    sort(C.begin(), C.end());
    rep(i, N) {
        ll x = p * C[N - 1 - i];
        x %= MOD;
        ans += x;
        ans %= MOD;
        //cout << i << " " << p << " " << x << " " << ans << endl;
        p += q;
        p %= MOD;
    }
    ans *= mod_pow(2, N, MOD);
    ans %= MOD;
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using vs = vector<string>;
using vb = vector<bool>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    string s = "ACL";
    REP(i, n - 1) s += "ACL";
    cout << s << endl;
}


Measured memory_bytes: 3644
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main(){
    long long A,B,K;
    scanf("%lld" "%lld" "%lld",&A,&B,&K);
    if(A>=K){
        A = A-K;
    }else if(A+B>=K){
        B = A+B-K;
        A = 0;
    }else{
        A = 0;
        B = 0;
    }
    printf("%lld" " %lld",A,B);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <numeric>
#include <cstdlib>
#include <limits>

int main(int argc, char *argv[]){
    constexpr int N_MAX = 8;

    int N, A, B, C;
    std::cin >> N >> A >> B >> C;
    static int L[N_MAX];
    for(int i=0; i<N; ++i){
        std::cin >> L[i];
    }

    int i,j;
    int sup = std::numeric_limits<int>::max();
    int iSup = 1<<(N<<1);
    int mp = sup, tmp;
    int NA, NB, NC;
    int LA, LB, LC;
    int state;
    for(i=0; i<iSup; ++i){
        NA = 0;
        NB = 0;
        NC = 0;
        LA = 0;
        LB = 0;
        LC = 0;
        tmp = 0;
        for(j=0; j<N; ++j){
            state = (i>>(j<<1))&3;
            switch(state){
                case 0: //choose for nothing
                    break;
                case 1: //choose for A
                    ++NA;
                    LA += L[j];
                    break;
                case 2: //choose for B
                    ++NB;
                    LB += L[j];
                    break;
                case 3: //choose for C
                    ++NC;
                    LC += L[j];
                    break;
                default:
                    break;
            }
        }
        if(NA==0 || NB==0 || NC==0){
            tmp = sup;
        }else{
            tmp += std::abs(LA - A) + (NA-1)*10;
            tmp += std::abs(LB - B) + (NB-1)*10;
            tmp += std::abs(LC - C) + (NC-1)*10;
        }
        mp = std::min(mp, tmp);
    }

    std::cout << mp << std::endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
a = [int(input()) for i in range(N)]
next_light = 0 
count = 0 
for i in range(N + 1): 
        next_light = a[next_light] - 1 
        count += 1
        if next_light  == 1:
                break
if count > N:
        print(-1)
else:
        print(count)

Measured memory_bytes: 7084
import java.util.Scanner;


public class Main {
	
	

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

		int n = sc.nextInt();
		int m = sc.nextInt();
		boolean[] broken = new boolean[n+1];
		
		for (int i=0;i<m;i++) {
			broken[sc.nextInt()]=true;
		}
		
		long[] dp = new long[n+1];
		dp[0]=1;
		
		for (int i=1;i<=n;i++) {
			if (broken[i]) {
				dp[i]=0;
			} else {
				if (i==1) {
					dp[i]=1;
				} else {
					dp[i]=(dp[i-1]+dp[i-2])%1_000_000_007;
				}
			}
		}
		System.out.println(dp[n]);
	}
}

Measured memory_bytes: 49004
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <set>
using namespace std;

typedef unsigned int uint;

template <class F, class T>
void convert(const F &f, T &t){
  stringstream ss;
  ss << f;
  ss >> t;
}

long int pow(long int n, int m){
  if(m<=0){
    return 1;
  }else{
    return n * pow(n,m-1);
  }
}

int main(){
  int N;
  cin >> N;
  int a[N];
  for(int i=0; i<N; ++i){
    cin >> a[i];
  }
  int ma;
  sort(&a[0], &a[N]);
  ma = a[N-1];
  bool ans = true;
  int p;
  if(N==2){
    if(!(a[0]==1 && a[1]==1)){
      ans = false;
    }else{
      cout << "Possible" << endl;
      return 0;
    }
  }else if(ma<2){
    if(N>2){
      ans = false;
    }
  }
  if(!ans){
    cout << "Impossible" << endl;
    return 0;
  }
  
  if(ma%2==0){
    if(!(a[0] == ma/2 && a[1] == ma/2+1)){
      ans = false;
    }
    p = 1;
  }else{
    if(!(a[0] == ma/2+1 && a[1] == ma/2+1 && a[2] == ma/2+2)){
      ans = false;
    }
    p = 2;
  }
  if(!ans){
    cout << "Impossible" << endl;
    return 0;
  }
  int now = a[p]-1;
  int count = 2;
  for(; p<N; ++p){
    if(a[p] != now){
      if(a[p] != now+1 || count < 2){
        ans = false;
        break;
      }else{
        now = a[p];
        count = 1;
      }
    }else{
      count++;
    }
  }
  if(count < 2){
    ans = false;
  }
  if(ans){
    cout << "Possible" << endl;
  }else{
    cout << "Impossible" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define prnt(m) for(auto it = m.begin() ; it != m.end() ; ++it){cout<<*it<<endl;}
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define DBG(x) cout<<"# # #     "<<x<<'\n';
#define fri(i,s,n) for(long long i=s;i<n;i++)
#define mod 1000000007LL
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define infy 2e18
#define five 100005;
#define six 1000005;
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//___________________________________________________________________________________________________________________________________________________________
const int N = 3003;
ll dp[N][N][3];
// 0 dont take
// 1 take
// 2 both
int n;
ll a[N];
ll ans;
ll f(int i,int j,int k)
{
       if(j<0){
              return 0;
       }
       if(j==0){
              return n-i+1;
       }
       if(i==n){
              if(j!=0){return 0;}
       }
       if(dp[i][j][k] != -1){return dp[i][j][k];}
       if(k==1){
              dp[i][j][k] = 0;
              dp[i][j][k] += f(i+1,j-a[i],2);
       }
       else{
              dp[i][j][k] = 0;
              dp[i][j][k] += (f(i+1,j-a[i],2) + f(i+1,j,2))%mod2;

       }
       dp[i][j][k] %= mod2;
       return dp[i][j][k];
}
int main(){
       memset(dp,-1,sizeof dp);
       ll s;
       cin>>n>>s;
       arrin(a,n);
       ans = 0;
       fri(i,0,n){
              ans += f(i,s,1)*(i+1);
              ans %= mod2;
       }
       cout<<ans<<endl;
}


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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int k, s;
  std::cin >> k >> s;
  int64_t c = 0;
  for (int64_t i = 0; i <= k; i++) {
    for (int64_t j = 0; j <= k; j++) {
      if (0 <= s - i - j && s - i - j <= k) {
        c++;
      }
    }
  }
  std::cout << c << std::endl;
  return 0;
}

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


int main(){
  int n, k;
  int a[100100];
  int b[100100];
  for(;;){
    cin >> n >> k;
    if(n==0 && k==0) break;
    
    for(int i=0; i<n; i++){
      cin >> a[i];
    }
    b[0] = 0;
    for(int i=0; i<n; i++){
      b[i+1] = b[i] + a[i];
    }
    int mx = -100000;
    for(int i=0; i<n-k+1; i++){
      int s = b[i+k] - b[i];
      if(mx < s) mx = s;
    }
    cout << mx << endl;
  }
  return 0;
}

Measured memory_bytes: 1940
def main():
  n,m,x = list(map(int,input().split()))
  a = list(map(int,input().split()))
  
  for i in range(0,m):
    if a[i]>x:
      if i<m-i:
        print(i)
      else:
        print(m-i)
      break
main()


Measured memory_bytes: 9076
#include <iostream>
#include <vector>

using namespace std;
typedef pair<int, int> P;

const int MAXH = 1010;
const int MAXW = 1010;

int h, w;

string s[MAXH];
bool visited[MAXW][MAXH];
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

bool check(int x, int y) {
  return 0 <= x && x < w && 0 <= y && y < h;
}

void solve() {
  vector<P> cur;
  for (int i=0;i<h;i++) {
    for (int j=0;j<w;j++) {
      if (s[i][j] == '#') {
        cur.push_back(P(i, j));
        visited[i][j] = true;
      }
    }
  }

  vector<P> next;
  int cnt = 0;
  while (cur.size() > 0) {
    for (int i=0;i<cur.size();i++) {
      P p = cur[i];
      for (int j=0;j<4;j++) {
        int nx = p.second + dx[j], ny = p.first + dy[j];
        if (!visited[ny][nx] && check(nx, ny)) {
          visited[ny][nx] = true;
          next.push_back(P(ny, nx));
        }
      }
    }
    cnt++;
    swap(cur, next);
    next.clear();
  }

  cout << (cnt - 1) << endl;
}

int main() {
  cin >> h >> w;
  for (int i=0;i<h;i++) {
    cin >> s[i];
  }
  solve();
}


Measured memory_bytes: 15848
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define ALL(a)			a.begin(), a.end()
#define REP(i, n)		for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)	for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF				2e9
#define MOD				(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)		(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)		(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)	((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)		(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)		(!IsOdd((x)))						
#define	MAX_QWORD		((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI			3.14159265358979323846
typedef long long		ll;
typedef pair<ll, ll>	P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int main()
{
	vector<int> val(3);
	REP(i, 3) cin >> val[i];
	sort(ALL(val));
	
	int ans = 0;
	int sum = val[2] - val[1];
	ans += sum;
	val[1] += sum;
	val[0] += sum;
	
	sum = CeilN(val[2] - val[0], 2);
	val[0] += sum;
	ans += sum / 2;
	if (val[0] != val[1]) ans++;
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] p = new int[n];
        for (int i = 0; i < p.length; i++) {
            p[i] = sc.nextInt();
        }
        int check = 0;
        for (int i = 0; i < p.length; i++) {
            if (p[i] != i + 1) {
                check++;
            }
        }
        if (check == 2 || check == 0) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
        sc.close();
    }
}

Measured memory_bytes: 21716
//                          VIVEK UPADHYAY
//                          MANIT, BHOPAL(M.P)
/**********************************************************************************************/
/**********************************************************************************************/
//                        $$ JAB-TAK TODEGA NHI,
//                           TAB -TAK CHODEGA NHI :D
#include<iostream>
#include<algorithm>
#include<vector>
#include<list>
#include<cstdlib>
#include<unistd.h>
#include<string>
#include<cstring>
#include<stack>
#include<queue>
#include<utility>
#include<cmath>
#include<set>
#include<unordered_map>
#include<cstdio>
#include<map>
#include<numeric>
using namespace std;
#define F first
#define S second
#define mk(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define LINE cout<<"\n" ;
#define ok cout<<"ok\n" ;
#define dbg(x) cout<<#x<<" = "<<(x)<<"\n";
#define fill(A, VAL) memset(A, VAL, sizeof(A))
#define sz(a) ((int) a.size())
typedef long long ll;
const int MAXN = 2*1e5 + 10;
const int MAX = 1e7 + 1 ;
double pi = 3.1415926535897932384626433832795;
const ll inf=1e18 ;
ll mod = 998244353 ;
ll powr(ll a , ll b){ if(b==0) return 1LL ; ll x = powr(a,b/2) ; x = (x*x)%mod ; if(b%2) return ((a%mod)*x)%mod ; return x ;}
ll gcd(ll a , ll b){if(a==0) return b ; return gcd(b%a,a);}
int m[405][405] , H , W;
string s[405] ;
int dx[] = {1 , -1 , 0 , 0};
int dy[] = {0 , 0 , 1 , -1};
bool v[405][405] , mark[405][405];
bool check(int x, int y){
    if(x>=0 && x < H && y >=0 && y < W) return true ;
    return false;
}
ll cntb =0 ,cntw =0 ;
void dfs(int x , int y ) {
    char nxt = (s[x][y]=='.' ?  '#' : '.') ;
    v[x][y]= true;
    if(s[x][y]=='.')cntw++;
    else cntb++ ;
    for(int i =0 ; i < 4 ;i++)
    {
        int ex  = dx[i] + x, ey = dy[i]  + y ;
        //cout<<s[ex][ey]<<" "<<nxt<<endl;
        if(check(ex,ey) && v[ex][ey]==false && s[ex][ey]==nxt){
        
            dfs(ex,ey);
        }
    }
    
    
}
int main () {
    
    cin >> H >> W ;
    for(int i =0 ; i < H ;i++)
        cin >> s[i] ;
    for(int i =0 ; i < 405 ;i++)
        for(int j =0 ; j < 405;j++)
            v[i][j]=false;
    ll ans=0 ;
    for(int i =0 ; i  < H ;i++)
        for(int j =0 ;j < W ;j++)
            if(v[i][j]==false){
                cntb=0;cntw=0;
                dfs(i,j) ;
                /*for(int i =0 ; i < H ;i++)
                {
                    for(int j =0 ; j < W ;j++)
                        cout<<v[i][j]<<" " ;
                    LINE ;
                }
                LINE ; */
                ans+=cntb*cntw;
                
            }
                
    cout<<ans<<endl;
    
    return 0 ;
}


Measured memory_bytes: 13184
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

using namespace std;
const int MX = 1e6;
const int inf = 1e9;
//const int mod = 1e9+7;



using ll = long long;
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
mint(ll x=0):x((x%mod+mod)%mod){}
mint operator-() const { return mint(-x);}
mint& operator+=(const mint a) {
if ((x += a.x) >= mod) x -= mod;
return *this;
}
mint& operator-=(const mint a) {
if ((x += mod-a.x) >= mod) x -= mod;
return *this;
}
mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
mint operator+(const mint a) const { return mint(*this) += a;}
mint operator-(const mint a) const { return mint(*this) -= a;}
mint operator*(const mint a) const { return mint(*this) *= a;}
mint pow(ll t) const {
if (!t) return 1;
mint a = pow(t>>1);
a *= a;
if (t&1) a *= *this;
return a;
 }
mint inv() const { return pow(mod-2);}
mint& operator/=(const mint a) { return *this *= a.inv();}
mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
vector<mint> fac(MX);
vector<mint> ifac(MX);
mint comp(ll a, ll b) {
    return fac[a]/fac[b]/fac[a-b];
}

signed main(){
    ll a, v, b, w, t;
    cin >> a >> v>>b>>w>>t;
    if(a>b) swap(a,b);

    ll aa = v*t+a;
    ll bb= w*t+b;
    if(aa>=bb) {
        cout << "YES" << endl;
    }else cout << "NO" << endl;
    
    return 0;
}


Measured memory_bytes: 18696
#include <bits/stdc++.h>
#include <functional>
#include <iostream>
#define  pb push_back
#define  xx first
#define  yy second
#define PI acos(-1)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define NL printf("\n")
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;


int dp[102][1002];
int inf  = 100000009;
int N,M;
int a[101][101];
int solve(int n, int m){

        if(n>=N || m>=M){
            return inf;
        }

        if(dp[n][m]!=-1) return dp[n][m];

        dp[n][m]=min(solve(n-1,m) , solve(n,m-1))+a[n][m];
        return dp[n][m];
}
int sum[101][101];

int main()
{
      //fast;
     int t=1;
    // cin >> t;

    while(t--)
    {
      int n,m,ans = 0;
      cin >> n >> m;
      ans= (n*(n-1))/2;
      ans +=(m*(m-1))/2;
      cout << ans << endl;

    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cctype>

using namespace std;

typedef long long Board;

const int N = 9;
const Board GOAL = 0x087654321;

struct State {
    Board board;
    int count;
};

queue<State> q;
set<Board> history;

inline void swap(int numpos, int spacepos, Board& board) {
    long long num = (board >> (numpos*4)) & 15;
    board |= num << (spacepos*4);
    board &= ~(15LL << (numpos*4));
}

inline int swap_and_check(int numpos, int spacepos, State s) {
    swap(numpos, spacepos, s.board);
    if (s.board == GOAL) {
        return ++s.count;
    }
    if (history.insert(s.board).second) {
        ++s.count;
        q.push(s);
    }
    return -1;
}

void print(Board b) {
    for (int i = 0; i < N; ++i) {
        printf("%2lld", (b >> (i*4) & 15));
    }
    printf("\n");
}

// OK
int main(void) {

    Board board = 0;
    for (int i = 0, num; i < N; ++i) {
        scanf("%d", &num);
        board |= static_cast<long long>(num) << (i*4);
    }
//    print(GOAL);
//    print(board);

    int count = 0;
    if (board == GOAL) {
        goto END;
    }

    q.push({ board, 0 });
    while (!q.empty()) {
        State s = q.front();
        q.pop();

        int pos = -1;
        while (++pos < N) {
            if (((s.board >> (pos*4)) & 15) == 0) {
                break;
            }
        }

        if (pos < 6) {
            if ((count = swap_and_check(pos + 3, pos, s)) > 0) {
                break;
            }
        }
        if (pos > 2) {
            if ((count = swap_and_check(pos - 3, pos, s)) > 0) {
                break;
            }
        }
        if (pos % 3 < 2) {
            if ((count = swap_and_check(pos + 1, pos, s)) > 0) {
                break;
            }
        }
        if (pos % 3 > 0) {
            if ((count = swap_and_check(pos - 1, pos, s)) > 0) {
                break;
            }
        }
    }

END:
    printf("%d\n", count);

    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
int main(void){
    // Your code here!
    int n;
    ll k; 
    cin >> n >> k;
    vector<int> a(n);
    vector<int> f(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> f[i];
    sort(a.begin(), a.end());
    sort(f.rbegin(), f.rend());
    ll l = -1, r = 1e12;
    while(l+1 < r){
        ll c = (l+r) / 2;
        ll sum = 0;
        rep(i,n)sum += max(0ll, (a[i] - c/f[i]));
        if(sum <= k)r = c;
        else l = c;
    }
    cout << r << endl;
}


Measured memory_bytes: 1792