akhauriyash/Code-Regression huggingface dataset:
#define ENABLE_DEBUG 1
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
#define LOOP(k) for(i64 ngtkana_is_a_genius=0; ngtkana_is_a_genius<(i64)k; ngtkana_is_a_genius++)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T, class U> using pair = std::pair<U, T>;
template <class T> using diag_pair = std::pair<T, T>;
template <class... Args> using tuple = std::tuple<Args...>;
template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/

int main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15) << std::fixed;

    std::string s;
    std::cin >> s;
    for (usize i=0; i<s.length(); i++) if (i%2==0) {
        std::cout << s.at(i);
    }
    std::cout << '\n';
}


Measured memory_bytes: 592
package main

import (
	"fmt"
)

const mod = 1000000007

func main() {
	var l string
	fmt.Scan(&l)

	dp := make([][]int,len(l)+1)
	for i := 0; i < len(l)+1; i++ {
		dp[i] = append(dp[i],make([]int,2)...)
	}

	dp[0][0] = 1
	for i, e := range l {
		if string(e) == "1" {
			dp[i+1][1] = (dp[i][0]+dp[i][1]*3%mod)%mod
			dp[i+1][0] = dp[i][0]*2%mod
		} else {
			dp[i+1][1] = dp[i][1]*3%mod
			dp[i+1][0] = dp[i][0]
		}
	}

	fmt.Println((dp[len(l)][0]+dp[len(l)][1])%mod)

}


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

int main() {
	int n; cin >> n;
	vector<int> a(n), b(n);
	long long suma = 0, sumb = 0;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		suma += a[i];
	}
	for(int i = 0; i < n; i++) {
		cin >> b[i];
		sumb += b[i];
	}

	long long addone = 0, addtwo = 0;
	for (int i = 0; i < n; i++)
	{
		if(a[i] >= b[i]) addone += a[i] - b[i];
		else addtwo += (b[i] - a[i] + 1) / 2;
	}

	if(addone <= sumb - suma && addtwo <= sumb - suma) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}



Measured memory_bytes: 3688
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;



 class Main{
     
    
    
     public static void main(String args[]){
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
         try{
         //int n=1;
         //for(int i=0; i<n;i++){
         String line;
         while((line=br.readLine())!=null){
            double wei=Double.parseDouble(line);
             
            if(wei<=48.00)System.out.println("light fly");
            else if(wei<=51.00)System.out.println("fly");
            else if(wei<=54.00)System.out.println("bantam");
            else if(wei<=57.00)System.out.println("feather");
            else if(wei<=60.00)System.out.println("light");
            else if(wei<=64.00)System.out.println("light welter");
            else if(wei<=69.00)System.out.println("welter");
            else if(wei<=75.00)System.out.println("light middle");
            else if(wei<=81.00)System.out.println("middle");
            else if(wei<=91.00)System.out.println("light heavy");
            else System.out.println("heavy");
         }
         }catch(Exception e){}
         
     }
     
 }

Measured memory_bytes: 16908
// WARNING: Add compile option "-std=c++11" for C++11 compile.

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;


/*--- Macro ---*/
#define rep(i, a, b) for(int i=(int)a; i<(int)b; i++)
#define erep(i, a, b) for(int i=(int)a; i<=(int)b; i++)
#define mp make_pair
#define pb push_back


/*---  Type ---*/
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;


/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// 4-direction
int dy4[] = {0,  1, -1,  0};
int dx4[] = {1,  0,  0, -1};

// 8-direction
int dy8[] = {0,  1,  1,  1,  0, -1, -1, -1};
int dx8[] = {1,  1,  0, -1, -1, -1,  0,  1};

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

int main() {
  int n;
  cin >> n;
  cout << (n-2) * 180 << endl;
  return 0;
}

Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_f)
ave = a.inject(:+) / n
x = ave.ceil
y = ave.to_i
sum1 = a.map{|b|(b.to_i - x) ** 2}.inject(:+)
sum2 = a.map{|b|(b.to_i - y) ** 2}.inject(:+)
p [sum1, sum2].min

Measured memory_bytes: 1788
program main
  implicit none
  integer :: n, k, m, p, i, j, j2, j3, a, b, c(1000)
  integer, allocatable :: dp(:)
  read *, n, m
  k = 2 ** n
  allocate (dp(0:k - 1))
  dp = 10 ** 9
  dp(0) = 0

  do i = 1, m
    read *, a, b
    read *, c(1:b)
    j3 = 0
    do p = 1, b
      j3 = ibset(j3, c(p) - 1)
    end do
    do j = k - 1, 0, -1  ! 配る
      j2 = ior(j, j3)
      dp(j2) = min(dp(j2), dp(j) + a)
    end do
  end do
  if (dp(k - 1) == 10 ** 9) dp(k - 1) = -1
  print "(i0)", dp(k - 1)
end program main


Measured memory_bytes: 384
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n; cin >> n;
    int m = 5;
    vll a(m); for(auto& e : a) cin >> e;

    ll mincap = *min_element(_all(a));
    ll res = 4 + (n + mincap - 1) / mincap;

    cout << res << endl;

    return 0;
}


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

