akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] array = new int[n];
		int tmp = 0;
		int tmpNum = 0;
		for (int i = 0; i < array.length; i++) {
			array[i] = sc.nextInt();
		}
		Sort st = new Sort();
		st.insertionSort(array);
	}
}

class Sort {
	public void insertionSort(int[] array) {
		int j = 0;
		boolean flag = false;
		for (int k = 0; k < array.length - 1; k++) {
			System.out.print(array[k] + " ");
		}
		System.out.println(array[array.length - 1]);
		for (int i = 1; i < array.length; i++) {
			j = i - 1;
			while (j >= 0 && array[j + 1] < array[j]) {
				swap(array, j + 1, j);
				j--;
			}
			for (int k = 0; k < array.length - 1; k++) {
				System.out.print(array[k] + " ");
			}
			System.out.println(array[array.length - 1]);
		}
	}
	
	public void swap(int[] array, int a, int b) {
		int tmp = 0;
		tmp = array[a];
		array[a] = array[b];
		array[b] = tmp;
	}
}


Measured memory_bytes: 31288
from collections import defaultdict
MOD = 10**9+7
from math import gcd


n = int(input())
ans = 1
C = defaultdict(int)
z = 0
r = 0
for i in range(n):
    a, b = map(int, input().split())
    if a == 0 and b == 0:
        r += 1
    elif b == 0:
        z += 1
    elif a == 0:
        C[0] += 1
    else:
        g = gcd(abs(a), abs(b))
        a //= g
        b //= g
        if a < 0:
            a, b = -a, -b
        C[(a, b)] += 1
D = tuple(C.items())
used = {0}
for c, v in D:
    if c in used:
        continue
    a, b = c
    if b > 0:
        d, e = b, -a
    else:
        d, e = -b, a
    ans *= pow(2, v, MOD)+pow(2, C[(d, e)], MOD)-1
    ans %= MOD
    used.add((d, e))
ans *= pow(2, C[0], MOD)+pow(2, z, MOD)-1
ans += r
ans -= 1
ans %= MOD
print(ans)

Measured memory_bytes: 186748
using System;
using System.Collections.Generic;
using System.Linq;
class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var ab = Console.ReadLine().Split(' ');
            var a = int.Parse(ab[0]);
            var b = int.Parse(ab[1]);
            var pn = Console.ReadLine().Split(' ');
            var p = new List<int>();

            foreach(var v in pn)
            {
                var v2 = int.Parse(v);
                p.Add(v2);
            }
            var count = p.Where(x => x <= a).Count();
            var t = p.Where(x => x > a && x <= b).Count();
            if (count > t) count = t;
            t = p.Where(x => x > b).Count();
            if (count > t) count = t;
            Console.WriteLine(count);
        }
    }

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
 
using namespace std;
using std::cout;
using ll =long long;
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}
ll gcd11(ll x, ll y){
  long long a= max(x,y), b=min(x,y), c=a%b;
  while( c!=0){
    a =b;
    b =c;
    c = a%b;
  }
  return b;
}

int ab(int x, int y){
  if(x>=y){
    return x-y;
  }
  else if(y>x){
    return y-x;
  }
}
int main(){
  vector<int> a(3);
  for(int i=0;i<3;i++){
    cin>>a[i];
  }
  sort(a.begin(), a.end());
  cout<< a[0]+a[1]+10*a[2]<<endl;

}


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

using namespace std;

int main() {

    int N;
    cin >> N;

    int D,X;
    cin >> D >> X;

    int A;
    int sum = X;
    for(int i = 0 ; i < N ; i ++){
        cin >> A;

        for(int ai = 0 ; ai < D ; ai++){
            int _a = ai * A + 1;
            if (_a <= D) sum ++;
        }
    }

    cout << sum << endl;
}


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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;

int main() {
    int n, k;
    cin >> n >> k;
    vector<pair<ll, ll>> v(n);
    int a, b;
    REP(i, n) {
        cin >> a >> b;
        v[i] = make_pair(a, b);
    }

    auto calc = [&](int x) {
        ll r = 0;
        for (auto p : v) if ((p.first | x) == x) r += p.second;
        return r;
    };

    ll ans = calc(k);

    REP1(i, 30) {
        int b = (1 << i);
        if ((k & b) == 0) continue;
        int t = (k - b) | (b - 1);
        chmax(ans, calc(t));
    }

    cout << ans << endl;
}


Measured memory_bytes: 1792
/*	
*  Sachin Mittal
*/
#include<bits/stdc++.h>
#define int long long
#define M 998244353
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define rep(i,j,n) for(int i=j;i<n;i++)
#define F first
#define S second
#define lb lower_bound
#define mem0(dp) memset(dp,0,sizeof(dp))
#define mem1(dp) memset(dp,-1,sizeof(dp))
#define pb push_back
#define sz(s) (int)(s.size())
#define debug(x) cout << #x << " = " << x << '\n';
using namespace std;

