akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const int N = 222222;
int a[N], vst[N], ans[N], col[N];
vector<pair<int, int> > e[N];
int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	for(int i(1); i <= n; i++) {
		scanf("%d", &a[i]);
	}
	for(int i(1); i <= m; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		e[x].push_back({y, i});
		e[y].push_back({x, i});
	}
	set<pair<int, int> > st;
	memset(col, -1, sizeof(col));
	for(int i(1); i <= n; i++) {
		for(pair<int, int> tmp : e[i]) {
			int y = tmp.first;
			if(a[i] == a[y]) {
				int v = i;
				vst[i] = vst[y] = 1;
				if(col[v] == -1 && col[y] == -1) {
					col[v] = 0; col[y] = 1;
				}else if(col[v] == -1) {
					col[v] = col[y] ^ 1;
				}else if(col[y] == -1) {
					col[y] = col[v] ^ 1;
				}
				ans[tmp.second] = a[i];
				st.insert({a[i], i});
				st.insert({a[y], y});
			}
		}
	}
	for(int i(1); i <= n; i++) {
		if(st.empty()) {
			printf("-1\n");
			exit(0);
		}
		int v = st.begin()->second;
		//printf("v = %d\n", v);
		st.erase(st.begin());
		for(pair<int, int> tmp : e[v]) {
			int y = tmp.first;
			if(!vst[y] && a[y] >= a[v]) {
				st.insert({a[y], y});
				col[y] = col[v] ^ 1;
				vst[y] = 1;
				ans[tmp.second] = a[y];
			}
		}
	}
	for(int i(1); i <= n; i++) printf("%c", col[i] ? 'B' : 'W');
	printf("\n");
	for(int i = 1; i <= m; i++) printf("%d\n", ans[i] ? ans[i] : (int)1e9);
}


Measured memory_bytes: 20212
import sys
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=0
for i in range(n):
    if a[i]>=b[i]:
        a[i]=a[i]-b[i]
        ans+=b[i]
    else:
        ans+=a[i]
        b[i]-=a[i]
        a[i]=0
        ans+=min(b[i],a[i+1])
        a[i+1]=max(0,a[i+1]-b[i])
        
   
print(ans)
        
        
    
    


