akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
// #include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <bitset>
using namespace std;
typedef long long LL;
typedef double db;
const int oo=2139063143;
const int N=110;
const int P=1000000007;
const db eps=1e-7;
#define pritnf printf
//char buf[1<<22],*p1=buf,*p2=buf,obuf[1<<22],*O=obuf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
template <typename T>
inline void sc (T &x)
{
    x=0; static int p; p=1; static char c; c=getchar();
    while (!isdigit(c)) { if (c=='-') p=-1; c=getchar(); }
    while ( isdigit(c)) { x=(x<<1)+(x<<3)+(c-48); c=getchar(); }
    x*=p;
}
template <typename T>
inline void print (T x)
{
    if (x< 0) putchar('-'),x=-x;
    if (x>=10) print(x/10);
    putchar(x%10+'0');
}
template <typename T>
inline void pr (T x) { print(x),putchar(' '); }
template <typename T1,typename T2>
void chkmax (T1 &A,T2 B) { A=A>=B?A:B; }
template <typename T1,typename T2>
void chkmin (T1 &A,T2 B) { A=A<=B?A:B; }
int n;
int x[N],y[N],ma=0,dep[N],son[N]; LL f[N],g[N];
bool e[N][N];
void dfs (int u,int fa)
{
	chkmax (ma,dep[u]=dep[fa]+1);
	son[u]=0;
	for (int v=1; v<=n; v++) if (e[u][v]&&v!=fa)
		dfs (v,u),++son[u];
	chkmax (f[dep[u]],son[u]);
}
LL get ()
{
	LL ans=0;
	for (int i=n; i>=1; i--)
		if (f[i]) g[i]=f[i]*g[i+1];
		else g[i]=1;
	for (int i=1; i<=n; i++)
		ans+=(f[dep[i]]-son[i])*g[dep[i]+1];
	for (int i=1; i<=n; i++)
		ans+=dep[i]==ma;
	return ans;
}
int main ()
{
    // freopen (".in","r",stdin);
    // freopen (".out","w",stdout);
	sc(n);
	for (int i=1; i< n; i++)
	{
		sc(x[i]),sc(y[i]);
		e[x[i]][y[i]]=e[y[i]][x[i]]=1;
	}
	LL ans=1e18,mi=1e18;
	for (int i=1; i<=n; i++)
	{
		ma=0; memset (f,0,sizeof (LL)*(n+1)); dfs (i,0);
		if (ma< ans) ans=ma,mi=get ();
		else if (ma==ans) chkmin (mi,get ());
	}
	for (int i=1; i< n; i++)
	{
		e[x[i]][y[i]]=e[y[i]][x[i]]=0;
		ma=0; memset (f,0,sizeof (LL)*(n+1)); dfs (x[i],0),dfs (y[i],0);
		if (ma< ans) ans=ma,mi=get ();
		else if (ma==ans) chkmin (mi,get ());
		e[x[i]][y[i]]=e[y[i]][x[i]]=1;
	}
	pr(ans),pr(mi);

    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
    
        var sc = new Scanner(System.in);
    
        int n = Integer.parseInt(sc.next());
        String c = sc.next();
    
        int r2 = -1;
        int w2 = -1;
        for(int i = 1; i <= n; i++){
            if(c.charAt(i-1) == 'R'){
                r2 = i;
            }else{
                if(w2 == -1){
                    w2 = i;
                }
            }
        }
        if(r2 == -1 || w2 == -1){
            System.out.println(0);
            return;
        }
        var r = new int[n+1];
        var w = new int[n+1];
        for(int i = 1; i <= n; i++){
            if(c.charAt(i-1) == 'R'){
                if(i < w2){
                    r[i] = r[i-1];
                }else{
                    r[i] = r[i-1] +1;
                }
                w[i] = w[i-1];
            }else{
                r[i] = r[i-1];
                if(r2 < i){
                    w[i] = w[i-1];
                }else{
                    w[i] = w[i-1] +1;
                }
            }
        }
        
        int ans = n;
        for(int i = 0; i < n; i++){
            int a = Math.max(r[n] - r[i], w[i]);
            ans = Math.min(a, ans);
        }
        System.out.println(ans);
    }
}

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

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

    int n;
    cin >> n;
    int t = 0, x = 0, y = 0;
    for(int i = 0; i < n; i++){
        int a, b, c;
        cin >> a >> b >> c;
        int dt = a - t;
        int dx = abs(b - x);
        int dy = abs(c - y);

        int nx = dx + dy;
        if(dt % 2 == nx % 2 && dt >= nx);
        else{
            cout << "No" << endl;
            return 0;
        }

        t = a;
        x = b;
        y = c;
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
import collections
from operator import mul
from functools import reduce
N, M = map(int, input().split())

def cmb(n, r):
    r = min(r, n-r)
    if r==0: return 1
    over = reduce(mul, range(n, n-r, -1))
    under = reduce(mul, range(1, r+1))
    return over // under

ps = []
tmp = M
for m in range(2, M+1):
    while tmp % m == 0:
        tmp /= m
        ps.append(m)
    if int(tmp) == 1:
        break
    if m*m > M:
        if N > 1:
            ps.append(M)
        break

ps = collections.Counter(ps)

ans = 1
mod = 10**9+7
for c in ps.values():
    ans *= cmb(c+N-1, c) % mod
    if ans > mod:
        ans %= mod

print(ans)


Measured memory_bytes: 3572
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto W = RD;
	auto a = RD;
	auto b = RD;

	if (a < b)
		writeln(max(b-(W+a), 0));
	else
		writeln(max(a-(W+b), 0));
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 256
a[6]={2,3,5,10,12,15},b[6]={380,550,850,1520,1870,2244},m[51];main(n,d,T){for(n=1;n<51;n++)for(m[n]=9999,d=5;T=n-a[d],~d;d--)if(T>=0&&m[n]>(T=m[T]+b[d]))m[n]=T;for(;scanf("%d",&n),n;)printf("%d\n",m[n/100]);exit(0);}

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

int main() {
  long long n, m;
  cin >> n >> m;
  vector<vector<long long>> ab(n, vector<long long>(2));
  int i;
  for (i = 0; i < n; i++) {
    cin >> ab[i][0] >> ab[i][1];
  }
  sort(ab.begin(), ab.end());
  long long result = 0;
  for (i = 0; m > 0; i++) {
    result += (long long)(ab[i][0] * min(ab[i][1], m));
    m -= ab[i][1];
  }
  cout << result << endl;

  return 0;
}


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

int main() {
	double a, l, x;
	while (~scanf("%lf%lf%lf", &a, &l, &x)) {
		double s1 = (a + l + l) / 2, s2 = (l + l + x) / 2;
		double d = (l + x) / 2;
		printf("%.10lf\n", sqrt(s1*(s1 - a)*(s1 - l)*(s1 - l)) + sqrt(s2*(s2 - d)*(s2 - d)*(s2 - l)) * 2);
	}
}

Measured memory_bytes: 3120
#include<bits/stdc++.h>
/* #define int long long */
/* #define double long double */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
#define MOD 1000000007
using namespace std;
using ll = long long;
typedef vector<int> vi;
typedef pair<int, int> P;
#define rrep(i,a,b) for(int i=a;i>=b;i--)
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; }