void solve()
{
	int s,w;cin>>s>>w;
	if(w>=s)cout<<"unsafe\n";
	else cout<<"safe\n";
}

int32_t main(){

ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int tst=1;
//cin>>tst;
while(tst--)
{
	solve();
}
}

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

using namespace std;


int main()
{
	int n,k;
	cin>>n>>k;
	int sum=0;
	int a=1;
	while(n>0)
	{
		n=n/k;
		sum++;
	}
	cout<<sum;
	return 0;
}

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

using namespace std;

int main() {
	long long int n;
	cin >> n;
	vector<long long int> a(n);
	long long int aa, bb, cc;
	aa = bb = cc = 0;
	long long int p = 0;
	for (long long int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] % 4 == 0) {
			aa++;
		}
		else if (a[i] % 2 == 0) {
			bb++;
		}
		else {
			cc++;
		}
	}
	p = aa;
	if (aa + 1 < cc) {
		cout << "No" << endl;
	}
	else {
		aa -= cc;
		if (aa < 0) {
			if (bb == 0 && p > 0) {
				cout << "Yes" << endl;
			}
			else {
				cout << "No" << endl;
			}
		}
		else {
			cout << "Yes" << endl;
		}
	}
	return 0;
}

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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
template <typename T> using vec = vector<T>;
typedef vec<int> vi;
typedef vec<ll> vl;


template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }

const int MAX_N = 100000;
int n,k;
ll a[MAX_N];

int main()
{
  cin >> n >> k;
  forn(i,n) cin >> a[i];

  ll total = 0;
  for (int i = k; i < n; i++)
    if (a[i] >= 0) total += a[i];

  ll c = accumulate(a,a+k,0LL);

  ll res = c < 0 ? total : total + c;

  for (int i = k; i < n; i++) {
    //cout << res << endl;
    if (a[i-k] >= 0) total += a[i-k];
    if (a[i] >= 0) total -= a[i];
    c -= a[i-k];
    c += a[i];
    ll temp = c < 0 ? total : total + c;
    chmax(res,temp);
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template <size_t I, class H, class... T> struct TupleReaderWriter{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple_cat(tuple<H>(v),TupleReaderWriter<sizeof...(T)-1,T...>::r(i));}static void w(ostream&o,tuple<H,T...>&t,string d){TupleReaderWriter<I-1,H,T...>::w(o,t,d);o<<d<<get<I>(t);}};
template <class H, class... T> struct TupleReaderWriter<0,H,T...>{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple<H>(v);}static void w(ostream&o,tuple<H,T...>&t,string d){o<<get<0>(t);}};
template<class T>istream&operator>>(istream&i,vector<T>&v){for(auto&x:v)i>>x;return i;}
template<class T>ostream&operator<<(ostream&o,vector<T>&v){string delim="";for(auto&x:v)o<<delim<<x,delim=" ";return o;}
template <class... T> istream& operator>>(istream&i,tuple<T...>& t) { t = TupleReaderWriter<sizeof...(T), T...>::r(i); return i; }
template <class... T> ostream& operator<<(ostream& o, tuple<T...>& t) { string delim = " "; TupleReaderWriter<sizeof...(T) - 1, T...>::w(o, t, delim); return o; }
template<typename T> using rev_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using vector2d = vector<vector<T>>;
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }

const int INF = 1e7;

int main() {
    int N, M;
    cin >> N >> M;
    vector2d<int> edge(N);
    for(int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        edge[--a].push_back(--b);
    }
    int k = -1, L = INF;
    for(int k_ = 0; k_ < N; k_++) {
        vector<int> len(N, 0);
        queue<pair<int, int>> q;
        q.push({k_, 0});
        while(!q.empty()) {
            int i, l;
            tie(i, l) = q.front(); q.pop();
            if(len[i]) continue;
            else len[i] = l;
            for(auto j : edge[i]) {
                q.push({j, l + 1});
                if (j == k_) {
                    if (L > l) {
                        L = l;
                        k = k_;
                    }
                    break;
                }
            }
        }
    }
    if(k < 0) {
        cout << -1 << endl;
        return 0;
    }
    vector<int> ans;
    {
        vector<int> chain(N, -1);
        queue<int> q;
        q.push(k);
        while(!q.empty()) {
            int i = q.front(); q.pop();
            for(auto j : edge[i]) {
                if(chain[j] < 0) {
                    chain[j] = i;
                    q.push(j);
                }
                if(j == k) break;
            }
        }
        {
            int i = k;
            do {
                i = chain[i];
                ans.push_back(i);
            } while(i != k);
        }
    }
    cout << ans.size() << endl;
    for(auto x : ans) cout << x + 1 << endl;
    return 0;
}

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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pop pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];

	cin>>n>>m;

	cout<<((n+1)*(m+1))-(n+1+2*(m+1)-2+(n+1)-2)<<endl;



}


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

