akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define MOD = 998244353;
#define int long long int
#define inf (int)(1e15)
#define all(x) (x).begin(), (x).end()
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define isYes(x) printf("%s\n", (x) ? "Yes" : "No")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define isIn(x, y, h, w) (x >= 0 && x < h && y >= 0 && y < w)
#define pair pair<int, int>
typedef vector<int> vi;   // Vector of long long
typedef vector<vi> vvi;   // Vector of vi
typedef vector<pair> vii; // Vector of pairs
typedef vector<vii> vvii; // Vector of Vector of pairs
typedef vector<bool> vb;  // Vector of bool
#define pq priority_queue // Max heap (To convert to min heap, use negative sign before every value)
#define ff first          // For pairs
#define ss second
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, -1, 0, 1};
const int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}, dy8[] = {1, -1, 1, 0, -1, 1, -0, -1};
#define testcases(t) \
    int(t);          \
    cin >> (t);      \
    while ((t)--)
#define range(c, r) (c).begin(), (c).begin() + (r)    // Mainly used in sorting
#define present(c, x) ((c).find(x) != (c).end())      // for sets, maps, multi-maps
#define cpresent(c, x) (find(all(c), x) != (c).end()) // for vectors
#define run(x, c) for ((x) = (c).begin(); (x) != (c).end(); (x)++)
signed main()
{
    string s;
    int k;
    cin >> k >> s;
    int len = s.length();
    for (int i = 0; i < min(k, len); i++)
    {
        cout << s[i];
    }
    if (len > k)
    {
        cout << "..." << endl;
    }
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define debug(x)  cout << #x << " = " << (x) << endl;
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;

int main() {
  string s; cin >> s;
  cout << s.at(0) << s.size()-2 << s.at(s.size()-1) << endl;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
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; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

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

    ll X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    vector<ll> p(A), q(B), r(C);
    REP(i, A) cin >> p[i];
    REP(i, B) cin >> q[i];
    REP(i, C) cin >> r[i];

    sort(p.rbegin(), p.rend());
    sort(q.rbegin(), q.rend());
    sort(r.rbegin(), r.rend());

    priority_queue<ll, vector<ll>, greater<ll>> pq;
    ll res = 0;
	REP(i, X){
		pq.push(p[i]);
		res += p[i];
	}   
	REP(i, Y){
		pq.push(q[i]);
		res += q[i];
	}

	REP(i, C){
		ll tmp = pq.top();
		if(tmp<r[i]){
			pq.pop();
			pq.push(r[i]);
			res += (r[i]-tmp);
		}
	}
	cout << res << endl;
    return 0;
}

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

int main()
{
    int N;
    cin>>N;
    
    bool flag=false;
    for(int i=0;i<N;++i)
    {
        char c;
        cin>>c;
        if(c=='Y')
        {
            flag=true;
        }
    }
    
    if(flag)
    {
        cout<<"Four";
    }
    else
    {
        cout<<"Three";
    }
    cout<<endl;
    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)


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

  if(a < b){
    REP(i,b){
      cout << a;
    }
  }else{
    REP(i,a){
      cout << b;
    }
  }
   
   cout << endl;

  return 0;
}

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


int main()
{
    int a,b, c;cin>>a>>b;
    if(b == 100) c = a * 1000 + b;
    else if(b >= 10) c = a * 100 + b;
    else c = a * 10+b;
    bool can = false;
    for(int i = 1; i <= 316; i++){
        if(c == i*i) can = true;
    }
    cout << (can?"Yes":"No") << 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)
typedef long long ll;
const ll MOD = 1e9+7;