const int A = 1000005;
signed main(){
    int n;
    cin >> n;
    vi a(n), c(A);
    rep(i, n){
        cin >> a[i];
        c[a[i]]++;
    }

    bool pc = true;
    for(int i = 2; i < A; i++){
        int cnt = 0;
        for(int j = i; j < A; j += i){
            cnt += c[j];
        }
        if(cnt > 1){
            pc = false;
        }
    }

    if(pc){
        cout << "pairwise coprime" << endl;
        return 0;
    }

    int g = 0;
    rep(i, n) g = __gcd(g, a[i]);
    if(g == 1){
        cout << "setwise coprime" << endl;
        return 0;
    }

    cout << "not coprime" << endl;




}

Measured memory_bytes: 11112
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int a = sc.nextInt();
        int i = 0;
        for ( i = 0; i<=10000; i++){
            if(a*i>=h){
                break;
            }
        }
        System.out.println(i);
    }
}

Measured memory_bytes: 21844
N, X, Y = map(int, input().split())

result = [0] * (N - 1)
for i in range(1, N):
    for j in range(i + 1, N + 1):
        result[min(j - i, abs(X - i) + 1 + abs(Y - j)) - 1] += 1
print(*result, sep='\n')


Measured memory_bytes: 9184
#include<stdio.h>
int main()
{
  int n,i,j;
  scanf("%d",&n);
  int a[n];
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(j=n-1;j>0;j--){
    printf("%d ",a[j]);
  }
  printf("%d\n",a[0]);
  return 0;
}

Measured memory_bytes: 596
# -*- coding: utf-8 -*-


def get_min(array):
    for a in array:
        if a % 10:
            return a
    return sum(array)


n = int(input())
S = [int(input()) for _ in range(n)]
S.sort()

ans = sum(S)
if ans % 10:
    print(ans)
else:
    print(ans - get_min(S))


Measured memory_bytes: 2940
n, m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
b = Array.new(m).map{Array.new(2)}
for i in 0..(m-1)
  b[i] = gets.split.map(&:to_i)
end

a.sort!
b.sort!{|x,y| y[1]<=>x[1]}
aid = bid = 0
res = b[bid][0]
while aid < n && bid < m
  if a[aid] < b[bid][1]
    a[aid] = b[bid][1]
  end
  aid += 1
  res -= 1
  if res <= 0
    bid += 1
    bid < m ? res = b[bid][0] : break
  end
end
sum = 0
a.each{|an| sum += an}
puts sum

Measured memory_bytes: 19988
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int a[3000010],n;
int main()
{
	scanf("%d",&n);
	for(register int i=1;i<=n;++i) scanf("%d",&a[i]);
	if(a[1]!=0) 
	{
		cout<<"-1"<<endl;
		return 0;
	}
	long long  ans=0,now=0;
	for(register int i=n;i>=1;--i)
	{
		if(a[i]-a[i-1]>1) 
		{
			cout<<"-1";return 0;
		}
		if(a[i])
		{
			if(a[i]==a[i-1]+1)
			{
			 	now++;continue;
			}
			ans+=a[i]+now;
			now=0;
		}
	}
	cout<<ans+now<<endl;
	return 0;
}

Measured memory_bytes: 1152
use std::io::Read;

