akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <list>
#include <algorithm>

using namespace std;

int main(){
  long long int X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;
  long long int p[A], q[B], r[C], ans=0;
  list<long long int> red, green, white;
  for(int i=0; i<A; i++) cin >> p[i];
  for(int i=0; i<B; i++) cin >> q[i];
  for(int i=0; i<C; i++) cin >> r[i];
  sort(p, p+A, greater<long long int>());
  sort(q, q+B, greater<long long int>());
  sort(r, r+C, greater<long long int>());
  for(int i=0; i<X; i++) red.push_back(p[i]);
  for(int i=0; i<Y; i++) green.push_back(q[i]);
  for(int i=0; i<C; i++) white.push_back(r[i]);
  white.merge(red);
  white.merge(green);
  white.sort(greater<long long int>());
  for(int i=0; i<X+Y; i++){
    ans += white.front();
    white.pop_front();
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 11392
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <cctype>
#include <fstream>
#include <cstring>

using namespace std;

#define ll long long
#define MOD 1000000007
#define INF 2000000000
#define LINF 9000000000000000000
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define du(x) cout<<#x<<'='<<x<<endl
#define du2(x,y) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<'\n'<<endl
#define du3(x,y,z) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<' '<<#z<<'='<<z<<'\n'<<endl
#define darr(arr,n) rep(i,(n-arr)){cout<<*(arr+i)<<' ';}cout<<endl
#define ddarr(arr,a,b) rep(i,a){rep(j,b){cout<<*(arr+i*b+j)<<' ';}cout<<endl;}
#define ddd ifstream in("Text.txt");cin.rdbuf(in.rdbuf());

int V[50], C[50];
int main() {
    

    int N;
    cin >> N;
    rep(i, N) {
        cin >> V[i];
    }
    rep(i, N)cin >> C[i];

    int ma = 0;
    int X = 0, Y = 0;
    rep(i, N) {
        if (V[i] > C[i]) {
            X += V[i];
            Y += C[i];
        }

    }

    

    cout << X-Y << endl;

}

Measured memory_bytes: 256
import numpy as np
import collections

N = int(input())
D_seq = input().split()
D_seq = list(map(int, D_seq))

D_seq_max = max(D_seq)

judge_list = np.arange(D_seq_max+1)
judge_set = set(judge_list)
D_seq_set = set(D_seq)

c = collections.Counter(D_seq)

N_list = []
if((judge_set == D_seq_set)and(D_seq[0]==0)):
    if(c[0]>1):
        print(0)
    else:
        counts = 1
        for i in range(D_seq_max):
            counts *= pow(c[i], c[i+1])
        if(counts < 998244353):    
            print(counts)
        else:
            print(int(counts%998244353))
else:
    print(0)

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

typedef long long ll;

int main() {
    int N;
    cin >> N;
    vector<int>a(N);
    vector<int>b(N);
    ll total_a = 0;
    ll total_b = 0;
    ll count = 0;

    for (int i = 0; i < N; i++) {
        cin >> a[i];
        total_a += a[i];
    }
    
    for (int i = 0; i < N; i++) {
        cin >> b[i];
        total_b += b[i];
    }

    count = total_b - total_a;

    ll res = 0;
    for (int i = 0; i < N; i++) {
        if (a[i] < b[i]) {
            res += ceil((double)(b[i]-a[i])/2.0);
        }
    }
    if (res <= count) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 384
first_place, K, Distance = map(int, input().split())
first_place = abs(first_place)
test = first_place
if first_place - Distance*K > 0:
    print(first_place -Distance*K)
else:
    for i in range(1,K+1):
        test -= Distance
        if test <= 0:
            a = i
            #print(a)
            break
    if (K-a)%2 == 0 or K-a == 0:
        print(abs(first_place - Distance*a))
    else:
        print(abs(first_place - Distance*(a-1)))


Measured memory_bytes: 62756
#include<iostream>
#include<cstdio>
#include<cstring>

template<typename T>inline void read(T &x)
{
	char c=x=0;
	for(c=getchar();!isdigit(c);c=getchar());
	for(;isdigit(c);c=getchar())x=(x<<3)+(x<<1)+(c^48);
}

namespace gg
{
	typedef long long ll;
	const int N=101000,MOD=1000000007;
	ll qpow(ll a,ll b){ll c=1;for(;b;b>>=1,a=a*a%MOD)if(b&1)c=c*a%MOD;return c;}
	struct disjoint_union_set
	{
		int q[N];
		inline void init(int n){for(int i=1;i<=n;i++)q[i]=i;}
		inline int ask(int p){return p==q[p]?p:q[p]=ask(q[p]);}
		inline void link(int u,int v){q[ask(u)]=ask(v);}
		inline bool uni(int u,int v){return ask(u)==ask(v);}
	}d;
	ll fact[N],ifact[N];
	bool is_cir[N],not_leave[N],vis[N];
	int dep[N],cnt[N];
	int s[N];
	int n;
	ll initialize()
	{
		read(n),d.init(n);
		fact[0]=1;
		for(int i=1;i<=n;i++)
		{
			read(s[i]);
			not_leave[s[i]]=1;
			fact[i]=fact[i-1]*i%MOD;
		}
		ifact[n]=qpow(fact[n],MOD-2);
		for(int i=n;i;i--)ifact[i-1]=ifact[i]*i%MOD;

		for(int i=1;i<=n;i++)
		{
			if(d.uni(i,s[i]))
			{
				for(int p=i;!is_cir[p];p=s[p])
					vis[p]=is_cir[p]=1;
			}
			d.link(i,s[i]);
		}

		for(int i=1;i<=n;i++)
			if(!not_leave[i])
			{
				int p=i,w=0;
				for(;!vis[p];p=s[p])
					vis[p]=1,w++;
				if(!is_cir[p] || dep[p])return 0;
				dep[p]=w;
			}

		ll ret=1;
		memset(vis,0,sizeof(vis));
		for(int i=1;i<=n;i++)
			if(dep[i] && !vis[i])
			{
				int p=s[i],w=1;
				for(;!vis[p];vis[p]=1,p=s[p])
				{
					if(dep[p]>w)return 0;
					else if(dep[p])
					{
						if(dep[p]<w)ret=ret*2%MOD;
						w=0;
					}
					w++;
				}
			}

		for(int i=1;i<=n;i++)
			if(!vis[i] && is_cir[i])
			{
				int p=i,w=0;
				for(;!vis[p];vis[p]=1,p=s[p])w++;
				cnt[w]++;
			}


		return ret;
	}
	void solve()
	{
		ll ans,ret,res,tmp;
		if(!(ans=initialize())){printf("0\n");return;}
		for(int x=1;x<=n;x++)
		{
			int K=cnt[x];if(!K)continue;
//			printf("%d : %d\n",x,K);
			res=0;
			for(int i=0;i*2<=K;i++)
			{
				ret=fact[K]*ifact[K-i*2]%MOD*ifact[i]%MOD*qpow(x,i)%MOD;
				tmp=qpow(2,i),tmp=qpow(tmp,MOD-2);
				ret=ret*tmp%MOD;
				if(x>1 && x%2)ret=ret*qpow(2,K-2*i)%MOD;

				res=(res+ret)%MOD;
			}
			ans=ans*res%MOD;
		}
		printf("%lld\n",ans);
	}
}
int main()
{
//	freopen("E.in","r",stdin);
//	freopen("E.out","w",stdout);
	gg::solve();
	return 0;
}


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

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

    int a=A.size(), b=B.size();

    if(A.at(a-1)==B.at(0) && B.at(b-1)==C.at(0)) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

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

template<typename T, typename U>
using pv=vector<pair<T,U>>;
template<typename T>
using matrix=vector<vector<T>>;
template<typename T>
using pque=priority_queue<T>;
template<typename T>
using lpque=priority_queue<T,vector<T>,greater<T>>;

using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using ilpair=pair<int,ll>;
using lipair=pair<ll,int>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;

#define PI 3.141592653589793
#define INTINF ((1<<30)-1)
#define LLINF ((1LL<<62)-1)
#define MPRIME 1000000007
#define MPRIME9 998244353
#define MMPRIME ((1ll<<61)-1)

#define len length()
#define pushb push_back
#define fi first
#define se second

#define setpr fixed<<setprecision(15)
#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())

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

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

template<class T>
inline void init(T& v) {
	for(auto &a: v) cin>>a;
}
template<class T, class U>
inline void init(vector<pair<T,U>>& v) {
	for(auto &a: v) cin>>a.first>>a.second;
}
template<class T, class N>
inline void init(T& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a;
}
template<class T, class U, class N>
inline void init(vector<pair<T,U>>& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a.first>>a.second;
}

inline void out() {
	cout<<endl;
}
template<class T, class... U>
inline void out(T a, U... alist) {
	cout<<a<<" ";
	out(forward<U>(alist)...);
}

template<class N>
void resiz(N n) {
	//empty
}
template<class N, class T, class... U>
void resiz(N n, T&& hd, U&&... tl) {
	hd.resize(n);
	resiz(n,forward<U>(tl)...);
}

bool isout(int h, int w, int H, int W) {
	return ( h<0 || h>=H || w<0 || w>=W );
}

ll binpow(ll a, ll ex, ll p) {
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}


int N,R,ans=0;
string S;
intvec reds;

void input() {
	cin>>N>>S;
	reds.resize(N+1);
}

void solve() {
	int l=0, r=N-1;
	while(r-l>0) {
		while(l<N && S[l]=='R') l++;
		if(r-l<=0) break;
		while(r-l>0 && S[r]=='W') r--;
		if(r-l<=0) break;
		l++,r--;
		ans++;
	}
	cout<<ans<<endl;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(15);
	int t=1;
	while(t) {
		input();
		solve();
		t--;
	}
}


Measured memory_bytes: 4376
s = input().split('T')
x, y = map(int, input().split())

h, v = [], []
for i, si in enumerate(s):
    if i % 2 == 0:
        h.append(len(si))
    else:
        v.append(len(si))

def search(move, goal, horisontal):
    if horisontal:
        goal -= move.pop(0)

    move.sort(reverse=True)
    for m in move:
        if goal > 0:
            goal -= m
        else:
            goal += m
    return goal == 0

if search(h, x, True) and search(v, y, False):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
#define bit(n,k) ((n>>k)&1) //*n no k bit me 1 or 0*/

const int mx=100010;
const ll mod=1e9+7;


int main(){  
  int n;
  cin >> n;
  vector<ll> a(n);
  vector<ll> r(n+1,0);
  rep(i,n){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  rep(i,n){
    r[i+1] = r[i] + a[i];
  }  
  int ans = 1;
  for(int i=n-2; i>=0; i--){
    if(r[i+1]*2>=a[i+1]){
      ans++;
    } else {
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void){
	int n, m, order;
	int card[201], tmp[401];
	int i, j, k;
	
	scanf("%d %d", &n ,&m);
	
	for (i = 0; i < n*2; i++) card[i] = i+1;
	
	for (i = 0; i < m; i++){
		scanf("%d", &order);
		for (j = 0; j < n*2; j++) tmp[j] = card[j];
		for (j = 0; j < n*2; j++) tmp[j+n*2] = card[j];
		if (order){
			for (j = 0; j < n*2; j++) card[j] = tmp[j+order];
		}
		else{
			k = 0;
			for (j = 0; j < n*2; j++){
				if (j%2 == 0){
					card[j] = tmp[k];
					k++;
				}
				else card[j] = tmp[n+k-1];
			}
		}
	}
	
	for (i = 0; i < n*2; i++) printf("%d\n", card[i]);
	
	return 0;
}

Measured memory_bytes: 604
#include <iostream>
using namespace std;
long long s;
int x[3],y[3];
int main(){
    cin>>s;
    x[1]=1e9; x[2]=1;
    int a=s/x[1],b=s%x[1];
    if(b==0)y[2]=a;
    else{y[2]=a+1;y[1]=x[1]-b;}
    for(int i=0;i<3;i++){
        if(i)cout<<" ";
        cout<<x[i]<<" "<<y[i];
    }
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

const yes = "Yes"
const no = "No"

func solve(s string) bool {
	anyA := s[0] == 'A' || s[1] == 'A' ||s[2] == 'A'
	anyB := s[0] == 'B' || s[1] == 'B' ||s[2] == 'B'
	return anyA && anyB
}

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	s := next()
	if solve(s) {
		fmt.Fprintln(out, yes)
	} else {
		fmt.Fprintln(out, no)
	}
}

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

func nextStringAsBytes(n int64) []byte {
	sc.Scan()
	return []byte(sc.Text())
}

func nextInt() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int64) []int64 {
	ret := make([]int64, n)
	for i := int64(0); i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}

func nextFloats(n int64) []float64 {
	ret := make([]float64, n)
	for i := int64(0); i < n; i++ {
		ret[i] = nextFloat()
	}
	return ret
}
func nextStrings(n int64) []string {
	ret := make([]string, n)
	for i := int64(0); i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func containStr(arr []string, target string) bool {
	for _, v := range arr {
		if v == target {
			return true
		}
	}
	return false
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "orz")
	}
}

// mapからkeysとvaluesを返す
func splitKeyValue(m map[interface{}]interface{}) (keys, values []interface{}) {
	switch reflect.TypeOf(m).Kind() {
	case reflect.Map:
		s := reflect.ValueOf(m)
		for _, v := range s.MapKeys() {
			keys = append(keys, v)
			values = append(values, s.MapIndex(v))
		}
	default:
		fmt.Fprintln(out, "orz")
	}
	return
}


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

int main(){
    int64_t n;
    cin>>n;
    if(n==0){
        cout<<0;
        return 0;
    }
    int64_t i=1;

    vector<int> s(0);//s.at(i)は-2のi乗の位
    for(int64_t j=0;n!=0;j++){
        if(n%(i*2)!=0){
            s.push_back(1);
            n-=pow(-2,j);
        }
        else s.push_back(0);
        i*=(-2);
    }
    int64_t m=s.size();
    for(int64_t j=0;j<m;j++){
        cout<<s.at(m-j-1);
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<set>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const int INF = 2000000000;

    ll N,A[100],D,X,ans;
    bool F=true;
int main(){
    ios_base::sync_with_stdio(false);
    cin>>N>>D>>X;
    REP(i,N)cin>>A[i];
    REP(i,N){
        ans+=D/A[i];
        if(D%A[i]!=0)ans++;
        DEB(D/A[i]+1)END
    }
    cout<<ans+X;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <assert.h>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <sstream>
#include <memory.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
#include <functional>
#include <algorithm>
using namespace std;
typedef long long ll;
int main()
{
	int n;
	cin >> n;
	vector<pair<int, int> > v(n);
	for (auto &x : v)
		cin >> x.first >> x.second;
	map<pair<int, int>, int> freq;
	for(int i=0;i<n;++i)
		for (int j = 0; j < n; ++j) {
			int dx = v[i].first - v[j].first;
			int dy = v[i].second - v[j].second;
			if (dx || dy)
				++freq[{dx, dy}];
		}
	int res = n;
	for (auto &x : freq)
		res = min(res, n-x.second);
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

//しっかり制約確認したか?
int main()
{
    int l, r, d; cin >> l >> r >> d;
    int ans = 0;
    for(int i = l; i <= r; i++){
        if(i % d == 0)ans++;
    }
    cout << ans << endl;
    system("pause");
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
char a[4][4];
int main()
{
	for(int i=1;i<=3;++i)
	{
		for(int j=1;j<=3;++j)
		{
			cin>>a[i][j];
		}
	}
	cout<<a[1][1]<<a[2][2]<<a[3][3];
	return 0;
}

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int T, P, R;
  while (cin >> T >> P >> R, T) {
    vector<int> ac(T), penalty(T);
    vector<vector<int>> wa(T, vector<int>(P));
    while (R--) {
      int i, j, t;
      string s;
      cin >> i >> j >> t >> s;
      --i, --j;
      if (s == "CORRECT") {
        ++ac[i];
        penalty[i] += wa[i][j] * 1200 + t;
      } else {
        ++wa[i][j];
      }
    }
    vector<int> idx(T);
    iota(begin(idx), end(idx), 0);
    stable_sort(begin(idx), end(idx), [&](int l, int r) {
      return ac[l] != ac[r] ? ac[l] > ac[r] : penalty[l] < penalty[r];
    });
    for (int i : idx) {
      cout << i + 1 << ' ' << ac[i] << ' ' << penalty[i] << '\n';
    }
  }
}



Measured memory_bytes: 3212
#include<bits/stdc++.h>
#include<boost/algorithm/string/replace.hpp>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::algorithm;
using namespace boost::multiprecision;
 
#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const int INF = 1e9;
const int MOD = 1e9+7;

template<typename T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//C++17以上
template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

template<typename T>//文字列の置換/Boost:replace_all()
T replace_str(T str, string target, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(target, pos), pos != string::npos) {
        str.replace(pos, target.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

int main() {
    ull a,b,c,d;cin >> a >> b >> c >> d;
    if(c == 1 || d == 1){
        cout << 0 << endl;
        return 0;
    }
    ull sumB = b/c  + b/d - b/LCM(c,d);
    ull sumA = (a-1)/c + (a-1)/d - (a-1)/LCM(c,d);
    cout << (b-a+1) - (sumB - sumA) << endl;
    return 0;
}


Measured memory_bytes: 256
def caddi2018b_d():
    n = int(input())
    a = [int(input()) for _ in range(n)]
    for val in a:
        if val % 2 == 1:
            print("first")
            return 0
    print("second")
    # if 1 in a:
    #     print("first")
    # else:
    #     print(["second", "first"][sum(a) % 2])


caddi2018b_d()

Measured memory_bytes: 7196
#include <iostream>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <iomanip>
#include <vector>
#include <functional>
#include <algorithm>
#include <cstdio>
#include <random>
#include <ctime>
#include <cstdlib>
#include <unordered_map>
#include <string.h>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

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

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
x = 0
ans = 0
for i in range(n):
  if a[i]>i+1:
    ans+=1
  else:
    if a[i]<=x or a[i]>x+1:
      ans+=1
    elif a[i]==x+1:
      x = a[i]
if ans == n:
  ans = -1
print(ans)

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

int main(){
string s,t;
  cin>>s>>t;
  cout<<t<<s<<endl;
    return 0;
}

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

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;

typedef pair<ll, ll> P;

int main()
{
    int n;
    cin >> n;
    ll cnt = 0, tmp = inf, k;
    for (int i = 0; i < n; i++) {
        cin >> k;
        if (tmp > k) {
            tmp = k;
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}



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

int main()
{
    string s;
    cin >> s;
    int m=s.size(),c=0;
    for(int i=0;i<(int)s.size();i++){
        if(i%2==0){
            if(s[i]=='R'||s[i]=='U'||s[i]=='D')
                c++;
        }
        else{
            if(s[i]=='L'||s[i]=='U'||s[i]=='D')
                c++;
        }
    }
    if(c==m)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


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

namespace Contest
{
    class ABC
    {
        static void Main()
        {
            Solve();
        }

        private static void Solve()
        {
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int n = input[0];
            int k = input[1];
            input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Console.WriteLine(input.Count(a => a >= k));
        }
    }
}


Measured memory_bytes: 19040
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> sticks(n);
    for (size_t i = 0; i < n; ++i) cin >> sticks[i];
    sort(sticks.begin(), sticks.end(), greater<int>());
    cout << accumulate(sticks.begin(), sticks.begin() + k, 0) << endl;
    return EXIT_SUCCESS;
}

Measured memory_bytes: 256
S = []

N = int(input())
for i in range(N):
	S.append(input())

S.sort()
count = 0
max_count=0
s_max=[]
for i in range(N):
	if i==0:
		s_0 = S[i]
		s_max.append(s_0)
		continue
	s_1 = S[i]
    
	if s_0 == s_1:
		count += 1
	else:
		count = 0
      
	if max_count==count:
		max_count = count
		s_max.append(s_1)
	elif max_count < count:
		max_count = count
		s_max=[]
		s_max.append(s_1)
      
	s_0 = s_1
    

for i in s_max:
  print(i)
    

Measured memory_bytes: 20676
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)

struct INIT{
    INIT(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(0);
        cout << fixed << setprecision(13);
    }
}INIT;


int n;
int a[202020];


int main(){
    cin >> n;
    REP(i, n)cin >> a[i];
    int idx = 1;
    REP(i, n){
        if(a[i] == idx)idx++;
    }
    cout << (idx - 1 == 0 ? -1 : n - (idx - 1)) << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
using namespace std;
int main(){
	string str,str1;
	int player1,player2,point1=0,point2=0,len,a=0,b=0,turn,count,count2;
	cin>>turn;
	for(count=0;count<turn;count++){
		cin>>str>>str1;
		if(str.length()>str1.length()){
			len=str1.length();
		}else if(str.length()<str1.length()){
			len=str.length();
		}else{
			len=str.length();
		}
		for(count2=0;count2<len;count2++){
			a=str[count2]-'a';
			b=str1[count2]-'a';
			if(a>b){
				player1=1;
				player2=0;
				break;
			}else if(a<b){
				player1=0;
				player2=1;
				break;
			}else{
				player1=0;
				player2=0;
			}
		}
		if(player1==1){
			point1+=3;
		}else if(player2==1){
			point2+=3;
		}else if(str.length()==str1.length()){
			point1++;
			point2++;
		}else if(str.length()>str1.length()){
			point1+=3;
		}else{
			point2+=3;
		}
	}
	cout<<point1<<' '<<point2<<endl;
	return 0;
}

Measured memory_bytes: 1200
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main()
{
    string s;
    cin >> s;
    string ans = "Yes";
    int i = 0;
    int n = s.size();
    while(ans=="Yes" && i<n ){
        if(i%2==0){
            if(s[i] == 'L') ans = "No";
        }
        else if(i%2==1){
            if(s[i] == 'R') ans = "No";
        }
        i++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <tuple>
#include <utility>
#include <stdlib.h>
#include <set>
#include <map>
using namespace std;
#define rep(i,n,x) for(int i=n;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define RSORT(x) sort(x.begin(),x.end(),greater<int>())
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define setp(x) setprecision(x)
using LL = long long;
using ULL = unsigned long long;

int main() {
	LL n;
	cin >> n;
	string ans = "Yes";
	vector<pair<int, int>> t;
	rep(i, 0, n) {
		int a, b;
		cin >> a >> b;
		t.pb(mp(b, a));
	}
	SORT(t);
	/*for (auto& x : t) {
		cout << x.first << x.second << endl;
	}*/
	LL time = 0;
	rep(i, 0, n) {
		time += t[i].second;
		if (time > t[i].first) ans = "No";
	}
	cout << ans << endl;

	return 0;
}

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

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

	int N;
	scanf("%d", &N);

	vector<vector<pair<int, int>>> edge(N + 1,
	                                    vector<pair<int, int>>());  // 1-Nを使う
	int a, b, c;
	for (int i = 0; i < N - 1; i++) {
		scanf("%d %d %d", &a, &b, &c);
		edge[a].insert(edge[a].end(), make_pair(b, c));
		edge[b].insert(edge[b].end(), make_pair(a, c));
	}

	// for (int i = 1; i <= N; i++) {
	// 	cout << i << ":";
	// 	for (auto a : edge[i]) {
	// 		cout << a.first << " ";
	// 	}
	// 	cout << "\n";
	// }

	int Q, K;
	scanf("%d %d", &Q, &K);

	vector<pair<int, long long>> d_k(N + 1, make_pair(-1, -1));  // <親,距離 >
	stack<int> st;

	st.push(K);
	d_k[K].first = -1;
	d_k[K].second = 0;
	// cout << "size=" << st.size() << "\n";
	while (st.size() > 0) {
		int n = st.top();
		// cout << "pop " << n << "\n";
		st.pop();
		for (auto a : edge[n]) {
			if (a.first != d_k[n].first) {
				d_k[a.first].second = d_k[n].second + a.second;
				d_k[a.first].first = n;
				st.push(a.first);
				// cout << "push " << n << "\n";
			}
		}
	}

	// for (int i = 1; i <= N; i++) {
	// 	cout << i << ":" << d_k[i].first << " " << d_k[i].second << "\n";
	// }

	for (int i = 0; i < Q; i++) {
		int x, y;
		scanf("%d %d", &x, &y);
		cout << d_k[x].second + d_k[y].second << "\n";
	}
	return 0;
}

Measured memory_bytes: 9588
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define int ll

#define FOR(i, a, b) for (int i=a; i<b; i++)
#define For(i, a) for (int i=0; i<a; i++)
#define FORR(i,a,b) for (int i = a; i >= b; i--)
#define Forr(i,a) for (int i = a; i >= 0; i--)

#define deb(...) cerr << "[" << #__VA_ARGS__ << "] : [", DBG(__VA_ARGS__)
void DBG() { cerr << "]\n";}
template<typename T, typename ...Args> void DBG(T first, Args... args)
{cerr << first; if(sizeof...(args))cerr<<", "; DBG(args...); }

void solve(){
  int n,a,m; cin >> n >> a >> m;
  vector<int> pref(m+1,0);
  vector<int> visited(m+1,0),noCycle,Cycle;
  int i=0;
  while(1){
    if(visited[a]){
      for(int j=0;j<(int)noCycle.size();j++){
        if(noCycle[j]==a){
          int k=j;
          while(k<(int)noCycle.size()){
            Cycle.push_back(noCycle[k]);
            k++;
          }
          break;
        }
      }
      if(a==0){
        cout << pref[i-1] << "\n";
        return;
      }
      break;
    }
    else{
      visited[a]=1;
      noCycle.push_back(a);
      if(i>0)pref[i]=pref[i-1]+a;
      else pref[i]=a;
    }
    a = (a%m*a%m)%m;
    i++;
    if(i>=n){
      cout << pref[i-1] << "\n";
      return;
    }
  }
  int len1=noCycle.size()-Cycle.size();
  int tt = (n-len1)/((int)Cycle.size());
  vector<int> pref1(m+10,0);
  
  if(Cycle.size()>0)pref1[0]=Cycle[0];
  for(int j=1;j<(int)Cycle.size();j++){
    pref1[j]=pref1[j-1]+Cycle[j];
  }  
  int len2=Cycle.size();
  int sum=(len1-1>=0?pref[len1-1]:0)+tt*(pref1[len2-1]);
  if((n-len1)%tt-1>=0){
    sum += pref1[(n-len1)%tt-1];
  }
  cout << sum << "\n";
}


int32_t main(){
  ios_base:: sync_with_stdio(false);
  cin.tie(0);
  int t=1;
  for(int tt=1;tt<=t;tt++){
    solve();
  }
}


Measured memory_bytes: 6416
#include<bits/stdc++.h>
#define ll long long
using namespace std;

ll INF = 1e9 + 5;

int main()
{
	ll n,k; 
	cin>>n>>k;
	
	vector<ll> minimumPointsToJump(n+1, INF);
	vector<ll> heights(n+1, 0);
	minimumPointsToJump[0]=0;
	
	for(int i=0;i<n;i++){
		cin>>heights[i];
		for(int j=i-1;(j>=(i-k)) && (j>=0);j--)
			{
				//cout<<j<<"j ";
				minimumPointsToJump[i] = min(minimumPointsToJump[i], minimumPointsToJump[j] + abs(heights[i]-heights[j]));
			}
	}

	cout<<minimumPointsToJump[n-1]<<"\n";
}

Measured memory_bytes: 1792
import java.util.*;

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

        int excludeTax = (int)Math.ceil(Double.valueOf(amount) / 1.08d);
        int includeTax = (int)Math.floor(Double.valueOf(excludeTax) * 1.08d);
        if(amount == includeTax){
            System.out.println(String.valueOf(excludeTax));
        }else{
            System.out.print(":(");
        }
    }
}

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

#define REP(i, n) for (ll i = 0; i < ll(n); ++i)
#define RREP(i, n) for (ll i = ll(n) - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < ll(n); ++i)
#define RFOR(i, m, n) for (ll i = ll(n) - 1; i >= ll(m); --i)
#define ALL(v) (v).begin(), (v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  if (s == "Sunny")
    cout << "Cloudy" << endl;

  else if (s == "Cloudy")
    cout << "Rainy" << endl;
  else
    cout << "Sunny" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
const int N = 2e5+1e3;
char s[N];
int main(){
	scanf(" %s",s+1);
	int n=strlen(s+1);
	long long now=0,ans=0;
	for(int i=n;i;--i){
		if(s[i]=='W'){
			now++;
		}
		else{
			ans+=now;
		}
	}
	printf("%lld",ans);
} 

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
using namespace std;
typedef long long ll;
#define rep(i,a,n)	for(int i=a;i<n;i++)
#define rrep(i,a,n) for(int i=(a-1);i>=n;i--)

ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll lcm(ll a,ll b){
	ll g=gcd(a,b);
	return a/g*b;
}
int main(){
	int n;
	cin>>n;
	ll ans=1LL;
	for(int i=0;i<n;i++){
		ll t;
		cin>>t;
		ans=lcm(ans,t);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <string.h>
//#include <unordered_set>
//#include <unordered_map>
//#include <bits/stdc++.h>

#define MP(A,B) make_pair(A,B)
#define PB(A) push_back(A)
#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define fi first
#define se second

using namespace std;

template<typename T>inline bool upmin(T &x,T y) { return y<x?x=y,1:0; }
template<typename T>inline bool upmax(T &x,T y) { return x<y?x=y,1:0; }

typedef long long ll;
typedef unsigned long long ull;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod eps=1e-11;
const lod pi=acos(-1);
const int oo=1<<30;
const ll loo=1ll<<62;
const int mods=998244353;
const int MAXN=600005;
const int INF=0x3f3f3f3f;//1061109567
/*--------------------------------------------------------------------*/
inline int read()
{
	int f=1,x=0; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') f=-1; c=getchar(); }
	while (c>='0'&&c<='9') { x=(x<<3)+(x<<1)+(c^48); c=getchar(); }
	return x*f;
}
PR a[MAXN];
int b[MAXN];
int main()
{
	int n=read(),num=0;
	ll s1=0,s2=0;
	for (int i=1;i<=n;i++)
	{
		a[i]=MP(read(),read());
		s1+=a[i].fi,s2+=a[i].se;
		b[++num]=a[i].fi,b[++num]=a[i].se;
	} 
	sort(b+1,b+num+1);
	ll ans=min(s1,s2),sum=0;
	for (int i=1;i<=n;i++) sum+=b[i];
	for (int i=1;i<=n;i++)
	{
		if (max(a[i].fi,a[i].se)<b[n]) { printf("%lld\n",sum); return 0; }
		if (min(a[i].fi,a[i].se)>b[n]) { printf("%lld\n",sum); return 0; }
		upmin(ans,sum+(max(a[i].fi,a[i].se)-b[n])+max(0,min(a[i].fi,a[i].se)-b[n-1]));
	}
	printf("%lld\n",ans);
	return 0;
}

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

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

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

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

    int N;
    cin >> N;
    vector<double> p(N);
    REP(i, N)
    cin >> p[i];
    vector<vector<double>> dp(2, vector<double>(N + 1));
    dp[0][0] = 1.0;
    REP(i, N) {
        REP(t, i + 2) {
            if (t == 0)
                dp[1][0] = dp[0][0] * (1.0 - p[i]);
            else
                dp[1][t] = dp[0][t] * (1.0 - p[i]) + dp[0][t - 1] * p[i];
        }
        dp[0] = dp[1];
    }
    double ans;
    FOR(i, N - N / 2, N + 1) ans += dp[0][i];
    cout << setprecision(10) << ans << "\n";
}

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

#define MAX 101
#define INF (1<<29)

int n, m;
int cost[MAX][MAX];
int minCost[MAX];
bool used[MAX];

int prim(){
  fill(minCost, minCost+MAX, INF);
  memset(used, false, sizeof(used));
  
  minCost[0] = 0;
  int ans = 0;
  
  while(true){
    int v = -1;
    for(int i = 0 ; i < n ; i++){
      if(!used[i] && (v == -1 || minCost[i] < minCost[v])) v = i;
    }
    
    if(v == -1) break;
    used[v] = true;
    ans += minCost[v];
    
    for(int i = 0 ; i < n ; i++){
      minCost[i] = min(minCost[i], cost[v][i]);
    }
  }
  return ans;
}
    
int main(){
  while(cin >> n >> m){
    if(n == 0 && m == 0) break;
    fill(cost[0], cost[0]+MAX*MAX, INF);
    int a, b, C;
    for(int i = 0 ; i < m ; i++){
      cin >> a >> b >> C;
      cost[a][b] = C;
      cost[b][a] = C;
    }
    cout << prim() << endl;
  }
  return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
	int a;
	int c=0;
	cin>>a;
	vector<int> b(a);
	for(int i=0;i<a;i++)
		cin>>b.at(i);
	for(int i=0;i<a;i++)
		c+=b.at(i)-1;
cout<<c<<endl;
}


Measured memory_bytes: 256
n = int(input())
f = []
for _ in range(n):
    f.append(list(map(int, input().split())))
p = []
for _ in range(n):
    p.append(list(map(int, input().split())))

ans = -10**9
for i in range(1, 2**10):
    profit = 0
    for ff, pp in zip(f, p):
        cnt = 0
        for j in range(10):
            cnt += ((i>>j)&1)&ff[j]
        profit += pp[cnt]
    ans = max(ans, profit)
print(ans)

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

int main(){
  int N, M;
  cin >> N;
  
  vector<string> s(N);
  vector<string> c(N);
  vector<int> sum(N);
  int ans = 0;
  for(int i = 0;i < N;i++){
    bool flg = false;
    cin >> s.at(i);
    for(int j = 0;j < N;j++){
      if(c.at(j) == s.at(i)){
        sum.at(j)++;
        flg = true;
        break;
      }
    }
    if(flg == false){
      c.at(i) = s.at(i);
      sum.at(i) += 1;
    }
  }
  
  cin >> M;
  vector<string> t(M);
  for(int i = 0;i < M;i++){
    cin >> t.at(i);
    for(int j = 0;j < N;j++){
      if(c.at(j) == t.at(i)){
        sum.at(j)--;
        break;
      }
    }
  }
  for(int i = 0;i < N;i++){
    if(ans < sum.at(i)){
      ans = sum.at(i);
    }  
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
N=int(input())

alist=[]
for _ in range(N):
  a=int(input())
  alist.append(a)
alist.sort()
#print(alist)

if N%2==0:
  answer=0
  for i in range(N//2-1):
    a=alist.pop()
    answer+=2*a
  answer+=alist.pop()
  answer-=alist.pop()
  for i in range(N//2-1):
    a=alist.pop()
    answer-=2*a
    
  print(answer)
else:
  ans1=0
  alist_copy=alist[:]
  for i in range(N//2-1):
    a=alist_copy.pop()
    ans1+=2*a
  ans1+=alist_copy.pop()
  ans1+=alist_copy.pop()
  for i in range(N//2):
    a=alist_copy.pop()
    ans1-=2*a
    
  ans2=0
  alist_copy=alist[:]
  for i in range(N//2):
    a=alist_copy.pop()
    ans2+=2*a
  ans2-=alist_copy.pop()
  ans2-=alist_copy.pop()
  for i in range(N//2-1):
    a=alist_copy.pop()
    ans2-=2*a
    
  print(max(ans1,ans2))

Measured memory_bytes: 13752
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define ll long long
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define moder 1000000007
#define pie 3.141592653589793238462643383279
#define P std::pair<int,int>
#define prique priority_queue
using namespace std;
int n,a[100010],b[100010];
vector<int> v2;
signed main(){
	cin>>n;
	int sum=0;
	rep(i,n){
		cin>>a[i];
		sum+=a[i];
	}
	rep(i,n){
		cin>>b[i];
		sum-=b[i];
	}
	if(sum<0){
		cout<<-1<<endl;
		return 0;
	}
	sum=0;
	int cnt=0;
	rep(i,n){
		if(a[i]<b[i]){
			sum+=b[i]-a[i];
			cnt++;
		}
		if(a[i]>b[i])v2.push_back(a[i]-b[i]);
	}
	sort(v2.begin(),v2.end(),greater<int>());
	if(!cnt){
		cout<<0<<endl;
		return 0;
	}
	rep(i,v2.size()){
		sum-=v2[i];
		if(sum<0){
			cout<<cnt+1+i<<endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 2428
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <set>
#include <bitset>
#include <unordered_map>
#include <queue>

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)


int main(){
    int r;
    cin >> r;
    cout << r * r << endl;
    
}

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

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#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, a, b) for(int i = a;i < b;++i)
#define ALL(x) (x).begin(),(x).end()
#define INF 999999999
using namespace std;
#define lint long long

int main()
{
  int n; cin >> n;
  int x[n],y[n];
  double sum = 0;
  int count = 0;
  REP(i,n){
    cin>> x[i] >> y[i];
  }
  REP(i,n){
    REP(j,n){
      if(i != j){
      	sum += sqrt(pow(x[i] - x[j],2) + pow(y[i] - y[j],2));
        ++count;
      }
    }
  }
  cout << setprecision(10)<<sum*(n-1)/count;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int mp[90][90];
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };
int m,n;

int dfs(int x,int y,int b){
    int d=b;
    for(int i=0;i<4;++i){
        int tx = x+dx[i],ty = y +dy[i];
        if(tx>=0&&tx<m&&ty>=0&&ty<n&&mp[ty][tx]){
            mp[ty][tx]=0;
            d = max(d,dfs(tx,ty,b+1));
            mp[ty][tx]=1;
        }
    }
    return d;
}
int main(){
    while(cin>>m>>n && m){
        for(int i=0;i<n;++i){
            for(int j=0;j<m;++j){
                cin>>mp[i][j];
            }
        }
        int ans = 0;
        for(int i=0;i<n;++i){
            for(int j=0;j<m;++j){
                if(mp[i][j]){
                    mp[i][j]=0;
                    ans = max(ans,dfs(j,i,1));
                    mp[i][j]=1;
                }
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 3124
#include <math.h>
#include <stdio.h>
#include <bitset>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
  int H, W, K;
  cin >> H >> W >> K;
  char cs[H][W];
  string s;
  for (int i = 0; i < H; i++) {
    cin >> s;
    for (int j = 0; j < W; j++) {
      cs[i][j] = s[j];
    }
  }
  int total = 0;
  int count = 0;
  for (int bit1 = 0; bit1 < (1 << H); bit1++) {
    vector<int> hs;
    for (int i = 0; i < H; i++) {
      if (bit1 & (1 << i)) {
        hs.push_back(i);
      }
    }
    for (int bit2 = 0; bit2 < (1 << W); bit2++) {
      vector<int> ws;
      for (int i = 0; i < W; i++) {
        if (bit2 & (1 << i)) {
          ws.push_back(i);
        }
      }
      int count = 0;
      for (int i = 0; i < (int)hs.size(); i++) {
        for (int j = 0; j < (int)ws.size(); j++) {
          if (cs[hs.at(i)][ws.at(j)] == '#') {
            count++;
          }
        }
      }
      if (count == K) {
        total++;
      }
    }
  }
  cout << total << endl;
}

Measured memory_bytes: 3624
import std.stdio;
import std.range;
import std.array;
import std.algorithm;
import std.conv;
import std.string;
import std.math;

void main()
{
	int n;
	readf("%d\n",&n);
	while(n--)
	{
		double[] coox = new double[4],
				 cooy = new double[4];
		readf("%f %f %f %f %f %f\n",&coox[0],&cooy[0],&coox[1],&cooy[1],&coox[2],&cooy[2]);
		coox[3] = coox[0];
		cooy[3] = cooy[0];
		
		double A1, B1, C1, A2, B2, C2;
		A1 = 2 *(coox[1] - coox[0]);
		B1 = 2 * (cooy[1] - cooy[0]);
		C1 = coox[0]^^2 - coox[1]^^2 + cooy[0]^^2 - cooy[1]^^2;
		A2 = 2 * (coox[2] - coox[0]);
		B2 = 2 * (cooy[2] - cooy[0]);
		C2 = coox[0]^^2 - coox[2]^^2 + cooy[0]^^2 - cooy[2]^^2;
		double centerx, centery, radius;
		centerx = (B1 * C2 - B2 * C1)/(A1 * B2 - A2 * B1);
		centery = (C1 * A2 - C2 * A1)/(A1 * B2 - A2 * B1);
		radius = sqrt((centerx - coox[0])^^2 + (centery -cooy[0])^^2);
		writefln("%.3f %.3f %.3f",centerx,centery,radius);
	}
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

int main()
{
  char s[4];
  while (scanf(" %s", s) != EOF)
  {
    printf("%s\n", s[0] != s[1] || s[1] != s[2] ? "Yes" : "No");
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long x;
struct lesson
{
	 long long b, l, u;
	 int p;
}a[200001], b[200001];
bool cmp1(lesson xx, lesson yy)
{
	return x * xx.u - xx.b * xx.u + xx.b * xx.l > x * yy.u - yy.b * yy.u + yy.b * yy.l;
}
int n;
bool check(long long xx)
{
	long long lim = xx / x;
	int i;
	long long suma = 0, sumb = 0;
	for(i = 1; i <= lim + 1; i++)
	{
		suma += x * a[i].u;
		sumb += a[i].b * a[i].u;
	}
	for(i = lim + 2; i <= n; i++)
		sumb += a[i].b * a[i].l;
	long long last = xx - lim * x;
	long long sum;
	if(lim == n)
		return suma >= sumb;
	for(i = 1; i <= n; i++)
	{
		if(i <= lim)
			sum = -x * a[i].u + a[i].b * (a[i].u - a[i].l);
		else
			sum = -x * a[lim + 1].u + a[lim + 1].b * (a[lim + 1].u - a[lim + 1].l);
		long long sum1 = last * a[i].u - a[i].b * (a[i].u - a[i].l);
		long long sum2 = last * a[i].l;
		if(suma + sum1 + sum >= sumb)
			return true;
		if(suma + sum2 + sum >= sumb)
			return true;
	}
	return false;
}
int main()
{
	int i;
	scanf("%d%lld%", &n, &x);
	long long sumb = 0, suma = 0;
	for(i = 1;i <= n; i++)
	{
		scanf("%lld%lld%lld", &a[i].b, &a[i].l, &a[i].u);
		sumb += a[i].b * a[i].l;
		a[i].p = i;
	}
	sort(a + 1, a + 1 + n, cmp1);
	long long l = 0, r = x * n;
	while(l <= r)
	{
		long long mid = (l + r) / 2ll;
		if(check(mid))
			r = mid - 1;
		else
			l = mid + 1;
	}
	printf("%lld\n", l);	
	return 0;
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
const int MAX_N = 100025;
const ll MOD=1e9+7;
int eid,p[100010];
ll dp[100010][2];
struct edge{
	int v,next;
}e[100010<<2];
void add(int u,int v){
	e[eid].v=v;
	e[eid].next=p[u];
	p[u]=eid++;
}
void dfs(int u,int fa){
	ll x=1,y=1;
	if(e[p[u]].next==-1&&e[p[u]].v==fa){
		dp[u][0]=dp[u][1]=1;
		return;
	}
	for(int i=p[u];i+1;i=e[i].next){
		int v=e[i].v;
		if(v==fa)continue;
		dfs(v,u);
		x=(x*((dp[v][0]+dp[v][1])%MOD))%MOD;
		y=(y*(dp[v][0]))%MOD;
	}
	dp[u][0]=x,dp[u][1]=y;
}
int n,a,b;
int main(){
	memset(p,-1,sizeof(p));
	eid=0;
	cin>>n;
	for(int i = 1;i<n;++i){
		cin>>a>>b;
		add(a,b);
		add(b,a);
	}
	dfs(1,0);
	cout<<(dp[1][0]+dp[1][1])%MOD<<endl;
	return 0;
}


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

const ll mod = 1e9 + 7;

long long gcd(ll x, ll y){
	if(x > y) swap(x, y);
	while(x != 0){ y %= x; swap(x, y); }
	return y;
}

ll mpow(ll x, ll r){
	if(r == 0) return 1;
	if(r % 2 == 1){ return x * mpow(x, r-1) % mod; }
	else{ ll aa = mpow(x, r/2); return aa*aa%mod; }
}

int main(){
	ll N, M; cin >> N >> M;
	ll A[M], s = 0;
	rep(i, M){ cin >> A[i]; s+=A[i]; }
	if(s <= N) cout << N - s << endl;
	else cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 3668
#include<iostream>
#include<cmath>
#include<vector>
#include<limits.h>


using namespace std;

int main(){

  int n=0,m=0,l=0,term=0;
int matrix_a[120][120]={};
int matrix_b[120][120]={};
long  int matrix_c[120][120]={0};

//cout << INT_MAX << endl;

    cin >> n >> m >> l;
/*    if(n >= 100 || m >= 100 || l >=100 ){
      //cout  << "Too Large" << endl;
      return 0;
}*/

//cout << INT_MAX << endl;

  for(int i=0 ; i<n ; i++){
    for(int j=0 ; j<m ; j++){
      cin >> matrix_a[i][j];                   //??????????´?
    }
  }

  for(int i=0 ; i<m ; i++){
    for(int j=0 ; j<l ; j++){
      cin >> matrix_b[i][j];                   //??????????´?
    }
  }


  for (int i = 0 ; i < n ; i++) {
         for (int j = 0 ; j < l ; j++) {
             // Multiply the row of A by the column of B to get the row, column of product.
             for (int k = 0 ; k < m ; k++) {
                 matrix_c[i][j] += matrix_a[i][k] * matrix_b[k][j];
             }

         }
     }



  /* ??????????????????????????? */
/*    for(int i=0; i<n; ++i){
      for(int j=0; j<l ; ++j){
        matrix_c[i][j] = matrix_a[i][j] * matrix_b[i][j];

        // ????????????????¨????
        for(int i=0;i<n;i++){
          for(int j=0 ; j<l ; j++){
             term = 0;
            for(int k=0 ; k<m ; k++)
              term = term + matrix_a[i][k] * matrix_b[k][j];
            matrix_c[i][j] = term;
          }
        }

      }
    }
*/
    for(int i=0;i<n;i++){
      for(int j=0;j<l;j++){
        if(j==0){
            cout << matrix_c[i][j];                        //?????????????????????????????¨???
          }
          else{
            cout << ' ' << matrix_c[i][j];                //????????\??????????????¨???
          }
        }
        cout << endl;
    }
    return 0;



}

Measured memory_bytes: 1392