akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
    int n; cin >> n;
    vector<int> x(n);
    REP(i, n) cin >> x[i];

    int ans = 1000000;
    FOR(p, 1, 101) {
        int s = 0;
        REP(i, n) {
            s += pow(x[i] - p, 2);
        }
        ans = min(ans, s);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
n,m,l = map(int,input().split())

a = [[0 for i in range(m)] for j in range(n)]
b = [[0 for i in range(l)] for j in range(m)]
c = [[0 for i in range(l)] for j in range(n)]

for i in range(n):
    mat_tmp = list(map(int,input().split()))
    for j in range(m):
        a[i][j] = mat_tmp[j]

for i in range(m):
    mat_tmp = list(map(int,input().split()))
    for j in range(l):
        b[i][j] = mat_tmp[j]

for i in range(n):
    for j in range(l):
        for k in range(m):
            c[i][j] += a[i][k]*b[k][j]

for i in range(n):
    print(' '.join(str(x) for x in c[i]))

Measured memory_bytes: 8940
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

vector<ll> enum_divisors(ll N){
  vector<ll> res;
  for (ll i = 1; i * i <= N; ++i){
    if (N % i == 0) {
      res.push_back(i);
      //重複しない時
      if (N / i != i) res.push_back(N / i);
    }
  }
  sort(res.begin(), res.end());
  return res;
}

int main(){
  int N, M; cin >> N >> M;
  vector<ll> que = enum_divisors(M);
  sort(que.begin(), que.end(), greater<ll>());
  rep(i, que.size()) {
    if (M / que[i] >= N){
      cout << que[i] << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
from bisect import bisect_right


def solve():
    N, M, K = map(int, input().split())

    A = map(int, input().split())
    B = map(int, input().split())

    sum_as = [0] * (N+1)
    sum_bs = [0] * (M+1)

    for i, a in enumerate(A):
        sum_as[i+1] = sum_as[i] + a

    for i, b in enumerate(B):
        sum_bs[i+1] = sum_bs[i] + b
    sum_bs = sum_bs[1:]

    answer = 0
    for i, sa in enumerate(sum_as):
        remain = K - sa
        if remain < 0:
            continue
        
        idx = bisect_right(sum_bs, remain)
        answer = max(answer, i + idx)

    return answer


def main():
    print(solve())


if __name__ == "__main__":
    main()


Measured memory_bytes: 50812
n = int(input())
A = sorted(list(map(int, input().split())))

from collections import Counter
c = Counter(A)

NMAX = 10 ** 6 + 1000
dp = [True] * (NMAX + 1)
for k, v in c.items():
    if not dp[k]:
        continue
    for i in range(k * 2, NMAX + 1, k):
        dp[i] = False
    if v > 1:
        dp[k] = False

count = 0
for k, v in c.items():
    if v > 1: continue
    if dp[k]: count += 1

print(count)


Measured memory_bytes: 121804
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N;
vector<vector<LL>> adj;

LL ans = INF;

LL dfs(LL now=1,LL prev=-1){
	//頂点1を根としてみなした時、
	//頂点nowより下の木が表す
	//トーナメントの深さをこの関数は返す
	vector<LL> depth;
	for(auto next:adj[now]){
		if(next==prev) continue;
		depth.push_back(dfs(next,now));
	}
	if(depth.size()==0) return 0;
	sort(depth.begin(),depth.end(),greater<LL>());
	LL ret = -1;
	for(int i=0;i<depth.size();i++){
		depth[i] += (i+1);
		ret = max(ret,depth[i]);
	}
	return ret;
}

void solve(){
	ans = dfs();
}

int main(){
    cin >> N;
    adj = vector<vector<LL>>(N+1);
    for(int i=2;i<=N;i++){
    	LL a;cin >> a;
    	adj[i].push_back(a);
    	adj[a].push_back(i);
    }

    solve();

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

Measured memory_bytes: 15104
#include <iostream>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
 
  string S;
  cin >> S;
  string result;
  char c;
  for(int i=0; i < S.size(); i++){
    c = S[i];
    if(i%2 == 0){
      if(c != 'R' && c != 'U' && c != 'D'){
        result = "No";
        break;
      }
    } 
    else {
      if(c != 'L' && c != 'U' && c != 'D'){
        result = "No";
        break;
      }
    }
    result = "Yes";
  }

  cout << result << endl;
}

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

int main(){
  int N;
  cin>>N;
  int x,y,z;
  x = N / 100;
  y = (N - x * 100) / 10;
  z = (N - (x * 100) -( y *10));
  if(x != 7 && y != 7 && z != 7){
    cout<<"No";}else{
      cout<<"Yes";
    }
}


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

int main(){
  long int a[4];
  long int m;
  for(int i=0;i<4;i++)
    cin >> a[i];

  for(int i=0;i<2;i++){
    for(int j=2;j<4;j++){
      if(i==0 && j==2)
	m = a[i]*a[j];
      else
	m = max(m,a[i]*a[j]);
    }
  }

  cout << m << endl;
}

Measured memory_bytes: 3628
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

void ComputeKakezan(const string& lhs,const string& rhs,string& result){
  ll a = strtol(lhs.c_str(),NULL,10);
  ll b = strtol(rhs.c_str(),NULL,10);

  char str[32];
  sprintf(str,"%ld",a*b);
  result = str;
}

int main(){
  int n;
  while(~scanf("%d",&n)){
    for(int i=0;i<n;i++){
      int count = 0;
      string seed;
      cin >> seed;
      
      map<string,bool> visited;
      visited[seed] = true;

      string current_max = seed;

      while(current_max.size() > 1){
	ll tmp_max = 0;
	for(int i=0;i<current_max.size()-1;i++){
	  string lhs = current_max.substr(0,i+1);
	  string rhs = current_max.substr(i+1,current_max.size()-(i+1));

	  string result;
	  ComputeKakezan(lhs,rhs,result);

	  ll result_ll = strtol(result.c_str(),NULL,10);
	  tmp_max = max(result_ll,tmp_max);
	  
	  // cout << lhs <<"\n";
	  // cout << rhs <<"\n";
	}
	
	char tmp[100];
	sprintf(tmp,"%ld",tmp_max);
	current_max = tmp;
	// cout << current_max << "\n";
	count++;
	if(visited.find(current_max) != visited.end()){
	  if(current_max.size() != 1) count = -1;
	  break;
	}
	visited[current_max] = true;
      }

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

Measured memory_bytes: 1264
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>

#define rep(i,n) for(int i=0;i<int(n);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back

using namespace std;
using ll = long long;


const ll mod = 1000000007;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
// bool debug=false;

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

int main(){
  int N;
  cin >> N;
  vector<int> d(N);
  for(int i = 0; i < N; i++) {
    cin >> d[i];
  }
  sort(all(d));
  //cerr << d[d.size() / 2 - 1] << " " << d[d.size() / 2] << endl;
  cout << d[d.size() / 2] - d[d.size() / 2 - 1]  << endl;
  return 0;
}


Measured memory_bytes: 640
m=10**9+7
def f(r,c):
 s=t=1
 for i in range(c):s=s*(r+c-i)%m;t=t*-~i%m
 return s*pow(t,m-2,m)%m
a,b,c,d=map(int,input().split())
print((f(a,b)-f(c+1,b)-f(a,d+1)+f(c+1,d+1))%m)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;

int main() {
  ll n; cin >> n;
  Vl a(n);
  rep(i, 0, n) cin >> a[i];

  ll ans = 0;
  rep(i, 0, n) ans ^= a[i];

  if(ans == 0) puts("Yes");
  else puts("No");


  return 0;
}


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

int main() {
    int N, M, P; cin >> N >> M >> P;
    vector<int> d(M);
    for(int i=0; i<M; i++) {
        cin >> d[i];
        d[i] -= P;
        (d[i] += N) %= N;
    }
    sort(d.begin(), d.end());

    int ans = min(d.back(), N - d[0]);
    for(int i=0; i+1<M; i++) {
        int v = N - (d[i+1] - d[i]);
        int a1 = d[i], a2 = N - d[i+1];
        // fprintf(stderr, "v = %d, a1 = %d, a2 = %d\n", v, a1, a2);
        ans = min(ans, min(a1, a2) + v);
    }
    cout << ans * 100 << endl;
    return 0;
}



Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    string s;
    int n;
    cin >> n >> s;
    // 右向いてる人の数
    vi a(n,0),b(n,0);
    if(s[0]=='E') a[0]= 1;
    else b[0] = 1;
    for(int i=1;i<n;i++){
        a[i] = a[i-1] + (s[i]=='E'? 1:0);
        b[i] = b[i-1] + (s[i]=='W'? 1:0);
    }
    ll ans = INF;
    rep(i,n){
        ll t;
        if(i==0){
            t = a[n-1] - a[0];
        }else if(i==n-1){
            t = b[n-2];
        }else{
            t = b[i-1] + (a[n-1] - a[i]);
        }
        ans = min(ans,t);
    }
    cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld;

#define fi first
#define se second
#define pb push_back
#define mp make_pair

const int MOD = 1e9 + 7;

vi adj[2001];
int dist[2001];
int dist2[2001];
int cnt;
int k;
bool visited[2001];

void dfs(int u)
{
	visited[u] = true;
	for(int i = 0; i < adj[u].size(); i++)
	{
		int v = adj[u][i];
		if(!visited[v])
		{
			dist[v] = dist[u] + 1;
			if(dist[v] > k/2) cnt++;
			dfs(v);
		}
	}
}

void dfs2(int u)
{
	visited[u] = true;
	for(int i = 0; i < adj[u].size(); i++)
	{
		int v = adj[u][i];
		if(!visited[v])
		{
			dist2[v] = dist2[u] + 1;
			if(dist2[v] > k/2) cnt++;
			dfs2(v);
		}
	}
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n;
	cin >> n >> k;
	for(int i = 0; i < n - 1; i++)
	{
		int u, v;
		cin >> u >> v;
		u--; v--;
		adj[u].pb(v); adj[v].pb(u);
	}
	if(k&1)
	{
		int ans = n;
		for(int i = 0; i < n; i++)
		{
			for(int j = 0; j < adj[i].size(); j++)
			{
				int v = adj[i][j];
				int u = i;
				memset(dist, 0, sizeof(dist));
				memset(dist2, 0, sizeof(dist));
				memset(visited, 0, sizeof(visited));
				dfs(u);
				memset(visited, 0, sizeof(visited));
				dfs2(v);
				cnt = 0;
				for(int l = 0; l < n; l++)
				{
					if(dist[l] > k/2 && dist2[l] > k/2)
					{
						cnt++;
					}
				}
				ans = min(ans, cnt);
			}
		}
		cout << ans;
	}
	else
	{
		int ans = n;
		for(int i = 0; i < n; i++)
		{
			dfs(i);
			memset(dist, 0, sizeof(dist));
			memset(visited, 0, sizeof(visited));
			ans = min(ans, cnt);
			cnt = 0;
		}
		cout << ans;
	}
	return 0;
}


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

class Program
{
    public void Proc()
    {
        Reader.IsDebug = false;
        int kushi = int.Parse(Reader.ReadLine());
        int[] kushiList = Reader.ReadLine().Split(' ').Select(a=>int.Parse(a)).OrderBy(a=>a).ToArray();

        int ans = 0;
        for(int i=0; i<kushiList.Length; i+=2) {
            ans += Math.Min(kushiList[i], kushiList[i+1]);
        }
        Console.WriteLine(ans);

    }

    public class Reader
    {
        public static bool IsDebug = true;
        private static String PlainInput = @"


5
100 1 2 3 14 15 58 58 58 29


 
";
        private static System.IO.StringReader Sr = null;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (Sr == null)
                {
                    Sr = new System.IO.StringReader(PlainInput.Trim());
                }
                return Sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }

    }
    static void Main()
    {
        Program prg = new Program();
        prg.Proc();
    }
}

Measured memory_bytes: 3032
#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> a = {1,3,1,2,1,2,1,1,2,1,2,1};
  int x,y;
  cin >> x >> y;
  if(a.at(x - 1) == a.at(y - 1)) {
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }
}

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

int main()
{
    int n;
    cin>>n;
    int temp;
    int arr[n], minimum[n] = {0};
    for(int i=0; i<n; ++i)
    {
        cin>>arr[i];
    }
    minimum[1] = abs(arr[0]- arr[1]);
    for(int i=2; i<n; ++i)
    {
        minimum[i] = min(minimum[i-2] + abs(arr[i] - arr[i-2]), minimum[i-1] + abs(arr[i] - arr[i-1]));
    }
    cout<<minimum[n-1];
    return 0;
}


Measured memory_bytes: 1024
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[5];//marchを数える。
        for (int i = 0; i < n; i++) {
            String s = sc.next();
            if (s.charAt(0) == 'M') a[0]++;
            if (s.charAt(0) == 'A') a[1]++;
            if (s.charAt(0) == 'R') a[2]++;
            if (s.charAt(0) == 'C') a[3]++;
            if (s.charAt(0) == 'H') a[4]++;
        }
        long sum = 0;
        for (int i = 0; i < 3; i++) {
            for (int j = i+1; j < 4; j++) {
                for (int k = j+1; k < 5 ; k++) {
                    long tmp = a[i] * a[j];
                    sum += tmp * a[k];
                }

            }
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 45876
# coding: utf-8
# Your code here!
n=int(input())
A=list(map(int,input().split()))
q=int(input())
m=list(map(int,input().split()))

flag=[False]*2000
for i in range(2**n):
    cnt=0
    for j in range(n):
        if ((i>>j) & 1):
            cnt+=A[n-j-1]
    flag[cnt]=True
    
for o in m:
    print('yes' if flag[o]==True else 'no')       



Measured memory_bytes: 5636
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    LLONG N, K; cin >> N >> K; // N <= 2 * 1e5
    // 全ての数を選んでも1e5程度なので，余りが一巡することはない
    // Kの値が異なるとき，1e100の項の数が異なるので，値は全て異なる
    // K個選択するとき，最小値は0+...+(K-1)=K(K-1)/2，
    // 最大値は(N-K+1)+...+N=K(2N-K+1)/2で，間の値は全て作れる
    LLONG ans = 0;
    for (LLONG k = K; k <= N + 1; ++k)
    {
        LLONG max = k * (2 * N - k + 1) / 2;
        LLONG min = k * (k - 1) / 2;
        LLONG tmp = max - min + 1;
        ans += tmp;
        ans %= MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

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

    int X, A;
    cin >> X >> A;

    cout << ((X < A) ? 0 : 10) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>

int main(){
    int n,x;
    for(int i = 0;; i++){
        scanf("%d %d",&n,&x);
        if(n == 0 && x == 0){
            break;
        }
        int s = 0;
        int j,k,l;
        for(j = n; j >= 3; j--){
            for(k = j - 1; k >= 2; k--){
                for(l = k - 1; l >= 1; l--){
                    if(j + k + l == x){
                        s++;
                    }
                }
            }
        }
        printf("%d\n",s);
    }
    return 0;
}


Measured memory_bytes: 2696
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define pi pair<ll,ll>
#define pii pair<ll,pi>
#define pb push_back
#define mk make_pair
vector<ll>v;
int n;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	v.resize(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
		v[i] = v[i] - i;
	}
	sort(v. begin(), v.end());
	ll sum = 0;
	ll b = v[n / 2];
	for (int i = 0; i < n; i++) {
		sum += abs(v[i] - b);
	}
	cout << sum << endl;
}

Measured memory_bytes: 1792
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner sc = null;
		try {
			sc = new Scanner(System.in);
			while (sc.hasNextInt()) {
				int n = sc.nextInt();
				int sum = (n * n + n + 2) / 2;
				System.out.println(sum);
			}

		} finally {
			sc.close();
		}
	}
}

Measured memory_bytes: 17192
#pragma region includes, macros
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <limits>

using namespace std;

typedef int64_t i64;
typedef pair<i64, i64> P;

template<class T>
const T INF = numeric_limits<T>::max();
template<class T>
const T SINF = numeric_limits<T>::max() / 10;
static const i64 MOD = 1000000007;

//int dx[5] = {-1,0,0,0,1}, dy[5] = {0,-1,0,1,0};
//int dx[8] = {-1,0,1,1,1,0,-1,-1}, dy[8] = {1,1,1,0,-1,-1,-1,0};
//int dx[9] = {-1,0,1,1,1,0,-1,-1,0}, dy[9] = {1,1,1,0,-1,-1,-1,0,0};

struct edge {
    i64 from, to, cost;
    edge(i64 to, i64 cost) : from(-1), to(to), cost(cost) {}
    edge(i64 src, i64 to, i64 cost) : from(src), to(to), cost(cost) {}
};

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
    for (auto& e : t) fill_v(e, v);
}
//

#pragma endregion

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

// 

int main() {
    i64 m, k;
    cin >> m >> k;
    if ((1LL << (m)) <= k) {
        cout << -1 << endl;
        return 0;
    }
    if (m == 1 && k == 0) {
        cout << "0 0 1 1" << endl;
        return 0;
    }else if(m == 1 && k == 1){
        cout << -1 << endl;
        return 0;
    }
    list<i64> ans;
    vector<int> u;
    vector<bool> used(1 << m, false);
    for (int i = 0; i < m; ++i) {
        if ((1 << i) & k) {
            ans.push_back(1 << i);
            u.push_back(1<<i);
            used[1 << i] = true;
        }
    }
    for (int i = 0; i < 1 << m; ++i) {
        if (!used[i]) {
            ans.push_front(i);
            ans.push_back(i);
            used[i] = true;
        }
    }
    for (int i = 0; i < u.size(); ++i) {
        ans.push_front(u[i]);
    }
    for_each(ans.cbegin(), ans.cend(), [](i64 x) {
        std::cout << x << " ";
    });

}

Measured memory_bytes: 9984
n = int(input())
lis = []
for i in range(n):
    lis.append(int(input()))

max_1 = sorted(lis)[-1]
max_2 = sorted(lis)[-2]

for i in range(n):
    if lis[i] == max_1:
        print(max_2)
    else:
        print(max_1)

Measured memory_bytes: 14940
A = []
for i in range(3):
    p,q,r = map(int, input().split())
    A.append(p)
    A.append(q)
    A.append(r)
n = int(input())
for i in range(n):
    b = int(input())
    if b in A:
        A[A.index(b)] = 0

if A[0]==A[1]==A[2]==0 or A[3]==A[4]==A[5]==0 or A[6]==A[7]==A[8]==0 or A[0]==A[3]==A[6]==0 or A[1]==A[4]==A[7]==0 or A[2]==A[5]==A[8]==0 or A[0]==A[4]==A[8]==0 or A[2]==A[4]==A[6]==0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
import java.util.*;
public class Main{

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int w= sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();

        if(Math.abs(a-b)<=w){
            System.out.println("0");
        }else {
            System.out.println(Math.abs(b-a)-w);
        }
    }
}




Measured memory_bytes: 23380
#include<iostream>
#include<algorithm>
using namespace std;
int a[110000],b[110000],n,i,Ans;
int main()
{ 
  cin >> n;
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  for(i=0;i<n;i++){
    if(a[i]!=0)b[a[i]-1]++;
    b[a[i]]++;
    b[a[i]+1]++;
    }
  for(i=0;i<110000;i++){
    if(b[i]>Ans)Ans=b[i];
  }
  printf("%d",Ans);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

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

inline int Read()
{
	int x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

const int MAXN = 100;

short n, m, stx, sty, p[MAXN][MAXN], q[MAXN][MAXN], f[MAXN][MAXN][MAXN][MAXN];
char s[MAXN][MAXN];

inline bool Chkmax(short &x, short y) { return x < y ? x = y, 1 : 0; }

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	n = Read(), m = Read();
	for (int i = 0; i < n; i ++)
	{
		scanf("%s", s[i]);
		for (int j = 0; j < m; j ++)
			if (s[i][j] == 'E')
				stx = i, sty = j;
			else
				p[i][j] = q[i][j] = s[i][j] == 'o';
	}
	for (int i = 1; i < n; i ++)
		for (int j = 0; j < m; j ++)
			p[i][j] += p[i - 1][j];
	for (int i = 0; i < n; i ++)
		for (int j = 1; j < m; j ++)
			q[i][j] += q[i][j - 1];
	for (int u = 0; u <= stx; u ++)
		for (int d = 0; d < n - stx; d ++)
			for (int l = 0; l <= sty; l ++)
				for (int r = 0; r < m - sty; r ++)
				{
					int cur = f[u][d][l][r];
					if (u < stx)
					{
						int L = max(sty - l, r), R = min(sty + r, m - 1 - l), val = cur;
						if (L <= R && stx - u - 1 >= d)
							val += q[stx - u - 1][R] - (L ? q[stx - u - 1][L - 1] : 0);
						Chkmax(f[u + 1][d][l][r], val);
					}
					if (d < n - stx - 1)
					{
						int L = max(sty - l, r), R = min(sty + r, m - 1 - l), val = cur;
						if (L <= R && stx + d + 1 < n - u)
							val += q[stx + d + 1][R] - (L ? q[stx + d + 1][L - 1] : 0);
						Chkmax(f[u][d + 1][l][r], val);
					}
					if (l < sty)
					{
						int U = max(stx - u, d), D = min(stx + d, n - 1 - u), val = cur;
						if (U <= D && sty - l - 1 >= r)
							val += p[D][sty - l - 1] - (U ? p[U - 1][sty - l - 1] : 0);
						Chkmax(f[u][d][l + 1][r], val);
					}
					if (r < m - sty - 1)
					{
						int U = max(stx - u, d), D = min(stx + d, n - 1 - u), val = cur;
						if (U <= D && sty + r + 1 < m - l)
							val += p[D][sty + r + 1] - (U ? p[U - 1][sty + r + 1] : 0);
						Chkmax(f[u][d][l][r + 1], val);
					}
				}
	return printf("%d\n", f[stx][n - stx - 1][sty][m - sty - 1]), 0;
}


Measured memory_bytes: 192896
N = parse(Int, readline())

mask(i) = 1 << ((i - 3) >> 1)

function dfs(block, a, use)
    if a > N
        return
    end

    if use == 0b111
        block(a)
    end

    for i in [3,5,7]
        dfs(block, a * 10 + i, use | mask(i))
    end
end

function main()
    ans = 0
    dfs(0, 0) do a
        ans += 1
    end
    return ans
end

println(main())

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

#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define ssort(n) sort((n).begin(),(n).end())
#define rsort(n) sort((n).begin(),(n).end(),greater<int>())
using ll=long long;
using ld=long double;
typedef pair<int,string> P;

#define repl(i,n) for(ll i=0;i<(n);++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl

int main()
{
    int n,m;
    cin >> n >> m;
    vector<P> point(m);
    vector<bool> isAC(n,false);
    vector<int> countWA(n,0);
    rep(i,m)cin >> point[i].first >> point[i].second;
    ll count_ac=0;
    ll count_wa=0;
    rep(i,m){
        if(!isAC[point[i].first-1]){
            if(point[i].second=="AC"){
                count_ac++;
                count_wa+=countWA[point[i].first-1];
                isAC[point[i].first-1]=true;
            }else{
                countWA[point[i].first-1]++;
            }
        }
    }
    cout << count_ac << " " << count_wa << endl;
}

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

int main(){
    int n, m;
    cin >> n >> m;
    ll p[100000], y[100000];
    vector <int> yd[100001];
    
    rep(i, m){
        cin >> p[i] >> y[i];
        yd[p[i]].emplace_back(y[i]);
    }
    rep(i,n){
        sort(yd[i+1].begin(), yd[i+1].end());
    }
    rep(i,m){
        printf("%012lld\n", p[i]*1000000 + lower_bound(yd[p[i]].begin(), yd[p[i]].end(), y[i]) - yd[p[i]].begin() +1);
    }

    return 0;
}

Measured memory_bytes: 8576
/*****Enigma_27*****/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pll         pair<ll,ll>
#define vll          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define endl		'\n'
#define ios        	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll n,i,j,l=2,t=0,k=1,x,ans=0,s,f;
int main()
{   ios
    map<ll,ll> m;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>x;m[x]++;
    }
    for(map<ll,ll> ::reverse_iterator i=m.rbegin();i!=m.rend();i++)
    {
       // cout<<i->F<<" "<<i->S<<" "<<t<<" "<<ans<<endl;
        if((i->S)>=4&&t==0) {cout<<(i->F*i->F);return 0;}
        else if(i->S>1&&t==0)  {ans=i->F;t=1;}
        else if(t==1&&i->S>1)  {cout<<ans*i->F<<endl;return 0;}
    }
    cout<<0<<endl;
	return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
#define eb(t) emplace_back(t)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;

string st[200010];

void solve(){

    int n;
    cin >> n;
    map<string,int> mp;
    rep(i,n){
        cin >> st[i];
        if(mp.count(st[i])!=0) mp[st[i]]++;
        else mp[st[i]]=0;
    }

    vector<int> v;

    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        v.eb(itr->second);
    }

    sort(v.begin(), v.end(), greater<int>());
    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        if(itr->second==v[0]) cout << itr->first << endl;
    }


}

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


Measured memory_bytes: 26356
#include <cstdio>
#include <cstdlib>

int main() {
    int n,t,x,y;
    scanf("%d", &n);
    int tnow = 0, xnow = 0, ynow = 0, dist;
    bool flg = true;
    for (int i = 1; i <= n; i++) {
        scanf("%d%d%d", &t, &x, &y);
        dist = abs(x - xnow) + abs(y - ynow);
        if (!(t - tnow >= dist && ((t - tnow - dist) % 2 ==0))) {
            flg = false;
        }
    }
    printf(flg?"Yes\n":"No\n");
    return 0;
}

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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

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

// 重み付きグラフ
// できてほしいこと
// DFS, BFS, bellman-ford, サイクル検出、トポロジカルソートなど
struct Graph {
	struct Edge {
		int to;
		int weight;
	};
	vector<vector<Edge>> g;

	// 初期化
	Graph(int N) { g.assign(N, vector<Edge>()); }
	// 辺追加
	Edge add(int from, int to, int weight = 1) {
		Edge e = { to, weight };
		g[from].push_back(e);
		return e;
	}
	// 深さ優先探索（startからの全点への距離を返す）
	vector<int> dfs(int start) {
		vector<int> dist(g.size(), INF);
		vector<int> seen(g.size(), false);

		stack<int> s;
		s.push(start);
		seen[start] = true;

		while (!s.empty()) {
			int u = s.top(); s.pop();
			for (Edge e : g[u]) {
				if (seen[e.to]) continue;
				else {
					dist[e.to] = min(dist[e.to], dist[u] + e.weight);
					s.push(e.to);
					seen[e.to] = true;
				}
			}
		}
		return dist;
	}
	// 深さ優先探索（再帰バージョン）（startからの全点への距離を返す）
	void dfs2_internal(int v, vector<int>& seen, vector<int>& dist) {
		seen[v] = true;
		for (Edge e : g[v]) {
			if (seen[e.to]) continue;
			else {
				dist[e.to] = min(dist[e.to], dist[v] + e.weight);
				dfs2_internal(e.to, seen, dist);
				seen[e.to] = true;
			}
		}
	}
	vector<int> dfs2(int start) {
		vector<int> dist(g.size(), INF);
		vector<int> seen(g.size(), false);
		dist[start] = 0;
		dfs2_internal(start, seen, dist);

		return dist;
	}
	// Dijkstra法（蟻本）
	vector<int> dijkstra(int start) {
		vector<int> dist(g.size(), INF);
		priority_queue<P, vector<P>, greater<P>> q;

		dist[start] = 0;
		q.push({ 0,start });
		while (!q.empty()) {
			int d, v;
			tie(d, v) = q.top(); q.pop();
			if (dist[v] < d) continue;  // 枝刈り
			for (Edge e : g[v]) {
				if (dist[e.to] <= dist[v] + e.weight) continue; // 枝刈り
				dist[e.to] = dist[v] + e.weight;
				q.push({ dist[e.to], e.to });
			}
		}
		return dist;
	}
	// Bellman-Ford
	pair<vector<int>, bool> BellmanFord(int start) {
		vector<int> dist(g.size(), INF);
		int N = g.size();

		dist[start] = 0;

		bool negative_cycle = false;

		for (int i = 0; i < N; i++) {
			for (int v = 0; v < N; v++) {
				for (Edge e : g[v]) {

					if (dist[v] != INF && dist[e.to] > dist[v] + e.weight) {
						dist[e.to] = dist[v] + e.weight;
						// N回目にも更新があれば負サイクルあり
						if (i == N - 1) {
							dist[e.to] = -INF;
							negative_cycle = true;
						}
					}
				}
			}
		}
		return { dist, negative_cycle };
	}

};


signed main() {

	int N, M, start;
	cin >> N >> M >> start;
	Graph g(N);
	rep(i, M) {
		int s, t, d;
		cin >> s >> t >> d;
		g.add(s, t, d);
	}
	auto result = g.dijkstra(start);

	rep(i, N) {
		if (result[i] == INF) cout << "INF" << endl;
		else cout << result[i] << endl;
	}

	return 0;
}



Measured memory_bytes: 19496
N=gets.to_i
S=[]
N.times{S.push(gets.chomp.to_s)}

h=S.group_by(&:itself).map{|key,value| [key, value.length] }.to_h
maxcount=h.values.max.to_i

puts h.delete_if{|key,value| value.to_i < maxcount}.keys.sort


Measured memory_bytes: 81756
(defun main ()
    (let* ((n (read)) (a (read)) (b (read)))
        (format t "~A~%" 
            (loop for i from 1 to n sum
                (progn
                    (let ((x (reduce #'+
                                (map 'list #'digit-char-p
                                        (write-to-string i)))))
                        (if (and (<= a x) (<= x b)) i
                            0)))))))

(main)

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

namespace contest_Csharp
{
    class Program
    {
        static void Main(string[] args)
        {
            int N, K, C;
            var prop = Console.ReadLine().Split(' ')
                .Select(x => int.Parse(x)).ToList();
            N = prop[0];
            K = prop[1];
            C = prop[2];
            string S = Console.ReadLine();
            List<long> frontwork = new List<long>(), backwork = new List<long>(),
                recastleft = new List<long>(), capacity = new List<long>();
            long f = 0;
            long recast = 0;
            for (int i = 0; i < N; i++)
            {
                frontwork.Add(f);
                recastleft.Add(recast);


                if (S[i] == 'o' && recast == 0)
                {
                    f++;
                    recast = C;
                }
                else
                {
                    recast = Math.Max(recast - 1, 0);

                }
            }
            long b = 0;
            long brecast = 0;
            for (int i = (int)N - 1; i >= 0; i--)
            {
                backwork.Add(b);
                capacity.Add(C - brecast);


                if (S[i] == 'o' && brecast == 0)
                {
                    b++;
                    brecast = C;
                }
                else
                {
                    brecast = Math.Max(brecast - 1, 0);
                }
            }
            backwork.Reverse();
            capacity.Reverse();
            for (int i = 0; i < N; i++)
            {
                if (S[i] == 'o')
                {
                    if (frontwork[i] + backwork[i] < K ||
                        (frontwork[i] + backwork[i] == K && capacity[i] - recastleft[i] > C))
                    {
                        Console.Write((i + 1) + " ");
                    }
                }
            }

        }
    }
}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define Rep(i,n) for(int i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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; }



int main(){
    int n;
    cin >> n;
    V<V<int>> g(n);
    rep(i,n) {
        int a;
        cin >> a;
        a--;
        int k;
        cin >> k;
        rep(j,k) {
            int b;
            cin >> b;
            b--;
            g[a].push_back(b);
        }
    }

    V<int> d(n,-1);
    d[0] = 0;
    queue<int> q;
    q.push(0);
    while(sz(q)) {
        int v = q.front(); q.pop();
        for(int nv : g[v]) {
            if(d[nv] != -1) continue;
            d[nv] = d[v] + 1;
            q.push(nv);
        }
    }

    rep(i,n) {
        printf("%d %d\n", i+1, d[i]);
    }
}


Measured memory_bytes: 3288
// https://atcoder.jp/contests/abc088/tasks/abc088_b
"use strict"
function Main(input) {
  const params = input.split('\n');
  const n = Number(params[0]);
  const a = params[1].split(' ').map(Number);
  const sortA = a.sort((s1, s2) => s2 - s1);
  
  const aliceTotal = sortA.reduce((acc, cur, index) => {
    if (index % 2 === 0) {
      return acc + cur;
    }
    
    return acc;
  }, 0);

  const bobTotal = sortA.reduce((acc, cur, index) => {
    if (index % 2 !== 0) {
      return acc + cur;
    }
    
    return acc;
  }, 0);

  console.log(aliceTotal - bobTotal);

}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

using namespace std;
using P = pair<int, int>;

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

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

signed main(){
    int N, K; cin >> N >> K;
    vector<int> a( N );
    map<int, int> mp;
    REP( i, N ){
        cin >> a[i];
        mp[a[i]]++;
    }

    int t = 0, sum = 0, res = 0;
    for( auto p : mp ){
        if( t == 0 ){
            sum += p.second;
            t++;
            continue;
        }

        res += sum * p.second % MOD;
        sum += p.second;

    }

    int ans = 0;
    ans += ( ( K * ( K - 1 ) / 2 ) % MOD ) * res % MOD;

    int cnt = 0;
    REP( i, N - 1 ){
        FOR( j, i + 1, N ){
            if( a[i] > a[j] ){
                cnt++;
            }
        }
    }
    
    ans += cnt * K % MOD;

    cout << ans % MOD << endl;

}
// 3
// 1 5 3
// 1 5 3 1 5 3 1 5 3
// 5 + 2 + 3 + 1 + 1 = 12
// 1 1 3 3

// 2 1 2 1

Measured memory_bytes: 384
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
  Scanner sc;

  void run() {
    HashMap<Character, Character> map = new HashMap<Character, Character>();
    HashSet<Character> sets = new HashSet<Character>();
    HashSet<Character> sete = new HashSet<Character>();
    map.put( ')', '(' );
    map.put( ']', '[' );
    sets.add( '(' );
    sets.add( '[' );
    sete.add( ')' );
    sete.add( ']' );

    for ( ;; ) {
      char[] str = ns().toCharArray();

      if ( str.length == 1 && str[ 0 ] == '.' ) {
        break;
      }

      LinkedList<Character> list = new LinkedList<Character>();
      list.add( '\0' );

      boolean flag = true;
      for ( char c : str ) {
        if ( sets.contains( c ) ) {
          list.addFirst( c );
        }
        if ( sete.contains( c ) ) {
          char e = list.poll();
          flag &= map.get( c ) == e;
          if ( !flag ) {
            break;
          }
        }
      }
      flag &= list.size() == 1;

      System.out.println( flag ? "yes" : "no" );
    }
  }

  Main() {
    sc = new Scanner( System.in );
  }

  int ni() {
    return sc.nextInt();
  }

  String ns() {
    return sc.nextLine();
  }

  public static void main(String[] args) {
    new Main().run();
  }

  void debug(Object... os) {
    System.err.println( Arrays.deepToString( os ) );
  }
}

