akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
#define vv(a,b,c,d) vector<vector<a> >(b,vector<a>(c,d))
#define vvv(a,b,c,d,e) vector<vector<vector<a> > >(b,vv(a,c,d,e))
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

ll f(ll x) {
    ll res = 0;
    while (x > 0) {
        res += x % 10;
        x /= 10;
    }
    RT res;
}

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

    ll N;
    cin >> N;
    ll ans = f(N);

    string S = to_string(N);

    rep(i, sz(S)) {
        string T = S;
        if (T[i] == '0')continue;
        T[i]--;
        FOR(j, i + 1, sz(T))T[j] = '9';
        smax(ans, f(stoll(T)));
    }
    cout << ans << endl;
}

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

int main(){
  string S;
  cin >> S;
  if (S == "AAA" || S == "BBB") cout << "No" << endl;
  else cout << "Yes" << endl;
}


Measured memory_bytes: 3604
#入力
N = int(input())
H = list(map(int,input().split()))

#処理
ans = 0
#iは今見ている山
for i in range(N):

    #自分より高い山がなかったかどうかのフラグ
    flag = True

    #j これから調べる山 iより西側なので、i未満について調べる
    for j in range(0,i):
        if H[j] > H[i]:
            flag = False
    if flag:
        ans+=1