typedef long long ll;

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

    string S;

    cin >> S;

    if(S.length() % 2 == 1) {
        cout << "No" << endl;
        return 0;
    }

    for(int i = 0; i < S.length() - 1; i += 2) {
        if(S[i] != 'h' || S[i + 1] != 'i') {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  
  double W,H,x,y;
  cin >> W>>H>>x>>y;
  bool flg=0;
  if(W/2==x && H/2==y) flg=1;
  
  if(flg) cout << W*H/2 << " " << 1 << endl;
  else cout << W*H/2 << " " << 0 << endl;
}

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

int main() {
  int ans=0;
  //int a,b,c;
  string s;
  cin>>s;
  
  if(s.at(1)=='S'){
    for(int i=0;i<3;i++){
  	if(s.at(i)=='R')ans=1;
    }
  }
  else{
  	for(int i=0;i<3;i++){
  	if(s.at(i)=='R')ans++;
    }
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 3620
a = list(map(int, input().split()))
a.sort()
c_b_diff = a[2] - a[1]
c_a_diff = a[2] - (a[0] + c_b_diff)
if c_a_diff % 2 == 1:
    print(c_b_diff + c_a_diff // 2 + 2)
elif c_a_diff == 0:
    print(c_b_diff)
else:
    print(c_b_diff + c_a_diff // 2)

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

using namespace std;

int main() {
    int phi;
    cin >> phi;
    for (int i = 1; i <= 360; ++i)  {
        if ((i * phi) % 360 == 0) {
            cout << i << "\n";
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3640
K, N = [int(i) for i in input().split()]
AList = sorted([int(i) for i in input().split()])

ans = float("inf")
for i in range(N):
    if i == 0:
        ans = min(ans, K - abs(K + AList[i] - AList[N-1]),
                  K - abs(AList[i] - AList[i + 1]))
    elif i == N - 1:
        ans = min(ans, K - abs(AList[i] - AList[i - 1]),
                  AList[0] + AList[i])
    else:
        ans = min(ans, K - abs(AList[i] - AList[i - 1]),
                  K - abs(AList[i] - AList[i + 1]))

print(ans)


Measured memory_bytes: 26444
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

using Weight = int;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int s = 0, int d = 0, Weight w = 0)
    : src(s), dst(d), weight(w) {
  }
};

using Edges  = vector<Edge>;
using Graph  = vector<Edges>;
using Array  = vector<Weight>;
using Matrix = vector<Array>;

void addArc(Graph &g, const int &a, const int &b, const Weight &w = 1) {
  g[a].emplace_back(a, b, w);
}

void addEdge(Graph &g, const int &a, const int &b, const Weight &w = 1) {
  addArc(g, a, b, w);
  addArc(g, b, a, w);
}

Matrix warshallFloyd(const Graph &g) {
  int n = g.size();
  Matrix d(n, Array(n, INF));
  rep(i, n) d[i][i] = 0;
  rep(i, n) for (auto &e : g[i]) cmin(d[e.src][e.dst], e.weight);
  rep(k, n) rep(i, n) rep(j, n) {
    if (d[i][k] != INF && d[k][j] != INF) cmin(d[i][j], d[i][k] + d[k][j]);
  }
  return d;
}

void solve() {
  int n, m;
  cin >> n >> m;
  Graph g(n);
  Edges es(m);
  rep(i, m) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    es[i] = Edge(a, b, c);
    addEdge(g, a, b, c);
  }
  Matrix t = warshallFloyd(g);
  int c    = 0;
  for (Edge &e : es) {
    rep(i, n) if (t[i][e.src] + e.weight == t[i][e.dst]) goto next;
    c++;
  next:;
  }
  cout << c << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
using namespace std;
 
int n;
int d[200000];
int m;
int t[200000];
 
map<int, int> a;
map<int, int> b;
 
signed main()
{
	int i;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> d[i];
		if (a.find(d[i]) == a.end()) a[d[i]] = 0;
		a[d[i]]++;
	}
	cin >> m;
	for (i = 0; i < m; i++) {
		cin >> t[i];
		if (b.find(t[i]) == b.end()) b[t[i]] = 0;
		b[t[i]]++;
	}
 
	for (map<int, int>::iterator it = b.begin(); it != b.end(); it++) {
		int key = it->first;
		int val = it->second;
		if (a.find(key) == a.end() || a[key] < val) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 20608
#include <bits/stdc++.h>
using namespace std;
#define pr(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define all(v) (v).begin(), (v).end()
#define int long long
#define sz(v) (int)(v).size()
#define mod 1000000007 // ((a- b)% mod+ mod)% mod

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int dp[22][1<< 21];

void solve() {
        int n; cin >> n;
        vector<vector<int>> v(n);

        for (auto& i: v) {
                vector<int> vv(n);
                for (auto& x: vv) cin >> x;
                i= vv;
        }

        int val= (1<< n)- 1;
        memset(dp, -1, sizeof(dp));

        auto setbit= [=](int idx, int &msk) {
                msk= (msk| 1<< idx);
        };

        auto clearbit= [=](int idx, int &msk) {
                msk= msk & ~(1 << idx);
        };

        function<int(int, int)> calc= [&](int idx, int msk)->int{
                if (idx== n) {
                        if (msk!= val) return 0;
                        else return 1;
                }

                int &ret= dp[idx][msk];
                if (ret!= -1) return ret;
                ret= 0;

                for (int j= 0; j< n; j++) {
                        if (v[idx][j]&& ((msk&(1<< j))== 0)) {
                                setbit(j, msk);
                                ret= (ret+ calc(idx+ 1, msk))% mod;
                                clearbit(j, msk);
                        }
                }

                return ret% mod;
        };
        cout << calc(0, 0)% mod;
}

int32_t main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        int T= 1;
        //cin >> T;
        while ( T-- ) {
                solve();
        }
return 0;
}


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

using namespace std;

int main() {
	vector<int> p;

	for (int i = 0; i < 3; i++) {
		int n;
		cin >> n;
		p.push_back(n);
	}
	sort(p.begin(), p.end());
	cout << p[0] + p[1] << endl;

	return 0;
}

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

using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define repr(i, a, n) for (int i = (n); i >= (a); --i)

template<typename T,typename U>
void Inparray(T &f,U n){
  for(int i=0;i<n;i++) cin>>f[i];
}

template<typename T,typename U>
void Printarray(T f,U n){
  for(int i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i];
}

void flagfunc(bool flag,string A,string B){
  flag ? cout<<A<<endl : cout<<B<<endl;
}

void flag2func(bool flag){
  flag ? cout<<"Yes"<<endl : cout<<"No"<<endl;
}

void flag3func(bool flag){
  flag ? cout<<"YES"<<endl : cout<<"NO"<<endl;
}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int h,w;cin>>h>>w;
  vector<string> v1(h);
  vector<vector<char>> v2(h+2, vector<char>(w+2));
  rep(i,0,h)cin>>v1[i];
  rep(i,0,h+2)
  	rep(j,0,w+2)
  		v2[i][j]='#';
  rep(i,0,h)
  	rep(j,0,w)
  		v2[i+1][j+1]=v1[i][j];
  rep(i,0,h+2){
  	rep(j,0,w+2)
  		cout<<v2[i][j];
  	cout<<endl;
  }
  /*
  */
}

Measured memory_bytes: 256
<?php 
  $n = fgets(STDIN);
  $array = explode(" ", trim(fgets(STDIN)));
  foreach($array as $i => &$val){
     $val -= $i + 1; 
  }
  sort($array);
  if(count($array) % 2 == 1){
     $cp = ($n - 1) / 2;
     $cv = $array[$cp];
  }else{
     $cp = $n / 2;
     $cv = round(($array[$cp] + $array[$cp - 1])/2);
  }
  $sum = 0;
  foreach($array as $v){
    $sum += abs($v - $cv);
  }
  echo $sum;

Measured memory_bytes: 25076
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pi pair<int,int>
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define sz(x) ((int)x.size())
#define ln(x) ((int)x.length())
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define dbg(x) cout<<#x<<": "<<x<<endl
#define clr(x,v) memset(x, v, sizeof(x))
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const double eps = 1e-9;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
const int MAXN = 1e6 + 5;

void cp()
{
	int n;
	cin>>n;
	map<string, int> cnt;
	while(n--)
	{
		string s;
		cin>>s;
		cnt[s]++;
	}
	cout<<"AC x "<<cnt["AC"]<<endl;
	cout<<"WA x "<<cnt["WA"]<<endl;
	cout<<"TLE x "<<cnt["TLE"]<<endl;
	cout<<"RE x "<<cnt["RE"]<<endl;
}

int main()
{
    FASTIO;
    int t;
    t = 1;
    // cin >> t;
    while(t--)
    {
        cp();
    }
    return 0;
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
#define sz(a) ll(a.size())
ll par[200005],sz[200005];
ll find(ll i){
	if(par[i]==i)
		return i;
	return par[i]=find(par[i]);
}
void merge(ll x,ll y){
	x=find(x),y=find(y);
	if(x==y)
		return;
	if(sz[x]<sz[y])
		swap(x,y);
	par[y]=x;
	sz[x]+=sz[y];
}
void solve(){
	ll n,m;
	cin>>n>>m;
	for(ll i=1;i<=n;i++){
		par[i]=i;
		sz[i]=1;
	}
	for(ll i=0;i<m;i++){
		ll x,y;
		cin>>x>>y;
		merge(x,y);
	}
	ll res=0;
	for(ll i=1;i<=n;i++)
		if(par[i]==i)
			res=max(res,sz[i]);
	cout<<res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w", stdout);
    #endif
    clock_t z=clock();
    ll qc=1;
    //cin>>qc;
    for(ll i=1;i<=qc;i++)
        solve();
    debug("Total Time:%.4Lf\n",(ld)(clock()-z)/CLOCKS_PER_SEC);
}

Measured memory_bytes: 6900
/**
 *    author:  tourist
 *    created: 20.11.2019 14:11:01       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<long long> a(n + 1);
  for (int i = 0; i < n; i++) {
    cin >> a[i + 1];
    a[i + 1] += a[i];
  }
  long long ans = (long long) 9e18;
  for (int i = 1; i < n; i++) ans = min(ans, abs(2 * a[i] - a[n]));
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args){



		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		
		int n = sc.nextInt();
		int[] a = new int[n];
		int sum=0;
		for(int i =0;i<n;i++) {
			a[i]=sc.nextInt();
			sum +=a[i];
		}
		
		if(sum>=h) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
			
		}
	}

}
/*
class City{
	int order;
	int prefecture;
	int year;
	int number;
	City(int order,int prefecture, int year){
		this.order = order;
		this.prefecture = prefecture;
		this.year = year;
	}
}
*/


Measured memory_bytes: 50476
#include <math.h>

#include <algorithm>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  int ans = 0;
  for (int i = 0; i < n; i += 2) {
    if (a[i] % 2 != 0) {
      ans++;
    }
  }
  cout << ans;
  return 0;
}


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

using namespace std;

int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if(a==1&&b>1)
    {
        printf("Alice");
    }
    else if(b==1&&a>1)
    {
        printf("Bob");
    }
    else if(a>b)
    {
        printf("Alice");
    }
    else if (a==b)
    {
        printf("Draw");
    }
    else 
    {
    	printf("Bob");
	}
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int r = Integer.parseInt(sc.next());
		int g = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		sc.close();
		int num = 100 * r + 10 * g + b;
		System.out.println(num%4==0 ? "YES" : "NO");
	}
}

Measured memory_bytes: 21332
N = int(input())
MARCH = [0]*5
for i in range(N):
    name = input()
    if name[0] == 'M':
        MARCH[0] += 1
    elif name[0] == 'A':
        MARCH[1] += 1
    elif name[0] == 'R':
        MARCH[2] += 1
    elif name[0] == 'C':
        MARCH[3] += 1
    elif name[0] == 'H':
        MARCH[4] += 1
    else:
        continue

ans = 0
for i in range(3):
    for j in range(i+1, 4):
        for k in range(j+1, 5):
            ans += MARCH[i]*MARCH[j]*MARCH[k]

print(ans)

Measured memory_bytes: 3064
def abc119_c():
  n, a, b, c = map(int, input().split())
  L = [int(input()) for _ in range(n)]
  ans = 10**9

  def dfs(arr):
    if len(arr) == n:
      # ABCともに材料が1つ以上あるなら得点計算する
      if arr.count(1) > 0 and arr.count(2) > 0 and arr.count(3) > 0:
        calc_score(arr)
      return
    for i in range(4):
      dfs(arr + [i])

  def calc_score(arr):
    nonlocal ans
    # パターンにあわせて棒を用意する
    tools_a = [L[i] for i in range(n) if arr[i] == 1]
    tools_b = [L[i] for i in range(n) if arr[i] == 2]
    tools_c = [L[i] for i in range(n) if arr[i] == 3]
    # 得点計算して答えを更新
    score = magic(tools_a, a)
    score += magic(tools_b, b)
    score += magic(tools_c, c)
    ans = min(score, ans)

  def magic(tools, target):
    # 延長短縮で長さ合わせにいく
    pt = abs(target - sum(tools))
    # 棒が複数あると合成コスト追加、棒の数マイナス1
    if len(tools) >= 2:
      pt += 10 * (len(tools) - 1)
    return pt

  dfs([])
  print(ans)

abc119_c()

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int[][] a = new int[3][3];
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				a[i][j] = sc.nextInt();
			}
		}
		int n = sc.nextInt();
		for (int k = 0; k < n; k++) {
			int b = sc.nextInt();
			for (int i = 0; i < 3; i++) {
				for (int j = 0; j < 3; j++) {
					if (a[i][j] == b) {
						a[i][j] = 0;
					}
				}
			}
		}
		sc.close();

		if (a[0][0] == 0 && a[0][1] == 0 && a[0][2] == 0
				|| a[1][0] == 0 && a[1][1] == 0 && a[1][2] == 0
				|| a[2][0] == 0 && a[2][1] == 0 && a[2][2] == 0
				|| a[0][0] == 0 && a[1][0] == 0 && a[2][0] == 0
				|| a[0][1] == 0 && a[1][1] == 0 && a[2][1] == 0
				|| a[0][2] == 0 && a[1][2] == 0 && a[2][2] == 0
				|| a[0][0] == 0 && a[1][1] == 0 && a[2][2] == 0
				|| a[0][2] == 0 && a[1][1] == 0 && a[2][0] == 0
				) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 23764
def palindrome(_string): return _string.find(_string[::-1])

def main():
    s = input()
    length = len(s)
    if palindrome(s) == 0 and palindrome(s[0:int((length - 1)/2)]) == 0 and palindrome(s[int((length + 3)/2 - 1):]) == 0:
        ans = "Yes"
    else:
        ans = "No"

    print(ans)

if __name__ == '__main__':
    main()



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

int main(){
    int n, maxv, minv;
    cin >> n;
    vector<int> R(n);
    cin >> R.at(0);
    minv = R.at(0);
    maxv = -2000000000;
    for (int i = 1; i < n; ++i){
        cin >> R.at(i);
        maxv = max(maxv, R.at(i) - minv);
        minv = min(minv, R.at(i));
    }
    cout << maxv << endl;
}


Measured memory_bytes: 3548
#include <iostream>

using namespace std;
int main()
{
	long long L, R, ans=2019,buffer;
	cin >> L >> R;
	if (R - L >= 2019) cout << 0;
	else
	{
		for (int i = L; i < R; i++)
		{
			for (int j = i+1; j <= R; j++)
			{
				buffer = ((i % 2019)*(j % 2019)) % 2019;
				if (ans > buffer) ans = buffer % 2019;
			}
		}
		cout << ans;
	}
}


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


int main(){
	int n,l;
	string s[128];
	string ans = "";

	cin >>n >>l;
	for(int i=0;i<n;i++){
		cin >>s[i];
	}

	sort(s,s+n);
	for(int i=0;i<n;i++){
		ans += s[i];
	}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
    string s1,s2;
    cin>>s1>>s2;
    ll n=s1.length()+1;
    ll m=s2.length()+1;
    ll dp[n][m];
    for(ll i=0;i<n;i++) dp[i][0]=0;
    for(ll i=0;i<m;i++) dp[0][i]=0;
    for(ll i=1;i<n;i++) {
        for(ll j=1;j<m;j++) {
            if(s1[i-1]==s2[j-1]) dp[i][j]=dp[i-1][j-1]+1;
            else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            //cout<<dp[i][j]<<" ";
        } 
    }
    ll i=n-1,j=m-1;
    vector<char> ans;
    while(1) {
        if(i==0 || j==0) break;
        if(s1[i-1]==s2[j-1]) { ans.push_back(s1[i-1]); i--; j--; }
        else {
            if(dp[i-1][j]>dp[i][j-1]) { i--; }
            else j--;
        }
    }
    for(ll i=ans.size()-1;i>=0;i--) cout<<ans[i];
}

Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr int INF = 2e9;
constexpr int mod = 1e9 + 7;

int main(){ 
  int l, r, d;
  cin >> l >> r >> d;
  cout << r / d - (l - 1) / d << endl;
  return 0;
} 

Measured memory_bytes: 3516
from collections import deque,Counter
n,m,k = map(int,input().split())
G = [[] for _ in range(n)]

exc = [0]*n
for _ in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)
    exc[a] += 1
    exc[b] += 1

