akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define INF 100100100
#define MOD 1000000007

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

#define FOR(i,n) for(ll i=0;i<n;i++)

vector<vector<int> >edge;
int ans = 0;
int N;

void func(int memo,int now){
   if(__builtin_popcount(memo) == N){
      ans++;
      return ;
   }
   for(int i=0;i<edge[now].size();i++){
      if((memo>>(edge[now][i]-1))&1)continue;
      func(memo|(1<<(edge[now][i]-1)),edge[now][i]);
   }
   return ;
}

int main(int argc, char const* argv[]){
   ios::sync_with_stdio(false);
   cin.tie(0); 
   int M;
   cin >> N >> M;
   edge.resize(N+1);
   FOR(i,M){
      int a;
      int b;
      cin >> a >> b;
      edge[a].push_back(b);
      edge[b].push_back(a);
   }
   func(1,1);
   cout << ans << endl;
   return 0;
}


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

using namespace std;

int N;
long long votes_T = 1, votes_A = 1;

void solve() {
    long long T, A;
    for(int i = 0; i < N; i++) {
        cin >> T >> A;
        long long a = votes_A/A;
        if(votes_A%A) a++;
        long long t = votes_T/T;
        if(votes_T%T) t++;        
        long long times = max(a, t);
        votes_T = times * T; votes_A = times * A;
    }
    cout << votes_T + votes_A << endl;
}

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

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
    int n;

    cin >> n;

    int div = 100;
    for(int i = 0; i < 3; ++i)
    {
        cout << 10 - (n / div);
        n %= div;
        div /= 10;
    }
    cout << endl;

    return 0;
}

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