Measured memory_bytes: 36724
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(all(x), val), x.end())
typedef long long ll;
typedef pair<int, int> P;
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 MOD = 1000000007;
int INF = 1001001001;

template <typename T>
T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); }
template <typename T>
T lcm(T a, T b) { T g = gcd(a, b); return a * b / g; }

void solve()
{
    ll n, k; cin >> n >> k;
    if(n <= k)
    {
        cout << min(n, k - n) << endl;
        return;
    }
    ll p = n / k;
    cout << min(n - p * k,(p+1)*k - n) << endl;
    return;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


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

using namespace std;

int main() {
  int n = 0;
  cin >> n;
  vector<long long> a(n), b(n);
  for (int i=0; i<n; i++) {
    cin >> a.at(i);
  }
  for (int i=0; i<n; i++) {
    cin >> b.at(i);
  }
  long long sum_a = 0, sum_b = 0;
  for (int i=0; i<n; i++) {
    sum_a += a.at(i);
    sum_b += b.at(i);
  }
  long long diff = sum_a - sum_b;
  if (diff < 0) {
    cout << -1 << endl;
  } else {
    for (int i=0; i<n; i++) {
      a.at(i) -= b.at(i);
    }
    sort(a.begin(), a.end());
    int cnt = 0;
    for (int i=0; i<n; i++) {
      if (a.at(i) < 0) {
        continue;
      } else if (a.at(i) <= diff) {
        cnt++;
        diff -= a.at(i);
      }
    }
    cout << n - cnt << endl;
  }
  return 0;
}


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

typedef long long ll;

using namespace std;

int main(){
  ll N,i,k;
  string S;
  map<string,int> mp;
  cin >> N;
  for(i=0;i<=N-1;i++){
    cin >> S;
    sort(S.begin(),S.end());
    mp[S]++;
    }
  ll ans = 0;
  for(auto &p : mp){
    ll s = p.second;
    ans += s*(s-1)/2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 11136
#include<iostream>
#include<string>
using namespace std;
int main()
{
  int a,b;
  string s,t,u;
  cin >> s >> t;
  cin >> a >> b;
  cin >> u;
  if(u==s)
    cout << a-1 << " " << b << endl;
  else
    cout << a << " " << b-1 << endl;
  return 0;
}

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

int main() {
  int A, B, K;
  scanf("%d %d %d", &A, &B, &K);

  int i;
  for (i=A; i<std::min(B+1, A+K); ++i)
    printf("%d\n", i);

  for (i=std::max({i, A, B-K+1}); i<=B; ++i)
    printf("%d\n", i);
}


Measured memory_bytes: 128
#include <stdio.h>

int main(){
  int H, W;
  char S[60][60] = {};
  int count = 0;

  scanf("%d %d", &H, &W);
  for(int i = 0; i < H; i++){
    scanf("%s", S[i]);
  }

  if(S[0][0] == '.'){
    count = 0;
    for(int k = 0; k <= 1; k++){
      for(int l = 0; l <= 1; l++){
        if(S[k][l] == '#'){
          count++;
        }
      }
    }
    S[0][0] = count + '0';
  }

  if(S[0][W-1] == '.'){
    count = 0;
    for(int k = 0; k <= 1; k++){
      for(int l = -1; l <= 0; l++){
        if(S[k][W-1+l] == '#'){
          count++;
        }
      }
    }
    S[0][W-1] = count + '0';
  }

  if(S[H-1][0] == '.'){
    count = 0;
    for(int k = -1; k <= 0; k++){
      for(int l = 0; l <= 1; l++){
        if(S[H-1+k][l] == '#'){
          count++;
        }
      }
    }
    S[H-1][0] = count + '0';
  }

  if(S[H-1][W-1] == '.'){
    count = 0;
    for(int k = -1; k <= 0; k++){
      for(int l = -1; l <= 0; l++){
        if(S[H-1+k][W-1+l] == '#'){
          count++;
        }
      }
    }
    S[H-1][W-1] = count + '0';
  }

  for(int i = 1; i < H-1; i++){
    if(S[i][0] == '.'){
      count = 0;
      for(int k = -1; k <= 1; k++){
        for(int l = 0; l <= 1; l++){
          if(S[i+k][l] == '#'){
            count++;
          }
        }
      }
      S[i][0] = count + '0';
    }
    if(S[i][W-1] == '.'){
      count = 0;
      for(int k = -1; k <= 1; k++){
        for(int l = -1; l <= 0; l++){
          if(S[i+k][W-1+l] == '#'){
            count++;
          }
        }
      }
      S[i][W-1] = count + '0';
    }
  }

  for(int j = 1; j < W-1; j++){
    if(S[0][j] == '.'){
      count = 0;
      for(int k = 0; k <= 1; k++){
        for(int l = -1; l <= 1; l++){
          if(S[k][j+l] == '#'){
            count++;
          }
        }
      }
      S[0][j] = count + '0';
    }
    if(S[H-1][j] == '.'){
      count = 0;
      for(int k = -1; k <= 0; k++){
        for(int l = -1; l <= 1; l++){
          if(S[H-1+k][j+l] == '#'){
            count++;
          }
        }
      }
      S[H-1][j] = count + '0';
    }
  }

  for(int i = 1; i < H-1; i++){
    for(int j = 1; j < W-1; j++){
      if(S[i][j] == '.'){
        count = 0;
        for(int k = -1; k <= 1; k++){
          for(int l = -1; l <= 1; l++){
            if(S[i+k][j+l] == '#'){
              count++;
            }
          }
        }
        S[i][j] = count + '0';
      }
    }
  }
  for(int i = 0; i < H; i++){
    printf("%s\n", S[i]);
  }
  return 0;
}


Measured memory_bytes: 128
import fractions
a,b,c,d=map(int,input().split())
count=0
def cc(a,b,c):
    if a%c==0:
        k=a
    else:
        k=a+c-(a%c)
    return ((b//c)-(k//c)+1)
print(b-a+1-cc(a,b,c)-cc(a,b,d)+cc(a,b,(c*d)//fractions.gcd(c,d)))

Measured memory_bytes: 5048
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

vector<ll> makeDivisors(ll n) {
    vector<ll> ret;
    for(ll i = 1; i * i <= n; i++) {
        if(n%i == 0) {
            ret.push_back(i);
            if(i*i != n) ret.push_back(n/i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}

int main() {
    int N;
    cin >> N;
    vector<int> A(N+1);
    rep(i, N) cin >> A[i+1];
    vector<int> cnt(N+1, 0);
    vector<int> B(N+1, 0);
    vector<int> ans;
    for (int i = N; i >= 1; i--) {
        if (A[i] ^ cnt[i]) {
            B[i] = 1;
        }
        if (B[i]) {
            ans.push_back(i);
            vector<ll> C = makeDivisors(i);
            for (int c : C) {
                if (c == i) continue;
                cnt[c] ^= 1;
            }
        }
    }
    cout << sz(ans) << '\n';
    show(ans);
    return 0;
}

Measured memory_bytes: 6132
N,M = map(int,input().split())
A = [i for i in map(int,input().split())]
BC = [[i for i in map(int,input().split())] for j in range(M)]

A.sort()
BC.sort(reverse=True, key=lambda x:x[1])

for i in range(N):
  if A[i] < BC[0][1]:
    A[i] = BC[0][1]
    BC[0][0] -= 1
    if BC[0][0] == 0:
      BC.pop(0)
      if BC==[]:
        break
        
print(sum(A))

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

int main() {
    int n;
    double ans=0;
    cin >> n;
    vector<int> vec(n);
    for(int i=0; i<n; i++) cin >> vec.at(i);
    sort(vec.begin(), vec.end());
    ans=vec.at(0);
    for(int i=1; i<n; i++) {
        ans += vec.at(i);
        ans /= 2;
    }
    cout << fixed << setprecision(5);
    cout << ans;
}

Measured memory_bytes: 256
N = int( input() )
s_list = [ int(i) for i in input().split() ]
b = [0] * (10**5)
for i in range( N ):
    b[s_list[i]-1] = i + 1
for i in b:
    if i == 0:
        break
    else:
        print(i,end = " ")

Measured memory_bytes: 13812