stk = deque()
grp = [-1]*n
grpnum = 0
def dfs(s,g):
    stk.append(s)
    grp[s] = g
    while stk:
        cur = stk.pop()
        for nxt in G[cur]:
            if grp[nxt] != -1: continue
            grp[nxt] = g
            stk.append(nxt)

for i in range(n):
    if grp[i] != -1: continue
    dfs(i,grpnum)
    grpnum += 1
cnt = Counter(grp)

for _ in range(k):
    c,d = map(int,input().split())
    c -= 1
    d -= 1
    if grp[c] == grp[d]:
        exc[c] += 1
        exc[d] += 1

ans = [cnt[grp[i]] - exc[i] - 1 for i in range(n)]
print(*ans)   

Measured memory_bytes: 33032
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define eb 			emplace_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define inf        1000000000000000000
#define puts(n)		cout<<n;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define setbits(x) __builtin_popcount(x)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll v1,v2;
	v1 = ceil(a/(d*1.0));
	v2 = ceil(c/(b*1.0));
	if(v1>=v2) cout<<"Yes";
	else cout<<"No";
	
	return 0;
}

Measured memory_bytes: 3656
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int i;
        double sum1 = 0;
        double sum2 = 0;
        double sum3 = 0;
        double sum4 = 0;
        double ans2,ans3,ans4;
        double max;
        double[] array_max;
        array_max = new double[1000];
        double[] array_x,array_y;
        array_x = new double[1000];
        array_y = new double[1000];
        for(i = 0; i < n; i++){
        	array_x[i] = scan.nextDouble();
        }
        for(i = 0; i < n; i++){
        	array_y[i] = scan.nextDouble();
        }
        for(i = 0; i < n; i++){
        	sum1 += Math.abs(array_x[i] - array_y[i]);
        	sum2 += (array_x[i] - array_y[i]) * (array_x[i] - array_y[i]);
        	sum3 += Math.abs(array_x[i] - array_y[i]) * Math.abs(array_x[i] - array_y[i]) * Math.abs(array_x[i] - array_y[i]);
        }
        for(i = 0; i < n; i++){
        	sum4 = Math.abs(array_x[i] - array_y[i]);
        	array_max[i] = sum4;
        }
        max = array_max[0];
        for(i = 0; i < n - 1; i++){
        	if(max < array_max[i + 1])
        		max = array_max[i + 1];
        }
        ans2 = Math.sqrt(sum2);
        ans3 = Math.cbrt(sum3);
        System.out.println(sum1);
        System.out.println(ans2);
        System.out.println(ans3);
        System.out.println(max);
            }
}



		

	

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