int main(){
    int n;
    string s;
    cin >> n;
    cin >> s;
    int cntR = 0;
    int cntB = 0;
    for(int i = 0; i < s.length(); i++){
        if(s[i] == 'R') cntR++;
        else if(s[i] == 'B') cntB++;
    }
    if(cntR > cntB) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
dp=[10**4*n]*n
l=list(map(int,input().split()))
dp[0]=0
dp[1]=abs(l[0]-l[1])
for i in range(2,n):
  dp[i]=min(dp[i-1]+abs(l[i]-l[i-1]),dp[i-2]+abs(l[i]-l[i-2]))
print(dp[-1])

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

def main():
    S = input()
    zenhan = int(S[0] + S[1])
    kouhan = int(S[2] + S[3])

    judgeZenhan = judge12(zenhan)
    judgeKouhan = judge12(kouhan)

    print(judgeFormat(judgeKouhan, judgeZenhan))


def judgeFormat(judgeKouhan, judgeZenhan):
    if judgeZenhan and judgeKouhan:
        return 'AMBIGUOUS'
    elif judgeZenhan and not judgeKouhan:
        return 'MMYY'
    elif not judgeZenhan and judgeKouhan:
        return 'YYMM'
    else:
        return 'NA'


def judge12(num):
    if num < 13 and num > 0:
        return True
    return False


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long ans = 0;
        for (int i = 1; i <= n; i++) {
            if (i % 15 != 0 && i % 3 != 0 && i % 5 != 0) {
                ans += i;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 27236
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  ll n, k;
  cin >> n >> k;
  combination comb(n);
  rep(i,k) {
    mint ans = comb(n-k+1, i+1) * comb(k-1, i);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

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

    vector<int> P;
    int p[101] = {0};

    for ( int i = 2; i <= 100; i++ ) {

        if ( p[i] == 0 ) {
            P.push_back(i);
            for ( int j = i*2; j <= 100; j += i ) {
                p[j] = 1;
            }
        }

    }

    vector<int> X( P.size() );
    for ( int j = 2; j <= N; j++ ) {        
        int a = j;
        for ( int i = 0; i < P.size(); i++ ) {
            while ( a%P[i] == 0 ) {
                a /= P[i];
                X[i]++;
            }
        }
    }

    int ans = 0;


    for ( int i = 0; i < P.size(); i++ ) {        
        if ( X[i] >= 74 ) {
            ans++;
        }
        
        for ( int j = i+1; j < P.size(); j++ ) {
            int a = max( X[i], X[j] );
            int b = min( X[i], X[j] );
            if ( a >= 24 && b >= 2 ) {
                if ( b >= 24 ) { ans += 2; }
                else { ans++; }
            }
            if ( a >= 14 && b >= 4 ) {
                if ( b >= 14 ) { ans += 2; }
                else { ans++; }
            }
        }
        
    }

    for ( int i = 0; i < P.size(); i++ ) {
    for ( int j = i+1; j < P.size(); j++ ) {
    for ( int k = j+1; k < P.size(); k++ ) {
        vector<int> v;
        v.push_back(X[i]);
        v.push_back(X[j]);
        v.push_back(X[k]);
        sort( v.begin(), v.end() );
        if ( v[0] >= 2 && v[1] >= 4 ) {
            if ( v[0] >= 4 ) { ans += 3; }
            else { ans++; }
        }
    }
    }
    }

    cout << ans << endl;
    

    return 0;
}

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

typedef long long ll;
typedef pair<int,int>P;
#define INF (int)(1e9)
#define EPS (1e-7)
#define MOD ((ll)1e9+7)
#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 FOR(i,k,n) for(int i = (k); i < (int)(n); i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define pb push_back
#define vec vector<int>


/*--------------------------------------------*/
/*ll factorial(ll);
void list_Prime(ll);
ll divisor(ll);
ll lcm(ll, ll);//AとBの最小公倍数
ll gcd(ll,ll);*/
/*--------------------------------------------*/
/*--------------------------------------------*/
/*
ll factorial(ll n){
    if(n==1)return 1;
    return n*factorial(n-1);
}
ll lcm(ll A, ll B) {//最小公倍数
    ll a = A;
    ll b = B;
    if (a == 0 || b == 0) { return 0; }
    if (a < 0) { a = -a; }
    if (b < 0) { b = -b; }
    while (b > 0) {
        ll c = a % b;
        a = b;
        b = c;
    }
    return A/a*B;
}

ll gcd(ll a,ll b){
    while (b != 0) {
        int t = b;
        b = a % b;
        a = t;
    }
    return a;
}


void list_Prime(ll n){//n以下の素数を全て見つける
    ll Limit=(int)sqrt((double)n);
    for(ll i=2;i<=n;i++)prime[i]=1;//最初はみんな素数かも
    //素数の整数倍を消していく(ルートnまで)
    for(ll i=2;i<=Limit;i++){
        if(prime[i]){
            for(ll j=2*i;j<=n;j++){
                if(j%i==0){
                    prime[j]=0;                
                }
            }
        }
    }
}

ll divisor(ll n){
    for(ll i=2;i<=n;i++){
        ll d=1;
        ll tmp=i;
        while(tmp>0){
            d++;
            while(tmp%d==0){
                prime[i]++;
                tmp/=i;
            }
        }
    }
    ll sum=1;
    for(ll i=2;;i<=n;i++){
        sum*=(prime[i]+1)/MOD;
    }    
    cout<<"sum="<<sum<<endl;

    return sum%MOD;
}
*/
/*--------------------------------------------*/

const int MAX_N = 100000+10;

vec memo(MAX_N,-1); // memo[i] が i についての答え
int rec(int n){
    if(n==0)return memo[n]=0;
    if(memo[n]>=0) return memo[n];
    int res=n;
    for(int pow6=1;pow6<=n;pow6*=6)res=min(res,rec(n-pow6)+1);
    for(int pow9=1;pow9<=n;pow9*=9)res=min(res,rec(n-pow9)+1);
    return memo[n]=res;
}

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

    cout << rec(n) << endl;
}

Measured memory_bytes: 5376
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for(int i = 0; i<(n); ++i)

int main(){
    int n, rsl=0; cin >> n;
    vector<int>a(n);

    rep(i,n) cin >> a[i];

    rep(i,n){
        if(a[i]%2==0){
            while(a[i]%2==0){
                a[i] /= 2;
                rsl++;
            }
        }
    }

    cout << rsl << endl;


    return 0;
}

Measured memory_bytes: 3676
#include <list>
#include <map>
#include <set>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <memory.h>
#include <ctime>
#include <bitset>
#include <vector>
#include <string>

using namespace std;

int mp[100050];
int w[100050];

void solution() {
    int n, m;
    cin >> n >> m;
    for (int i = 0; i <= n; i++) {
        mp[i] = 1;
    }

    int ans1 = 0;
    int ans2 = 0;
    for (int i = 0; i < m; i++) {
        char a, b, c;
        int x;
        scanf("%d%c%c%c", &x, &a, &b, &c);
        if (b == 'W') {
            w[x]++;
        } else if (b == 'A') {
            if (mp[x]) {
                mp[x] = 0;
                ans1++;
                ans2 += w[x];
            }
        }
    }
    cout << ans1 << " " << ans2 << endl;
}

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

int main()
{
#ifdef Files
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    /*Test*/
    //freopen("input.txt", "w", stdout);

    double OcZ2X = clock();
#else
    //freopen("joke.in", "r", stdin);
    //freopen("joke.out", "w", stdout);
#endif

    solution();

#ifdef Time
    double P2HxQ = clock();
    printf("\n*** Total time = %.3f sec ***\n", (P2HxQ - OcZ2X) / CLOCKS_PER_SEC);
#endif
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
    
int main(){
  int n,x,m[1001];
  cin >> n >> x;
  int sum = 0, M = 1001001001;
  rep(i,n) {
    cin >> m[i];
    sum += m[i];
    if(m[i] < M){
      M = m[i];
    }
  }
  int ans = n + (x-sum)/M;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.io.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
       String w = sc.next().toLowerCase();
       int count = 0;
       while(true){
    	   String s = sc.next();
    	   if(s.equals("END_OF_TEXT")) {
    		   break;
    	   }
    	   if(s.toLowerCase().equals(w)) {
    		   count++;
    	   }
       }
       sc.close();
       System.out.println(count);
    }
}


Measured memory_bytes: 26192
#import numpy as np

    
##################################################################

if __name__ == "__main__":
    Input1 = [input() for i in range(2)]
    N = int(Input1[0])
    A = list(map(int,Input1[1].split()))

    B = [0]*N
    for i in range(N):
        temp = A[i]
        B[temp-1] = i+1
    print(' '.join(map(str,B)))
    


Measured memory_bytes: 18952
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <random>
#include <set>
#include <stack>

//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater<int>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#include <time.h>
typedef std::pair<int,int> pii;
using namespace std;
using ll = long long;


int main(){
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    vector<int> dp(n,1001001001);
    dp[0] = 0;
    rep(i,n){
        if (i>0) dp[i] = min(dp[i-1] + abs(h[i-1] - h[i]) , dp[i]);
        if (i>1) dp[i] = min(dp[i-2] + abs(h[i-2] - h[i]) , dp[i]);
    }
    cout << dp[n-1];
}









Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>

int libcmp(char* a, char*b){
	int i;
	for(i = 0; strlen(a) > i; i++){
		if(a[i] > b[i]) return 2;
		else if(a[i] < b[i]) return 1;
	}
	if(strlen(a) > strlen(b)) return 2;
	else if(strlen(a) < strlen(b)) return 1;
	else return 0;
}
int main(void) {
	int i, n, po[2] = {0};
	
	scanf("%d", &n);
	for(i = 0; n > i; i++){
		char a[101],b[101];
		scanf("%s%s", a, b);
		int bn = libcmp(a,b);
		switch(bn){
			case 2:
				po[1]+=3;
				break;
			case 1:
				po[0]+=3;
				break;
			case 0:
				po[0]++;
				po[1]++;
				break;
		}
	}
	printf("%d %d\n", po[1], po[0]);
	return 0;
}

Measured memory_bytes: 604
from sys import stdin
from collections import deque
def main():
    #入力
    readline=stdin.readline
    N=int(readline())
    g=[[] for _ in range(N)]
    AB=[]
    for _ in range(N-1):
        a,b=map(lambda x:int(x)-1,readline().split())
        g[a].append(b)
        g[b].append(a)
        AB.append(str(a)+" "+str(b))

    link=[0]*N
    que=deque([0])
    is_searched=[False]*N
    is_searched[0]=True
    K=0
    ans=dict()
    #bfs
    while len(que)>=1:
        now=que.popleft()
        color=1
        for x in g[now]:
            if is_searched[x]:
                continue
            else:
                is_searched[x]=True
                que.append(x)
                if color==link[now]:
                    color+=1
                link[x]=color
                ans[str(min(now,x))+" "+str(max(now,x))]=color
                color+=1
        color-=1
        K=max(K,color)

    #出力
    print(K)
    for key in AB:
        print(ans[key])
        
if __name__=="__main__":
    main()

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

namespace kakomon
{
    class Program
    {
        static void Main(string[] args)
        {
            abc069_b();
        }


        static void abc069_b()
        {
            // B - i18n
            string S = Console.ReadLine().Trim();
            int len = S.Length;
            string head = S.Substring(0, 1);  // 最初の1文字
            string tail = S.Substring(len - 1);  // 最後の1文字
            string ans = head + (len - 2).ToString() + tail;
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13012
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
template<class T> inline bool chmax(T &a, T b){
    if(a<b){
        a = b;
        return true;
    }
    return false;
}

template<class T> inline bool chmin(T &a, T b){
    if(a>b){
        a = b;
        return true;
    }
    return false;
}
ll sm = 0;
int main(){
    int n;
    cin >> n;
    cin >> sm;
    vector<bool> op(n-1);
    vector<ll> p(n-1);
    rep(i,n-1){
        char c;
        cin >> c;
        if(c=='-'){
            op[i] = 1;
        }else{
            op[i] = 0;
        }
        cin >> p[i];
    }
    vector<pair<ll,ll> > a;
    bool flag = 1;
    ll tmp  = 0;
    ll tt = 0;
    rep(i,n-1){
        if(op[i]){
            if(!flag){
                a.push_back(MP(tt,tmp));
            }
            flag = 0;
            tt = p[i];
            tmp = p[i];
            sm += p[i];
        }else{
            if(flag){
                sm += p[i];
            }else{
                tmp += p[i];
                sm += p[i];
            }
        }
    }
    if(!flag){
        a.push_back(MP(tt,tmp));
    }
    ll mx = -(1LL<<60);
    if(a.size()==0){
        mx = sm;
    }else{
        for(auto x:a){
            ll ss = x.first;
            ll ssss = x.second;
            chmax(mx,sm - ssss*2);
            sm -= 2*ss;
        }
    }
    cout << mx << endl;
    return 0;
}

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define ll long long 
#define fast cin.sync_with_stdio(false);
using namespace std;


int main()
{
 


	ll n,w;
	cin>>n>>w;
	ll dp[n+1][w+1];
	for (ll i=0;i<=n;i++)
		dp[i][0]=0;
	for (ll j=0;j<=w;j++)
		dp[0][j]=0;

	ll arr[n+1],val[n+1];
	for (ll i=1;i<=n;i++)cin>>arr[i]>>val[i];

	for (ll i=1;i<=n;i++)
		for (ll j=1;j<=w;j++)
		{
			if (j<arr[i])
				dp[i][j]=dp[i-1][j];
			else
				dp[i][j]=max(dp[i-1][j-arr[i]]+val[i],dp[i-1][j]);
		}

	cout<<dp[n][w];
}

Measured memory_bytes: 79104
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int> arr(2*n);
	int x;
	for(int i=0;i<2*n;i++){
		cin>>x;
		arr[i] = x;
	}	
	int	ans=0;
	sort(arr.begin(),arr.end());
	for(int i=0;i<2*n-1;i++){
		if(arr[i]<arr[i+1]) ans+=arr[i];
		else ans+=arr[i+1];
		i++;
	}
	cout<<ans;
}

Measured memory_bytes: 384
n =  int(input())
v_list =  list(map(int,input().split()))
c_list =  list(map(int,input().split()))
max_diff = 0
for i in range(n):
    if v_list[i] > c_list[i]:
        max_diff += v_list[i]-c_list[i]
print(max_diff)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N,f,t;
  	cin >> N;
    t = N;
  	while(t>0){
      f += t%10;
      t /= 10;
    }
  if(N%f == 0){
    cout << "Yes" << endl;
  }else{
   	cout << "No" << endl; 
  }
 
}
  

Measured memory_bytes: 256
n, m, x = map(int, input().split())
sup = [0]*n 
cost = [0]*n

for i in range(n):
  CA = list(map(int, input().split()))
  cost[i] = CA[0]
  sup[i] = CA[1:]
  
ans = -1

for i in range(2**n):
  skills = [0]*m
  c = 0
  for j in range(n):
    if i>>j&1:
      c += cost[j]
      for k in range(m):
        skills[k] += sup[j][k]
  if min(skills)>=x:
    if ans < 0:
      ans = c
    elif c<ans:
      ans = c
    
print(ans)
      
  



Measured memory_bytes: 9072
#include<stdio.h>

int main()
{
    int i,j,n,count,num=0;
    int prime[50001]={0};
    int p[20000]={0};

    for(i = 2;i < 50001;i++) prime[i]=1;

    for(i = 2;i < 50001;i++){
        if(prime[i]){
            p[num]=i;
            num++;
            for(j=i+i;j<=50001;j+=i){
                prime[j]=0;
            }
        }
    }

    while(scanf("%d",&n),n){

        count=0;

        if(n%2){
            for(i=0;p[i]<n;i++){
                if(p[i]==n-2) count++;
            }
        } else {
            for(i=0;p[i]<=n/2;i++){
                if(prime[n-p[i]]){
                    count++;
                }
            }
        }

        printf("%d\n",count);
    }

    return 0;}

Measured memory_bytes: 880
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"
#include "set"
#include "stack"
#include "tuple"

#define rep(n) for (int i = 0; i < n; ++i)
#define REP(n,i) for (int i = 0; i < n; ++i)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define intinf 1000000000
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define mkt make_tuple
#define P pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

int n, x[100], y[100], h[100],H;
bool b,f;
int main() {
	cin >> n;
	rep(n)
		cin >> x[i] >> y[i] >> h[i];
	for (int cx = 0; cx <= 100; ++cx) {
		for (int cy = 0; cy <= 100; ++cy) {
			f = true;
			rep(n) {
				if (h[i] != 0) {
					H = h[i] + abs(x[i] - cx) + abs(y[i] - cy);
					break;
				}
			}
			rep(n) {
				if (h[i]>0) {
					if (h[i] != H - abs(x[i] - cx) - abs(y[i] - cy)) {
						f = false;
						break;
					}
				}
				else {
					if (H - abs(x[i] - cx) - abs(y[i] - cy) > 0) {
						f = false;
						break;
					}
				}
			}
			if (f) {
				cout << cx << sp << cy << sp << H << endl;
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
  int n;
  cin >> n;
  vector<int> is;
  for (int i = 0;i<n;i++) {
    int t;
    cin >> t;
    is.push_back(t);
  }
  sort(is.begin(), is.end());
  int c = is[is.size()/2] - is[is.size()/2-1];
  cout << c << endl;
  return 0;
}


Measured memory_bytes: 892
#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>;

const int INF = 1001001001;



int main() {
  int n, m, x;
  cin >> n >> m >> x;
  int a[n][m];
  vector<int> c(n);
  rep(i,n) {
    cin >> c[i];
    rep(j,m) cin >> a[i][j];
  }

  int ans = INF;
  rep(s,1<<n) {
    int cost = 0;
    vector<int> d(m);
    rep(i,n) {
      if (s>>i&1) {
        cost += c[i];
        rep(j,m) d[j] += a[i][j];
      }
    }
    bool ok = true;
    rep(j,m) if (d[j] < x) ok = false;
    if (ok) ans = min(ans, cost);
  }
  if (ans == INF) cout << -1 << endl;
  else cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3628
n = int(input())
arr = []

res = {}
for i in range(n):
    s = input()
    if res.get(s) == None:
        res.__setitem__(s, 1)
    else:
        res.__setitem__(s, res.get(s) + 1)


def calculate(n,res):
    values = list(res.values())
    maxValue = max(values)

    results = []
    for re in res.keys():
        if res.get(re) == maxValue:
            results.append(re)

    results = sorted(results)
    for res in results:
        print(res)

calculate(n,res)


Measured memory_bytes: 34640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;
int a[30], b[maxn];
string s[maxn];
int ans[maxn];
map<string, ll>mp;
int main(){
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++){
		cin >> s[i];
		memset(a, 0, sizeof a);
		string ss;
		for (int j = 0; j < s[i].size(); j++){
			a[s[i][j] - 'a']++;
		}
		for (int i = 0; i < 26; i++)
			ss += a[i]-'0';
		//cout << ss << endl;
		mp[ss]++;
	}
	ll ans = 0;
	for (auto it : mp){
		ll x = it.second;
		if(x!=1)ans += (x)*(x - 1) / 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 21376
#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define loop(i,x,n) for(ll i = x;i<n;i++)
#define loopr(i,x,n) for(ll i = n-1;i>=x;i--)
#define S(v) sort(v.begin(), v.end());
#define ff first
#define ss second
map<ll,bool> empty;


int main()
{		
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	ll t = 1;
	// cin>>t;
	while(t--){
		ll n;
		cin>>n;
		vector<ll> v(n), p(n);
		loop(i,0,n)cin>>v[i];
		ll ans = 0;
		p = v;
		loop(i,1,n){
			if(v[i] >= p[i-1])continue;
			else{
				ans += p[i-1] - v[i];
				p[i] = p[i-1];
			}
		}
		cout<<ans;
	}
}
/*

1 5 4 1 2 2 4

*/




Measured memory_bytes: 6360
import queue
h,w = map(int,input().split())

maze=[]

count_white=0

for i in range(h):
    maze_row = input()
    maze.append(maze_row)
    
    count_white+=maze_row.count(".")
    
dist = [ [-1]*w for i in range(h)]
goal = [w-1,h-1]
q=queue.Queue()
q.put((0,0,0))

moves = [[0,1], [1,0], [0,-1], [-1,0]]
dmax=-1
while not q.empty():
    
    x,y,d = q.get()
    
    if x==goal[0] and y==goal[1]:
        time=d
        dist[y][x]=d
        dmax=d
        break
    
    if dist[y][x] >= 0:
        continue
    
    else:
        
        dist[y][x]=d
        
        for dx,dy in moves:
            
            if 0<=x+dx<w and 0<=y+dy<h:
                if dist[y+dy][x+dx] == -1 and maze[y+dy][x+dx]!="#":
                
                    q.put((x+dx,y+dy,d+1))
if dmax!=-1:
    print(count_white-dmax-1)
    
else:
    print(-1)

Measured memory_bytes: 71936
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, K;
  cin >> N >> K;
  vector<int> a(N);
  for (int i = 0; i < N; i++){
    cin >> a[i];
  }
  for (int i = 0; i < N; i++){
    a[i] -= K;
  }
  vector<long long> S(N + 1, 0);
  for (int i = 0; i < N; i++){
    S[i + 1] = S[i] + a[i];
  }
  vector<long long> S2 = S;
  sort(S2.begin(), S2.end());
  S2.erase(unique(S2.begin(), S2.end()), S2.end());
  int cnt = S2.size();
  map<long long, int> mp;
  for (int i = 0; i < cnt; i++){
    mp[S2[i]] = i;
  }
  for (int i = 0; i <= N; i++){
    S[i] = mp[S[i]];
  }
  long long ans = 0;
  vector<int> BIT(cnt + 1, 0);
  for (int i = 0; i <= N; i++){
    int j;
    j = S[i] + 1;
    while (j > 0){
      ans += BIT[j];
      j -= j & -j;
    }
    j = S[i] + 1;
    while (j <= cnt){
      BIT[j]++;
      j += j & -j;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 20424
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
// using namespace atcoder;


ll mpow(ll x, ll n, ll mod){
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % mod;
        x = x*x % mod;
        n = n >> 1;
    }
    return ans;
}

vector<ll> fact;

void calcFact(ll n, ll mod) {
    fact.assign(n+1, 1);
    repi(i, n+1) {
        fact[i] = fact[i-1] * i % mod;
    }
}

ll combination(ll n, ll a, ll mod) {
    if (n < a) {
        return 0;
    }
    // if (n >= fact.size() || a >= fact.size() || n - a >= fact.size()) {
    //     put(1);
    // }
    // if (n < 0 || a < 0 || n - a < 0) {
    //     put(1);
    // }
    ll X = fact[n];
    ll Y = fact[a];
    ll Z = fact[n-a];
    ll iY = mpow(Y, mod - 2, mod);
    ll iZ = mpow(Z, mod - 2, mod);

    ll res = X * iY % mod;
    res = res * iZ % mod;

    return res;
}

void Main()
{
    ll n;
    cin >> n;
    vector<ll> a(n+1);
    rep(i, n+1) cin >> a[i];

    ll mod = 7LL + 1e9;
    
    auto b = a;
    sort(all(b));
    ll dup = -1;
    rep(i, b.size() - 1) {
        if (b[i] == b[i+1]) {
            dup = b[i];
            break;
        }
    }

    ll nA = 0;
    ll nC = 0;
    rep(i, a.size()) {
        if (dup == a[i]) {
            nA = i;
            break;
        }
    }
    rep(i, a.size()) {
        if (dup == a[a.size()-1-i]) {
            nC = i;
            break;
        }
    }

    calcFact(n+1, mod);
    for (ll k = 1; k <= n + 1; k++) {
        ll c1 = combination(n+1, k, mod);
        ll c2 = combination(nA + nC, k-1, mod);
        ll res = (c1 + mod - c2) % mod;
        put(res);
    }

    
}
signed main(){ Main();return 0;}

Measured memory_bytes: 5580
S = Array.new(13,false)
H = Array.new(13,false)
C = Array.new(13,false)
D = Array.new(13,false)

numbers = gets.to_i
numbers.times do | n |
    a,b = gets.split(' ')
    b = b.to_i
    case a
    when "S"
        S[b-1] = true
    when "D"
        D[b-1] = true
    when "C"
        C[b-1] = true
    when "H"
        H[b-1] = true        
    end
end

S.each_with_index do |n, i|
    puts "S #{i + 1}" if n == false
end
H.each_with_index do |n, i|
    puts "H #{i + 1}" if n == false
end
C.each_with_index do |n, i|
    puts "C #{i + 1}" if n == false
end
D.each_with_index do |n, i|
    puts "D #{i + 1}" if n == false
end


Measured memory_bytes: 6860
N=int(input())
A=list(map(int, input().split()))
res='APPROVED'
B=[]
for a in A:
    if a%2==0:
        B.append(a)

if len(B)==0:
    res='APPROVED'
if 0<len(B):
    for b in B:
        if (b%3!=0)&(b%5!=0):
            res='DENIED'
print(res)

Measured memory_bytes: 3064
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,cnt=0;
    cin>>n;
    string s;
    cin>>s;
    queue<int> que;
    for(int i=0;i<n;i++){
        if(s[i]=='('){
            que.push(1);
        }
        if(s[i]==')'){
            if(que.empty())cnt++;
            else que.pop();
        }
    }
    for(int i=0;i<cnt;i++){
        cout<<'(';
    }
    cout<<s;
    for(int i=0;i<que.size();i++){
        cout<<')';
    }
    cout<<endl;
    //cout<<cnt<<que.size();
}



Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#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>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for(int i = a; i < (int)b; i++)
#define pb push_back
#define mp make_pair
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef long long ll;
const int INF = 1<<28;
const ll MOD = 1000000007;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

void j(string &s) {
	s = s[s.size()-1] + s;
	s.erase(s.end()-1);
}
void c(string &s) {
	s = s + s[0];
	s.erase(s.begin());
}
void e(string &s) {
	if(s.size()%2)
		REP(i, s.size()/2)
			swap(s[i], s[s.size()/2+i+1]);
	else
		REP(i, s.size()/2)
			swap(s[i], s[s.size()/2+i]);
}
void a(string &s) {
	reverse(s.begin(), s.end());
}
void p(string &s) {
	REP(i, s.size())
		if(isdigit(s[i]))
			s[i] = s[i] == '0' ? '9' : s[i]-1;
}
void m(string &s) {
	REP(i, s.size())
		if(isdigit(s[i]))
			s[i] = s[i] == '9' ? '0' : s[i]+1;

}

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

	int n; cin >> n;
	REP(_, n) {
		string x, y;
		cin >> x >> y;

		reverse(x.begin(), x.end());
		REP(i, x.size()) {
			if(x[i] == 'J') j(y);
			if(x[i] == 'C') c(y);
			if(x[i] == 'E') e(y);
			if(x[i] == 'A') a(y);
			if(x[i] == 'P') p(y);
			if(x[i] == 'M') m(y);
		}
		cout << y << endl;
	}
	return 0;
}

Measured memory_bytes: 1224
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

int w, h;
int ans;
vector<vector<int> > field;
const int VACANT = 0, BLOCK = 1, START = 2, GOAL = 3;
const int dx[4] = {0, 0, 1, -1};
const int dy[4] = {1, -1, 0, 0};

inline bool out(int x, int y) {
	return x < 0 || y < 0 || x >= w || y >= h;
}

inline void dfs(int x, int y, int moves = 0) {
	if(moves + 1 >= ans)
		return;

	for(int d = 0; d < 4; ++d) {
		int nx = x + dx[d], ny = y + dy[d];
		if(!out(nx, ny) && field[ny][nx] != BLOCK) {
			while(!out(nx, ny)) {
				if(field[ny][nx] == GOAL) {
					ans = moves + 1;
					return;
				}

				if(field[ny][nx] == BLOCK) {
					field[ny][nx] = VACANT;
					dfs(nx - dx[d], ny - dy[d], moves + 1);
					field[ny][nx] = BLOCK;
					break;
				}

				nx += dx[d];
				ny += dy[d];
			}
		}
	}
}

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

	while(cin >> w >> h, w) {
		field.clear();
		field.resize(h, vector<int>(w));
		int sx, sy;
		for(int i = 0; i < h; ++i) {
			for(int j = 0; j < w; ++j) {
				cin >> field[i][j];
				if(field[i][j] == START) {
					sx = j;
					sy = i;
					field[i][j] = VACANT;
				}
			}
		}

		ans = 11;
		dfs(sx, sy);
		cout << (ans == 11 ? -1 : ans) << endl;
	}

	return EXIT_SUCCESS;
}

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

int main()
{
    int H, W;
    cin >> H >> W;
    vector<string> S(H);
    for(int i = 0;i < H;i++){
        cin >> S[i];
    }
    vector<vector<int>> cntO(H, vector<int>(W + 1)), cntI(H + 1, vector<int>(W));
    for(int i = 0;i < H;i++){
        for(int j = W - 1;j >= 0;j--){
            cntO[i][j] = cntO[i][j + 1] + (S[i][j] == 'O');
        }
    }
    for(int i = H - 1;i >= 0;i--){
        for(int j = 0;j < W;j++){
            cntI[i][j] = cntI[i + 1][j] + (S[i][j] == 'I');
        }
    }
    ll res = 0;
    for(int i = 0;i < H;i++){
        for(int j = 0;j < W;j++){
            if (S[i][j] == 'J') res += cntO[i][j] * cntI[i][j];
        }
    }
    cout << res << endl;
    return 0;
}



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

int main(){
  int N;
  cin >> N;
  for(int i=1;i<10;i++){
    for(int j=1;j<10;j++){
      if(i*j == N){
        cout << "Yes" << endl;
        return(0);
      }
    }
  }
  
  cout << "No" << endl;
  return(0);
}

Measured memory_bytes: 256
#include <stdio.h>

#define N 100

void selectionSort(int *, int);

int main(){
  int array[N], n, i;

  scanf("%d", &n);

  for(i = 0; i < n; i++)
    scanf("%d", &array[i]);

  selectionSort(array, n);

  return 0;
}

void selectionSort(int *array, int n){
  int i, j, tmp, min, cnt=0;

  for(i = 0; i <= n - 1; i++){
    min = i;
    for(j = i; j <= n - 1; j++)
      if(array[j] < array[min]) min = j;
    if(i != min){
      tmp = array[i];
      array[i] = array[min];
      array[min] = tmp;
      cnt++;
    }
  }

  for(i = 0; i < n; i++){
    if(i == n - 1) printf("%d\n", array[i]);
    else printf("%d ",array[i]);
  }

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

}

Measured memory_bytes: 600
import java.util.Scanner;
public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		long ans ;
		if(N == M) {
			ans = 2;
			for(int i = 1; i <= N; i++)
				ans = ans * i % 1000000007;
			for(int i = 1; i <= N; i++)
				ans = ans * i % 1000000007;
		}
		else if(Math.abs(N-M) == 1) {
			ans = 1;
			for(int i = 1; i <= N; i++)
				ans = ans * i % 1000000007;
			for(int i = 1; i <= M; i++)
				ans = ans * i % 1000000007;
		}
		else
			ans = 0;
		System.out.println(ans);
	}

}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF 2 << 29
#define MOD 1000000007
#define Yes(f) puts((f)? "Yes" : "No")
#define YES(f) puts((f)? "YES" : "NO")
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}

int main(){
	ll x, ans, n = 100; cin >> x;
	for(ans = 0; x > n; ans++){
		n *= 1.01;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3632
using System;
class Program
{
	static void Main(string[] args)
	{
		char[] s = Console.ReadLine().ToCharArray();
      	char[] t = Console.ReadLine().ToCharArray();
      
      	Array.Sort(s);
      	Array.Sort(t);
      	Array.Reverse(t);
      
      	Console.WriteLine( string.Compare( new string(s), new string(t) ) < 0 ? "Yes" : "No" );
	}
}

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

int main()
{
	int64_t N;
	scanf("%lld", &N);
	if (N % 2 == 1) puts("0");
	else
	{
		N /= 2;
		int64_t ans{};
		for (int64_t five{5}; five <= N; five *= 5)
			ans += N / five;
		printf("%lld\n", ans);
	}

	return 0;
}

Measured memory_bytes: 256
use proconio::input;
use proconio::marker::{Chars};
use std::iter::Iterator;
use std::collections::HashSet;

fn main() {
    input! {
    n: i32,
    m: i32,
    mut s: [i32; m],
    }

    let sum : i32 =  s.iter().sum();

    if sum <= n {
        println!("{}", n - sum);
    }else{
        println!("-1");
    }

}


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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}

//char->int
int ctoi(char c){
    return c-'0';
}



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

    int ans = 0;
    for(int i=1;i<=n;i++){
        ans += i;
    }

    cout << ans <<  endl;
}


Measured memory_bytes: 256
N,K = map(int,input().split())
L=[0]*N
for i in range(K):
 d=int(input())
 A=list(map(int,input().split()))
 for j in A:
  L[j-1]+=1
b=0
for k in range(N):
 if L[k]==0:
  b+=1
print(b)


Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
int main () {
    int m, d, ans = 0;
    scanf("%d%d", &m, &d);
    for (int i = 1; i <= m; i++) {
        for (int j = 1; j <= d; j++) {
            if (j / 10 >= 2 && j % 10 >= 2 && i == (j / 10) * (j % 10)) ans++;
        }
    }
    printf("%d\n", ans);
    return 0;
}

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

int main(){
    int a[4] = {1,2,4},n,memo = 0;
    
    
    rep(i,0,3){
        cin >> n;
        memo += n*a[i];
    }
    
    cout << ((memo >= 3)?"Open":"Close") << endl;
    return 0;
}


Measured memory_bytes: 3104
from math import gcd
import sys

N = int(input())

a = list(map(int,input().split()))

A = max(a)+1

# 全ての数に対して、入っているかいないかを判別する配列を作る
c = [0]*A
for i in range(N):
    c[a[i]] += 1

# print(c)

pairwise = True

for i in range(2,A):
    cnt = 0

    # 素因数ずつ数を増やしていき、同じ素因数を持つことがあればpairwiseではない
    # たとえば、3ならば、3,6,9,,と増やしていき、それがc[]に１つ以上含まれているか調べていく
    for j in range(i,A,i):
        cnt += c[j]
    if (cnt > 1):
        pairwise = False

if pairwise:
    print("pairwise coprime")
    sys.exit()

g = 0
for i in range(N):
    g = gcd(g,a[i])
if (g == 1):
    print("setwise coprime")
    sys.exit()

else:
    print('not coprime')

Measured memory_bytes: 189412
#include<bits/stdc++.h>
using namespace std;
long long a[100001],b[100001];
long long pl[100001],mi[100001];
int main()
{
	long long n;
	cin>>n; 
	long long ans=0,sum1=0,sum2=0,sum3=0;
	for(int i=1;i<=n;i++)
	{	
		cin>>a[i];
		sum1+=a[i];
	}
	int t1=0,t2=0;
	for(int i=1;i<=n;i++)
	{
		cin>>b[i];
		sum2+=b[i];
		if(b[i]>a[i])
		{
			t1++;
			pl[t1]=b[i]-a[i];
			sum3+=pl[t1];
			ans++;
		}
		else if(b[i]<a[i])
		{
			t2++;
			mi[t2]=a[i]-b[i];
		}
	}
	sort(pl,pl+t1+1);
	sort(mi,mi+t2+1);
	reverse(mi,mi+t2+1);
	if(sum1<sum2)
	{
		cout<<"-1\n";
		return 0;
	}
	if(ans==0)
	{
		cout<<ans<<endl;
		return 0;
	}
	for(int i=0;i<=t2*2;i++)
	{
		if(mi[i]>=sum3)
		{
			ans++;
			break;
		}
		else
		{
			sum3-=mi[i];
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2560
N = int(input())
A = [int(a) for a in input().split()]
B = [int(b) for b in input().split()]
C = [int(c) for c in input().split()]

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

L = [0]*N
j = 0
for i in range(N):
    while j < N and C[j] > B[i]:
        j += 1
    L[i] = j
    
for i in range(N-1):
    L[i+1] += L[i]

ans = 0
j = 0
for i in range(N):
    while j < N and B[j] > A[i]:
        j += 1
    if j > 0:
        ans += L[j-1]
    
print(ans)

Measured memory_bytes: 23640
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
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; }
using namespace std;

ll f(ll n){ return (n%2 == 0) ? n/2 : 3*n+1; }

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    map<ll, ll> mp; 
    ll s; cin >> s; mp[s]++;

    ll cnt = 1;
    for(;mp[s]<2;cnt++) s = f(s), mp[s]++;
    cout << cnt << endl;
}

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

int main(void){
  int q;
  cin >> q;

  for(int i=0; i<q; i++){
    string x, y;
    cin >> x >> y;
    
    int nx, ny;
    nx = x.size();
    ny = y.size();
    
    vector< vector<int> > lcs(nx+1, vector<int>(ny+1, 0));

    for(int i=1; i<=nx; i++){
      for(int j=1; j<=ny; j++){
	if(x[i-1] == y[j-1])
	  lcs[i][j] = lcs[i-1][j-1] + 1;
	else
	  lcs[i][j] = max(lcs[i-1][j], lcs[i][j-1]);
      }
    }
    
    cout << lcs[nx][ny] << endl;
  }

  return 0;
}

Measured memory_bytes: 6748
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#define N 100002
using namespace std;
int n,i,j,a[N],l,q,f[N][22];
int main()
{
	cin>>n;
	for(i=1;i<=n;i++) cin>>a[i];
	cin>>l>>q;
	for(i=1;i<=n;i++){
		int pos=lower_bound(a+1,a+n+1,a[i]+l)-a;
		if(a[pos]==a[i]+l) f[i][0]=pos;
		else f[i][0]=pos-1;
	}
	for(j=0;(1<<j)<=n;j++){
		for(i=1;i<=n;i++){
			if(f[i][j]==n) f[i][j+1]=0;
			else f[i][j+1]=f[f[i][j]][j];
		}
	}
	for(i=1;i<=q;i++){
		int x,y,ans=1<<30,tmp=0;
		cin>>x>>y;
		if(x>y) swap(x,y);
		for(j=log2(1.0*n);j>=0;j--){
			if(f[x][j]==0) continue;
			tmp+=pow(2,j);
			if(f[x][j]>=y){
				ans=min(ans,tmp);
				tmp-=pow(2,j);
			}
			else x=f[x][j];
		}
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 9856
n = gets.to_i
rests = []
n.times do |i|
  s, p = gets.chomp.split
  p = p.to_i

  rests << [i + 1, s, p]
end

rests.sort! do |a, b|
  if a[1] < b[1]
    -1
  elsif a[1] > b[1]
    1
  elsif a[2] > b[2]
    -1
  else
    1
  end
end

rests.each do |rest|
  puts rest[0]
end


Measured memory_bytes: 1788
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
 
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; }
 
struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};


 
void solve(){
    ll a[10];
    rep(i,3)cin>>a[i];
    sort(a,a+3);
    if(a[0]+a[1]==a[2]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}
 
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
     
    ll Q=1;
    // cin>>Q;
    rep(_,Q){
 
        solve();
 
    }
   
 
 
    return 0;
}

Measured memory_bytes: 256