using namespace std;

typedef long long ll;
const ll inf = 0x3f3f3f3f;
#define case(i) "Case #" << i << ": "
 
template <typename S, typename T>
ostream& operator<<(ostream& out, pair<S, T> const& p) {
    out << '(' << p.first << ", " << p.second << ')';
    return out;
}
template <typename T>
ostream& operator<<(ostream& out, vector<T> const& v) {
    ll l = v.size();
    for (ll i = 0; i < l - 1; i++) out << v[i] << ' ';
    if (l > 0) out << v[l - 1];
    return out;
}

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

    ll a, b;
    cin >> a >> b;
    cout << (a * b) / __gcd(a, b) << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    String S = sc.next();

    for (int i = 0; i < a; i++) {
      if (S.charAt(i) < '0' || S.charAt(i) > '9') {
        System.out.println("No");
        return;
      }
    }
    for (int i = a + 1; i < a + b + 1; i++) {
      if (S.charAt(i) < '0' || S.charAt(i) > '9') {
        System.out.println("No");
        return;
      }
    }
    if(S.charAt(a) != '-'){
      System.out.println("No");
      return;
    }
    System.out.println("Yes");
  }
}

Measured memory_bytes: 22608
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  vector<pair<double,string>>A(N);
  for (int i=0; i<N; i++)cin>>A[i].first>>A[i].second;
  double sum=0;
  for (int i=0; i<N; i++){
    if(A[i].second=="JPY")sum+=A[i].first;
    else sum+=A[i].first*380000;
  }
  cout<<fixed<<setprecision(5)<<sum<<endl;
}


Measured memory_bytes: 3752
#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 = INT32_MAX;
const ll INFL = INT64_MAX;
const int mod = 1e9 + 7;

template <typename T>
void print_vec(vector<T> v) {
  for (T i : v) cout << i << " ";
  cout << endl;
}
struct unionFind {
  vector<int> d;  // 根： 木のサイズ x -1, それ以外： 親のID
  unionFind(int n = 0) : d(n, -1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }

  bool unite(int x, int y) {
    // root化しておく
    x = find(x);
    y = find(y);
    if (x == y) return false;

    // x を y に unite
    // d[x] のほうが多きい（=サイズが小さい）場合はswap
    if (d[x] > d[y]) swap(x, y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return -d[find(x)]; }
} uf;

int main() {
  int n, m;
  cin >> n >> m;
  uf = unionFind(n * 2);
  rep(i, n) uf.unite(i, i + n);
  rep(i, m) {
    int x, y, z;
    cin >> x >> y >> z;
    x--, y--;
    uf.unite(x, y);
  }
  int ans = 0;
  rep(i, n) if (uf.find(i) == i) ans++;
  cout << ans << endl;
  return 0;
}

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

public class MainClass
{
	public const long Giri = 1000000007;