int main(void){
    int A, B, C, D;
    string ans;
    cin >> A >> B >> C >> D;
    
    // implements
    if(A+B > C+D){
        ans = "Left";
    }
    else if(A+B < C+D){
        ans = "Right";
    }
    else{
        ans = "Balanced";
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
MAXN = 100001
isPrime = [True for x in range(0, MAXN)]

def findPrime():
    isPrime[1] = False
    for i in range(2, MAXN):
        if isPrime[i]:
            for j in range(i + i, MAXN, i):
                isPrime[j] = False

findPrime()

cache = [0 for x in range(0, MAXN)]

pSum = 0
for i in range(1, MAXN, 2):
    cache[i] = pSum
    if isPrime[i] and isPrime[(i+1)//2]:
        cache[i] += 1
    pSum = cache[i]

Q = int(input())

for i in range(Q):
    l, r = map(int, input().split())
    print(cache[r] - cache[l - 2])





Measured memory_bytes: 5144
//ΔARC 061E
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long LL;
const int N = 1e5+5;
const int C = 1e6+5;
vector<pair<int,int> > V[C+5];
vector<int> G[N],P[4*N];
int vis[4*N];
int f[4*N],ff;
int b[4*N],bb;
void dfs(int u)
{
	vis[u]=1;
	b[++bb]=u;
	int i,s,x;
	s=G[u].size();
	for(i=0;i<s;i=i+1){
		x=G[u][i];
		if(!vis[x])
			dfs(x);
	}
}
queue<pair<int,int> > Q;
int main()
{
	int n,m,i,j,k,x,y,z,s,o;
	scanf("%d%d",&n,&m);
	for(i=1;i<=m;i=i+1){
		scanf("%d%d%d",&x,&y,&z);
		V[z].push_back(make_pair(x,y));
	}
	o=n;
	for(i=1;i<C;i=i+1){
		s=V[i].size();
		ff=0;
		for(j=0;j<s;j=j+1){
			G[V[i][j].first].push_back(V[i][j].second);
			G[V[i][j].second].push_back(V[i][j].first);
			f[++ff]=V[i][j].first;
			f[++ff]=V[i][j].second;
		}
		for(j=1;j<=ff;j=j+1){
			if(!vis[f[j]]){
				bb=0;
				dfs(f[j]);
				o++;
				for(k=1;k<=bb;k=k+1){
					P[b[k]].push_back(o);
					P[o].push_back(b[k]);
				}
			}
		}
		for(j=1;j<=ff;j=j+1){
			G[f[j]].clear();
			vis[f[j]]=0;
		}
	}
	Q.push(make_pair(1,0));
	while(!Q.empty()){
		x=Q.front().first;
		y=Q.front().second;
		Q.pop();
		vis[x]=1;
		if(x==n){
			cout<<y/2<<endl;
			return 0;
		}
		s=P[x].size();
		for(i=0;i<s;i=i+1)
			if(!vis[P[x][i]])
				Q.push(make_pair(P[x][i],y+1)),vis[P[x][i]]=1;
	}
	cout<<"-1\n";
	return 0;
}
/*
8 11
1 3 1
1 4 2
2 3 1
2 5 1
3 4 3
3 6 3
3 7 3
4 8 4
5 6 1
6 7 5
7 8 5

2

*/

Measured memory_bytes: 57592
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
 int n[5];
 cin >> n[0] >> n[1] >> n[2] >> n[3] >> n[4];
 for (int i=4;i>=1;i--) for (int j=0;j<i;j++) if (n[j]<n[j+1]) swap(n[j],n[j+1]);
 cout << n[0] << " " << n[1] << " " << n[2] << " " << n[3] << " " << n[4] << endl;
 return 0;
}

Measured memory_bytes: 1164
import java.io.*;
import java.util.ArrayList;

public class Main {
    public static void main(String [] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

        int n = Integer.parseInt(br.readLine());
        String s = br.readLine();
        ArrayList<Integer> w_idx = new ArrayList<>();
        ArrayList<Integer> r_idx = new ArrayList<>();

        for(int i=0;i<n;i++){
            if(s.charAt(i) == 'W') w_idx.add(i);
            else r_idx.add(i);
        }

        int ans = 0;
        for(int a=0, b=r_idx.size()-1; a<w_idx.size() && b>=0;a++, b--){
            if(w_idx.get(a) < r_idx.get(b)){
                ans += 1;
            }else break;
        }
        bw.write(ans+"");


        bw.flush();
        bw.close();
        br.close();
    }
}


Measured memory_bytes: 44856
def read():
    return int(input())

def reads(sep=None):
    return list(map(int, input().split(sep)))

def main():
    n, k = reads()
    d = dict()
    for _ in range(n):
        p = input()[0]
        if p not in d: d[p] = 0
        d[p] += 1
    l = [list(item) for item in d.items()]
    c = 0
    while k <= len(l):
        l = sorted(l, key=lambda x:x[1], reverse=True)
        for i in range(k):
            l[i][1] -= 1
        l = [x for x in l if x[1]]
        c += 1
    print(c)

main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string str, p;
  string oldstr;
  string order;
  stack<char> st;
  int q, a, b;
  cin >> str;
  cin >> q;
  for (int i = 0; i < q; i++)
  {
    cin >> order;
    if (order == "replace")
    {
      cin >> a >> b >> p;
      str.replace(a, p.size(), p);
   //   cout << str << "\n";
    }
    else
    {
      cin >> a >> b;
      if (order == "reverse")
      {
        // aからbまでを逆順
        for (int i = a; i < b + 1; i++)
        {
          st.push(str.at(i));
        }
        while (!st.empty())
        {
          oldstr += st.top();
          st.pop();
        }
      //  cout << oldstr << "\n"; // 連結
        str.replace(a, oldstr.size(), oldstr);
     //   cout << str << "\n";
        oldstr = "";
      }
      else
      {
        cout << str.substr(a, b - a + 1) << "\n";
      //  cout << str << "\n";
      }
    }
  }
}


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

int main() {
  long long num;
  long long cnt = 0;
  cin >> num;
  
  map<long long, long long> m;
  long long tmp;
  
  for(int i = 0; i < num; i++){
    cin >> tmp;
    m[tmp] += 1;
  }
  
  for(auto itr:m){
    if(itr.second % 2 != 0) cnt++;
  }
  
  cout << cnt;
}


Measured memory_bytes: 6528
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  int h = 0, cnt = 0, ans = 0;
  rep(i,n){
    int hi;
    cin >> hi;
    if(hi>h) {
      ans = max(ans,cnt);
      cnt = 0;
    }else{
      ++cnt;
    }
    h = hi;
  }
  ans = max(ans,cnt);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n;
  cin>>n;
  int ans=n;
  for(int i=0;i<=n;++i){
    int a=0,b=i;
    while(b>0){
      a+=b%6;
      b/=6;
    }
    b=n-i;
    while(b>0){
      a+=b%9;
      b/=9;
    }
    ans=min(ans,a);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n;
	scanf("%d", &n);
	int i;
	int a[102];
	for (i = 0; i < n; i++)
		scanf("%d", &a[i]);
	for (i = 0; i < n; i++)
	{
		if (a[i] % 2 == 0)
		{
			if (a[i] % 3 > 0 && a[i] % 5 > 0)
			{
				printf("DENIED\n");
				return 0;
			}
		}
	}
	printf("APPROVED\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define optimize ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define INF 2000000020LL
#define ALL(x) x.begin(), x.end()
#define UNIQUE(c) (c).resize(unique(ALL(c)) - (c).begin())
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define POS(n, x) (lower_bound(ALL(n), x) - (n).begin())
#define ll long long
#define ld long double
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define PB push_back
#define EB emplace_back
#define MOD 1000000007
#define PRIME 101 
#define MAXN 3030
#define MAXL 23
#define endl '\n'

using namespace std;

// (1 + sqrt(5)) / 2
const ld GOLDEN_RATIO = 1.6180339887498949025257388711906969547271728515625;
const ld PI = 2.0 * acos(0.0);
const int BLOCK = 333;

bool ok[MAXN][MAXN];
ld dp[MAXN][MAXN], p[MAXN];
int N;

ld solve(int i, int falta)
{
	if(i == N) return !falta;
	if(ok[i][falta]) return dp[i][falta];

	ok[i][falta] = true;

	return dp[i][falta] = (((ld)(1.0) - p[i]) * solve(i + 1, falta)) + (p[i] * solve(i + 1, falta - 1));
}

int main(int argc, char const *argv[])
{
	optimize;
	
	cin >> N;

	for(int i = 0; i < N; i++)
		cin >> p[i];

	int meio = (N + 1) / 2;

	ld ans = 0;

	for(int i = meio; i <= N; i++)
		ans += solve(0, i);

	cout << setprecision(10) << fixed << ans << endl;

	return 0;
}

Measured memory_bytes: 142112
#include<bits/stdc++.h>
using namespace std;
#define int long
using pi = pair<int, int>;
signed main() {
    int n, k, r, s, p, res = 0;
    cin >> n >> k >> r >> s >> p;
    string t,rs;
    cin >> t;
    rs = t;
    auto win = [](char c) { return c == 'r' ? 'p' : c == 's' ? 'r' : 's'; };
    auto f = [&](char c) { return c == 'r' ? r : c == 's' ? s : c == 'p' ? p : 0; };
    for (int i = 0; i < n; ++i) rs[i] = 'n';
    for (int i = 0; i < k;++i){
        rs[i] = win(t[i]);
    }
    for (int i = k; i < n;++i){
        if(win(t[i])==rs[i-k]) rs[i] = 'a';
        else rs[i] = win(t[i]);
    }
    for (int i = 0; i < n; ++i) res += f(rs[i]);
    cout << res;
}

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

int n;
long long sum = 0LL;

int main()
{
	ios::sync_with_stdio(0);
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		long long t = (long long) n / i;
		t = ((1 + t) * t / 2 * i);
		sum += t;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<stdio.h>
using namespace std;

int main() {
	int n, s = 0;
	int v[20], c[20];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> c[i];
	}
	for (int i = 0; i < n; i++) {
		if (v[i] - c[i] > 0)
			s += v[i] - c[i];
	}
	cout << s << endl;
}

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

int main() {
    int N, ans = 0;
    cin >> N;
    vector<int> A(N), B(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    for (int i = 0; i < N; i++) cin >> B[i];
    
    vector<int> D(N);
    for (int i = 0; i < N; i++) {
        D[i] = A[i] - B[i];
    }
    
    long long P = 0, M = 0;
    for (auto &d : D) {
        if (d < 0) { M += d; ans++; }
        else P += d;
    }
    
    if (P < abs(M)) { cout << -1 << endl; return 0;}
    
    sort(D.rbegin(), D.rend());
    for (int i = 0; i < N; i++) {
        if (0 <= M) break;
        M += D[i];
        ans++;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int H, W, M; 
	cin >> H >> W >> M; 
	int A[300010] = {}; int B[300010] = {};
	map<pair<int, int>, bool> mp; 
	int mxa = 0; int mxb = 0; 
	for(int i = 0; i < M; i++){
		int h, w; 
		cin >> h >> w; 
		h--; w--; 
		mp[make_pair(h, w)] = true; 
		A[h] ++; B[w] ++; 
		mxa = max(mxa, A[h]); 
		mxb = max(mxb, B[w]); 
	}
	vector<int> MA, MB; 
	for(int i = 0; i < H; i++){
		if(A[i] == mxa) MA.emplace_back(i);
	}
	for(int i = 0; i < W; i++){
		if(B[i] == mxb) MB.emplace_back(i);
	}
	int ans = mxa + mxb; 
	long long num = (long long) MA.size() * (long long) MB.size(); 
	if(num > (long long) M){
		cout << ans << "\n"; return 0; 
	}
	bool exist = false; 
	for(auto i : MA){
		for(auto j : MB){
			if(!mp[make_pair(i, j)]){
				exist = true; break; 
			}
		}
		if(exist) break; 
	}
	if(!exist) ans--; 
	cout << ans << "\n"; 
}

Measured memory_bytes: 28468
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<string>
#include<queue>
#include<iomanip>

using namespace std;

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second

typedef pair<double, double> P;
const lint MOD = 1e9+7;
const lint INF = MOD * MOD;

double dist(P s, P t){
    return sqrt((s.fi-t.fi)*(s.fi-t.fi)+(s.se-t.se)*(s.se-t.se));
}
P middle(P s, P t){
    return make_pair((s.fi+t.fi)/2, (s.se+t.se)/2);
}
P circumcenter(P p, P q, P r, double a, double b, double c){
    a *= a; b *= b; c *= c;
    double d = a*(b+c-a), e = b*(c+a-b), f = c*(a+b-c);
    double x = (p.fi*d + q.fi*e + r.fi*f) / (d+e+f);
    double y = (p.se*d + q.se*e + r.se*f) / (d+e+f);
    return make_pair(x, y);
}

int main(){
    int n; cin >> n;
    vector<P> vp;
    rep(i, n){
        double x, y; cin >> x >> y;
        vp.push_back(make_pair(x, y));
    }
    cout << fixed << setprecision(10);

    if(n == 2){
        cout << dist(vp[0], vp[1])/2 << endl;
        return 0;
    }
    
    double ans = 1000;
    rep(i,n) rep(j,n) rep(k, n){
        if((i-j)*(j-k)*(k-i) == 0) continue;
        double a = dist(vp[j], vp[k]), b = dist(vp[k], vp[i]), c = dist(vp[i], vp[j]);
        vector<double> e = {a, b, c}; sort(all(e));

        P ctr; double r;
        if(e[0]*e[0] + e[1]*e[1] <= e[2]*e[2]){
            r = e[2] / 2;
            if(e[2] == a) ctr = middle(vp[j], vp[k]);
            else if(e[2] == b) ctr = middle(vp[k], vp[i]);
            else if(e[2] == c) ctr = middle(vp[i], vp[j]);
        }
        else{
            ctr = circumcenter(vp[i], vp[j], vp[k], a, b, c);
            r = dist(ctr, vp[i]);
        }

        bool ok = true;
        rep(l, n){
            if((i-l)*(j-l)*(k-l) == 0) continue;
            if(dist(vp[l], ctr) > r) ok = false;
        }
        if(ok) ans = min(ans, r);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
a, b = gets.chomp.split.map(&:to_i)

a_min = ((100 * a)/8.0).ceil
a_max = ((100 * (a+1))/8.0)
a_max = a_max == a_max.floor ? a_max -1 : a_max
aa = (a_min..a_max).to_a

b_min = ((100 * b)/10.0).ceil
b_max = ((100 * (b+1))/10.0).floor
b_max = b_max == b_max.floor ? b_max -1 : b_max
bb = (b_min..b_max).to_a

c = []
c = aa & bb
if c.empty?
  p -1
else
  p c.min
end


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

#include <iostream>
#include <vector>
#include <queue>
using namespace std;
using Graph = vector<vector<int>>;
using P = pair<int, int>;

ll modnum = 1000000007;


long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}



int main() {
    string s; cin >> s;
    if(s[2] == s[3] && s[4] == s[5]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
int main(void){
    int x,y;
    int InX,InY;
    int sum=0;
    int a[1001][1001],b[1001];
    
    
    scanf("%d %d",&InX,&InY);
    
    for(x=0;x<InX;x++){
        for(y=0;y<InY;y++){
            scanf("%d",&a[x][y]);
        }
    }
    for(x=0;x<InY;x++){
        scanf("%d",&b[x]);
    }
    
    for(x=0;x<InX;x++){
        for(y=0;y<InY;y++){
            sum = sum + a[x][y]*b[y];
        }
        printf("%d\n",sum);
        sum=0;
    }
}


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

int main(void)
{
  int ret = 0;
  int next = 0;
  char str[4];
  char contest[][4] = {"ABC","ARC"};
  
  /* input S */
  ret = scanf("%s", str);
  
  /* Jude */
  if (strcmp(str, contest[0]) == 0) {
    next = 1;
  } else if (strcmp(str, contest[1]) == 0) {
    next = 0;
  } else {
    return -1;
  }
  
  /* output contest */
  printf("%s", contest[next]);
  
  return 0;
}

Measured memory_bytes: 1736
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
const int oo=1010101010;
const int mod=1000000007;
struct abc
{
	int l,r;
	bool operator<(const abc &a)const
	{
		if(l!=a.l)
			return l<a.l;
		return r>a.r;
	}
}a[101010];
bool cmp(const abc &x,const abc &y)
{
	return x.r<y.r;
}
int x[101010],y[101010],h[101010];
int sum[101010],cnt=0;
void add(int p,int v)
{
	for(int i=p;i<=cnt;i+=(i&(-i)))
		(sum[i]+=v)%=mod;
}
int query(int p)
{
	int ret=0;
	for(int i=p;i;i-=(i&(-i)))
		(ret+=sum[i])%=mod;
	return ret;
}
int main()
{
	int n,m,ne,la,an=0,now=0,k;
	scanf("%d%d",&n,&m);
	a[0].l=a[0].r=0;
	for(int i=1;i<=n;i++)
		scanf("%d",&x[i]);
	for(int i=1;i<=m;i++)
		scanf("%d",&y[i]);
	y[0]=0;
	y[m+1]=oo;
	for(int i=1;i<=n;i++)
	{
		k=lower_bound(y,y+m+2,x[i])-y;
		ne=y[k];
		la=y[k-1];
		if(la==0||ne==oo)
			continue;
		an++;
		a[an].l=x[i]-la;
		a[an].r=ne-x[i];
	}
	sort(a+1,a+an+1,cmp);
	for(int i=1;i<=an;i++)
	{
		if(a[i].r!=now)
		{
			now=a[i].r;
			cnt++;
		}
		a[i].r=cnt;
	}
	cnt++;
	memset(sum,0,sizeof(sum));
	add(1,1);
	sort(a+1,a+an+1);
	for(int i=1;i<=n;i++)
		if(a[i].l!=a[i-1].l||a[i].r!=a[i-1].r)
		{
			now=query(a[i].r);
			add(a[i].r+1,now);
		}
	printf("%d",query(cnt));
	return 0;
}

Measured memory_bytes: 2176
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    O = readline().strip()
    E = readline().strip()

    ans = ''.join(O[i // 2] if i % 2 == 0 else E[i // 2] for i in range(len(O) + len(E)))
    print(ans)
    return


if __name__ == '__main__':
    main()


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

ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x; }
ll lcm(ll x, ll y) { return x*y / gcd(x,y); }

int main(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    a--;
    ll ansa = a - (a/c+a/d-a/lcm(c,d));
    ll ansb = b - (b/c+b/d-b/lcm(c,d));
    cout << ansb - ansa << endl;
    return 0;
}

Measured memory_bytes: 256
/********IN THE NAME OF ALLAH**********/
/*THE MOST GRACIOUS, THE MOST MERCIFUL*/

#include <bits/stdc++.h>
using namespace std;


#define FASTIO ios::sync_with_stdio(0); cin.tie(0);
#define ll long long
#define ull unsigned long long
#define pqueue priority_queue
#define uset unordered_set
#define umset unordered_multiset
#define bsearch binary_search
#define gcd __gcd
#define clz __builtin_clz
#define ctz __builtin_ctz
#define popcount __builtin_popcount
#define parity __builtin_parity
#define mp make_pair
#define pb push_back
#define popb pop_back
#define pf push_front
#define popf pop_front
#define in insert
#define out erase
#define low lower_bound
#define up upper_bound
#define endl '\n'
#define N 10000000
#define INF 1000000007

int a[N];
int main() {
    int n;
    cin >> n;
    int c = 0;
    for(int i = 0; i < n; i++)
        cin >> a[i];
    
    for(int i = 1; i <= n; i++) {
        if(i % 2 != 0 && a[i - 1] % 2 != 0)
            c++;
    }
    cout << c << endl;
}

Measured memory_bytes: 3636
#include <stdio.h>
 
int main(){
	int i, j, k, sum;
	


	scanf("%d %d %d", &i, &j, &k);

	sum = 100*i + 10*j + k;

	if(sum % 4 == 0) {
		printf("YES");
	}

	else {
		printf("NO");
	}
 
}

Measured memory_bytes: 128