#出力
print(ans)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e18;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N;
    string S,T;
    cin >> N >> S >> T;
    for(int i = N; i >= 0; i--) {
        if(S.substr(N-i,i) == T.substr(0,i)) {
            cout << N*2-i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1000000000000;
signed main() {
	int n, ng = 0; cin >> n; vector<vector<int>> asd(123456, vector<int>(3));
	for (int h = 0; h < n; h++) {
		cin >> asd[h][2] >> asd[h][1] >> asd[h][0];
	}
	sort(asd.begin(), asd.end()); reverse(asd.begin(), asd.end());
	for (int h = 0; h < n; h++) {
		swap(asd[h][2], asd[h][0]);
	}
	for (int h = 0; h <= 100; h++) {
		for (int i = 0; i <= 100; i++) {
			int z = 0, ok = 0;
			for (int j = 0; j < n; j++) {
				if (asd[j][2] == 0) {
					if (z - abs(asd[j][0] - h) - abs(asd[j][1] - i) > 0) { z = INF; break; }
					continue;
				}
				if (ok == 0) { z = abs(asd[j][0] - h) + abs(asd[j][1] - i) + asd[j][2]; ok++; }
				else {
					if (z != abs(asd[j][0] - h) + abs(asd[j][1] - i) + asd[j][2]) {
						z = INF; break;
					}
				}
			}
			if (z != INF) { cout << h << ' ' << i << ' ' << z << endl; return 0; }
		}
	}
	return 0;
}

Measured memory_bytes: 10132
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
#include<unordered_set>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

VI g[55];
bool a[55][55];
signed main(void)
{
	while(1) {
		int n;
		cin >> n;
		if(!n) break;
		REP(i, 30) g[i].erase(ALL(g[i]));
		REP(i, n) REP(j, n) a[i][j] = false;
		REP(i, n) {
      int m;
      cin >> m;
      REP(j, m) {
        int f;
        cin >> f;
        f--;
        g[f].PB(i);
      }
			a[i][i] = true;
    }
		//REP(j, n) cout << a[j] << endl;
		bool no = true;
		REP(i, 30) {
			REP(j, g[i].size()) {
				FOR(k, j+1, g[i].size()) {
					REP(l, n) {
						bool t = a[g[i][j]][l] || a[g[i][k]][l];
						a[g[i][j]][l] = t;
						a[g[i][k]][l] = t;
					}
				}
			}
			//cout << "i:" << i << endl;
			//REP(j, n) cout << a[j] << endl;
			bool flag = false;
			REP(j, n) {
				bool f = true;
				REP(k, n) {
					if(!a[j][k]) f = false;
				}
				if(f) flag = true;
			}
			if(flag) {
				cout << i+1 << endl;
				no = false;
				break;
			}
		}
		if(no) {
			cout << -1 << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3132
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define int long long
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB emplace_back
#define PF emplace_front
#define FILL(a,b) memset(a,b,sizeof(a))
#define lwb lower_bound
#define upb upper_bound
using namespace std;
int n,mod=1e9+7;
P<int,int> p[200005];
map<P<int,int>,int> m;
int POW(int x,int y){
	if(!y)RE 1;
	int t=POW(x,y/2);
	t=t*t%mod;
	if(y&1)t=t*x%mod;
	RE t;
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;
	int x,y,ans=1,c=0;
	FOR(i,1,n){
		cin>>x>>y;
		if(!x){
			if(!y){c++;
			}else m[MP(0ll,1ll)]++;
		}else if(!y)m[MP(1ll,0ll)]++;
		else{
			int t=__gcd(x,y);
			x/=t;y/=t;
			if(x<0){
				x=-x;y=-y;
			}
			m[MP(x,y)]++;
		}
	} 
	for(auto u:m){
		int x=u.F.F,y=u.F.S,z=u.S,cnt=POW(2,z);
		if(!z)continue;
		if(x>=0&&y>=0){
			if(m.count(MP(y,-x))){
				cnt=(cnt+POW(2,m[MP(y,-x)])-1)%mod;
				m[MP(y,-x)]=0;
			}
			ans=ans*cnt%mod;
		}else{
			if(m.count(MP(-y,x))){
				cnt=(cnt+POW(2,m[MP(-y,x)])-1)%mod;
				m[MP(-y,x)]=0;
			}
			ans=ans*cnt%mod;
		} 
	}
	cout<<(ans-1+mod+c)%mod<<'\n';
	RE 0;
}




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

int main(){
	int x,y,w,h,r;
	cin >> w >> h >> x >> y >> r;
	
	if((x<=w-r)&&(x>=r)&&(y<=h-r)&&(y>=r )) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i < n; i++)
#define elif else if
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = 1e15;

int main(){
    ll N, A, B, C, D, x, s, c, d;
    cin >> N >> A >> B >> C >> D;
    x = max(A-B, B-A);
    s = C + D;
    c = x + (N-1)*C;
    d = x + (N-1)*D;
    bool able = false;
    if(c%s == 0){
        if(c <= (N-1)*s) able = true;
    }
    else{
        if(c/s < d/s && c < (N-1)*s) able = true;
    }
    if(able) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,P> PP;

//-----------------------------------------------------------------------------

int a,b,c,d;

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

	cin>>a>>b>>c>>d;
	cout<<min(a,b)+min(c,d)<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
  
using namespace std;
  
typedef long long ll;
  
const int N = 2e5 + 5;
const int mod = 1e9 + 7;
struct node {
	double x, y;
}a[N];
double distance(node x) {
	return sqrt(x.x * x.x + x.y * x.y);
}
int main() {
	ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
	int n, d; cin >> n >> d;
	for(int i = 1; i <= n; i++) {
		cin >> a[i].x >> a[i].y;
	}
	int ans = 0;
	for(int i = 1; i <= n; i++) {
		if(distance(a[i]) <= d) ans++;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 6784
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            int n = int.Parse(Console.ReadLine());

            for (int i = 0; i < n; i++)
            {
                string input = Console.ReadLine();

                char[] temp = input.ToCharArray();
                Array.Sort(temp, (a, b) => b - a);
                int max = int.Parse(new string(temp));
                Array.Sort(temp);
                int min = int.Parse(new string(temp));

                sb.AppendLine((max - min).ToString());
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 9320
def selection_sort(array):
    count_swap = 0
    for i in range(len(array)):
        minj = i
        for j in range(i + 1,len(array)):
            if num(array[j]) < num(array[minj]):
                minj = j
        if num(array[minj]) is not num(array[i]):
            tmp = array[minj]
            array[minj] = array[i]
            array[i] = tmp
            count_swap += 1
    return count_swap

def bubble_sort(array):
    isEnd = False
    count_swap = 0
    while isEnd is False:
        isEnd = True
        for j in reversed(range(1,len(array))):
            if num(array[j - 1]) > num(array[j]):
                tmp = array[j - 1]
                array[j - 1] = array[j]
                array[j] = tmp
                count_swap += 1
                isEnd = False
    return count_swap

def print_array(array):
     print(str(array)[1:-1].replace(', ', ' ').replace('\'', ''))

def num(s):
    # print(s[1])
    return int(s[1])

def main():
    N = int(input())
    array = [s for s in input().split(' ')]
    array2 = [i for i in array]
    # print(array)
    bubble_sort(array)
    print_array(array)
    print('Stable')
    selection_sort(array2)
    print_array(array2)
    if array == array2:
        print('Stable')
    else:
        print('Not stable')

if __name__ == '__main__':
    main()

Measured memory_bytes: 7828
#include<iostream>
using namespace std;
int n;
bool flag=0;
int main()
{
cin>>n;
while (n)
{
	if (n<=0) break;
	if (n%10==9) {flag=1;break;}
	else 
	{
		n/=10;
	}
}
if (flag==1) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}

Measured memory_bytes: 256
//কী পেয়েছো তুমি, কী চেয়েছিলে তুমি.? হিসেবটা তোমার বড়ই গড়মিল...!!//
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
string ch="abcdefghijklmnopqrstuvwxyz";
typedef long long ll;
int main()
{
    string s;
    cin>>s;
    int n=s.size();
    string t="";
    for(int i=0;i<n;i++)t+="x";
    cout<<t<<endl;
}



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

int main() {
    string s;
    cin >> s;
    if ((s.at(0) == 'A' && s.at(1) == 'A' && s.at(2) == 'A') || (s.at(0) == 'B' && s.at(1) == 'B' && s.at(2) == 'B')) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>

using namespace std;


int main() {
    int a, b;
    cin >> a >> b;
    
    if (a + b == 15)
    {
        cout << "+" << endl;
    }
    else if (a * b == 15)
    {
        cout << "*" << endl;
    }
    else
    {
        cout << "x" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#template
def inputlist(): return [int(j) for j in input().split()]
#template
X,K,D= inputlist()
count = abs(X)//D +1
if K < count:
    print(min(abs(X-D*K),abs(X+D*K)))
    exit()
d_odd = 0
d_even = 0
if X >= 0:
    d_odd = X - D*(count-1)
    d_even = X-D*count
if X < 0:
    d_odd = X + D*(count-1)
    d_even = X + D*count
K -=count
if K % 2 == 0:
    print(abs(d_even))
else:
    print(abs(d_odd))

Measured memory_bytes: 9204
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def main():
    A, B, C, D = map(int, input().split())
    ans = -10**9**2

    for ab in (A, B):
        for cd in (C, D):
            if ab * cd > ans:
                ans = ab * cd

    print(ans)


if __name__ == "__main__":
    main()


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

int main() {
  int N,M,X,Y;
  cin >> N >> M >> X >> Y;
  vector<int> x(N);
  vector<int> y(M);

  int i=0;
  for(;i<N;i++){
    cin >> x.at(i);
  }
  for(i=0;i<M;i++){
    cin >> y.at(i);
  }
  sort(x.begin(), x.end());
  sort(y.begin(), y.end());
  if( (x.at(N-1)<Y) && (X<y.at(0)) && (x.at(N-1)<y.at(0))){
    cout << "No War" << endl;
  }else{
    cout << "War" << endl;
  }
}



Measured memory_bytes: 256
# coding: utf-8
# Your code here!
n=int(input())
v=[int(x) for x in input().split()]
if len(set(v))==1:
    print(n//2)
    import sys
    sys.exit()
from collections import Counter
v1=[]
v2=[]
for i in range(n):
    if i%2==0:
        v1.append(v[i])
    else:
        v2.append(v[i])
v1=Counter(v1)
v2=Counter(v2)
ans=10**10
# print(v1,v2)
for i1 in v1.most_common(min(len(v1),10)):
    for i2 in v2.most_common(min(len(v1),10)):
        # print(n-i1[1]-i2[1],i1,i2)
        if i1==i2:
            continue
        ans=min(n-i1[1]-i2[1],ans)
print(ans)

Measured memory_bytes: 82564
X,Y=map(int,input().split())
P=10**9+7

def fac(n,k,p):
    ans=1
    for i in range(n-k+1,n+1):
        ans=(ans*i)%p
    return ans

def makeinv(length,p):
    L=[0,1]
    for i in range(2,length+1):
        x=p-((L[p%i]*(p//i))%p)
        L.append(x)
    return L

def comb(n,k,p):
    ans=fac(n,k,p)
    inv=makeinv(k,p)
    for i in range(1,k+1):
        ans=(ans*inv[i])%p
    return ans

if (X+Y)%3!=0:
    print(0)
else:
    N=(X+Y)//3
    K=(2*Y-X)//3
    if N>=0 and K>=0:
        print(comb(N,K,P))
    else:
        print(0)

Measured memory_bytes: 19828
#include <iostream>
using namespace std;
int euler_phi(int n) {
  int r=n;
  for(int i=2;i*i<=n;i++) {
    if(!(n%i)){
      r-=r/i;
      while(!(n%i))n/=i;
    }
  }
  if(n>1)r-=r/n;
  return r;
}
int main() {
  int n;cin>>n;
  cout<<euler_phi(n)<<endl;
  return 0;
}

Measured memory_bytes: 3076
X, N = map(int, input().split(' '))
if N == 0:
    print(X)
else:
    P_ls = list(map(int, input().split(' ')))
    diff, rst = -1, 0
    for i in range(101, -1, -1):
        if i not in P_ls:
            if diff == -1:
                diff = abs(X - i)
                rst = i
            else:
                diff = min(diff, abs(X - i))
                if diff == abs(X - i):
                    rst = i
    print(rst)

Measured memory_bytes: 9208
N, M = gets.split.map(&:to_i)
ABs = readlines.map{|l| l.split.map(&:to_i)}

h = ABs.each_with_object(Hash.new(0)){|(a, b), h| h[a] += 1; h[b] += 1}
(1 .. N).each{|i| puts h[i]}

Measured memory_bytes: 1916
def gcd(a, b):
    if b == 0: return a
    return gcd(b, a%b)

n,k=map(int,input().split())
l=list(map(int,input().split()))
if k>max(l):print("IMPOSSIBLE");exit()
g=l[0]
for i in l:
    g=gcd(g,i)
if k%g==0:print("POSSIBLE")
else:print("IMPOSSIBLE")

Measured memory_bytes: 14224
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
typedef long long ll;

ll ft_sqrt(ll n)
{
	ll i = 1;
	ll cnt = 0;
	while (i <= n)
	{
		if (i % 2)
		{
			n -= i;
			cnt++;
		}
		i++;
	}
	return (cnt);
}

int main(void)
{
	ll N;
	scanf("%lld", &N);
	ll i = 1;
	ll a;
	ll b;
	while (i <= (ll)sqrt((double)N))
	{
		if (N % i == 0)
			a = i;
		i++;
	}
	b = N / a;
	printf("%lld", (a+b) - 2);
	return (0);
}


Measured memory_bytes: 256
#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)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int bit[1<<17+1],N;
int sum(int i){
    int s=0;
    while(i>0){
        s +=bit[i];
        i -=i&-i;
    }
    return s;
}
void add(int i,int x){
    while(i<=N){
        bit[i]+=x;
        i +=i&-i;
    }
}
int main(){
    int n,q,c,x,y;
    cin>>N>>q;
    rep(i,q){
        cin>>c>>x>>y;
        if(c==0) add(x,y);
        else{
            cout<<sum(y)-sum(x-1)<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3432
A, B, C, X, Y = map(int, input().split())
C *= 2
t,s,P = 0,max(X,Y),1000000000000
while s>=0:
  P = min(P, C*s+A*max(X-s, 0)+B*max(Y-s, 0))
  s -= 1
print(P)

Measured memory_bytes: 8832
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int x = sc.nextInt();
		if (k * 500 >= x) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

}

Measured memory_bytes: 20820
#define _USE_MATH_DEFINES
#include<iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main()
{
	string s;
	cin >> s;
	int len = s.length();
	
	int flug = 1;
	for (int i = 0; i < len; i++){
		for (int j = i + 1; j < len; j++){
			if (s[i] == s[j]){
				flug = 0;
				break;
			}
		}
		if (flug == 0){
			break;
		}
	}

	if (flug){
		cout << "yes";
	}
	else{
		cout << "no";
	}

	return 0;
}

Measured memory_bytes: 256
n = gets.to_i
p = gets.split.map(&:to_i)
sum = 0
flag = 0
(0...n).each do |i|
  if flag == 1
    flag = 0
    next
  end
  if p[i] == i + 1
    sum += 1
    flag = 1
  end
end
puts sum

Measured memory_bytes: 8068
import java.io.*;
import java.util.ArrayList;

class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        String[] input = br.readLine().split(" ");
        int n = Integer.parseInt(input[0]);
        int q = Integer.parseInt(input[1]);
        String[] names = new String[n];
        ArrayList<int[]> processes = new ArrayList<int[]>();
        int[] currentProcess;
        int time = 0;
        StringBuilder sb = new StringBuilder();

        for (int i = 0; i < n; i++) {
            input = br.readLine().split(" ");
            names[i] = input[0];
            processes.add(new int[] {i, Integer.parseInt(input[1])});
        }

        while (processes.size() > 0) {
            currentProcess = processes.remove(0);
            if (currentProcess[1] <= q) {
                time += currentProcess[1];
                sb.append(names[currentProcess[0]]).append(" ").append(time).append("\n");
            } else {
                time += q;
                currentProcess[1] -= q;
                processes.add(currentProcess);
            }
        }
        System.out.print(sb.toString());
    }
}

Measured memory_bytes: 56372
def trans(A):
    """????¬??????????????????¢???"""
    return list(map(list, zip(*A)))

if __name__ == '__main__':
    r, c = [int(i) for i in input().split()]
    sheet = [[int(i) for i in input().split()] for y in range(r)]
    [sheet[y].append(sum(sheet[y])) for y in range(r)]
    sheet = trans(sheet)
    [sheet[y].append(sum(sheet[y])) for y in range(c+1)]
    sheet = trans(sheet)
    [print(' '.join([str(i) for i in sheet[y]])) for y in range(r+1)]

Measured memory_bytes: 6836
import java.util.*;
public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        Map<Integer, List<Integer>> mp = new HashMap<>();
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] H = new int[N];
        for(int i=0;i<N;i++){
            H[i] = sc.nextInt();
        }
        for(int i=0;i<M;i++){
            int A = sc.nextInt()-1;
            int B = sc.nextInt()-1;
            mp.putIfAbsent(A, new ArrayList<>());
            mp.putIfAbsent(B, new ArrayList<>());
            mp.get(A).add(B);
            mp.get(B).add(A);
        }
        int cnt=0;
        for(int i=0;i<N;i++){
            if(!mp.containsKey(i)){
                cnt++;
                continue;
            }
            boolean hasTaller = false;
            for(Integer nei:mp.get(i)){
                if(H[nei] >= H[i]){
                    hasTaller = true;
                }
            }
            if(!hasTaller){
                cnt++;
            }
        }
        System.out.println(cnt);
    }

}


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

int N,R[200000],W[200000];
char c[200000];

int main(){
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>c[i];
	}
	for(int i=0;i<N;i++){
		if(c[i]=='R')R[i]++;
		else W[i]++;
	}
	for(int i=1;i<N;i++){
		R[i]+=R[i-1];
		W[i]+=W[i-1];
	}
	int res=R[N-1];
	for(int i=0;i<N;i++){
		res=min(res,max(W[i],R[N-1]-R[i]));
	}
	cout<<res<<endl;
}


Measured memory_bytes: 5348
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<fstream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

struct AccSum{
    vector<ll> Ac;
    ll L;
    AccSum(vector<ll> &A){
        L = A.size();
        Ac.resize(L+1);
        FOR(i, 0, L){
            Ac[i+1] = Ac[i] + A[i];
        }
    }

    // sum of [a, b]
    ll sum(ll a, ll b){
        if(a<0) return -1;
        if(b>L-1) return -1;
        return Ac[b+1] - Ac[a];
    }
};

ll max3(ll a, ll b, ll c){
    ll d = max(a, b);
    return max(d, c);
}

// 0 black
// 1 white

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

    // input
    ll N, K;
    cin >> N >> K;

    string s;
    cin >> s;
    ll L = s.size();

    // count 
    vector<ll> C;

    char current = s[0];
    ll count = 1;
    FOR(i, 1, L){
        char c = s[i];
        if(c==current){
            count++;
        }else{
            C.push_back(count);
            count = 1;
        }
        current = c;
    }
    C.push_back(count);

    bool is_head_white;
    if(s[0]=='0'){
        is_head_white = false;
    }else{
        is_head_white = true;
    }

    vector<ll> B;
    vector<ll> W;

    if(is_head_white){
        FOR(i, 0, C.size()){
            ll c = C[i];
            if(i%2==0){
                W.push_back(c);
            }else{
                B.push_back(c);
            }
        }
    }
    // 先頭が黒
    else{
        FOR(i, 0, C.size()){
            ll c = C[i];
            if(i%2==0){
                B.push_back(c);
            }else{
                W.push_back(c);
            }
        }
    }

    // 全員1にできる
    if(B.size()<=K){
        p(N);
        return 0;
    }

    // 以降、B.size()>K

    // 累積和
    auto AcB = AccSum(B);
    auto AcW = AccSum(W);

    ll max_sum = 0;
    FOR(i, 0, B.size()-K+1){
        // i ~ i+K-1までの和
        ll b_sum = AcB.sum(i, i+K-1);
        
        if(is_head_white){
            ll w_sum = AcW.sum(i, i+K-1);
            
            if(i+K<W.size()){
                w_sum += W[i+K];
            }
            
            ll sum = b_sum + w_sum;
            max_sum = max(max_sum, sum);
        }
        else{
            ll w_sum = AcW.sum(i, i+K-2);

            if(i+K-1<W.size()){
                w_sum += W[i+K-1];
            }
            if(i-1>=0){
                w_sum += W[i-1];
            }
            ll sum = b_sum + w_sum;
            max_sum = max(max_sum, sum);
        }
    }

    p(max_sum);
    
    return 0;
}


Measured memory_bytes: 3140
#include <stdio.h>

int main() {
    int n[5];
    scanf("%d %d %d %d %d", &n[0], &n[1],&n[2],&n[3],&n[4]);

    {
        bool finished = false;
        while (!finished) {
            finished = true;
            for (int i = 0; i < 4; ++i) {
                if (n[i] < n[i + 1]) {
                    int temp = n[i + 1];
                    n[i + 1] = n[i];
                    n[i] = temp;
                    finished = false;
                }
            }
    }
    }

    for (int i = 0; i < 5; ++i) {
        char c = (i == 4) ? '\n' : ' ';
        printf("%d%c", n[i], c);
    }
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<fstream>
#include<cmath>
#include<string>
#include<set>
#include <map>
#include<algorithm>
#include<vector>
#include <queue>
#include <stack>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
const double PI = acos(-1.0);
const ll INF = LLONG_MAX;
const int A = 1234567;
ll arr[A]; 

int main() {
	ll a, k,temp,temp1;
	cin >> a >> k;
	while (a--)
	{
		cin >> temp >> temp1;
		arr[temp] += temp1;
	}
	ll b = 0;
	for (int i = 1;i <= 100000;i++)
	{
		//cout << arr[i] + b << endl;
		if (arr[i] + b >= k)
		{
			cout << i;
			return 0;
		}
		else
			b += arr[i];
	}
	
}

Measured memory_bytes: 1024
{-# LANGUAGE
    BangPatterns, MultiWayIf, TupleSections, TypeApplications #-}
{-# OPTIONS_GHC -O2 #-}


import Control.Arrow
import Control.Concurrent
import Control.Monad
import qualified Data.ByteString.Builder as B
import qualified Data.ByteString.Char8 as C
import Data.Bits
import Data.Complex
import Data.Char
import Data.Function
import Data.Function.HT
import qualified Data.IntMap.Strict as IM
import qualified Data.IntSet as IS
import Data.List
import Data.Monoid
import Data.Ord
import qualified Data.Sequence as Sq
import Data.Vector.Algorithms.Search
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import Debug.Trace
import System.IO

r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

main = do
    n <- readLn :: IO Int
    cs <- Sq.fromList <$> getLine
    print $ solve 0 cs

solve ac Sq.Empty       = ac
solve ac ('R' Sq.:<| sq) = solve ac sq
solve ac (sq Sq.:|> 'W') = solve ac sq
solve ac ('W' Sq.:<| (sq Sq.:|> 'R')) = solve (ac+1) sq


Measured memory_bytes: 16168
import itertools

N,K = map(int,input().split())

list_1 = []

for i in range(K):
    x = input()
    list_2 = list(map(int,input().split()))
    list_1.append(list_2)

print(N-len(set(list(itertools.chain.from_iterable(list_1)))))


Measured memory_bytes: 9224
n = int(input())
c = [[0] * 10 for _ in range(10)]
for i in range(1, n + 1):
    s = str(i)
    l = int(s[0])
    r = int(s[-1])
    c[l][r] += 1
ans = 0
for i in range(10):
    for j in range(10):
        ans += c[i][j] * c[j][i]

print(ans)

Measured memory_bytes: 9092
//#include <fsociety>
#include <cmath>
#include <deque>
#include <algorithm>
#include <iterator>
#include <list>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <stack>
#include <string>
#include <vector>
#include <fstream>
#include <iostream>
#include <stdio.h>
//end of libraries ;
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
// ll lmax(ll o , ll w) {if(o>w)return o; return w;}
// ll lmin(ll o , ll w) {if(o<w)return o; return w;}
#define INF 3999999999999999999
#define N 3000003
#define PI 3.14159265359
#define F first
#define S second
#define pb push_back
#define ll long long
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
int n , m , x , sum , a[N];
int main(){
fcin;
	cin>>n;
	for(int i = 0 ; i< n-1 ; i ++){
		cin>>x;
		a[x] ++;
	}
	for(int i = 1 ; i <= n ; i++){
		cout<<a[i]<<"\n";
	}
}

Measured memory_bytes: 4440
#include <stdio.h>

int main(void){
    int n,type[4]={0},i;
    char b[3]={0};
    while(scanf("%d,%s",&n,b) != EOF){
        if(b[0] == 'A'){
            if(b[1] == 'B')
                type[2]++;
            else
                type[0]++;
        }
        else if(b[0] == 'B')
            type[1]++;
        else
            type[3]++;
    }
    for(i=0;i<4;i++){
        printf("%d\n",type[i]);
    }
    return 0;
}

Measured memory_bytes: 592
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int data[31]={0};
  int m;
  for(int i=0;i<30;i++){
    cin >> m;
    data[m]++;
  }
  for(int i=1;i<31;i++){
    if(data[i]==0){
      cout << i << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1164
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args){
    Scanner scanner =  new Scanner(System.in);
    int card[][] = new int[3][3];
    for(int i = 0;i < 3;i++){
      for(int j = 0;j < 3;j++){
        card[i][j] = scanner.nextInt();
      }
    }
    
    boolean appears[][] = new boolean[3][3];
    
    int N = scanner.nextInt();
    int b[] = new int[N];
    for(int i = 0;i < N;i++) b[i] = scanner.nextInt();
    
    for(int i = 0;i < 3;i++){
      for(int j = 0;j < 3;j++){
        for(int k = 0;k < N;k++){
        	if(card[i][j] == b[k]) appears[i][j] = true;
        }
      }
    }
    
    String bingo = "No";
	for(int i = 0;i < 3;i++){
      if(appears[i][0] && appears[i][1] && appears[i][2]) bingo = "Yes";
      if(appears[0][i] && appears[1][i] && appears[2][i]) bingo = "Yes";
    }
    
    if(appears[0][0] && appears[1][1] && appears[2][2]) bingo = "Yes";
    if(appears[2][0] && appears[1][1] && appears[0][2]) bingo = "Yes";
    
   
    System.out.println(bingo);
  }
}

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

int Partition(vector<pair<char, int> >& A, int p, int r)
{
    int x = A[r - 1].second;
    int i = p - 1;
    
    for(int j = p; j < r - 1; ++j){
        if(A[j].second <= x){
            ++i;
            swap(A[i], A[j]);
        }
    }
    swap(A[i + 1], A[r - 1]);
    return i + 1;
}

void QuickSort(vector<pair<char, int> >& A, int p, int r)
{
    if(p < r){
        int q = Partition(A,p,r);
        QuickSort(A,p,q);
        QuickSort(A,q + 1,r);
    }
}

bool comp(const pair<char, int>& p1, const pair<char, int>& p2)
{
    return p1.second < p2.second;
}

int main()
{
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<pair<char, int> > A(n);
    
    for(int i = 0; i < n; ++i){
        cin >> A[i].first >> A[i].second;
    }
    
    vector<pair<char, int> > B(A);
    
    stable_sort(B.begin(),B.end(),comp);
    QuickSort(A,0,n);
    
    cout << (A == B ? "Stable" : "Not stable") << endl;
    for(int i = 0; i < n; ++i){
        cout << A[i].first << ' ' << A[i].second << endl;
    }
}

Measured memory_bytes: 3384
#include<iostream>
#include<cstdio>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<map>
#include<cmath>
#include<numeric>
#include<stack>
#include<queue>
#include<functional>
#include<cassert>
#include<set>
#define rep(a,b) for(int a=0;a<b;++a)
#define REP(a,b,c,d) for(int a=b;a<c;a+=d)
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define mod 1000000007
using namespace std;
using ll = long long;
using p_i = pair<int, int>;
int main() {
	int N;cin>>N;
  double sum=0,dd;
    vector<double> a(N),d(N);
    rep(i,N){
        cin>>a[i];
        sum+=a[i];
    }
    double ave=sum/N;
  bool ok=true;
  dd=abs(ave-a[0]);
  rep(i,N){
    d[i]=abs(a[i]-ave);
    if(d[i]==0){
    	cout<<i<<endl;
      return 0;
    }
    if(dd!=d[i])ok=false;
  }
  if(ok){
    cout<<0<<endl;
    return 0;
  }
  sort(d.begin(),d.end());
  rep(i,N){
    if(abs(a[i]-ave)==d[0]){
      cout<<i<<endl;
      return 0;
    }
  }
}

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

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

    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let s: String = read();

    if s[0..n / 2] == s[n / 2..n] {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
import heapq
n,k=map(int,input().split())
V=[int(i) for i in input().split()]
M=sum(v for v in V if v>=0)
A=[[0,0]]
for i in range(1,n):
  VS=V[:i]
  cost=i
  A.append([cost,sum(VS)])
  heapq.heapify(VS)
  for _ in range(i):
    cost+=1
    heapq.heappop(VS)
    A.append([cost,sum(VS)])
B=[[0,0]]
V=V[::-1]
for i in range(1,n):
  VS=V[:i]
  cost=i
  B.append([cost,sum(VS)])
  heapq.heapify(VS)
  for _ in range(i):
    cost+=1
    heapq.heappop(VS)
    B.append([cost,sum(VS)])
ans=-float("inf")
for a in A:
  for b in B:
    if a[0]+b[0]<=k:
      ans=max(ans,a[1]+b[1])
print(M if n==1 else min(ans,M))

Measured memory_bytes: 3444
package main

import (
	"fmt"
)

func main() {
	var h int
	var w int

	fmt.Scanf("%d %d", &h, &w)

	arr := make([]string, h)

	for i := 0; i < h; i++ {
		fmt.Scanf("%s", &arr[i])
	}

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

	fail := false
	for r := 0; r < h; r++ {
		for c := 0; c < w; c++ {
			if arr[r][c] == '.' {
				continue
			}

			//fmt.Printf("lol\n")

			found := false
			for m := 0; m < 4; m++ {
				r2 := r + dx[m]
				c2 := c + dy[m]

				if r2 >= 0 && r2 < h && c2 >= 0 && c2 < w && arr[r2][c2] == '#' {
					//fmt.Printf("%d %d %d %d\n", r, c, r2, c2)
					found = true
					break
				}
			}

			if !found {
				fail = true
				break
			}
		}
	}

	ans := "Yes"
	if fail {
		ans = "No"
	}

	fmt.Printf("%s\n", ans)

}


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

int main() {
    int A,B,C,D;
    cin >> A >> B >> C >> D;

    bool even = true;
    while(even) {
        C -= B;
        if (C < 1) {
            even = false;
            break;
        }
        else A -= D;
    }

    if (A > 0) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int a,b;
  cin >> a>>b;
  if(a <= 8 && b <= 8) cout << "Yay!" << endl;
  else cout << ":(" << endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
const int INF = 1001001001;
int main(){
    int x; cin >> x;
    int n=x/100;
    if(x-n*100<=n*5) cout << 1;
    else cout << 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <tuple>
#include <cmath>
using namespace std;
//typedef long long ll;
using ll = long long;
//typedef pair<ll, ll> P;

#define rep(i, m) for(ll i=0;i<(m);i++)
#define rep1(i, m) for(ll i=1;i<=(m);i++)
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define V vector

int main() {
   int a = 0, b = 0; double per = 0;
   int A,B,C,D,E,F; cin >> A >> B >> C>>D>>E>>F;
   for(int i=0;i<=F;i+=100*A) {
      for (int j=0;i+j<=F;j+=100*B) {
         for (int p=0;p+i+j<=F;p+=C) {
            //cout << i << " " <<j << " " << p << " " << endl;
            int q = max(min(((i+j)*E/100-p), (F-p-i-j))/D, 0);
            q *= D;
            if ((i+j)*E < (p+q)*100 || i+j+p+q > F) {
               continue;
            }
            double val = 100.0*(p+q)/(i+j+p+q);
            if (per <= val) {
               per = val;
               a = i+j;
               b = p+q;
            }
         }
      }
   }
   cout << a+b << " " <<  b << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cmath>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)

class UnionFindTree{

private:
  // indexツづ個青板づ個親ツノツーツド
  vector<int> par;
  // indexツづーツ債ェツづつキツづゥツ姪伉づ個δ可δ督ク
  vector<int> rank;
  // ツ姪伉づ個催妥・ツ値
  int treeSize;
  
public:
  UnionFindTree(int initTreeSize = 1000){
     // ツ暗クツ青板づ与ツつヲツづァツづェツつスツ値ツづーツ催妥・ツ格ツ納ツ青板づつキツづゥUnionFindTreeツづ個催ャツ青ャ
    treeSize = initTreeSize;
    init();
  }
  
  
  void init(){
    
    for(int i = 0; i < treeSize; i++){
      par.push_back(i);
      rank.push_back(0);
    }
    
  }

  // ツ与ツつヲツづァツづェツつスツ青板つェツ格ツ納ツつウツづェツづつ「ツづゥツ姪伉づ個δ仰ーツトツづーツ探ツ催オ
  int find(int x){
    
    if(par[x] == x){
      return x;
    }
    else{
      return par[x] = find(par[x]);
    }
    
  }
  
  void unite(int x,int y){
    
    x = find(x);
    y = find(y);
    
    if(x == y)
      return;
    
    if(rank[x] < rank[y]){
      par[x] = y;
    }
    else{
      par[y] = x;
      if(rank[y] == rank[x]){
	rank[x]++;
      }
    }
    
  }
  
  bool same(int x,int y){
    return find(x) == find(y);
  }

};
class Circle{
public:
	double x,y,z,r;
	Circle(){}
	Circle(double x_,double y_,double z_,double r_){
		x=x_;
		y=y_;
		z=z_;
		r=r_;
	}
};

const int MAX_V = 200;

double cost[MAX_V][MAX_V];
double mincost[MAX_V];
bool used[MAX_V];

int V;
const double INF = 1000000000;

double prim(){
	for(int i = 0; i < V; i++){
		mincost[i] = INF;
		used[i] = false;
	}
	mincost[0] = 0;
	double res = 0;
	while(1){
		int v = -1;
		// Xツづ可堕ョツつウツづ按つ「ツ陳クツ点ツづ個つ、ツつソXツつゥツづァツづ個陛督づ個コツスツトツつェツ催渉ャツづ可づ按づゥツ点ツづーツ探ツつキ
		for(int u = 0; u < V; u++){
			if(!used[u] && (v == -1 || mincost[u] < mincost[v]))
				v = u;
		}
		if(v==-1)
			break;
		used[v] = true;
		res += mincost[v];
		
		for(int u = 0; u < V; u++){
			mincost[u] = min(mincost[u],cost[v][u]);
		}
	}
	return res;
}


int main(){

	int n;
	while(cin>>n&&n!=0){
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				cost[i][j]=INF;
			}
		}
		V=n;
		vector<Circle> vc;
		for(int i = 0; i < n; i++){
			Circle c;
			cin>>c.x>>c.y>>c.z>>c.r;
			vc.push_back(c);
		}
		UnionFindTree uft(n);
		for(int i = 0; i < n; i++){
			for(int j = i+1; j < n; j++){
				//if(i==j)
				//	continue;
				double dist=sqrt((vc[i].x-vc[j].x)*(vc[i].x-vc[j].x)
					+(vc[i].y-vc[j].y)*(vc[i].y-vc[j].y)
					+(vc[i].z-vc[j].z)*(vc[i].z-vc[j].z));
				// ツ重ツづ按づづつ「ツづゥ
				if(EQ(dist,(vc[i].r+vc[j].r))||(dist<(vc[i].r+vc[j].r))){
					uft.unite(i,j);
					break;
				}
			}
		}
		// ツ重ツづ按づづつ「ツづゥツづÍRXg0Ìm[hð£ÁÄ¨­
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				if(i==j)
					continue;
				if(uft.same(i,j)){
					cost[i][j]=0;
				}
				else{
				double dist=sqrt((vc[i].x-vc[j].x)*(vc[i].x-vc[j].x)
					+(vc[i].y-vc[j].y)*(vc[i].y-vc[j].y)
					+(vc[i].z-vc[j].z)*(vc[i].z-vc[j].z));
				cost[i][j]=dist-(vc[i].r+vc[j].r);
				if(cost[i][j]<0)
					cost[i][j]=0;
				}
			}
		}
		double res=prim();
		printf("%.3f\n",res);
	}


	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x) cout << #x << " = " << (x) << endl;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define P pair<int, int>
#define V vector<int>
#define S set<int>
#define itn int
#define tin int
#define tni int
bool dbg = false;
int N, M, A[100010];
V o;
void solve()
{
    if (M == 1) {
        if (A[0] == 1) {
            cout << 1 << " " << 1 << " " << 1 << endl;
            return;
        }
        cout << A[0] << endl;
        cout << 2 << endl;
        cout << A[0] - 1 << " " << 1 << endl;
        return;
    }
    int c = 0;
    FOR(i, 0, M)
    {
        if (A[i] % 2) {
            c++;
            o.pb(A[i]);
            A[i] = -1;
        }
    }
    if (c > 2) {
        cout << "Impossible" << endl;
        return;
    }
    if (c == 0) {
        FOR(i, 0, M)
        {
            cout << A[i] << " ";
        }
        cout << endl;
        cout << M << endl;
        FOR(i, 0, M)
        {
            int a = A[i];
            if (i == 0) {
                cout << A[i] - 1 << " ";
            } else if (i == M - 1) {
                cout << A[i] + 1;
            } else {
                cout << A[i] << " ";
            }
            cout << endl;
        }
    } else if (c == 1) {
        V B;
        FOR(i, 0, M)
        {
            if (A[i] % 2 == 0) {
                B.pb(A[i]);
            }
        }
        B.pb(o[0]);
        FOR(i, 0, M)
        cout << B[i] << " ";
        cout << endl;
        cout << M << endl;
        B[0]--;
        B[M - 1]++;
        FOR(i, 0, M)
        {
            cout << B[i] << " ";
        }
        cout << endl;
    } else {
        V B;
        B.pb(o[0]);
        FOR(i, 0, M)
        {
            if ((A[i] % 2) == 0) {
                B.pb(A[i]);
            }
        }
        B.pb(o[1]);
        FOR(i, 0, M)
        {
            cout << B[i] << " ";
        }
        cout << endl;
        B[0]--;
        B[M - 1]++;
        if (B[0] == 0) {
            cout << M - 1 << endl;
            FOR(i, 1, M)
            cout << B[i] << " ";
            cout << endl;
        } else {
            cout << M << endl;
            FOR(i, 0, M)
            cout << B[i] << " ";
            cout << endl;
        }
    }
}

signed main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    FOR(i, 0, M)
    cin >> A[i];
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
#define repi(i,n) for(int i=0; i<=(n); i++)
int main() {
  int x, y;
  bool check = false;
  cin >> x >> y;
  
  repi(i,x) {
    if (i*2+(x-i)*4 == y) {
      check = true;
      break;
    }
  }

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

Measured memory_bytes: 3640
N = int(input())
tbl = [[0 for i in range(13)] for j in range(4)]
suit_pattern = ["S","H","C","D"]

for i in range(N):
    suit, number = map(str,input().split())
    if suit =="S":
        tbl[0][int(number)-1] = 1
    if suit =="H":
        tbl[1][int(number)-1] = 1
    if suit =="C":
        tbl[2][int(number)-1] = 1
    if suit =="D":
        tbl[3][int(number)-1] = 1

for i in range(4):
    for j in range(13):
        if tbl[i][j] == 0:
            print(suit_pattern[i],j+1)


Measured memory_bytes: 5616
import sys
input = sys.stdin.buffer.readline


# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
# import numpy as np

def main():
	a,b,m=map(int,input().split())
	A=list(map(int,input().split()))
	B=list(map(int,input().split()))
	ans=min(A)+min(B)

	for i in range(m):
		x,y,c=map(int,input().split())
		ans=min(ans,A[x-1]+B[y-1]-c)
	print(ans)




if __name__ == "__main__":
	main()


Measured memory_bytes: 61884
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int A,B,K;
    bool check = 0;
    cin >> K >> A >> B;
    for(int i=A;i<=B;i++){
    	if(i%K==0){
    		check = 1;
    		break;
    	}
    }
    if(check==1)
    	cout << "OK";
    if(check==0)
    	cout << "NG";
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N,K;
    cin >> N >> K;
    double ans = 0;
    rep(i,1,N+1){
        double p = 1;
        ll num = i;
        while(num < K){
            num *= 2;
            p /= 2;
        }
        ans += p;
    }
    ans /= N;
    printf("%.9lf\n",ans);
}

Measured memory_bytes: 256
N, Y = map(int, input().split())
x, y, z = -1, -1, -1

for i in range(N+1):
    for j in range(N-i+1):
            k = N - i - j
            if 10000*i+5000*j+1000*k == Y:
                x, y, z = i, j, k
                break
print(x, y, z)


Measured memory_bytes: 2940
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static int[] count;
	static long[] sum;
	static int size;

	static void add(int val, int pos, int lo, int hi) {
		++count[pos];
		sum[pos] += val;
		if (hi - lo == 1) {
			return;
		}
		int mid = (lo + hi) / 2;
		if (val < mid) {
			add(val, pos * 2 + 1, lo, mid);
		} else {
			add(val, pos * 2 + 2, mid, hi);
		}
	}

	static int howMany(int countSum, long fooSum, long minB, int pos, int lo, int hi) {
		if (fooSum + sum[pos] <= minB * (countSum + count[pos])) {
			return countSum + count[pos];
		}
		if (count[pos] == 0) return countSum;
		if (hi - lo == 1) {
			// (countSum + x) * minB >= fooSum + lo * x
			// countSum * minB - fooSum >= (lo - minB) * x
			// x <= (countSum * minB - fooSum) / (lo - minB)
			if (countSum * minB < fooSum) return -1;
			return (int) (countSum + (countSum * minB - fooSum) / (lo - minB));
		}
		int mid = (lo + hi) / 2;
		int ret = howMany(countSum, fooSum, minB, pos * 2 + 1, lo, mid);
		if (ret == -1) {
			return -1;
		}
		if (ret < countSum + count[pos * 2 + 1]) {
			return ret;
		}
		int ret2 = howMany(countSum + count[pos * 2 + 1], fooSum + sum[pos * 2 + 1], minB, pos * 2 + 2, mid, hi);
		if (ret2 > 0) return ret2;
		return ret;
	}

	static int howMany(int minB) {
		return howMany(0, 0, minB, 0, 0, size);
	}

	public static void main(String[] args) {
		int N = sc.nextInt();
		size = 1;
		while (size < 100000) {
			size *= 2;
		}
		count = new int[size * 2];
		sum = new long[size * 2];
		Bug[] bugs = new Bug[N];
		for (int i = 0; i < N; ++i) {
			int a = Integer.parseInt(sc.next());
			int b = Integer.parseInt(sc.next());
			bugs[i] = new Bug(a, b);
		}
		Arrays.sort(bugs, new Comparator<Bug>() {
			public int compare(Bug o1, Bug o2) {
				return o2.b - o1.b;
			}
		});
		int ans = 0;
		for (int i = 0; i < N; ++i) {
			add(bugs[i].a, 0, 0, size);
			if (i == N - 1 || bugs[i].b != bugs[i + 1].b) {
				ans = Math.max(ans, howMany(bugs[i].b));
			}
		}
		System.out.println(ans);
	}

	static class Bug {
		int a, b;

		Bug(int a, int b) {
			this.a = a;
			this.b = b;
		}
	}

}

Measured memory_bytes: 118956
#include<stdio.h>

int main(void){

int i,j=1,N,key,n;

int data[101];

scanf("%d",&N);

for(i=1;i<=N;i++){

scanf("%d",&data[i]);

}

for(j=1;j<=N;j++){

key = data[j];

i = j -1;

while(i>0 && data[i] > key){

data[i+1] = data[i];

i=i-1;

data[i+1] = key;

}

for(n=1;n<=N;n++){

printf("%d",data[n]);

if(n<N) printf(" ");

}

printf("\n");

}

return 0;

}

Measured memory_bytes: 1804
n = int(input())
listAB = list(map(int,input().split()))
listP=list(map(int,input().split()))

a = listAB[0]
b = listAB[1]

num0 = sum([1 for p in listP if p <=a])
num2 = sum([1 for p in listP if p > b])
num1 = n - num0 -num2
print(min([num0,num1,num2]))


Measured memory_bytes: 3060
#include <stdio.h>
int main(int argc, const char * argv[]) {
    int a[4][3][10]={0},n,b,f,r,v,i,j,k;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d %d %d %d",&b,&f,&r,&v);
        a[b-1][f-1][r-1]+=v;
    }
    for(i=0;i<4;i++){
        for(j=0;j<3;j++){
            for(k=0;k<10;k++){
                printf("%2d",a[i][j][k]);
            }
                       printf("\n");
        }
        if(i!=3){
            printf("####################\n");
        }
    }
    return 0;
}

Measured memory_bytes: 620