	public static void Main(string[] args)
	{
		var n = Console.ReadLine().ToInt();
		var set = new HashSet<string>();
		char mae = '0';
		for(int i = 0; i < n; i++)
		{
			var str = Console.ReadLine();
			if(mae != '0' && (set.Contains(str) || str[0] != mae))
			{
				Console.WriteLine("No");
				return;
			}
			set.Add(str);
			mae = str[str.Length - 1];
		}
		Console.WriteLine("Yes");
	}

	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}


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

int main()
{
    int a,b,c;
    int n;
    int sum=0;
    cin>>a>>b>>c>>n;
    int s=max(max(a,b),c);
    if(a==s){
        sum+=b+c;
        for(int i=0;i<n;i++) {
            a=a*2;
        }
        sum+=a;
    }
    else if(b==s){
        sum+=a+c;
        for(int i=0;i<n;i++) {
            b=b*2;
        }
        sum+=b;
    }
    else if(c==s){
        sum+=b+a;
        for(int i=0;i<n;i++) {
            c=c*2;
        }
        sum+=c;
    }
    cout<<sum;
    return 0;
}


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

int main()
{
	int a,b;

	int sum;

	while(std::cin >> a >> b)
	{
		sum=a+b;

		for(int i=1;;++i)
		{
			if(sum/(int)pow(10.0,i)==0)
			{
				std::cout << i << '\n';
				break;
			}
		}
	}
}

Measured memory_bytes: 1204
local n = io.read("*n")
local t = {}
for i = 1, n do
  local a = io.read("*n")
  if(t[a] ~= nil) then t[a] = nil else t[a] = true end
end
local cnt = 0
for k, v in pairs(t) do cnt = cnt + 1 end
print(cnt)


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

int main() {
  int n, a = -1;
  cin >> n;
  for(int i = 1; i <= n; ++i){
    if(int(i * 1.08) == n){
      a = i;
      break;
    }
  }
  if(a == -1) cout << ":(" << endl;
  else cout << a << endl;
}

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

class P
{
    static void Main()
    {
        int[] HW = Console.ReadLine().Split().Select(int.Parse).ToArray();
        string res = "";
        for (int i = 0; i < HW[0]; i++)
        {
            string[] s = Console.ReadLine().Split();
            for (int j = 0; j < HW[1]; j++)
            {
                if (s[j] == "snuke")
                {
                    res = $"{char.ConvertFromUtf32('A' + j)}{i + 1}";
                }
            }
        }
        Console.WriteLine(res);
    }
}

Measured memory_bytes: 13396
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

fn main(){
    let line = read_as_vec::<i32>();
    let (_, _, x_pos, y_pos) = (line[0], line[1], line[2], line[3]);

    let mut x = read_as_vec::<i32>();
    let mut y = read_as_vec::<i32>();

    x.sort();
    y.sort();

    if *y.first().unwrap() - *x.last().unwrap() > 0 &&
        x_pos < *y.first().unwrap() &&
        *x.last().unwrap() < y_pos{
        println!("No War");
    }else{
        println!("War");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    ll a, b, c;
    cin >> a >> b >> c;
    ll x = c-a-b;
    if(x < 0) cout << "No" << endl;
    elif(x*x > 4*a*b) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N, T[5]; cin >> N;
    rep(i, 5) cin >> T[i];
    sort(T, T+5);
    ll num_send = (N + (T[0]-1)) / T[0];
    cout << num_send + 4 << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
using namespace std;
#define LOCAL  1
#define UPLOAD 2
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
template <class T = long long> T input(){T x;cin >> x;return x;}
template <class T> void output(T x){cout << x << endl;}
#define debug(x) cerr << #x<< ": " << x<< '\n';

#define ll long long

int main()
{
#if ENVIRONMENT == LOCAL
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
  ll N = input();

  vector<ll> H;
  for(int i=0;i<N;i++){
    ll h = input();
    H.push_back(h);
  }
  //次のマスが低ければ、自身を低くする
  for(int i=N-1;i>0;i--){
    if(H[i-1] > H[i]){
      H[i-1]--;
    }
    if(H[i-1] > H[i]){
      output("No");
      return 0;
    }
  }


  output("Yes");

  return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> pii;
typedef pair<ll,ll> pll;
 
 
/*bool compare_function(const pair<int, int> a, const pair<int, int> b)
{
    return a.first < b.first;
}*/
// use case
//sort(V.begin(), V.end(), compare_function);
 
/*struct compare
{
    bool operator ()(const pair<int, int> &a, const pair<int, int> &b) {
    if (a.second-a.first==b.second-b.first)
    {
        return a.first>b.first;
    }
    return a.second-a.first < b.second-b.first;}
};
priority_queue <pair<int,int>, vector <pair<int,int>>, compare> Q;*/
 
/*void print1(vector <int> X)
{
    for (int i=0; i<X.size(); i++)
    {
        cout<<X[i]<<" ";
    }
    cout<<endl;
    return;
}
 
void print2(vector <vector <int>> X)
{
    for (int i=0; i<X.size(); i++)
    {
    for (int j=0;j<X[i].size();j++) {
        cout<<X[i][j]<<" ";}
    cout<<endl;}
    return;
}*/

 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    vector <int> A(n,0);
    int a=0;
    for (int i=0;i<n;i++) {cin>>A[i];a=a^A[i];}
	for (int i=0;i<n;i++) 
	{int x=a^A[i]; 
	cout<<x<<" ";}
	cout<<endl;
    return 0;
}


Measured memory_bytes: 3972
import sys

S = input()

K = int(input())

now = 1
ans = 0

same = False
dic = {}
for i in S:
    if i not in dic:
        dic[i] = 1

if len(dic) == 1:
    print (len(S) * K // 2)
    sys.exit()

for i in range(len(S)-1):

    if S[i+1] == S[i]:
        now += 1

    else:

        ans += now // 2
        now = 1

ans += now // 2



S2 = S + S

now = 1
ans2 = 0
for i in range(len(S2)-1):

    if S2[i+1] == S2[i]:
        now += 1

    else:

        ans2 += now // 2
        now = 1



ans2 += now // 2
sub = ans2 - ans

#print (ans,ans2)


print (ans + sub * (K-1))


Measured memory_bytes: 38376
'''     ##     ##  #######  # #  ######
        ##     ##  ##   ##  ###    ##
        ##     ##  ##    #  # #    ##
        #########  #######  # #    ##    '''

import sys
import math
# sys.setrecursionlimit(10**6)

def get_ints(): return map(int, input().strip().split())
def get_list(): return list(get_ints())

def printspx(*args): return print(*args, end="")
def printsp(*args): return print(*args, end=" ")
def printchk(*args): return print(*args, end=" \ ")

MODPRIME = int(1e9+7); BABYMODPR = 998244353;

ONLINE_JUDGE = 1
if not ONLINE_JUDGE:
    sys.stdin = open("input.txt","r")  # <<<  Comment this line  >>> #
    sys.stdout = open("output.txt","w")  # <<<  Comment this line  >>> #
    sys.stderr = open("output.txt","w")  # <<<  Comment this line  >>> #

# for _testcases_ in range(int(input())):
x, y = get_ints()
flag = True
b = (y-2*x)/2
if math.floor(b) != b or b < 0:
    flag = False
if flag:
    a = x-b
    if a < 0 :
        flag = False
if flag:
    print("Yes")
else:
    print("No")

'''
>>> COMMENT THE STDIN!! CHANGE ONLINE JUDGE !!
THE LOGIC AND APPROACH IS BY ME @luctivud ( UDIT GUPTA )
SOME PARTS OF THE CODE HAS BEEN TAKEN FROM WEBSITES LIKE::
(I Own the code if no link is provided here or I may have missed mentioning it)
DO NOT PLAGIARISE.
TESTCASES:
>>> COMMENT THE STDIN!! CHANGE ONLINE JUDGE !!
'''

Measured memory_bytes: 62288
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        //MyDebugger.MakeTestCase("../TextFile2.txt"); return;
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static int h;
    static int w;
    static char[][] ss;

    static object process(TextReader input) {
        var spl   = input.ReadLine().Split(' ');
        h     = int.Parse(spl[0]);
        w     = int.Parse(spl[1]);

        ss = new char[h][];

        for(int i=0; i<h; i++) {
            ss[i] = new char[w];
            var s = input.ReadLine();
            for(int j=0; j<w; j++) {
                ss[i][j] = s[j];
            }
        }

        int max = 0;
        for(int sh=0; sh<h; sh++) {
            for(int sw=0; sw<w; sw++) {
                max = Math.Max(calc(sh, sw), max);
            }
        }

        return max;
    }

    static bool isWall(int i, int j) {
        if (i < 0 || i >= h || j < 0 || j >= w) return true;
        if (ss[i][j] == '#') return true;
        return false;
    }

    static int calc(int sh, int sw) {
        var tbl = new int[h][];
        for (int ii = 0; ii < h; ii++) {
            tbl[ii] = new int[w];
            for(int jj = 0; jj < w; jj++) {
                tbl[ii][jj] = int.MaxValue;
            }
        }

        sett(sh, sw, 0, tbl);

        int max = 0;
        for(int i=0; i<h; i++) {
            for(int j=0; j<w; j++) {
                if(tbl[i][j] != int.MaxValue) {
                    max = Math.Max(tbl[i][j], max);
                }
            }
        }
        return max;
    }

    static void sett(int i, int j, int value, int[][] tbl) {
        if (i < 0 || i >= h || j < 0 || j >= w) return;
        if (ss[i][j] == '#') return;

        if(value < tbl[i][j]) {
            tbl[i][j] = value;
            sett(i - 1, j, value + 1, tbl);
            sett(i + 1, j, value + 1, tbl);
            sett(i, j - 1, value + 1, tbl);
            sett(i, j + 1, value + 1, tbl);
        }
    }
}


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

const long long INF = 1LL << 60;
int MOD = 1000000007;
double PI = 3.14159265358979323846;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define For(i,s,n) for (int i=s;i<(int)(n);i++)
#define vi vector<int>
#define vii vector< vector<int> >
#define vs vector<string>
#define All(c) (c).begin(), (c).end()
#define Print(x) cout<<(x)<<"\n"

string S;

int main() {
	cin >> S;
	int N = S.size();
	if (N == 2) cout << S << endl;
	else cout << S[2] << S[1] << S[0] << endl;
}


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

int main(){
    int r, c, t;
    cin >> r >> c;
    int ans[r + 1][c + 1];
    for(int i = 0; i <= r; i++) for(int j = 0; j <= c; j++) ans[i][j] = 0;
    for(int i = 0; i < r; i++){
        for(int j = 0; j < c; j++){
            cin >> t;
            ans[i][j] = t;
            ans[i][c] += t;
            ans[r][j] += t;
            ans[r][c] += t;
        }
    }
    for(int i = 0; i <= r; i++){
        for(int j = 0; j <= c; j++){
            cout << ans[i][j];
            if(j < c) cout << " ";
            else cout << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3068
//by xxj
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#define fi first
#define se second
#define ll long long 
#define mpa make_pair
#define pb push_back
#define pii pair<int,int>
using namespace std;
const int inf=1e9+7;
const ll linf=1e18+7;
const ll hh=523;
const int mod=998244353;
int p[17],c[17];
int main(){
	int D,G;
	scanf("%d%d",&D,&G);
	G/=100;
	for (int i=0;i<D;i++){
		scanf("%d%d",p+i,c+i);
		c[i]/=100;
	} 
	int ans=inf;
	for (int i=0;i<(1<<D);i++){
		int nw=0,res=0;
		for (int j=0;j<D;j++){
			if (i&(1<<j)){
				nw+=p[j]*(j+1)+c[j];
				res+=p[j];
			}
		}
		//cout<<i<<' '<<nw<<endl;
		for (int j=D-1;j>=0;j--){
			if (!(i&(1<<j))){
				//cout<<j<<endl;
				for (int k=0;k<p[j] && nw<G;k++){
					nw+=j+1;
					res+=1;
				}
				break;
			}
		}
		if (nw>=G){
			ans=min(ans,res);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 4e5 + 10;
int a[N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, k;
	cin >> n >> k;
	for (int i = 1; i <= n; i++) cin >> a[i];
	int ans = 0;
	for (int i = 0; i <= n && i <= k; i++)
	{
		for (int j = 0; i + j <= min(n, k); j++)
		{
			vector<int> v;
			for (int o = 1; o <= i; o++) v.push_back(a[o]);
			for (int o = 1; o <= j; o++) v.push_back(a[n - o + 1]);
			sort(v.rbegin(), v.rend());
			int rest = k - i - j;
			while (rest && !v.empty() && v.back() < 0)
				v.pop_back(), rest--;
			int sum = 0;
			for (auto& x : v) sum += x;
			ans = max(ans, sum);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int compare_char_ao(const void *a, const void *b){
  return *(char *)a - *(char *)b;
}

int compare_char_do(const void *a, const void *b){
  return *(char *)b - *(char *)a;
}

int main(){
  char s[110] = {};
  char t[110] = {};

  scanf("%s %s", s, t);
  int ls = strlen(s), lt = strlen(t);

  qsort(s, ls, sizeof(char), compare_char_ao);
  qsort(t, lt, sizeof(char), compare_char_do);

  if(s[0] < t[0]){
    printf("Yes\n");
  }else if(ls < lt && s[ls-1] == s[0] && s[0] == t[0] && t[0] == t[ls-1]){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
const int INF = 1000000007;

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

int main(){
    int N;
    cin >> N;
    vector<int> march(5, 0);
    rep(i, N){
        string s;
        cin >> s;
        if(s[0] == 'M') march[0]++;
        else if(s[0] == 'A') march[1]++;
        else if(s[0] == 'R') march[2]++;
        else if(s[0] == 'C') march[3]++;
        else if(s[0] == 'H') march[4]++;
    }

    ll ans = 0;
    rep(i, 5){
        rep(j, 5){
            if(i == j) continue;
            ll tmp = 1;
            rep(k, 5){
                if(k != i && k != j) tmp *= march[k];
            }
            ans += tmp;
        }
    }

    cout << ans / 2  << endl;

}

Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStreamReader
import kotlin.math.max
import kotlin.math.min

fun main() {
    val jin = BufferedReader(InputStreamReader(System.`in`))
    val (n, k) = jin.readLine().split(" ").map { it.toInt() }
    var bulbs = jin.readLine().split(" ").map { it.toInt() }.toIntArray()
    for (j in 1..k) {
        var newBulbs = IntArray(n + 1)
        for (b in 0 until n) {
            newBulbs[max(0, b - bulbs[b])]++
            newBulbs[min(n, b + bulbs[b] + 1)]--
        }
        var changed = false
        for (b in 1 until n) {
            newBulbs[b] += newBulbs[b - 1]
            if (newBulbs[b] != bulbs[b]) {
                changed = true
            }
        }
        if (!changed) {
            break
        }
        bulbs = newBulbs
    }
    println(bulbs.toList().subList(0, n).joinToString(" "))
}

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

int main(){
    int N, Y;
    cin >> N >> Y;
    int itiman = -1, gosen = -1, sen = -1;
    for(int x = 0;x <= N; x++){
        for(int y = 0;y <= N-x; y++){
            // int c = N-x-y;
            // int total = 10000*x + 5000*y + c*1000;
            if(Y == 10000*x + 5000*y + (N-x-y)*1000){
                itiman = x;
                gosen = y;
                sen = N-x-y;
                x = 3000;
                y = 3000;
            }
        }
    }
    cout << itiman << " " << gosen << " " << sen << endl; 
}

Measured memory_bytes: 256
//初見でわからなかった

#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  char a, b, c;
  cin >> a >> b >> c;

  if (a != b && b != c && c != a) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define maxn 2333
using namespace std;
char s[maxn], t[maxn];
int main() {
	int n, m;
	scanf("%s", s);
	scanf("%s", t);
	n = strlen(s), m = strlen(t);
	int Ans = 233333;
	for(int i = 0; i <= n - m; ++i) {
		int ans = 0;
		for(int j = 0; j < m; ++j) {
			if(s[i + j] != t[j]) ++ans;
		}
		Ans = min(Ans, ans);
	}
	printf("%d", Ans);
	return 0;
}

Measured memory_bytes: 3824
t = [2,5,22,22,14,17,3,21,25,2,23,4,22,2,6,9,14,7,13,17,23,7,26,16,15,24,24,3,21,16,10,23,22,9,3,14,13,6,21,21,4,19,24,23,19,11,12,11,1,19,14,7,26,1,8,7,17,25,3,25,7,17,5,20,6,20,23,26,1,26,13,10,16,12,4,14,13,12,11,22,7,19,10,26,24,1,13,15,3,16,20,7,6,25,11,3,10,7,17,8,10,24,25,4,23,14,25,20,7,24,22,16,14,19,3,3,25,4,24,17,23,13,26,5,4,24,5,3,26,24,22,23,19,17,7,14,25,12,11,17,20,13,4,7,9,18,16,20,21,8,8,9,17,1,24,17,25,16,14,16,3,17,20,18,1,10,20,9,19,17,23,3,7,22,16,22,18,5,24,20,6,7,17,9,5,3,3,26,12,7,1,11,20,1,25,3,2,17,22,25,12,8,3,25,15,3,18,4,22,3,15,20,10,23,5,9,21,17,20,18,16,2,13,5,25,1,5,16,24,10,6,21,20,18,8,5,5,8,23,20,25,19,25,17,11,4,13,23,12,22,26,22,18,21,4,11,5,14,5,25,3,12,6,12,15,26,5,18,24,7,21,19,23,2,12,3,15,25,26,21,2,25,20,24,9,4,16,6,26,1,17,18,14,16,24,18,23,17,25,2,22,13,12,3,14,6,15,11,23,21,20,17,2,21,24,17,22,12,8,13,25,6,7,5,11,3,4,1,13,6,14,15,6,26,6,26,7,26,13,14,26,26,19,10,24,11,18,26,8,8,2,18,8,5,26,1,24,25,7,7,21,23,5,18,3]
for i in range(365):
  print(t[i])

Measured memory_bytes: 9264
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch StringFormation | diff StringFormation.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address StringFormation.cpp && ./a.out

/*
 
 3/8/2020
 
 20:51-
 
 */

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  string S; int N;
  cin>>S>>N;
  deque<char> Q(ALL(S));
  bool rev=0;
  REP(i,N) {
    int t; cin>>t;
    if(t==1) {
      rev^=1;
    } else {
      int f; char c; cin>>f>>c;
      if(f==1) {
        if(rev) Q.push_back(c);
        else Q.push_front(c);
      } else {
        if(rev) Q.push_front(c);
        else Q.push_back(c);
      }
    }
  }
  string res(ALL(Q));
  if(rev) reverse(ALL(res));
  cout<<res<<endl;
  
  return 0;
}


Measured memory_bytes: 1232
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
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 argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  ll n;
  cin >> n;
  // ll n, m;
  // cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  int a[n], b[n], d[n];
  fi(0, n)
    cin >> a[i];
  fi(0, n)
    cin >> b[i];
  ll diff_sum = 0;
  fi(0, n) {
    d[i] = a[i] - b[i];
    diff_sum += d[i];
  }
  if(diff_sum < 0) {
    cout << "-1\n";
    return 0;
  }
  sort(d, d + n);
  int e[n];
  memcpy(e, d, sizeof(d));
  int i = 0, j = n - 1;
  while(d[i] < 0) {
    if(abs(d[i]) == abs(d[j])) {
      i++, j--;
    }
    else if(abs(d[i]) > abs(d[j])) {
      d[i] += d[j--];
    }
    else {
      d[j] += d[i++];
    }
  }
  ans = i + n - 1 - j;
  if(d[j] != e[j])
    ans++;


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



Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
 
int main(void)
{
    int X,N,a=0;
    cin >> X;
    if(X <=3)
        cout << 1 << endl;
    else{
        for(int i = 2;i < X;i++){
                N=i;
            for(int j = 0;;j++){
                N *= i;
                if(N > X){
                    if(j >= 1){
                         if(a < N/i){
                            a = N/i;
                        }
                    }
                    break;
                }
            }
        }
        cout << a << endl;
    }                                                                        
}

Measured memory_bytes: 256
#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=0;i<n;i++)
#define INF INT_MAX/3
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define debug(x) cout<<#x<<":"<<x<<endl
#define debug2(x,y) cout<<#x<<","<<#y":"<<x<<","<<y<<endl
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& vec){
    os << "[";
    for(const auto& v : vec){
        os << v << ",";
    }
    os << "]";
    return os;
}

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

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

    int N,K;
    cin >> N >> K;
    vector<vector<int>> G(N);
    vector<int> A(N-1),B(N-1);
    rep(i,N-1){
        int a,b;cin>>a>>b;
        a--;
        b--;
        A[i]=a;
        B[i]=b;
        G[a].PB(b);
        G[b].PB(a);
    }

    if(K%2==0){
        int ans = INF;
        rep(i,N){
            queue<int> que;
            vector<int> d(N,INF);
            d[i]=0;
            que.push(i);
            int tt=0;
            while(!que.empty()){
                tt++;
                if(tt>4000) assert(false);
                int q = que.front();
                que.pop();
                assert(d[q]!=INF);
                rep(j,G[q].size()){
                    int nx = G[q][j];
                    if(d[nx]!=INF) continue;
                    d[nx] = d[q]+1;
                    que.push(nx);
                }
            }
            int cnt=0;
            rep(j,N) if(d[j]>K/2) cnt++;
            //cerr << i << endl;
            //cerr << d << endl;
            ans = min(ans,cnt);
        }
        cout << ans << endl;
    }else{
        int ans=INF;
        rep(i,N-1){
            int s=A[i],t=B[i];
            vector<int> ds(N,INF);
            queue<int> que;
            que.push(s);
            ds[s]=0;
            int tt=0;
            while(!que.empty()){
                tt++;
                if(tt>4000) assert(false);
                int q = que.front();
                que.pop();
                rep(j,G[q].size()){
                    int nx = G[q][j];
                    if(ds[nx]!=INF) continue;
                    ds[nx]=ds[q]+1;
                    que.push(nx);
                }
            }

            vector<int> dt(N,INF);
            dt[t]=0;
            que.push(t);
            tt=0;
            while(!que.empty()){
                tt++;
                if(tt>4000) assert(false);
                int q = que.front();
                que.pop();
                rep(j,G[q].size()){
                    int nx=G[q][j];
                    if(dt[nx]!=INF) continue;
                    dt[nx]=dt[q]+1;
                    que.push(nx);
                }
            }
            int cnt=0;
            rep(j,N){
                int d=min(ds[j],dt[j]);
                if(d>(K-1)/2) cnt++;
            }
            ans = min(ans,cnt);
        }
        cout << ans << endl;
    }
}


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

namespace AGC019
{
    public class B
    {
        private void Run()
        {
            var A = Console.ReadLine().Trim();
            long N = A.Length;
            long result = 1 + (((N - 1) * N) / 2);

            var counts = new long[26];
            foreach (var a in A)
            {
                counts[a - 'a']++;
            }

            foreach (var c in counts)
            {
                result -= ((c - 1) * c) / 2;
            }
            Console.WriteLine(result);
        }

        public static void Main()
        {
            var old = Console.Out;
            using (var writer = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false })
            {
                Console.SetOut(writer);
                new B().Run();
                Console.Out.Flush();
                Console.SetOut(old);
            }
        }
    }
}


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

const string YES = "YES";
const string NO = "NO";

void solve(string r, string g, string b)
{
    string sum_str;
    sum_str = r + g + b;
    long long sum;
    sum = stol(sum_str);
    if (sum % 4 == 0)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    string r;
    string g;
    string b;
    cin >> r >> g >> b;
    solve(r, g, b);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n, esc, count=0;
    bool flag;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    
    flag = 1;
    while(flag){
        flag = 0;
        for(int j=n-1;j>0;j--){
            if(a[j]<a[j-1]){
                esc = a[j];
                a[j] = a[j-1];
                a[j-1] = esc;
                count++;
                flag = 1;
            }
        }
    }
    
    for(int i=0;i<n;i++){
        cout << a[i];
        if(i!=n-1){
            cout << " ";
        }
    }
    cout << endl << count << endl;
    
    return 0;
}


Measured memory_bytes: 3108
#include<stdio.h>
int main(void){
    int i,j,W,H,x;
    while(1){
    scanf("%d %d",&H,&W);
    if(W == 0 && H == 0) break;
    for(i = 0;i < H;i++){
        x = i;
        for(j = 0;j < W;j++){
            
        if(x % 2 == 0){
            printf("#");
        }    
        else {
            printf(".");
        }
        x++;
        }
        printf("\n");
    }
    printf("\n");
    }
}


Measured memory_bytes: 2080