int main(){
    int n,k; cin >> n >> k;
    vector<pair<int,int>> edge;
    if(k > (n-1)*(n-2)/2){
        cout << -1 << endl;
        return 0;
    }
    cout << n-1+(n-1)*(n-2)/2-k << endl;
    for(int i = 2; i <= n; ++i) cout << i << " " << 1 << "\n";
    int cnt = (n-1)*(n-2)/2 -k;
    int cnt2 = 2;
    int cnt3 = 3;
    while(cnt){
        cnt--;
        if(cnt3 == n+1){
            cnt3 = cnt2+2;
            cnt2++;
        }
        cout << cnt2 << " " << cnt3 << "\n";
        cnt3++;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	int a=0,b=0,ab=0,o=0,h;
	char z;
	string x;
	while(cin>>h>>z>>x){
		if(x=="A")
			a++;
		if(x=="B")
			b++;
		if(x=="AB")
			ab++;
		if(x=="O")
			o++;
	}
	cout<<a<<endl;
	cout<<b<<endl;
	cout<<ab<<endl;
	cout<<o<<endl;
	return 0;
}

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

int main()
{
	int n;
	cin>>n;
	long long a[n+1];
	long long last=0;
	int cnt=0, mx=0;
	a[n]=1000000001;
	for(int i=0; i<n; i++)
	{
		cin>>a[i];
	}
	for(int i=0; i<=n; i++)
	{
		if(a[i]>last) last=a[i], mx=max(mx, cnt), cnt=0;
		else last=a[i], cnt++;
	}
	cout<<mx;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(){
    string x; cin >> x;
    long long count = 0, ans = 0;
    for(char c : x) {
        if(c == 'S') {
            count++;
        } else if(c == 'T' && count >= 1) {
            count--;
            ans++;
        }
    }
    cout << x.size() - (ans * 2) << endl;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"

using namespace std;
using ll = long long int;
using ullong = unsigned long long;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)
#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define int ll
int INF = 1e9;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
typedef pair<int, int> Vec2;
const int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };

string s;
string t;

bool match(int k) {
	rep(i, t.size()) {
		if (s[i + k] != t[i] and s[i + k] != '?')
			return false;
	}
	return true;
}

string construct(int k) {
	string res = s;
	rep(i, t.size()) {
		res[i + k] = t[i];
	}
	rep(i, s.size()) {
		if (res[i] == '?')
			res[i] = 'a';
	}
	return res;
}

signed main() {
	ios::sync_with_stdio(false);
	cin >> s >> t;
	vector<string> ss;
	rep(i, s.size()) {
		if (match(i)) 
			ss.pb(construct((i)));
	}
	sort(ALL(ss));
	if (ss.size() == 0) cout << "UNRESTORABLE" << endl;
	else cout << ss[0] << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

template<class T> inline bool chmin(T &a,T b){
    if (a>b){a=b; return true;}
    return false;
}
template<class T> inline bool chmax(T &a,T b){
    if (a<b){a=b; return true;}
    return false;
}

const int MAX_N=2010;

int N,K,ans=0,e=0;
vector<vector<int>> G(MAX_N);
vector<vector<int>> d(MAX_N,vector<int>(MAX_N));
vector<int> cnt(MAX_N,1);
vector<int> cnt2(MAX_N,0);

void dfs(int v,int p,int r,int &c){
    for (auto nv:G[v]){
        if (nv==p) continue;
        d[r][nv]=d[r][v]+1;
        if (d[r][nv]<=K/2) ++cnt[r];
        if (K%2==1&&d[r][nv]==(K+1)/2) ++c;
        dfs(nv,v,r,c);
    }
    if (p==r) chmax(cnt2[r],c),c=0;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> K;
    rep(i,N-1){
        int a,b; cin >> a >> b; --a,--b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    rep(i,N) d[i][i]=0;
    rep(i,N) dfs(i,-1,i,e),chmax(ans,cnt[i]+cnt2[i]);
    cout << N-ans << endl;
}

Measured memory_bytes: 18304
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int n = sc.nextInt();

		HashSet<Integer> s = new HashSet<Integer>();
		for ( int i=0; i<n; i++ ) {
			s.add(sc.nextInt());
		}

		if ( ( n>0 && !s.contains(x) ) || n==0 ) {
			System.out.println(x);
			System.exit(0);
		}
		for ( int i=1; i<=110; i++ ) {
			if ( !s.contains(x-i) ) {
				System.out.println(x-i);
				System.exit(0);
			}
			if ( !s.contains(x+i) ) {
				System.out.println(x+i);
				System.exit(0);
			}
		}
	}
}

Measured memory_bytes: 36068
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(b);i>=(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
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(b<a){a=b;return 1;}return 0;}
template<class T>
ll sum(const T& a){return accumulate(all(a),0LL);}

ll a[4][3][10];
void solve(){
    ll n;cin>>n;
    rep(i,n){
        ll b,f,r,v;cin>>b>>f>>r>>v;
        b--,f--,r--;
        a[b][f][r]+=v;
    }
    rep(i,4){
        if(i>0)cout<<"####################"<<endl;
        rep(j,3){
            rep(k,10)cout<<" "<<a[i][j][k];
            cout<<endl;
        }
    }
}

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



Measured memory_bytes: 3200
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

n, = map(int, readline().split())
*p, = map(int, readline().split())
*x, = map(int, readline().split())

dp = [1]*n
z = [0]*n

for i in range(n-1,-1,-1):
    #print(i,x[i],(z[i],(dp[i].bit_length()-1)),bin(dp[i])[2::][::-1])
    if dp[i]==0:
        #print(i)
        #print(dp)
        #print(z)
        print("IMPOSSIBLE")
        exit()

    y = dp[i].bit_length()-1
    # (z[i]-y,y) を (z[i]-y,x)にするのが最善

    if i == 0:
        #print(dp)
        #print(z)
        print("POSSIBLE")
        exit()
    else:
        pi = p[i-1]-1
        v = dp[pi]
        dp[pi] = ((v<<x[i]) | (v<<(z[i]-y))) & ((1<<(x[pi]+1))-1)
        z[pi] += x[i]+z[i]-y












Measured memory_bytes: 9260
def resolve():
    x,y=(int(i) for i in input().split())
    if x==1 and y==1:
        print(1000000)
        return
    c=0
    if x==1:
        c+=300000
    if x==2:
        c+=200000
    if x==3:
        c+=100000

    if y==1:
        c+=300000
    if y==2:
        c+=200000
    if y==3:
        c+=100000
    print(c)




if __name__ == "__main__":
    resolve()

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

int main() {
  int K, X,s;
  cin >> K >> X;
 // vector<int> A(2000000);
  s=X-K;
  int i,d;
  d=2*K-2;
  for( i=0; i<=d; i=i+1){
  s=s+1;;
  cout << s << " " ;
  }
/*  A.at(i)=-1000000
  for(int i=0; i<=2000000; i++){
     A.at(i+1)=A.at(i)+1;
  }*/
 
  
  return(0);
  
}

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

int main() {
	long long N ; cin >> N;
	vector<long long> K(5);
	for(int i = 0 ; i < 5 ; i++){
		cin >> K[i];
	}
	sort(K.begin(),K.end());
	if(N%K[0] == 0){
		cout << N/K[0] + 4 << endl;
	} else{
		cout << N/K[0] + 5 << endl;
	}
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define df 0
void f(char c,int a){
  int i;
  for(i=0;i<a;i++){
    printf("%c",c);
  }
}

int main(){
  int a,b,c,d;
  scanf("%d%d%d%d",&a,&b,&c,&d);
  int w=c-a,h=d-b;
  f('U',h);
  f('R',w+1);
  f('D',h+1);
  f('L',w+1);
  f('U',1);
  f('R',w);
  f('U',h+1);
  f('L',w+1);
  f('D',h+1);
  f('R',1);

  return 0;
}


/// confirm df==0 ///


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

using namespace std;

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if (AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


//const int NM = 20000;//ここを問題の制約を見ながらいじる．配列の確保に使う．
//ll A[NM];//あまり褒められたことではないが関数の外側に配列を確保すると怒られにくい．
//bool Minus[NM];//あまり褒められたことではないが関数の外側に配列を確保すると怒られにくい．

         //ll dp[NM];//あまり褒められたことではないが関数の外側に配列を確保すると怒られにくい．
//string S[NM];//あまり褒められたことではないが関数の外側に配列を確保すると怒られにくい．
//int B[NM];//あまり褒められたことではないが関数の外側に配列を確保すると怒られにくい．
//double Perf[NM];

ll MOD = 1000000007;
int digit_length(int num)
{
    int count = 0;
    while (num) {
        num = num / 10;
        ++count;
    }
    return count;
}


ll gcd(ll a, ll b) {
    ll v0 = a, v1 = b, v2 = a % b;
    while (v2 != 0) {
        v0 = v1;
        v1 = v2;
        v2 = v0 % v1;
    };
    return v1;
}


// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

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

ll lcm(ll a, ll b) {
    return( (a % MOD) *modinv(gcd(a, b), MOD) * (b % MOD)) % MOD;
}
       // Main program


void solve() {
    int  S[10];
    int  C[10];
    int N,M;
    string out = "000";
    cin >> N >> M;

    for (int i = 0; i < M; i++) {
        cin >> S[i];
        cin >> C[i];
    }

    bool match = false;

    for (int i = 0; i < M; i++) {
        for (int j = 0; j < M; j++) {
            if (S[i] == S[j] && C[i] != C[j]) {
                cout << -1;
                return;
            }
            if (1 == S[j] && 0 == C[j]) {
                if (N != 1) {
                    cout << -1;
                    return;
                }
            }
        }
    }

    

    for (int i = 0; i < M; i++) {
        out.at(S[i] - 1+(3-N) ) = '0'+C[i];
    }
    if (N == 3 && out.at(0) == '0') {
        out.at(0) = '1';
    }
    if (N == 2 && out.at(1) == '0') {
        out.at(1) = '1';
    }
    //if (N == 1 && out.at(2) == '0') {
    //    out.at(2) = '1';
    //}


    //for (int i = 0; i < N; i++) {
    //    if (out.at(i) == '0') {
    //        out.at(i) = '1';
    //    }
    //}

    int num = atoi(out.c_str());
    match = true;

    if (match) {
        cout << num;
    }
    else {
        cout << -1;
    }


    return;
}



int main() {
    solve();
    return 0;
}







Measured memory_bytes: 256
public class Main {

	public static final int BIG_NUM = 2000000000;
	public static final int MOD = 1000000007;

	public static void main(String[] args) {

		for(int a = 1; a <= 9; a++){
			for(int b = 1; b <= 9; b++){
				System.out.printf("%dx%d=%d\n",a,b,a*b);
			}
		}
	}
}



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

using namespace std;

int main(){
  int n;
  long long ans=0;
  cin >> n;
  for(int i=1;i<=n;i++){
	if(i%3==0 || i%5==0){
    }else{
      ans+=i;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3588
#include<cstdio>
using namespace std;
int n,a,b,k;
int solve(int a,int b){if(a%b==0)return a/b;int tp=(a%b)/(a/b+1)-1;if(tp<0)tp=0;a-=(a/b+1)*tp;return solve(a/b*(b-1)+a%b-1,b);}
int main()
{
	scanf("%d",&n);
	while(n--)scanf("%d%d",&a,&b),k^=solve(a,b);
	printf("%s\n",k?"Takahashi":"Aoki");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;
 
vvint g;
map<int,int> memo;
 
int dfs(int v) {
    if (memo.count(v)) return memo[v];
    int res = 0;
    for (int n_v : g[v]) chmax(res,dfs(n_v)+1);
    return memo[v] = res;
}
 
int main() {
    int n, m; cin >> n >> m;
    g.resize(n);
    rep(i,m) {
        int x, y; cin >> x >> y;
        x--; y--;
        g[x].push_back(y);
    }
    int ans = 0;
    rep(i,n) ans = max(ans,dfs(i));
    cout << ans << endl;
}

Measured memory_bytes: 13824
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
struct UnionFind{//雛形を与える(初期化と結合のみ)
    vector<int> par;//親(根)
    vector<int> rank;//木の深さ

    void init(int n){//初期化関数
        par.resize(n);
        rank.resize(n);
        for(int i = 0; i < n; i++){
            par[i] = i;//初めはノード一個の木なので根は自身
            rank[i] = 1;
        }
    }

    int root(int x){//木の根を求める
    if(par[x] == x) return x;
    else return par[x] = root(par[x]);
    }

    bool same(int x, int y){//同じ木かどうか判定
        return root(x) == root(y);//同じ木ならtrue
    }

    void unite(int x, int y){
        x = root(x);
        y = root(y);
        if(x == y) return;//もし同じ木に属していたら何もしない
        if(rank[x] < rank[y]) swap(x, y);//数が大きい方に小さい方を結合させる
        par[y] = x;
        rank[x] += rank[y];//深さが同じ時だけ結合後深さが増える
    }

    int size(int x) {//深さを返す関数
        return rank[root(x)];
    }
};
int main(){
    int N, M;
    cin >> N >> M;
    UnionFind U;
    vector<long long> X(M), Y(M), Z(M);
    vector<long long> cnt(M, 0);
    U.init(N);
    for(int i = 0; i < M; i++) {
        cin >> X[i] >> Y[i] >> Z[i];
        X[i]--;
        Y[i]--;
        U.unite(X[i], Y[i]);
    }
    set<long long> s;
    long long ans = 0;
    for(int i = 0; i < N; i++){
        if(!s.count(U.root(i))){
            ans++;
            s.insert(U.root(i));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 8832
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
const int N=1e9+7;
int32_t main()
{
    IOS;
    string s;
    cin>>s;
    int sum=0;
    for(auto x:s)
    {
        sum = sum + (x-48);
    }
    if(sum%9==0)
     cout<<"Yes";
    else
     cout<<"No";
}

Measured memory_bytes: 3760
local n = io.read("*n", "*l")
local s = io.read()

local function check(i, str)
  local left = str:sub(1, i)
  local right = str:sub(i + 1, #str)
  local t = {}
  for i = 1, i do
    t[left:sub(i, i)] = true
  end
  local c = 0
  for k, v in pairs(t) do
    if right:find(k) then
      c = c + 1
    end
  end
  return c
end

local cnt = 0
for i = 1, n - 1 do
  cnt = math.max(cnt, check(i, s))
end
print(cnt)


Measured memory_bytes: 376
import java.util.Scanner;

public class Main {


    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int a, b,c;
      a = sc.nextInt();
      b = sc.nextInt();
      c = sc.nextInt();
      if(a<b && b<c){
      System.out.println("Yes"); }           
    else {
              System.out.println("No");
}
     
}
    }
    


Measured memory_bytes: 26108
import random

def ans_is_zero():
    print(0)
    exit(0)

def solve():
    n=int(input())
    if n > 23: ans_is_zero()

    d=list(map(int,input().split()))
    for num in d:
        if num == 0: ans_is_zero()

    ans=0
    random.shuffle(d)
    
    N = 1 << n
    for i in range(N):#left or right
        t=1
        ret = 100
        for j in range(n):
            if (i>>j)&1: num = d[j]
            else: num = 24 - d[j]

            if (t >> num)&1:
                ret = -1
                break
            t |= (1 << num)

        if ret == -1:
            continue

        if bin(t).count("1") < n + 1:#重複あり
            continue

        prev = 0
        for j in range(1, 24):
            if ((t>>j)&1) == 0: continue
            ret = min(ret, j - prev)
            prev = j

        ret = min(ret, 24-prev)
        ans = max(ans, ret)
    print(ans)
solve()


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

Measured memory_bytes: 128
A , B = [int(i) for i in input().split()]

if A == B:
    print('Draw')
elif A == 1 or B == 1:
    if B != 1:
        print('Alice')
    else:
        print('Bob')
else:
    if A > B:
        print('Alice')
    else:
        print('Bob')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;

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

int main(){
    int n; cin>>n;
    vector<int> cnt(110, 0);
    for(int i=2; i<=n; i++){
        int num=i;
        for(int j=2; j<=i; j++){
            while(num%j==0){
                num/=j;
                cnt[j]++;
            }
            if(num==1) break;
        }
    }

    ll ans=0;
    for(int i=2; i<=n; i++){ // (74+1)
        if(74<=cnt[i]) ans++;
    }

    ll A=0, B=0;
    for(int i=2; i<=n; i++){ // (2+1)*(24+1)
        if(24<=cnt[i]) B++;
        if(2<=cnt[i]) A++;
    }
    ans+=B*(A-1);

    A=0, B=0;
    for(int i=2; i<=n; i++){ // (4+1)*(14+1)
        if(14<=cnt[i]) B++;
        if(4<=cnt[i]) A++;
    }
    ans+=B*(A-1);

    A=0, B=0;
    for(int i=2; i<=n; i++){ // (2+1)*(4+1)*(4+1)
        if(4<=cnt[i]) B++;
        if(2<=cnt[i]) A++;
    }
    ans+=B*(B-1)*(A-2)/2;

    cout << ans << endl;
}

Measured memory_bytes: 256
n = gets.to_i
v = gets.split().map {|v| v.to_i}
c = gets.split().map {|v| v.to_i}

v_c = v.zip(c).map{ |v, c| v - c}

max = 0

1.upto(v_c.size) do |i|
  v_c.combination(i).collect do |arr|
    sum = arr.inject(:+)
    max = sum if max <= sum
  end
end

p max


Measured memory_bytes: 10292
N, M = map(int, input().split())
ks = [list(map(int, input().split())) for i in range(M)]
p = list(map(int, input().split()))

ans = 0
for i in range(1 << N):
    all_on = True
    for j in range(M):
        n_on = 0
        for s in ks[j][1:]:
            if (i >> (s - 1)) & 1:
                n_on += 1
        if n_on % 2 != p[j]:
            all_on = False
    if all_on:
        ans += 1
print(ans)


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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;

const ll INF=1LL<<60;
const int MOD=1e9+7;



int main(){
    double X; cin >> X;
    X=X*M_PI/180;
    int res=1;
    double sum1=0, sum2=1;
    while(1){
        sum1-=sin(res*X);
        sum2+=cos(res*X);
        res++;
        if(sum1<=1e-10 && sum1>=-1e-10 && sum2<=1e-10 && sum2>=-1e-10){
            break;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4104
// テ・ツ淞コテヲツ慊ャテ」ツδ?」ツδウテ」ツδ療」ツδャテ」ツδシテ」ツδ?

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

typedef pair<int, int> pii;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int N, M;
int p[100010], info[100010][20];
int cnt[1 << 20], dp[1 << 20];

signed main() {
    cin >> N >> M;
    rep(i,0,N) {
        cin >> p[i];
        p[i]--;
        rep(j,0,M) info[i+1][j] = info[i][j] + (j == p[i]);
    }

    rep(i,1,1<<M) dp[i] = INF;
    rep(bit,0,1<<M) {
        rep(k,0,M) {
            if(bit >> k & 1) cnt[bit] += info[N][k];
        }
    }

    rep(bit,0,1<<M) {
        rep(k,0,M) {
            if(bit >> k & 1) continue;
            int nbit = bit | (1 << k);
            int l = cnt[bit], r = cnt[nbit];
            int rng = r - l;
            int seg = info[r][k] - info[l][k];
            chmin(dp[nbit], dp[bit] + (rng - seg));
        }
    }

    cout << dp[(1<<M) - 1] << endl;
    return 0;
}

Measured memory_bytes: 35772
using System;
using System.Collections.Generic;
class Program{
	static void Main(){
		int n=int.Parse(Console.ReadLine());
		int[] s=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		int o=0;
		var hs=new HashSet<int>();
		foreach(int i in s){
			if(hs.Contains(i)){o++;}
			else{hs.Add(i); }
		}
		o+=o&1;
		Console.WriteLine("{0}",n-o);
	}
}

Measured memory_bytes: 21344
#include<bits/stdc++.h>
using namespace std;
//#define int long long
inline int read() {
	int x=0,f=1; char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar())
		if(ch=='-')f=-f;
	for(;ch>='0'&&ch<='9';ch=getchar())
		x=x*10+ch-'0';
	return x*f;
}
#define _ read()
main() {
	double a,b;
	cin>>a>>b;
	printf("%.7lf",a/b);
}

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

int main()
{
	ll H,W,a,b,c;
	cin >> H >> W;
	ll S = H*W;
	ll ans = 1e11;
	for (int i = 1; i < H; ++i)
	{
		a = i*W;
		b = (H-i)/2*W;
		c = S-a-b;
		ans = min(ans,max(a,max(b,c)) - min(a,min(b,c)));

		b = W/2*(H-i);
		c = S-a-b;
		ans = min(ans,max(a,max(b,c)) - min(a,min(b,c)));
	}

	swap(H,W);
	for (int i = 1; i < H; ++i)
	{
		a = i*W;
		b = (H-i)/2*W;
		c = S-a-b;
		ans = min(ans,max(a,max(b,c)) - min(a,min(b,c)));

		b = W/2*(H-i);
		c = S-a-b;
		ans = min(ans,max(a,max(b,c)) - min(a,min(b,c)));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

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

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int n,k;
	cin >> n>>k;
	deque<int> vv;
	for(int i = 0; i < n; i++){
		int p;
		cin>>p;
		vv.push_back(p);
	}
	int x = min(n,k);
	int ans = 0;
	for(int left = 0; left <= x; left++){
		for(int right = 0; right <= x; right++){
			if(left+right>x)
				continue;
			int res = k-left-right;
			priority_queue<int,vector<int>,greater<int> > que;
			deque<int> v = vv;
			for(int i = 0; i < left; i++){
				if(v.empty())
					break;
				que.push(v.front());
				v.pop_front();
			}
			for(int i = 0; i < right; i++){
				if(v.empty())
					break;
				que.push(v.back());
				v.pop_back();
			}
			// cout << " left = " << left << " right = " << right << " res = "<< res << endl;
			while(!que.empty() && que.top()<0 && res>0){
				que.pop();
				res--;
			}
			int sum = 0;
			while(!que.empty()){
				// cout << que.top() << " ";
				sum += que.top();
				que.pop();
			}
			// printf("\n");
			ans=max(ans,sum);
		}
	}
	ans = max(0,ans);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int h,t,a,sum=0;
    cin>>h>>t;
    while(t--){
        cin>>a;
        sum+=a;
    }
    if(sum>=h)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using p=pair<int,int>;
#define int long long
#define rep(i,N) for(int i=0;i<N;i++)

signed main(){
  int A,B,C,ans=0;
  cin>>A>>B>>C;
  if(A*B*C%2==1){
    ans=min(B*C,min(C*A,A*B));
  }
  cout<<ans<<endl;
}

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

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

int main() {
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  if (c == 1 || d == 1){
    cout << 0 << endl;
    return 0;
  }
  ll gcd = c*d/f(c,d);
  ll ac = (a-1)/c,ad=(a-1)/d,bc=b/c,bd=b/d;  
  ll agcd = (a-1)/gcd,bgcd = b/gcd;
  ll bans = b - (bc+bd-bgcd), aans = (a-1) - (ac+ad-agcd);
  cout << bans - aans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
 
int main(){
	int n,m,x; cin>>n>>m>>x;
	vector<int> box(n+1,0);
	int temp;
	for(int i=0;i<m;i++) {
		cin >> temp;
		box[temp]=1;
	}
	int xl=0,xr=0;
	for(int i=0;i<n+1;i++){
		if(i<x) xl+=box[i];
		else xr+=box[i];
	}
	if(xl>xr) cout << xr << endl;
	else cout << xl << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cassert>
#include <utility>
#include <numeric>
#include <cstring>
#include <map>
#include <set>
#include <cmath>
#define rep(i,n) for (int i=0; i<(n); ++i)

using namespace std;
using ll = long long;

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

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

    while(true){
        bool flag = IsPrime(x);
        if (flag){
            cout << x;
            return 0;
        }
        else x += 1;

    }
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)


def dfs(start, dist, distance_list, explored):
    for node, cost in tree[start]:
        if explored[node] is False:
            explored[node] = True
            distance_list[node] = dist + cost
            dfs(node, distance_list[node], distance_list, explored)
    return distance_list


n = int(input())
tree = [[] for _ in range(n)]
distance = [float('inf') for _ in range(n)]

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

q, k = map(int, input().split())
k -= 1
query = []
distance[k] = 0

for _ in range(q):
    x, y = map(int, input().split())
    query.append((x-1, y-1))

XX = [False for _ in range(n)]
XX[k] = True

X = dfs(k, 0, distance, explored=XX)

for i, j in query:
    print(X[i] + X[j])

Measured memory_bytes: 145496
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) {
        cin >> a[i];
    }
    int ans = 0;
    int tmp = 0;
    do {
        tmp = 0;
        rep(i,n) {
            if (a[i] % 2 == 0) {
                a[i] /= 2;
                tmp++;
            }
        }
        ans += tmp;
    } while (tmp > 0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
  //fmt.Println("Input : ")
  sc := bufio.NewScanner(os.Stdin)
  sc.Split(bufio.ScanWords)

  var a int
  var b int
  var o string

  for {
    if sc.Scan() { a, _ = strconv.Atoi(sc.Text()) }
    if sc.Scan() { o = sc.Text() }
    if sc.Scan() { b, _ = strconv.Atoi(sc.Text()) }

    if o == "?" { break }
    if o == "+" {
      fmt.Printf("%d\n", a+b)
    } else if o == "-" {
      fmt.Printf("%d\n", a-b)
    } else if o == "*" {
      fmt.Printf("%d\n", a*b)
    } else if o == "/" {
      fmt.Printf("%d\n", a/b)
    }
  }
}



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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll H, W;
    cin >> H >> W;
    string sij;
    vector<string> S(H);
    ll NofBlack = 0;
    for(int i=0;i<H;i++){
        cin >> sij;
        S[i]=sij;
        for(int j=0;j<W;j++){
            if(sij[j]=='#') NofBlack++;
        }
    }

    priority_queue<std::array<ll,2>> q;
    std::vector<ll> d(H*W, numeric_limits<ll>::max());
    std::vector<ll> prev(H*W, numeric_limits<ll>::max());

    d[0] = 0;
    q.push(std::array<ll,2>{d[0], 0});

    while(!q.empty()){
        auto u = q.top()[1]; q.pop();
        auto h = u/W;
        auto w = u%W;
        vector<ll> candidate;
        if(h>0  ) candidate.push_back(u-W);
        if(h<H-1) candidate.push_back(u+W);
        if(w>0)   candidate.push_back(u-1);
        if(w<W-1) candidate.push_back(u+1);
        for(auto v : candidate){
            if(S[v/W][v%W]=='#') continue;
            auto alt = d[u] + 1;
            if(alt < d[v]){
                d[v] = alt;
                prev[v] = u;
                q.push(std::array<ll,2>{-alt, v});
            }
        }
    }
    if(d[H*W-1]==numeric_limits<ll>::max()){
        cout<<"-1"<<endl;
    }else{
        auto res = H*W - NofBlack - d[H*W-1] - 1;
        cout<<res<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <limits.h>
 
int n,m;
 
int Selection(int start,int goal,int Graph[101][101])
{
    int i;
    int min,minp = start;
    int Station[101];
    int Decided[101] = {0,};
 
    for(i=0;i<101;i++)
    {
        Station[i] = INT_MAX;
    }
 
    Station[start] = 0;
 
    while(Decided[goal] == 0)
    {
        for(i=0;i<m+1;i++)
        {
            if(Graph[minp][i] == -1) continue;
 
            if(Station[i] > Graph[minp][i] + Station[minp])
            {
                Station[i] = Graph[minp][i] + Station[minp];
            }
        }
 
        min = INT_MAX;
        for(i=0;i<m+1;i++)
        {
            if(min > Station[i] && Decided[i] != 1)
            {
                min = Station[i];
                minp = i;
            }
        }
        Decided[minp] = 1;
    }
 
    return Station[goal];
}
 
int main()
{
    int Gcost[101][101];
    int Gtime[101][101];
 
    int i,j;
    int a,b,time,cost;
    int k,start,goal,r;
    int ans;
 
    while(1)
    {
        for(i=0;i<101;i++)
        {
            for(j=0;j<101;j++)
            {
                Gcost[i][j] = -1;
                Gtime[i][j] = -1;
            }
        }
 
        scanf("%d%d",&n,&m);
        if(n == 0 && m==0) break;
 
        for(i=0;i<n;i++)
        {
            scanf("%d%d%d%d",&a,&b,&cost,&time);
            Gcost[a][b] = cost;
            Gcost[b][a] = cost;
            Gtime[a][b] = time;
            Gtime[b][a] = time;
        }
 
        scanf("%d",&k);
        for(i=0;i<k;i++)
        {
            scanf("%d%d%d",&start,&goal,&r);
            if(r==0) ans = Selection(start,goal,Gcost);
            else if(r==1) ans = Selection(start,goal,Gtime);
            printf("%d\n",ans);
        }
    }
 
    return 0;
}

Measured memory_bytes: 1104
n = int(input())
b = list(map(int,input().split()))

b.append(b[n-2])
b.append(0)
s = 0

for i in range(n):
  if b[i] < b[i+1]:
    s += b[i]
  else:
    s += b[i+1]

s += b[0]
print(s)

Measured memory_bytes: 3060
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import copy as cp
import sys
def sinput(): return sys.stdin.readline()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(): return list(imap())
def farr(): return list(fmap())
def sarr(): return sinput().split()
def gcd(numbers): return func.reduce(frac.gcd, numbers)
def lcm(numbers): return func.reduce(LCM, numbers)
sys.setrecursionlimit(10**7)
mod = 10 ** 9 + 7
inf = np.inf

n,m,r = imap()
cities = map(lambda x: int(x)-1, sinput().split())
abc = np.array([iarr() for i in range(m)])
a,b,c = abc.T[0]-1, abc.T[1]-1, abc.T[2]
graph = sps.csr_matrix((c,(a,b)),(n,n))
wf = sps.csgraph.floyd_warshall(graph,directed=0).astype(np.int64)

anss = []
for city in ite.permutations(cities):
    ans = 0
    for i in range(r-1): ans += wf[city[i]][city[i+1]]
    anss.append(ans)
print(min(anss))


Measured memory_bytes: 20640
using Primes
readint()=parse(Int,readline())
N=readint()
function ABC_D(N)
    s=0
    a=factor(N)
    for i in a.pe
        k=i.second
        for j in 1:10^7
            if k>=j
                k-=j
                s+=1
            else
                break
            end
        end
    end
    print(s)
end
ABC_D(N)


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

void go(string s, int a ,int c) {
    if (s.size()>=a) {
        cout << s << endl;
      return;
    }
    else {
        int d=c+1;
        rep(i,d){
            char e='a'+i;
            string f=s+e;
            if (i==c) c++;
            go(f,a,c);
        }
    }
}

int main() {
    int a;
    cin >> a;
    string s="a";
    go(s,a,1);
  return 0;
}

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

int main() {
    int n, m;

    cin >> n >> m;

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

    int ans = 0;
    for (int i = 0; i < m; i++) {
        ans += a[i];
    }

    if (ans <= n) {
        cout << n - ans << endl;
    } else {
        cout << -1 << endl;
    }

    return 0;
}

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

using namespace std;

typedef long long ll;

int sgn(ll x) {
    return x > 0 ? 1 : x == 0 ? 0 : -1;
}

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

    int n;
    ll k;
    cin >> n >> k;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a, a+n);

    ll l = -1.1e18, r = 1.1e18;
    while (r - l > 1) {
        ll mid = (l + r) / 2;

        ll t = 0;
        for (int i = 0; i < n; i++) {
            int cur;
            if (a[i] < 0) {
                ll q = mid / a[i];
                if (mid % a[i] != 0 && sgn(mid) * sgn(a[i]) > 0) {
                    q++;
                }
                int j = lower_bound(a, a + n, q) - a;
                cur = n - j - (i >= j);
            } else if (a[i] == 0) {
                cur = mid >= 0 ? n - 1 : 0;
            } else {
                ll q = mid / a[i];
                if (mid % a[i] != 0 && sgn(mid) * sgn(a[i]) < 0) {
                    q--;
                }
                int j = upper_bound(a, a + n, q) - a;
                cur = j - (i < j);
            }

            t += cur;
        }

        if (t / 2 >= k) {
            r = mid;
        } else {
            l = mid;
        }
    }

    cout << r << endl;

    return 0;
}


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

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    os << "{";
    for (int i = 0; i < (int)vec.size(); ++i) {
        os << vec[i] << (i + 1 == (int)vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
        os << "(" << itr->first << ", " << itr->second << ")";
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
        os << *itr;
        ++itr;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
void dump_func() {
    cerr << "\n";
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&&... tail) {
    cerr << head;
    if (sizeof...(Tail) == 0) {
        cerr << " ";
    } else {
        cerr << ", ";
    }
    dump_func(std::move(tail)...);
}
#define dump(...) cerr << "[" << to_string(__LINE__) << "]"        \
                       << "    " << string(#__VA_ARGS__) << " = ", \
                  dump_func(__VA_ARGS__)

using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<double>;
using VVI = vector<VI>;
using VVL = vector<VL>;
using PI = pair<int, int>;
using PL = pair<ll, ll>;
using VPI = vector<PI>;
using VPL = vector<PL>;
using VS = vector<string>;

#define ln '\n'
#define REP(t, n) for (int t = 0; t < (n); ++t)
#define FOR(t, a, b) for (int t = (a); t <= (b); ++t)
#define FORR(t, a, b) for (int t = (a); t >= (b); --t)
#define ALL(c) (c).begin(), (c).end()
#define CAUTO const auto&

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    bool ans = false;
    if (s[0] == s[1] && s[2] == s[3] && s[1] != s[2]) {
        ans = true;
    }
    if (s[0] == s[2] && s[1] == s[3] && s[0] != s[1]) {
        ans = true;
    }
    if (s[0] == s[3] && s[1] == s[2] && s[0] != s[1]) {
        ans = true;
    }

    if (ans)
        cout << "Yes" << ln;
    else
        cout << "No" << ln;

    return 0;
}


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

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int saiki(int x,vector<vector<int> >&v){
    if(v[x].size()==0){
        return 0;
    }
    vector<int>s;
    rep(i,v[x].size()){
        s.push_back(saiki(v[x][i],v));
    }
    sort(s.begin(),s.end(),greater<int>());
    int mx = 0;
    rep(i,s.size()){
        mx = max(mx,s[i]+i+1);
    }
    return mx;
}

int main(){
    int n;
    cin >> n;
    vector<vector<int> >v(n);
    rep(i,n-1){
        int tmp;
        cin >> tmp;
        tmp--;
        v[tmp].push_back(i+1);
    }
    cout << saiki(0,v) << endl;
    return 0;
}

Measured memory_bytes: 15104
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int n = int(s.size());
  ll sum = 0;
  rep(i, n) sum += s[i] - '0';
  if(sum % 9 == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3740
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int rowNum = sc.nextInt();
		int colNum = sc.nextInt();

		int sheet[][] = new int[rowNum][colNum];


		// 入力
		for(int i=0; i<rowNum; i++) {
			for(int j=0; j<colNum; j++) {
				sheet[i][j] = sc.nextInt();
			}
		}

		sc.close();

		// 出力
		// 1列ごとの合計値
		int colSum[] = new int[colNum];
		for(int i=0; i<rowNum; i++) {
			// 1行ごとの合計値
			int rowSum = 0;
			for(int j=0; j<colNum+1; j++) {
				if(j == colNum) {
					System.out.print(rowSum);
				} else {
					rowSum += sheet[i][j];
					colSum[j] += sheet[i][j];
					System.out.print(sheet[i][j] + " ");
				}
			}
			System.out.println("");
		}
		int totalSum = 0;
		for(int i=0; i<colNum; i++) {
			totalSum += colSum[i];
			System.out.print(colSum[i] + " ");
		}
		System.out.println(totalSum);


	}

}


Measured memory_bytes: 41812
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')

def solve():
    l = II()

    print(1 / 27 * l ** 3)


if __name__ == '__main__':
    solve()


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

  
int main(){
 string s;
  cin >> s;
  int ans=0;
  rep(i,4){
    if(s.at(i)=='+') ans++;
    if(s.at(i)=='-') ans--;
  }
  cout << ans << endl;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<long> H(N);
  for (int i = 0; i < N; i++) {
    cin >> H.at(i);
  }
  sort(H.begin(), H.end());
  long sum = 0;
  for (int i = 0; i < N - K; i++) {
    sum += H.at(i);
  }
  cout << sum << endl;
}

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

int main() {
	int a[10];
	for(int i=0;i<10;i++){
		cin>>a[i];
	}
	sort(a,a+10);
	cout<<a[9]<<endl;
	cout<<a[8]<<endl;
	cout<<a[7]<<endl;
	// your code goes here
	return 0;
}

Measured memory_bytes: 3144