Measured memory_bytes: 24216
#include <bits/stdc++.h>
using namespace std;
int INF=10;
int fac(int n){
  int a=1;
  for(int i=n; i>0; i--){
    a *=n;
    n--;
  }
  return a;
}
int banme(vector<int>v, int n){
  int ans;
  for(int i=0; i<v.size(); i++){
    if(v.at(i)==n){
      ans =i;
      break;
    }
  }
  return ans;
}
int jun(int n, vector<int> p){
  int ans=0;
  vector<int> re =p;
  sort(re.begin(), re.end());
  for(int i=0; i<n-1; i++){
    int b=banme(re, p.at(i));
    ans =ans +b*fac(n-i-1);
    re.at(b)=INF;
    sort(re.begin(), re.end());
    re.pop_back();
  }
  return ans;
}
int abs(int a){
  if(a>0) return a;
  else return -a;
}
int main(){
  int n;
  cin>>n;
  vector<int> p(n),q(n);
  
  for(int i=0; i<n; i++){
    int tmp;
    cin>>tmp;
    p.at(i)=tmp;
  }
  for(int i=0; i<n; i++){
    int tmp;
    cin>>tmp;
    q.at(i)=tmp;
  }
  cout<<abs(jun(n,p)-jun(n,q))<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
const ll MOD=(ll)1e9+7;
const ll MAX = 2000000;

ll fac[MAX],finv[MAX],inv[MAX];

void COMinit(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(int i=2;i<MAX;i++){
    fac[i]=fac[i-1]*i%MOD;
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    finv[i]=finv[i-1]*inv[i]%MOD;
  }
}

ll COMcalc(int n,int k){
  if(n<k)return 0;
  if(n<0 || k<0)return 0;
  return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

int main(){
  ll k,b,ans=0;
  string s;
  cin>>k>>s;
  ll n=s.size();
  ll m25[MAX],m26[MAX];
  m25[0]=1;m26[0]=1;
  for(int i=0;i<MAX-1;i++){
    m25[i+1]=m25[i]*25%MOD;
    m26[i+1]=m26[i]*26%MOD;
  }
  COMinit();
  for(int i=0;i<=k;i++){
    b=m26[k-i];
    b*=m25[i];b%=MOD;
    b*=COMcalc(i+n-1,n-1);b%=MOD;
    ans+=b;ans%=MOD;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 82376
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<tuple>


#define mod 1000000007
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back

using namespace std;

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

int main(){
    int N,A,B,C,D;
    cin>>N>>A>>B>>C>>D;
    string S;
    cin>>S;
    vector<int> x;
    vector<int> y;
    bool ok=true;

    rep(i,0,N-1)if(S[i]=='#' && S[i+1]=='#')x.PB(i+1);
    rep(i,0,N-2)if(S[i]=='.' && S[i+1]=='.' && S[i+2]=='.')y.PB(i+2);

    rep(i,0,x.size()){
        if(A<x[i] && x[i]<C)ok=false;
        if(B<x[i] && x[i]<D)ok=false;
    }
    int B_min=200001,A_min=200001;

    if(C>D){
        int ok_2=false;
        rep(i,0,y.size()){
            if(A<=(y[i]-1) && B<=y[i])ok_2=true;
            B_min=min(B_min,y[i]);
            A_min=min(A_min,y[i]+1);
        }
        if(!ok_2)ok=false;
        if(A_min>C)ok=false;
        if(B_min>D)ok=false;
        rep(i,0,x.size()){
            if(A<x[i] && x[i]<B)ok=false;
        }
    }

    if(ok)cout<<"Yes";
    else cout<<"No";

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

typedef std::uint64_t u64;
typedef std::int64_t  i64;
typedef std::uint32_t u32;
typedef std::int32_t  i32;

using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define repd(i, a, b) for(typeof(b) i = (a); (i) < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl

int main(int argc, const char* argv[]) {
  u64 n;
  cin >> n;
  
  u64 h[n];
  rep(i, n) {
    cin >> h[i];
  }

  u64 ret = 0;
  u64 maxh = 0;
  rep(i, n) {
    if(h[i] >= maxh) {
      ++ret;
      maxh = h[i];
    }
  }
  
  cout << ret << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back
int n;
vector<int>v[210];
char c[210][210];
int color[210];
bool dfs(int x,int c){
	color[x]=c;
	for(int g:v[x]){
		if(color[g]==c)return false;
		if(color[g]==0&&!dfs(g,-c))return false;
	}
	return true;
}
bool solve(){
	rep(i,n){
		if(color[i]==0){
			if(dfs(i,1)==false)return false;
		}
	}
	return true;
}
int d[210][210];	
int main(){
	cin>>n;
	rep(i,n){
		rep(j,n){
			cin>>c[i][j];
			if(i!=j)d[i][j]=1000000000;
			if(c[i][j]=='1'){
				v[i].pb(j);
				d[i][j]=1;
			}
		}
	}
	if(!solve()){
		puts("-1");
		return 0;
	}
	rep(k,n){
		rep(i,n){
			rep(j,n){
				d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
			}
		}
	}
	int ma=0;
	rep(i,n){
		rep(j,n){
			ma=max(ma,d[i][j]);
		}
	}
	cout<<ma+1<<endl;
}


Measured memory_bytes: 640
function Divisor(num) {
    var ret = 0;
    for (var p = 1; p <= num; p++) if (num % p == 0) ret++;
    return ret;
}
function Main(input) {
    var cnt = 0;
    N = Number(input);
    for (var i = 1; i <= N; i+=2) if (Divisor(i) == 8) cnt++;
    console.log(cnt);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

const int mod = 1000000007;

int main(){
  int n, m; cin >> n >> m;
  int a[100010];
  for (int i = 0; i < m; i++){
    cin >> a[i];
  }
  int dp[100010];
  dp[0] = 1;

  auto is_danger = [&](int i){
    if (a[0] > i) return false;
    int l = 0, r = m;
    while (r - l > 1){
      int c = (l + r)/2;
      if (a[c] <= i) l = c;
      else r = c;
    }
    if (a[l] == i) return true;
    else return false;
  };

  for (int i = 1; i <= n; i++){
    if (is_danger(i)) dp[i] = 0;
    else{
      if (i == 1) dp[i] = 1;
      else dp[i] = ((int64_t)dp[i-1] + dp[i-2]) % mod;
    }
  }
  cout << dp[n] << endl;
}

Measured memory_bytes: 1024
N = int(input())
XY = [list(map(int, input().split())) for i in range(N)]
ans = 0
for i in range(N):
    for j in range(i+1, N):
        ans += ((XY[i][0] - XY[j][0]) ** 2 + (XY[i][1] - XY[j][1]) ** 2) ** (1 / 2)
ans *= 2 / N
print(ans)

Measured memory_bytes: 9452
n = int(input())
s = input()

accum_w = [0] * (n+1)  # accum_w[i] = (s[:i].count('W'))
accum_e = [0] * (n+1)  # accum_e[i] = (s[i:].count('E'))

cnt_w = 0
for i in range(n):
  if s[i] == 'W':
    cnt_w += 1
  accum_w[i+1] = cnt_w

cnt_e = 0
for j in range(n-1, -1, -1):
  if s[j] == 'E':
    cnt_e += 1
  accum_e[j] = cnt_e

# print(accum_w)
# print(accum_e)

ans = 2**64-1
for i in range(n):
  ans = min(ans, accum_w[i]+accum_e[i+1])

print(ans)


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

using namespace std;

const int N = 100 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;

string s;

bool read() {
    if (!(cin >> s))
        return false;

    return true;
}

void solve() {
    sort(s.begin(), s.end());

    if (s[0] == s[1] && s[2] == s[3] && s[0] != s[3])
        cout << "Yes\n";
    else
        cout << "No\n";
}

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

    while (read())
        solve();

    return 0;
}



Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    N = int(input())
    P = tuple(map(int, input().split()))
    Q = tuple(map(int, input().split()))

    ls = [0] * 9
    ls[0] = 1
    for i in range(N):
        ls[i+1] = ls[i] * (i+1)

    p_sum = 0
    q_sum = 0
    p_ls = [1,2,3,4,5,6,7,8]
    q_ls = [1,2,3,4,5,6,7,8]
    for j in range(N):
        p_sum += p_ls.index(P[j]) * ls[N-j-1]
        p_ls.remove(P[j])
        q_sum += q_ls.index(Q[j]) * ls[N-j-1]
        q_ls.remove(Q[j])
    
    print(abs(p_sum - q_sum))

if __name__ == '__main__':
    main()


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

lint gcd(lint x, lint y) {
  if(x == 0) { return y; }
  else { return gcd(y%x,x); }
}

lint lcm(lint x, lint y) { return x/gcd(x,y)*y; }

lint C(lint n, lint k) {
  if(n == k) { return 1; }
  else if(n < k) { return 0; }
  else if(k == 0) { return 1; }
  else if(k == 1) { return n; }
  else return C(n-1,k-1) + C(n-1,k);
}

lint P(lint n, lint k) {
  if(k == 1) { return n; }
  return (n*(P(n-1,k-1)%1000000007)%1000000007);
}


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

  sort(a.begin(),a.end());

  lint ans=a[0];
  for(lint i=1;i<n;i++) {

    if((double)ans/1000000000000000000*(double)a[i] > 1 || (double)a[i]/1000000000000000000*(double)ans > 1) {
      cout << -1 << endl;
      return 0;
    }

    ans *= (lint)a[i];

    if(ans > 1000000000000000000) {
      cout << -1 << endl;
      return 0;
    }


  }

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

Measured memory_bytes: 4004
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         sort(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  int n, l; cin >> n >> l;
  vector<string> s(n); rep(i, n) cin >> s[i];
  sort(s);
  string ans = "";
  rep(i, n) ans += s[i];
  outl(ans);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned int ui;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
#define All(v) (v).begin(),(v).end()
#define Rep(i,n) for(int i = 0; i < (int)n; i++)
#define Reps(i,n) for(int i = 1; i <= (int)n; i++)
#define For(i,m,n) for(int i = m; i < n; i++)
#define Fors(i,m,n) for(int i = m; i <= n; i++)
#define Inf 2e9
#define F first
#define S second
#define pb push_back
#define mp make_pair
struct speed{speed(){cin.tie(); ios::sync_with_stdio(false); cout << fixed << setprecision(18);}}speed;

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

ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

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


int main (){
    int n,k;
    cin >> n >> k;
    double ans = 0;
    Reps(i,n){
        double prob = 1.0/n;
        int now = i;
        while(now < k){
            prob = prob / 2;
            now = now * 2;
        }
        ans += prob;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

using ll = long long;
using ld = long double;
using ull = unsigned long long;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

const int N = 210000;

int n;

void no() {
	cout << "No\n";
	exit(0);
}

int cnt;
vector<int> eds[N];
int p[N];

int get(int x) {
	if (x == p[x])
		return x;
	return p[x] = get(p[x]);
}

void un(int x, int y) {
	x = get(x);
	y = get(y);
	assert(x != y);
	p[x] = y;
}

void add(int x, int y) {
	cout << x << " " << y << "\n";
	//un(x, y);
	//++cnt;
	//eds[x].push_back(y);
	//eds[y].push_back(x);
}


bool dfs1(int v, int d, int now, int p = -1) {
	if (v <= n)
		now ^= v;
	else
		now ^= v - n;
	if (v == d) {
		assert(now == d - n);
		return 1;
	}
	for (int u: eds[v])
		if (u != p)
			if (dfs1(u, d, now, v))
				return 1;
	return 0;
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cout.setf(ios::fixed), cout.precision(20);
	cin >> n;
	for (int i = 1; i <= 2 * n; ++i)
		p[i] = i;
	if (n <= 2)
		no();
	int x = n + 1;
	int k = 0;
	while (x > 1)
		x >>= 1, k += 1;
	if (n == (1 << k))
		no();
	cout << "Yes\n";
	for (int i = 1; i + 1 < (1 << k); ++i)
		add(i, i + 1);
	add((1 << k) - 1, n + 1);
	for (int i = 1; i + 1 < (1 << k); ++i)
		add(n + i, n + i + 1);
	for (int i = (1 << k); i <= n; i += 2) {
		if (i < n) {
			add(i, i + 1);
			add(1, i);
			add(n + i, n + i + 1);
			add(1, n + i + 1);
		}
		else {
			add(i, n + i - 1);
			int now = i ^ (i - 1);
			add(n + i, now - 1);
		}
	}
	//assert(cnt == 2 * n - 1);
	//for (int i = 1; i <= n; ++i)
	//	assert(dfs1(i, n + i, 0));
	return 0;
}




Measured memory_bytes: 8320
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define  all(x) (x).begin(),(x).end()
typedef long long ll;

vector<int> frnd[100005];
vector<int> group(100005, 0);

void dfs(int node, int parentNode, int groupId){
    group[node] = groupId;
    for(int x: frnd[node]){
        if (x == parentNode) continue;
        if (group[x] != 0) continue;
        dfs(x, node, groupId);
    }
}

int main(){
    int n, m;
    cin >> n >> m;
    rep(i,m){
        int s, t;
        cin >> s >> t;
        frnd[s].push_back(t);
        frnd[t].push_back(s);
    }

    int gropuId = 1;
    rep(i,n){
        if (group[i] != 0) continue;
        dfs(i, -1, gropuId);
        gropuId++;
    }

    int q;
    cin >> q;
    vector<string> ans(q);
    rep(i,q){
        int s, t;
        cin >> s >> t;
        if (group[s] == group[t]) ans[i] = "yes";
        else ans[i] = "no";
    }
    rep(i,q){
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 13916
using System;
using System.Collections.Generic;

namespace AOJ
{
    class Program
    {

        const int BLOCK_W = 2;
        const int BLOCK_H = 4;

        private int w, h;
        private int[,] borad;
        private int start_x;
        private int start_y;
        private int goal_x;
        private int goal_y;

        private bool isToGoal(int c,int x,int y){

            if (x > w || y > h) return false;
            if (borad[x, y] != c) return false;
            if (x == goal_x && goal_y == y) return true;

            borad[x, y] += 10; //通過フラグ

            bool r = false;
            r = isToGoal(c, x + 1, y);
            if (!r) r = isToGoal(c, x - 1, y);
            if (!r) r = isToGoal(c, x, y + 1);
            if (!r) r = isToGoal(c, x, y - 1);
            return r;
        }

        private string solve(int p_w,int p_h)
        {
            w = p_w;
            h = p_h;
            string[] tmp_start = Console.ReadLine().Split(new char[] { ' ' });
            string[] tmp_goal = Console.ReadLine().Split(new char[] { ' ' });
            start_x = int.Parse(tmp_start[0]);
            start_y = int.Parse(tmp_start[1]);
            goal_x = int.Parse(tmp_goal[0]);
            goal_y = int.Parse(tmp_goal[1]);

            borad = new int[w+1,h+1];
            
            int n = int.Parse(Console.ReadLine());

            //ブロック読み込み
            for (int i = 0; i < n; i++)
            {
                string[] block_i = Console.ReadLine().Split(new char[] { ' ' });
                int color = int.Parse(block_i[0]);
                int d = int.Parse(block_i[1]);
                int x = int.Parse(block_i[2]);
                int y = int.Parse(block_i[3]);

                int x_e,y_e;
                if (d == 0)
                {
                    x_e = x + BLOCK_H - 1;
                    y_e = y + BLOCK_W - 1;
                }
                else
                {
                    x_e = x + BLOCK_W - 1;
                    y_e = y + BLOCK_H - 1;
                }
                for(int x_i = x;x_i<= x_e;x_i++){
                    for (int y_i = y; y_i <= y_e;y_i++ )
                    {
                        borad[x_i, y_i] = color;
                    }   
                }
            }

            //for (int i = 0; i < w; i++)
            //{
            //    for (int j = 0; j < h; j++)
            //    {
            //        Console.Write(borad[i, j].ToString() + ",");
            //    }
            //    Console.WriteLine();
            //}

            for (int c = 1; c <= 5; c++)
            {
                if (isToGoal(c, start_x, start_y)) return "OK";
            }
            return "NG";

        }
        
        static void Main(string[] args)
        {
            Program obj = new Program();
            while (true) {
                string[] s = Console.ReadLine().Split(new char[] { ' ' });
                if (s[0] == "0" && s[1] == "0") break;
                Console.WriteLine(obj.solve(int.Parse(s[0]), int.Parse(s[1])));
            }
        }
    }
}

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

int main(){
    string s;
    cin >> s;
    int ans;
    if(s == "SUN"){
        ans = 7;
    }
    if(s == "MON"){
        ans = 6;
    }
    if(s == "TUE"){
        ans = 5;
    }
    if(s == "WED"){
        ans = 4;
    }
    if(s == "THU"){
        ans = 3;
    }
    if(s == "FRI"){
        ans = 2;
    }    
    if(s == "SAT"){
        ans = 1;
    }
    cout << ans << endl;
    return 0;
}

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

int main(void) {
    int N, M;
cin >> N >> M;
const int NMMAX = 50;
    int A[NMMAX], B[NMMAX];
for (int i=0;i<M;++i){ cin >> A[i] >> B[i];
}
int road[NMMAX];
for (int i=0;i<N;++i){
road[i] = 0; }
for (int i=0;i<M;++i){ road[A[i] - 1] += 1; road[B[i] - 1] += 1;
}
for (int i=0;i<N;++i){ cout << road[i] << endl;
}
return 0; }



Measured memory_bytes: 3544
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
	int n, w;
	int value[1000];
	int weight[1000];
	int dp[101][10001] = { 0 };
	cin >> n >> w;

	REP(i, n){
		cin >> value[i];
		cin >> weight[i];
	}
	for (int i = 0; i < n; i++){
		for (int j = 0; j <= w; j++){
			if (j < weight[i])
				dp[i + 1][j] = dp[i][j];
			else
				dp[i+1][j] = max(dp[i][j],dp[i][j-weight[i]]+value[i]);
		}
	}
	cout <<dp[n][w] <<endl ;
}

Measured memory_bytes: 5120
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace B
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var n = int.Parse(Console.ReadLine());
            var k = n.ToString().Sum(x => x - '0');
            Console.WriteLine(n % k == 0 ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;
void chmax(int &a, int b) { a = max(a, b); }

int n;
int r[1000], w[1000];
bool dp[1001][1001];

void toSort() {
	typedef pair<int, int> P;
	vector<P> vec;
	for (int i = 0; i < n; i++) vec.push_back(P(r[i], w[i]));
	sort(vec.begin(), vec.end(), greater<P>());
	for (int i = 0; i < n; i++) {
		r[i] = vec[i].first;
		w[i] = vec[i].second;
	}
}

int main() {
	int i, j;
	
	while (cin >> n) {
		if (!n) break;
		rep(i, n) cin >> r[i] >> w[i]; toSort();
		
		int sum_r = 0;
		rep(i, n) sum_r += r[i];
		int blank = max(0, 2 * r[0] - sum_r);
		
		rep(i, n+1) rep(j, blank+1) dp[i][j] = false;
		dp[0][0] = true;
		rep(i, n) {
			rep(j, blank + 1) {
				dp[i + 1][j] |= dp[i][j];
				if (i > 0 && j + w[i] <= blank) dp[i + 1][j + w[i]] |= dp[i][j];
			}
		}
		
		int max_wb = 0;
		rep(j, blank + 1) {
			if (dp[n][j]) chmax(max_wb, j);
		}
		
		int gokei = 0;
		rep(i, n) gokei += r[i] + w[i];
		
		cout << gokei + blank - max_wb << endl;
	}
	return 0;
}

Measured memory_bytes: 4056
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_lr(i,l,r) for(int i=(l);i<(r);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr int INF = INT_MAX >> 1;
constexpr ll LINF = 5000000000000000LL;
constexpr int MOD = 1000000007;

int main() {

	int n, m;
	cin >> n >> m;
	vi x(m);
	rep(i, m)cin >> x[i];
	sort(all(x));
	vi dist(m - 1);
	rep(i, m - 1)dist[i] = x[i + 1] - x[i];
	sort(all(dist));

	int ans = 0;
	rep(i, m - n)ans += dist[i];
	cout << ans << endl;
}

Measured memory_bytes: 4036
from collections import deque
H,W=map(int,input().split())
S=[input() for i in range(H)]
visit=[[False]*W for i in range(H)]
par=[[None]*W for i in range(H)]
dd={}
X=[-1,0,1,0]
Y=[0,-1,0,1]
for j in range(H):
    for i in range(W):
        if visit[j][i]:
            continue
        if S[j][i]=='.':
            continue
        lH=deque()
        lH.append((j,i,0))#0が黒
        par[j][i]=(i,j)
        num=0
        while lH:
            y,x,t=lH.popleft()
            visit[y][x]=True
            for k in range(4):
                nx=x+X[k]
                ny=y+Y[k]
                if 0<=nx<W and 0<=ny<H:
                    if visit[ny][nx]:
                        continue
                    if t==0 and S[ny][nx]=='.':
                        visit[ny][nx]=True
                        num+=1
                        lH.append((ny,nx,1))
                    elif t==1 and S[ny][nx]=='#':
                        visit[ny][nx] = True
                        par[ny][nx]=(i,j)
                        lH.append((ny,nx,0))
        dd[(i,j)]=num
#print(par)
#print(dd)
ans=0
for j in range(H):
    for i in range(W):
        if S[j][i]=='#':
            x,y=par[j][i]
            ans+=dd[(x,y)]
print(ans)

Measured memory_bytes: 64604
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

int main() {
  int x;
  scanf("%d", &x);
  ll n = 1;
  while(n*(n+1)/2 < x) n++;
  printf("%lld\n", n);
}


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

using namespace std;

int sum(long long t){
	int res = 0;
	while(t){
		res += t%10;
		t /= 10;
	}
	return res;
}

bool valid(long long a, long long b){
	return a * sum(b) <= b * sum(a);
}

int main(){
	long long add = 1;
	vector<long long> res;
	res.push_back(1);
	while(res.back() < 1000000000000000){
		long long next = res.back() + add;
		if(valid(res.back(), next)){
			res.push_back(next);
		} else {
			res.pop_back();
			add *= 10;
		}
	}
	int K;
	while(cin >> K){
		for(int i=0;i<min<int>(res.size(), K);i++) cout << res[i] << endl;
	}
}

Measured memory_bytes: 256
use std::cmp::Ordering::*;
use std::io;
use std::io::prelude::*;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut buffer = String::new();
    io::stdin().read_to_string(&mut buffer)?;
    let mut input = buffer.lines();
    input.next();
    let mut input = input.map(|s| s.split_whitespace());
    let mut elevations: Vec<(u32, bool)> = input.next().unwrap().map(|n| (n.parse().unwrap(), true)).collect();
    let input = input.map(|l| l.map(|n| n.parse::<usize>().unwrap() - 1));
    for mut pair in input {
        let left = pair.next().unwrap();
        let right = pair.next().unwrap();
        match elevations[left].0.cmp(&elevations[right].0) {
            Less => elevations[left].1 = false,
            Equal => { elevations[left].1 = false; elevations[right].1 = false; },
            Greater => elevations[right].1 = false,
        }
    }
    let output = elevations.into_iter().filter(|&(_, good)| good).count();
    println!("{}", output);
    Ok(())
}


Measured memory_bytes: 5060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;
int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int ans = max({a, b, c}) - min({a, b, c});
    out(ans);
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)      x.begin(), x.end()
#define SIZE(x)     static_cast<i64>(x.size())
#define rep(i,n)    for (i64 i = 0, i ## _limit = (n); i < i ## _limit; ++i)
#define reps(i,s,t) for (i64 i = (s), i ## _limit = (t); i <= i ## _limit; ++i)
#define repr(i,s,t) for (i64 i = (s), i ## _limit = (t); i >= i ## _limit; --i)

#ifdef DBG
#define trace(...) _trace(#__VA_ARGS__, __VA_ARGS__);
#else
#define trace(...)
#endif

using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template<class T, class U>inline bool chmax(T &a, const U &b){return b>a && (a=b, true);}
template<class T, class U>inline bool chmin(T &a, const U &b){return b<a && (a=b, true);}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template<class T>
ostream& operator<< (ostream &os, const vector<T> &vec) {
    rep(i, vec.size()) os << vec[i] << (i+1 == vec.size() ? "" : " ");
    return os;
}

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

template<class Itr>
ostream& printContainer(Itr begin, Itr end, const string &separator = " ", ostream &os = cout) {
    const auto rbegin = std::prev(end);
    for (; begin != rbegin; ++begin) os << *begin << separator;
    os << *rbegin;
    return os;
}

ostream& operator<< (ostream &os, ostream&) {
    return os;
}

template <class T>
void _trace(const char *s, T&& x) {
    clog << '{';
    while(*s != '\0') clog << *(s++);
    clog << ":" << setw(3) << x << '}' << endl;
}

template <class Head, class... Tail>
void _trace(const char *s, Head&& head, Tail&&... tail) {
    clog << '{';
    while(*s != ',') clog << *(s++);
    clog << ":" << setw(3) << head << "}, ";
    for (++s; !isgraph(*s); ++s);
    _trace(s, std::forward<Tail>(tail)...);
}
// }}} End Header

signed main()
{
    // ios::sync_with_stdio(false); cin.tie(nullptr);
    string s;
    cin >> s;

    rep(i, SIZE(s) - 1) {
        char a = s[i];
        char b = s[i+1];
        char c = (i+2 < SIZE(s)) ? s[i+2] : '~';

        if (a == b) {
            cout << make_pair(i+1, i+2) << endl;
            return 0;
        } else if (a == c) {
            cout << make_pair(i+1, i+3) << endl;
            return 0;
        }
    }

    cout << make_pair(-1, -1) << endl;

    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
 
long long inv;
int *B;
 
long long countup(int *A, int p, int r);
 
int main(int argc, char *argv[])
{
  int n, i, j;
  int *A;
 
  inv = 0;
 
  scanf("%d", &n);
  A = (int *)malloc(sizeof(int) * n);
  B = (int *)malloc(sizeof(int) * n);
  for (i = 0; i < n; i++) scanf("%d", &A[i]);
 
  inv = countup(A, 0, n - 1);
 
  printf("%lld\n", inv);
 
  return 0;
}
 
long long countup(int *A, int p, int r)
{
  int q = p + (r-p)/2;
  int i, j, k, tmp;
  long long ct = 0;
 
  if (r - p < 3) {
    for (i = p; i < r; i++) {
      for (j = r; j > i; j--) {
    if (A[j] < A[j-1]) {
      tmp = A[j-1];
      A[j-1] = A[j];
      A[j] = tmp;
      ct++;
    }
      }
    }
    return ct;
  }
  ct += countup(A, p, q);
  ct += countup(A, q+1, r);
 
  i = p;
  j = q + 1;
  for (k = p; k <= r; k++) {
    if (i >= q + 1 || j >= r + 1) {
      if (i >= q + 1) B[k] = A[j++];
      else B[k] = A[i++];
    } else {
      if (A[i] > A[j]) {
    B[k] = A[j];
    ct += q - i + 1;
    j++;
      } else {
    B[k] = A[i];
    i++;
      }
    }
  }
  for (k = p; k <= r; k++) A[k] = B[k];
  return ct;
}

Measured memory_bytes: 3324
N = int(input())
ptn = [[0 for _ in range(10)] for __ in range(10)]
for num in range(1, N+1):
  str_num = str(num)
  if str_num[-1] != 0:
    ptn[int(str_num[0])][int(str_num[-1])] += 1
answer = 0
for i in range(10):
  for j in range(i, 10):
    if i == j:
      answer += ptn[i][j]**2
    else:
      answer += ptn[i][j]*ptn[j][i]*2
print(answer)

Measured memory_bytes: 73180
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	long long int q, h, s, d, n;
	cin >> q >> h >> s >> d >> n;
	long long int k = min(min(q * 4, h * 2), s);
	if(k * 2 > d){
		cout << (n / 2) * d + (n % 2) * k << endl;
	}else{
		cout << k * n << endl;
	}
}

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

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

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
    
    int n;
    char s[max];
    int cnt=0, mmax=INT_MIN;
    
    scanf("%d%s", &n, s);
    
    for (int i=0; i<n-1; i++) {
        int a[max]={0}, b[max]={0};
        cnt=0;
        for (int j=i+1; j<n; j++) {
            b[s[j]-97]++;
        }
        for (int k=0; k<i+1; k++) {
            a[s[k]-97]++;
        }
        rep(l, 26){
            if (a[l]!=0&&b[l]!=0) {
                cnt++;
                //printf("%d,", l);
            }
        }
        if (cnt>mmax) {
            mmax=cnt;
        }
    }
    
    printf("%d", mmax);
    
    return 0;
}


//s[i]-97;


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

const unsigned long long M = 1000000007;

bitset<30> b;

unsigned long long inv2() {
    b = M-2;
    unsigned long long p = 2;
    unsigned long long ans = 1;
    for (int i = 0; i < b.size(); i++) {
        if (b.test(i)) {
            ans = (ans * p) % M;
        }
        p = (p * p) % M;
    }
    return ans;
}

int main() {
    int n;
    unsigned long long ans = 0;
    unsigned long long c;
    unsigned long long d = 0;
    unsigned long long j = inv2();
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> c;
        ans = (ans + c) % M;
        d = (d + (c * c) % M) % M;
    }
    ans = ((((ans * ans) % M + M - d) % M) * j) % M;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3592
#include <stdio.h>

void matrixChainOrder(int*,int*,int);
int m(int,int);

int min[101][101];


void debug(int n){
  int i,j;
  for(i=0;i<=n;i++){
    for(j=0;j<=n;j++){
      printf("%d %d    %d\n",i,j,min[i][j]);
    }
  }

}


int main(){
  int i,j,n,r[101],c[101];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d%d",&r[i+1],&c[i+1]);
  }

  matrixChainOrder(r,c,n);

  printf("%d\n",min[1][n]);

  //debug(n);

  return 0;
}

void matrixChainOrder(int *r,int *c,int n){
  int i,j,k,l,q;

  for(i=1;i<=n;i++) min[i][i]=0;

  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
      min[i][j]=1000000000;

      for(k=i;k<=j-1;k++){
	q=min[i][k]+min[k+1][j]+r[i]*c[k]*c[j];

	min[i][j]=m(min[i][j],q);
      }
    }
  }

}

int m(int a,int b){
  return a<b ? a : b;
}



Measured memory_bytes: 2052
import java.util.Scanner;

public class Main {

    public static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        long[] a = new long[n];
        long sum = 0;
        for (int i = 0; i < n; i++) {
            long temp = Long.parseLong(sc.next());
            a[i] = temp;
            sum += temp;
            sum %= MOD;
        }
        long ans = sum * sum % MOD;
        for (int i = 0; i < n; i++) {
            ans = (ans - (a[i] * a[i] % MOD) + MOD) % MOD;
            ans %= MOD;
        }
        System.out.println(divide(ans, 2));
    }

    private static long multiply(long a, long b) {
        return (((long) a * b) % MOD);
    }

    private static long divide(long a, int b) {
        return multiply(a, pow(b, MOD - 2));
    }

    private static long pow(int n, int k) {
        if (k == 0) {
            return 1;
        } else if (k % 2 == 0) {
            long p = pow(n, k / 2);
            return multiply(p, p);
        } else {
            long p = pow(n, (k - 1) / 2);
            return multiply(multiply(p, p), n);
        }
    }
}

Measured memory_bytes: 61036
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    if(n==1) {
    	System.out.println("Hello World");
    } else {
    	int a = sc.nextInt();
    	int b = sc.nextInt();
    	System.out.println(a+b);
    }
    
    }
 }


Measured memory_bytes: 21076
#include <iostream>
#include <cstdio>
#include <cfloat>
#include <cmath>
#include <iomanip>
using namespace std;
using llong = long long;

llong n, k, t, u, v, l;
llong d[205];

int main() {
    cin >> n >> k >> t >> u >> v >> l;
    for (int i = 0; i < n; i++) {
        cin >> d[i];
    }

    long double ans = 0; //time
    llong ptr = 0; // d[ptr]
    llong speed = u; // (m/s)
    long double time = 0; // 加速していられる残り時間
    llong stock = 0;
    for (int i = 1; i <= l; i++) {
        
        ans += 1.0 / speed;
        if (time > DBL_EPSILON) {
            time -= 1.0 / speed;
            if (time < DBL_EPSILON) {
                speed = u;
                time = 0;
            }

            if (time < DBL_EPSILON && stock > 0) {
                stock--;
                speed = v;
                time = t;
            }
        }

        if (i == d[ptr]) {
            if (time > DBL_EPSILON && stock < k) {
                stock++;
            }
            else if (time < DBL_EPSILON || stock >= k) {
                time = t;
                speed = v;
            }

            ptr++;
        }
    }

    cout << fixed << setprecision(15) << ans << endl;
}



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

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

  vector<vector<int>> graph(n);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    graph.at(a).push_back(b);
    graph.at(b).push_back(a);
  }

  // vector<int> dist(n, -1);
  vector<int> guide_post(n, -1);
  queue<int> que;

  guide_post[0] = 0;
  que.push(0);

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

    // graph[1][0] = 0
    // graph[1][1] = 2
    // graph[1][2] = 3
    //
    // graph[1]
    //   0 は -1 ではないのでスキップ
    //   2 は -1 のため、処理を行う
    //
    for (int nv : graph[v]) {
      if (guide_post[nv] != -1) {
        continue;
      }
      // guide_post[2] = 1;
      guide_post[nv] = v;
      que.push(nv);
    }
  }

  bool flag = true;
  for (int v = 1; v < n; v++) {
    if (guide_post[v] == -1) {
      flag = false;
    }
  }
  if (flag == true) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  for (int v = 1; v < n; v++) {
    cout << (guide_post[v] + 1) << endl;
  }

  return 0;
}


Measured memory_bytes: 10156
import math
a, b, h, m = map(int, input().split())
double_pi = math.pi * 2
hx = a * math.sin(double_pi * (h / 12 + (1 / 12 * m / 60)))
hy = a * math.cos(double_pi * (h / 12 + (1 / 12 * m / 60)))
mx = b * math.sin(double_pi * m / 60)
my = b * math.cos(double_pi * m / 60)
ans = (hx - mx) ** 2 + (hy - my) ** 2
ans **= 0.5
print(ans)

Measured memory_bytes: 9524
#include <bits/stdc++.h>
#define int long long
using namespace std;
 
 
const int N = 2e5 + 7;

int a[N];
 
int32_t main() {
		int n, k; cin >> n >> k;
		for(int i = 1; i <= n; i++) cin >> a[i];
		sort(a + 1, a + n + 1, greater <int> ());

		int ans = 0;
		for(int i = k + 1; i <= n; i++) ans += a[i];

		cout << ans << endl;
}

Measured memory_bytes: 1792
// ConsoleApplication7.cpp : ??????????????? ??¢????????±????????§????????¨????????? ?????????????????????????????????
//

#include <stdio.h>

int main(int argc, char* argv[])
{
	int i;
	int a, b, c;
	int num = 0;
	char temp[18];

	fgets(temp, sizeof(temp), stdin);
	sscanf(temp, "%d %d %d", &a, &b, &c);
	
	for (i = a; i <= b; i++) {
		if (c % i == 0) num++;
	}
	printf("%d\n", num);
	
	return 0;
}

Measured memory_bytes: 2708
#!/usr/bin/env python3

import sys
# import math
# from string import ascii_lowercase, ascii_upper_case, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)


def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1               # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    n, k = mi()
    h = [ii() for _ in range(n)]
    h.sort()
    ans = inf
    for i in range(n - k + 1):
        j = i + (k - 1)
        ans = min(ans, h[j] - h[i])
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 7512
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
template<class T> using V=vector<T>; 
typedef pair<ll,ll> P;
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
vector<vector<int>> graph;
vector<ll> d1;
int n,m;
int main(){
    cin>>n;
    graph.resize(n);
    for(int i=0;i<n-1;i++){
        int a,b;
        cin>>a>>b;
        a--;b--;
        graph[a].emplace_back(b);
        graph[b].emplace_back(a);
    }
if(n<=3){
    if(n==2)cout<<1<<" "<<2<<endl;
    if(n==3)cout<<1<<" "<<2<<" "<<3<<endl;
    return 0;
    }
    int d=-1;
    for(int i=0;i<n;i++){
        if(graph[i].size()==1){
            d=i;
            break;
        }
    }
    queue<P> q;
    V<bool> used(n,false);
    used[d]=true;
    q.emplace(d,0);
    V<V<ll>> dat(2);
   // cout<<d<<endl;
    // cout<<111<<endl;
    while(q.size()){
        int now=q.front().fi,c=q.front().se;
        q.pop();
        dat[c].emplace_back(now);
        for(int v:graph[now]){
            if(used[v])continue;
            used[v]=true;
            q.emplace(v,c^1);
        }
    }
    set<ll> s;
    for(int i=1;i<=n;i++)s.insert(i);
    V<ll> ans(n,inf);
    int th=1;
    if(dat[0].size()<=n/3){
        for(int v:dat[0]){
                ans[v]=th*3;
                s.erase(th*3);
                th++;
        }

    }
    else if(dat[1].size()<=n/3){
        for(int v:dat[1]){
                ans[v]=th*3;
                s.erase(th*3);
                th++;
        }

    }
    else{
    for(int i=0;i<2;i++){
        int t=0;
        for(ll v:dat[i]){
            ll val=t*3+(i+1);
            if(s.find(val)==s.end()){
                if(s.find(th*3)==s.end()){
                    break;
                }
                ans[v]=th*3;
                s.erase(th*3);
                th++;
                continue;
            }
            ans[v]=val;
            s.erase(val);
            t++;
        }
    }
}
if(s.size()){
    for(int i=0;i<n;i++){
        if(ans[i]==inf){
            ans[i]=*s.begin();
            s.erase(ans[i]);
        }
    }
}
for(int i=0;i<n;i++)cout<<ans[i]<<" ";
cout<<endl;
}

Measured memory_bytes: 25708
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int a = scan.nextInt();

		if(x < a) {
			System.out.println(0);
		}else {
			System.out.println(10);
		}
	}
}


Measured memory_bytes: 23892
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
long long N;

int main(){
  int N;
  cin >> N;
  int a[N];
  rep(i, N){
    cin >> a[i];
  }
  sort(a, a+N);
  double ans = a[0];
  rep(i, N-1){
    ans =(double) (ans + a[i+1])/2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    int main(){
     long long  int n,d;
      cin>>n>>d;
      int count=0;
      while(n--){
         long long   int l=0;
       //  long long   int s=0;
       long long  int x,y;
        cin>>x>>y;
       l = x*x+y*y ;
        //int s=sqrt(x);
        if(l<=d*d)
          count++;}
      cout<<count<<endl;
        
        
    }

Measured memory_bytes: 3628