fn main(){
  let mut buf = String::new();
  std::io::stdin().read_to_string(&mut buf).unwrap();
  let N : i64 = buf.trim().parse().unwrap();
  for a in 1 .. 3500 {
    for b in a .. 3500 {
      let div = 4 * a * b - N * b  - N  * a;
      if div <= 0 {
        continue;
      }
      
      let m = (N * a * b) % div;
      let c = (N * a * b) / div;

      if m > 0 || c <= 0 {
        continue;
      }
      
      println!("{} {} {}", a,b,c);
      return;
      
    }
  }
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n;
    string s;
    cin >> n >> s;
    vector<set<ll>> vs(26);
    for(i = 0;i < n;++i){
        char tmp = s.at(i);
        vs.at(tmp - 'a').insert(i);
    }
    vector<char> ss(n);
    for(i = 0;i < n;++i){
        ss.at(i) = s.at(i);
    }
    ll q;
    cin >> q;
    for(i = 0;i < q;++i){
        ll com;
        cin >> com;
        if(com == 1){
            ll ind;
            char c;
            cin >> ind >> c;
            --ind;
            /**
            char tmp = ss.at(ind);
            ss.at(ind) = c;
            vs.at(tmp - 'a').erase(ind);
            vs.at(c - 'a').insert(ind);
            **/
            rep(j,26){
                vs.at(j).erase(ind);
            }
            vs.at(c-'a').insert(ind);
        }else{
            ll l,r;
            cin >> l >> r;
            ll ans = 0;
            /**
            for(auto x: vs){
                auto it1 = lower_bound(all(x), l-1);
                auto it2 = lower_bound(all(x), r);
                if(it1 != it2) ++ans;
            }**/
            rep(j,26){
                auto it = vs.at(j).lower_bound(l-1);
                if(it != vs.at(j).end()){
                    if(*it < r) ++ans;
                }
            }
            cout << ans << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 24708
#include<cstdio>
#include<algorithm>
using namespace std;
inline int read()
{
	int x;char c;
	while((c=getchar())<'0'||c>'9');
	for(x=c-'0';(c=getchar())>='0'&&c<='9';)x=x*10+c-'0';
	return x; 
}
#define MN 100000
struct edge{int nx,t;}e[MN*2+5];
int a[MN+5],h[MN+5],en,r[MN+5],ans;
long long s[MN+5],c[MN+5];
inline void ins(int x,int y)
{
	e[++en]=(edge){h[x],y};h[x]=en;++r[x];
	e[++en]=(edge){h[y],x};h[y]=en;++r[y];
}
void dfs(int x,int fa)
{
	if(r[x]==1){s[x]=c[x]=a[x];return;}
	for(int i=h[x];i;i=e[i].nx)if(e[i].t!=fa)
		dfs(e[i].t,x),c[x]+=c[e[i].t];
	long long j,k=0;
	for(int i=h[x];i;i=e[i].nx)if(e[i].t!=fa)
	{
		j=a[x]<c[x]?min(c[x]-a[x],min(s[x],s[e[i].t])):0;
		j+=a[x]<c[x]-j?min(c[x]-j-a[x],min(k,s[e[i].t]-j>>1)):0;
		c[x]-=j;c[fa]-=j;k+=j;s[x]+=s[e[i].t]-(j<<1);
	}
	if(a[x]^c[x])ans=1;
}
int main()
{
	int n=read(),i;
	for(i=1;i<=n;++i)a[i]=read();
	if(n==2){puts(a[1]^a[2]?"NO":"YES");return 0;}
	for(i=1;i<n;++i)ins(read(),read());
	for(i=1;i<=n;++i)if(r[i]>1){dfs(i,0);break;}
	puts(ans||s[i]?"NO":"YES");
}

Measured memory_bytes: 9856
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

struct UnionFind {
    UnionFind(int n) : p(n, -1) {}
    int root(int u) {
        return p[u] < 0 ? u : p[u] = root(p[u]);
    }
    bool same(int u, int v) {
        return root(u) == root(v);
    }
    void unite(int u, int v) {
        u = root(u);
        v = root(v);
        if (u == v) return;
        if (p[u] > p[v]) swap(u, v);
        p[u] += p[v];
        p[v] = u;
    }
    vector<int> p;
};

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

    int n, m;
    cin >> n >> m;

    vector<int> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
        p[i]--;
    }

    UnionFind uf(n);
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        x--; y--;

        uf.unite(x, y);
    }

    int s = 0;
    for (int i = 0; i < n; i++) {
        if (uf.same(i, p[i])) s++;
    }

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h> 
#define ll long long int 
using namespace std; 
  
int main() 
{  
    ios_base::sync_with_stdio(false) ;
    cin.tie(NULL);   
    ll a,b; 
    cin>>a>>b;
if((abs(a+b))%2==1)  cout<<"IMPOSSIBLE"<<endl; 
else cout<<((a+b)/2)<<endl;
    return 0; 
} 


Measured memory_bytes: 3644
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    imos=[0]*n
    over=0
    for i,x in enumerate(map(int,input().split())):
        imos[over]+=1
        over=max(over,i-(x-1)//2)

    for i in range(n-1):
        imos[i+1]+=imos[i]

    ans=1
    chosen=0
    for c in imos:
        ans*=(c-chosen)
        ans%=MOD
        chosen+=1

    print(ans)
resolve()

Measured memory_bytes: 63728
#include <stdio.h>

int main() {
	int n, max, num, sum;
	int a[3];
	scanf("%d",&n);

	for (int i = 0;i < n;i++) {
		scanf("%d %d %d", &a[0], &a[1], &a[2]);
		max = a[0]* a[0];
		num = 0;
		sum = 0;
		for (int j = 1;j < 3;j++) {
			if (max < a[j] * a[j]) {
				sum += max;
				max = a[j] * a[j];
				num = j;
			}
			else {
				sum += a[j] * a[j];
			}
		}

		if (max == sum) {
			printf("YES\n");
		}
		else {
			printf("NO\n");
		}
	}

	return 0;

}


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

using namespace std;

int main() {
  long long int W;
  long long int H;
  long long int C;
  cin >> W >> H >> C;
  int Min = min(W,H);

  long long int Ans = W * H * C;
  for(int i = 1; i <= Min; i++) {
    if(W % i == 0 && H % i == 0) {
      Ans = min((W / i) * (H / i) * C,Ans);
    }
  }
  cout << Ans << endl;


}

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

int ReturnDigitsSum(int x)
{
    int sum = 0;
    while (x > 0)
    {
        sum += x % 10;
        x /= 10;
    }

    return sum;
}

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

    int f = ReturnDigitsSum(N);
    if (N % f == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
using ll= long long;
#define rep(i,n) for(ll i=0;i<n;i++)
ll a[114514];
ll b[114514];
ll c[114514] = {};
int main() {
	ll n, k;
	cin >> n >> k;
	rep(i, n) {
		cin >> a[i] >> b[i];
		c[a[i]] += b[i];
	}
	for(ll i=1;i<=100000;i++) {
		if (k <= c[i]) { cout << i << endl; return 0; }
		k -= c[i];
	}
}

Measured memory_bytes: 2560
from collections import deque

N, M = map(int, input().split())
AB = []
for i in range(M):
    ab = list(map(int, input().split()))
    AB.append(ab)
# print(AB)

graph = [[] for _ in range(N)]
for a, b in AB:
    graph[a-1].append(b)
    graph[b-1].append(a)
# print(graph) -> [[], [2], [1, 3, 4], [2, 4], [3, 2]]

que = deque([1])
ans = [0 for _ in range(N)]

while que:
    x = deque.popleft(que)
    for i in graph[x-1]:
        if ans[i-1] != 0:
            continue
        ans[i-1] = x
        que.append(i)
for a in ans[1:]:
    if a == 0:
        print('No')
        break
else:
    print('Yes')
    print('\n'.join(map(str, ans[1:])))

Measured memory_bytes: 65744
#include<bits/stdc++.h>
#define M 100005
using namespace std;

struct edge{int u,next;}e[M]={0}; int head[M]={0},use=0;
void add(int x,int y){use++;e[use].u=y;e[use].next=head[x];head[x]=use;}
int n,k,cnt=0,a[M]={0};

int dfs(int x,int dep){
	int maxn=dep;
	for(int i=head[x];i;i=e[i].next) maxn=max(maxn,dfs(e[i].u,dep+1));
	if(a[x]!=1&&maxn-dep==k-1) {cnt++; return 0 ;} else return maxn;
}	

int main(){
	scanf("%d%d",&n,&k); 
	for(int i=1;i<=n;i++){
		scanf("%d",a+i);
		if(i!=1) add(a[i],i);
		else cnt+=(a[i]!=1);
	} 
	for(int i=head[1];i;i=e[i].next)
	dfs(e[i].u,0);
	cout<<cnt<<endl;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	long long H,W,ans;
	cin>>H>>W;
	if(H==1||W==1){
		cout<<1<<endl;
		return 0;
	}
	if(H%2==1&&W%2==1){
		ans=H*W/2+1;
	}
	else{
		ans=W*H/2;
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

#define ll long long
typedef complex<double> P;

int main() {
  int n; cin >> n;
  int adj[n][n] = {};

  for (int i = 0; i < n; i++) {
    int u, k; cin >> u >> k;
    
    for (int j = 0; j < k; j++) {
      int v; cin >> v;
      adj[u-1][v-1] = 1;
    }
  }

  int d[n];
  fill(d, d+n, -1);

  queue<int> que;
  que.push(0);
  d[0] = 0;

  while(!que.empty()) {
    int v = que.front(); que.pop();

    for (int i = 0; i < n; i++) {
      if(adj[v][i] == 1 && d[i] == -1) {
        que.push(i);
        d[i] = d[v] + 1;
      }
    }

  }

  for (int i = 0; i < n; i++) {
    cout << i+1 << ' ' << d[i] << endl;
  }

}

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

using namespace std;

vector<vector<int> > a;
vector<vector<int> > par;
vector<int> glebokosc;
vector<int> konce;

void znajdz_glebokosc(int ak, int ost, int gl)
{
    glebokosc[ak]=gl;
    par[ak][0]=ost;
    for(int i = 0;i<a[ak].size();i++)
    {
        if(a[ak][i]!=ost)
        {
            znajdz_glebokosc(a[ak][i],ak,gl+1);
        }
    }
    return;
}

int gca(int a,int b)
{
    while(glebokosc[a]>glebokosc[b])
    {
        int il=0;
        while(glebokosc[par[a][il+1]]>glebokosc[b])il++;
        a=par[a][il];
    }
    while(glebokosc[b]>glebokosc[a])
    {
        int il=0;
        while(glebokosc[par[b][il+1]]>glebokosc[a])il++;
        b=par[b][il];
    }
    while(b!=a)
    {
        int il=0;
        while(il<12&&par[a][il+1]!=par[b][il+1])il++;
        a=par[a][il];
        b=par[b][il];
    }
    return a;
}


int glebo(int a,int b)
{
    int gcab=gca(a,b);
    return (glebokosc[a]+glebokosc[b]-2*glebokosc[gcab]);
}

int main()
{
    long long n,u,v;
    cin>>n>>u>>v;
    u--;v--;
    a.assign(n,vector<int>(0,0));
    par.assign(n,vector<int>(12,0));
    glebokosc.assign(n,0);
    for(int i = 0;i<n-1;i++)
    {
        int o,d;
        cin>>o>>d;
        o--;d--;
        a[o].push_back(d);
        a[d].push_back(o);
    }
    for(int i = 0;i<n;i++)
    {
        if(a[i].size()==1)konce.push_back(i);
    }
    znajdz_glebokosc(0,0,0);
    for(int i = 1;i<12;i++)
    {
        for(int j = 0;j<n;j++)par[j][i]=par[par[j][i-1]][i-1];
    }
    int guv=gca(u,v);
    int odleglosc=(glebo(u,v)+1)/2-1;
    int najdalej=0;
    for(int i = 0;i<konce.size();i++)
    {
        int k = konce[i];
        //int gcav=gca(v,k);
        //int gcau=gca(u,k);
        //cout<<k<<" "<<" "<<gcau<<" "<<glebo(u,gcau)<<" "<<gcav<<" "<<glebo(v,gcav)<<"k\n";
        if(glebo(u,k)<glebo(v,k))najdalej=max(najdalej,glebo(v,k)-1);
    }
    cout<<najdalej;
}


Measured memory_bytes: 20372
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long cc;

cc N, K, i, j, k, A[500000], sub = 0, n = 0;
cc judge = 0, Ans, J[500000];

string S;


int main() {
	
	cin >> N >> K;
	sub = N + K;
	if (sub % 2 == 0) {
		Ans = sub / 2;

		cout << Ans << endl;
	}
	else
		cout << "IMPOSSIBLE" << endl;
		return 0;
}



Measured memory_bytes: 2304
#include<stdio.h>

int main(){

  int a[5];
  int am[5];
  int ansa[5]={};
  int min=10;
  int i;
  int ans=0;
  for(i=0;i<5;i++){
    scanf("%d",&a[i]);
    am[i]=a[i]%10;
  }

  for(i=0;i<5;i++){
    if(am[i]!=0){
      ansa[i]=a[i]-am[i]+10;
    }else{
      ansa[i]=a[i];
    }
  }

  for(i=0;i<5;i++){
    if(am[i]!=0){
    if(am[i]<min){
      min=am[i];
    }
  }
  }
  if(min==10){
    min=0;
  }

  if(min!=0){
    for(i=0;i<5;i++){
      ans+=ansa[i];
    }
    ans=ans-10+min;
  }else{
    for(i=0;i<5;i++){
      ans+=ansa[i];
    }
  }

    printf("%d",ans);

  return 0;
}

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

const int MAX_Q = 55;
int n, m, q;
int a[MAX_Q], b[MAX_Q], c[MAX_Q], d[MAX_Q];

int ans = 0;
 
void all_search(vector <int> &v, int dep) {
  if ( dep > n ) {
    int sum = 0;
    for ( int k = 0; k < q; k++ ) {
      if ( v[b[k]] - v[a[k]] == c[k] ) { sum += d[k]; }
    }
    ans = ( sum > ans ) ? sum : ans;
    return;
  }

  for(int k = v[dep - 1]; k <= m; k++) {
    v[dep] = k;
    all_search(v, dep+1);
  }
}
 
int main() {
  cin >> n >> m >> q;
  for ( int i = 0; i < q; i++ ) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }

  vector <int> v(n+1, 1);
  all_search(v, 1);

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

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

using namespace std;

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

int main(){
    int n;cin>>n;
    int k;cin>>k;
    int res=0;
    REP(i,n){
        int t;cin>>t;
        res+=min(t*2,abs(k-t)*2);
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <cctype>
#include <cstring>
#include <iostream>
#include <vector> 
#include <algorithm>
#include <functional>
#include <array>
using namespace std;

int main(){
  int N, K, i;
  long sum=0;
  cin >> N >> K;
  vector<int> p(N);
  for(i=0;i<N;i++)
    cin >> p[i];
  sort(p.begin(), p.end()); 
  for(i=0;i<K;i++){
    sum += p[i];
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3624
n,m=map(int,input().split())

ab=[]
for _ in range(m):
    a,b=map(int,input().split())
    ab.append([a,b])

ab.sort(key=lambda x: x[1])

cnt=0
border=0

for item in ab:
    if item[0]>=border:
        border=item[1]
        cnt+=1

print(cnt)



Measured memory_bytes: 62552
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int):
    s = 'abcdefghijkl'
    ans = []

    def f(t: str):
        if len(t) == N:
            ans.append(t)
            return
        
        if len(t) >= 2:
            x = s.index(max(list(t)))+2
        else:
            x = len(t)+1
        for i in range(x):
            f(t+s[i])


    
    f('')
    ans.sort()
    for i in ans:
        print(i)


    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 12720
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 0x3f3f3f3f
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, W, w, v, vp = 0;

  std::cin >> N >> W;

  long long dp[111111];

  memset(dp, 0x3f, sizeof(dp));

  dp[0] = 0;

  for (int i = 0; i < N; i ++) {
    std::cin >> w >> v;

    for (int j = 111110; j >= 0; j --)
      if (dp[j] < INF)
        dp[j + v] = std::min<long long>(dp[j] + w, dp[j + v]);
  }

  for (int i = 0; i < 111111; i ++)
    if (dp[i] <= W)
      vp = i;

  std::cout << vp << std::endl;
  
  return 0;
}


Measured memory_bytes: 1152
while True:
    n=input().split()
    n[0]=int(n[0])
    n[1]=int(n[1])
    if n[0]==0 and n[1]==0:
        break
 
    if n[0]>n[1]:
        c=n[0]
        n[0]=n[1]
        n[1]=c
    print(n[0],n[1])


Measured memory_bytes: 5612
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

const int maxn=1005;
int n, ans, data[maxn];

int main()
{
    while(~scanf("%d", &n)){
        for(int i=0;i<n;i++){
            scanf("%d", &data[i]);
        }
        ans=0;
        sort(data, data+n);
        for(int i=n-1;i>0;i--){
            ans+=data[i]-data[i-1];
        }
        printf("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            B105(int.Parse(Console.ReadLine()));
        }

        static void B105(int N)
        {
            var count = 0;
            for (var i = 1; i <= N; i += 2)
            {
                if (Counting(i) == 8) count++;
            }
            Console.WriteLine(count);
        }

        static int Counting(int n)
        {
            var count = 0;
            for (var i = 1; i <= n; i ++)
            {
                if (n % i == 0) count++;
            }
            return count;
        }
    }
}


Measured memory_bytes: 27508
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
#define MOD 998244353
//#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)


//座圧(破壊的)
int cocomp(ll*a,int n){
	//0～cnt-1に圧縮
	ll*b=(ll*)malloc(sizeof(ll)*n);
	memcpy(b,a,sizeof(ll)*n);
	sortup(b,n);
	int cnt=1;
	rep(r,1,n)if(b[r]!=b[cnt-1])b[cnt++]=b[r];
	rep(i,0,n){
		int l=0,r=cnt;
		while(r-l>1){int m=(l+r)/2;if(b[m]>a[i])r=m;else l=m;}
		a[i]=l;
	}
	free(b);
	return cnt;
}



//セグ木ここから
//*
//↓ここを変える
typedef struct atai{ll a;}atai;
atai xx(atai x,atai y){
	atai r;
	r.a=x.a+y.a;//sum
	return r;
}
atai aid={0};
//↑ここを変える

int segNUM;
atai *segN,*seg;
void seguse(int n){
	segN=(atai*)calloc(2*n,sizeof(atai));
	segNUM=n;
	seg=segN+segNUM;
	rep(i,1,2*segNUM)segN[i]=aid;
}
//seg[]に値を与えてから初期化
void seginit(){for(int node=segNUM-1;node;node--)segN[node]=xx(segN[node*2],segN[node*2+1]);}
void segupdate(int node,atai x){
	//seg[node]をxに更新
	node+=segNUM;
	segN[node]=x;
	while(node/=2)segN[node]=xx(segN[node*2],segN[node*2+1]);
}

atai segcalcsub(int l,int r,int k,int cl,int cr){
	if(l>=r)return aid;
	//完全に含むとき
	if(l<=cl&&cr<=r)return segN[k];

	int cm=(cl+cr)/2;
	//左側だけ
	if(r<=cm)return segcalcsub(l,r,2*k  ,cl,cm);
	//右側だけ
	if(cm<=l)return segcalcsub(l,r,2*k+1,cm,cr);
	//両方
	return xx(segcalcsub(l,r,2*k,cl,cm),segcalcsub(l,r,2*k+1,cm,cr));
}
atai segcalc(int l,int r){return segcalcsub(l,r,1,0,segNUM);}
//セグ木ここまで
//*/

ll x[200010],y[200010];
int c(const void*p,const void*q){
	if(y[*(int*)p]<y[*(int*)q])return -1;
	return 1;
}

ll n;
ll idx[200010];
int main(){
	scanf("%lld",&n);
	rep(i,0,n)scanf("%lld%lld",x+i,y+i);
	cocomp(x,n);
	rep(i,0,n)idx[i]=i;
	qsort(idx,n,sizeof(ll),c);
	seguse(1<<18);
	
	ll ans=0;
	rep(ii,0,n){
		int i=idx[ii];
		ans=(ans+pom(2,n-1,MOD))%MOD;
		ll a=segcalc(0,x[i]).a;
		ll b=ii-a;
		ll c=x[i]-a;
		ll d=n-1-a-b-c;
//		printf("%d %d %d %d %d\n",a,b,c,d,x[i]);
		rep(k,0,16)if((bit(k,0)||bit(k,1))&&(bit(k,2)||bit(k,3))&&(bit(k,0)||bit(k,2))&&(bit(k,1)||bit(k,3))){
			ll temp=1;
			if(bit(k,0))temp=temp*(pom(2,a,MOD)-1)%MOD;
			if(bit(k,1))temp=temp*(pom(2,b,MOD)-1)%MOD;
			if(bit(k,2))temp=temp*(pom(2,c,MOD)-1)%MOD;
			if(bit(k,3))temp=temp*(pom(2,d,MOD)-1)%MOD;
			ans=(ans+temp)%MOD;
		}
		atai xx=seg[x[i]];
		xx.a++;
		segupdate(x[i],xx);
		
	}
	printf("%lld",ans);
}

Measured memory_bytes: 10572
#include<iostream>
#include<bits/stdc++.h>
#define rep(i,n) for(i=0;i<n;i++)
#define pb push_back
#define lli long long int
#define all(v) (v.begin(),v.end())
#define fr first
#define sc second
#define mp make_pair
using namespace std;
string a,b;
lli dp[3005][3005];
lli rec(int n1,int n2)
{
    if(n1==0||n2==0) return dp[n1][n2]=0;
    if(dp[n1][n2]!=-1) return dp[n1][n2];
    if(a[n1-1]==b[n2-1]) return dp[n1][n2]=1+rec(n1-1,n2-1);
    return dp[n1][n2]=max(rec(n1,n2-1),
               rec(n1-1,n2));
}
int main()
{
    cin>>a>>b;
    int i,j;
    int n1=a.size();
    int n2=b.size();
    memset(dp,-1,sizeof(dp));

    lli y=rec(n1,n2);
    i=n1;j=n2;
    string s="";
    while(i>0&&j>0)
    {
        if(a[i-1]==b[j-1])
        {
            s=a[i-1]+s;
            i--;
            j--;
        }
        else if(dp[i-1][j]>dp[i][j-1])
        {
            i--;
        }
        else j--;
    }
    cout<<s;


}


Measured memory_bytes: 74432
import itertools
n = int(input())
l = list(map(int, input().split()))

l_c = list(itertools.combinations(l,3))
l_c = list(map(list, l_c))
ans = 0
for i in l_c:
  i.sort()
  if sorted(list(set(i))) == i:
    if i[0] + i[1] > i[2]:
      ans += 1
print(ans)


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

using namespace std;

const int N = 1e5;

vector<int>ans[N + 1];

int main() {
	//freopen("d.in", "r", stdin);
	//freopen("d.out", "w", stdout);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int t = 0;
	int x = 1;
	while (t < n) {
		t++;
		ans[1].push_back(t);
		ans[++x].push_back(t);
		for (int i = 2; i < x; i++) {
			t++;
			ans[i].push_back(t);
			ans[x].push_back(t);
		}
	}
	if (t > n) cout << "No" << endl;
	else {
		cout << "Yes" << endl;
		cout << x << endl;
		for (int i = 1; i <= x; i++) {
			int len = ans[i].size();
			cout << len;
			for (int j = 0; j < len; j++) cout << " " << ans[i].at(j);
			cout << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 4608
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>

#define rep(i,n) for(int i=0;i<int(n);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back

using namespace std;
using ll = long long;

const ll mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

bool contain(int mask, int bit){
  return (mask & (1 << bit)) != 0;
}

int main(){
  int data[4];
  string N;
  cin >> N;
  for(int i = 0; i < 4; i++) data[i] = N[i] - '0';

  for(int mask = 0; mask < (2 << 3); mask++){
    int res = data[0];
    string ans = to_string(data[0]);
    for(int bit = 0; bit < 3; bit++){
      if(contain(mask, bit)){
	res += data[bit + 1];
	ans += "+" + to_string(data[bit + 1]);
      }else{
	res -= data[bit + 1];
	ans += "-" + to_string(data[bit + 1]);
      }
    }
    if(res == 7){
      cout << ans << "=7" << endl;
      return 0;
    }
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
using namespace std;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;

int n;
double d;
double x,y;
int cnt;

int main() {
    //ios::sync_with_stdio(false);cin.tie(0);
    scanf("%d %lf",&n,&d);

    for(int i=1;i<=n;++i){
        scanf("%lf %lf",&x,&y);
        double dis=sqrt(x*x+y*y);
        if(dis<=d) cnt++;
    }

    printf("%d\n",cnt);

    return 0;
}

Measured memory_bytes: 3776
using System;
class gyakusu{
  public static void Main(){
    int n = int.Parse(Console.ReadLine());
    string[] s =  Console.ReadLine().Split(' ');
    double[] a = new double[n];
    double[] inverse = new double[n];
    double sum = 0;
    for (int i = 0; i<n; i++)
    {
      a[i]=double.Parse(s[i]);
      inverse[i]=1/a[i];
      sum+=inverse[i];
  }
  double answer = 1/sum;
  Console.WriteLine("{0}",answer);
}
}


Measured memory_bytes: 13140
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstring>
#include<queue>
#include<tuple>
#include<utility>
#include<map>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include<stdlib.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define MP make_pair
using Graph = vector<vector<int>>;
const unsigned long long mod = 1e9 + 7;
const long long INF = 1LL<<60;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }

int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll count = 0, N;
	cin >> N;
	FOR(i, 1, N)
	{
		int b = (N-1) / i;
		count += b;
	}

	cout << count << endl;

	return 0;
}



Measured memory_bytes: 3652
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

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

func init() {
	sc.Split(bufio.ScanWords)
}

func Max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {
	k, n := scanInt(), scanInt()
	arr := make([]int, n)
	max := 0
	for i := 0; i < n; i++ {
		arr[i] = scanInt()
		if i >= 1 {
			max = Max(max, arr[i]-arr[i-1])
		}
	}
	max = Max(max, k-(arr[n-1]-arr[0]))
	fmt.Println(k - max)
}


Measured memory_bytes: 3840
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
#include <cmath>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    string s;cin >> s;
    int ans = 700;
    REP(i,s.size()){
        if(s[i]=='o') ans += 100;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import itertools
n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
nums = [i for i in range(1,n+1)]
fac = [words for words in itertools.permutations(nums)]
ans = abs(fac.index(p) - fac.index(q))
print(ans)

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

int main(){
	int N;
	cin>>N;
	int max,min;
	cin>>max;
	min=max;
	int tmp;
	for(int i=0;i<N-1;++i){
		cin>>tmp;
		if (max<tmp) max=tmp;
		if (min>tmp) min=tmp;
	}
	cout<<max-min<<endl;
}


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;
using P = pair<int,int>;

int main(){
   int x,n;
  cin >> x >>n;
  vector<int> b(102);
  rep(i,n){
    int p;
    cin >> p;
    b.at(p) = 1;
  }
  P ans(999999,-1);
  rep(i,102){
   if(b.at(i) == 1) continue;
    int diff = abs(x-i);
    ans = min(ans, P(diff,i));
  }
  cout << ans.second << endl;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define ANS cout << ans << endl
#define RETURN(x)    \
  cout << x << endl; \
  return 0
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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

signed main() {
  init();
  ll W, H, N;
  cin >> W >> H >> N;

  ll a1 = 0;
  ll a2 = W;
  ll a3 = 0;
  ll a4 = H;

  rep(i, N) {
    ll x, y, a;
    cin >> x >> y >> a;
    if (a == 1) a1 = max(a1, x);
    if (a == 2) a2 = min(a2, x);
    if (a == 3) a3 = max(a3, y);
    if (a == 4) a4 = min(a4, y);
  }
  W = W - a1 - (W - a2);
  H = H - a3 - (H - a4);
  if (0 < H && 0 < W) {
    COUT(H * W);
  } else {
    COUT(0);
  }

  return 0;
}

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

int main()
{
    long long n, d1, d2;
    long long cnt = 0;
    bool chk = false;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> d1 >> d2;
        if (d1 == d2)
            cnt++;
        else
            cnt = 0;

        if (cnt >= 3) {
            chk = true;
        }
    }

    if (chk)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main(){
  int N, tmp, ans = 0;
  cin >> N;
  vector<int> V, C;
  for (int i=0; i<N; i++){
    cin >> tmp;
    V.push_back(tmp);
  }
  for (int i=0; i<N; i++){
    cin >> tmp;
    ans += max(V[i] - tmp, 0);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n;
  cin >> n;
  vll as(n), bs(n);

  rep(i, n) cin >> as[i];
  rep(i, n) cin >> bs[i];

  ll fuso = 0, ans = 0;
  vll mars;
  rep(i, n) {
    if (bs[i] > as[i])
      {fuso += bs[i] - as[i];
      ans++;
    } else
      mars.push_back(as[i] - bs[i]);
  }
  rSort(mars);

  ll idx = 0;
  while (idx < (ll)mars.size() && fuso > 0) {
    fuso -= mars[idx];
    idx++;
  }
  if (fuso <= 0)
    cout << ans + idx << endl;
  else
    cout << -1 << endl;

  return 0;
}


Measured memory_bytes: 5736
// -*- mode:c++; coding:utf-8; c-basic-offset:2; -*-
// ALDS1_6-C: Quick Sort

#include <algorithm>
#include <cstdio>
#include <cstring>

using uint = unsigned int;

struct Card {
  char suit;
  uint rank;
  uint index; // for stable check

  void set(char s, uint r, uint i)
  {
    suit = s;
    rank = r;
    index = i;
  }

  void print() const
  {
    std::printf("%c %u\n", suit, rank);
  }
};

static void print_cards(const Card cards[], const uint n)
{
  for (auto i = 0u; i < n; ++i) {
    cards[i].print();
  }
}

static bool is_stable(const Card cards[], const uint n)
{
  for (auto i = 0u; i< n-1; ++i) {
    if (cards[i].rank == cards[i+1].rank &&
        cards[i].index > cards[i+1].index) {
      return false;
    }
  }
  return true;
}

static uint partition(Card cards[], uint begin, uint end)
{
  auto last = end-1;
  auto gt = begin;
  for (auto i = begin; i < last; ++i) {
    if (cards[i].rank <= cards[last].rank) {
      std::swap(cards[gt++], cards[i]);
    }
  }
  std::swap(cards[gt], cards[last]);
  return gt;
}

static void quick_sort(Card cards[], uint begin, uint end)
{
  if (end - begin > 1) {
    auto middle = partition(cards, begin, end);
    quick_sort(cards, begin, middle);
    quick_sort(cards, middle+1, end);
  }
}

int main()
{
  uint n;
  std::scanf("%u", &n);
  Card cards[n];
  for (uint i = 0; i < n; ++i) {
    char s;
    uint r;
    std::scanf(" %c %u", &s, &r); // skip space
    cards[i].set(s, r, i);
  }

  quick_sort(cards, 0u, n);

  std::puts(is_stable(cards, n) ? "Stable" : "Not stable");
  print_cards(cards, n);
}

// eof

Measured memory_bytes: 3820
#include <iostream>
#include <string>
#include <vector>
#include<limits>
#include<stack>
#include<queue>
#include<math.h>
#include <iomanip>

#define rep(i,n) for(auto i=0;i<(n);i++)
#define all(vs) (vs).begin(),(vs).end()
#define roundup(A,B) (A)/(B)+(A%B==0?0:1)
#define maximize(A,B) A=max((A),(B))
#define read(type,name) type name;cin>>name
#define ll long long

using namespace std;
template<typename T>
T MAX() { return numeric_limits<T>::max(); }

//二次元テーブル
template<typename T>
class Table {
public:
	Table(int height, int width, T value) {
		if (width < 0)throw out_of_range("Width should be >=0");
		if (height < 0)throw out_of_range("Height should be >=0");
		this->wid = width;
		this->hgt = height;
		vs = new T[width * height];
		for (auto i = 0; i < width * height; i++)vs[i] = value;
	}
	Table(const Table& table) {
		hgt = table.hgt;
		wid = table.wid;
		vs = new T[hgt * wid];
		for (size_t i = 0; i < table.size(); i++) {
			vs[i] = table.vs[i];
		}
	}
	Table(Table&& table) {
		hgt = table.hgt;
		wid = table.wid;
		swap(vs, table.vs);
	}
	~Table() {
		if (vs)delete[] vs;
	}
	Table& operator=(const Table& table) {
		if (table == *this)return *this;
		this->wid = table.wid;
		this->hgt = table.hgt;
		if (vs)delete[] vs;
		vs = new T[wid * hgt];
		for (auto i = 0; i < wid * hgt; i++)vs[i] = table.vs[i];
	}
	Table& operator=(Table&& table) {
		wid = table.wid;
		hgt = table.hgt;
		swap(vs, table.vs);
	}
	inline T& at(int y, int x) {
		if (wid > x)throw out_of_range("x>width.");
		if (hgt > y)throw out_of_range("y>height.");
		return vs[x + y * wid];
	}
	int size()const { return wid * hgt; }
	int width()const { return wid; };
	int height()const { return hgt; };
	T* begin() { return vs; }
	T* end() { return vs + wid * hgt; }
	T& operator()(int y, int x) { return vs[x + y * wid]; }
	const T& operator()(int y, int x)const { return vs[x + y * wid]; }
private:
	int wid, hgt;
	T* vs;
};
//Nが偶数であれば偶奇が同じ数だけあるので0.5である。
//Nが奇数2k+1である場合はk+1個の奇数とk個の偶数が存在する
void A() {
	read(int, N);
	if (N % 2 == 0)cout << 0.5 << endl;
	else cout << (double)(N / 2 + 1) / N << endl;
}

//前から順に操作すればよい。
//空間量としてはO(1)である。
void B() {
	read(int, N);
	read(int, K);
	int h; int result = 0;
	for (auto i = 0; i < N; i++) {
		cin >> h; if (h >= K)result++;
	}
	cout << result << endl;
}

void C() {
}

void D() {

}

void E() {}
void F() {}

int main() {
	B();
}

Measured memory_bytes: 3628