akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,d;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    while(cin>>n>>d)
    {
        ll x=d*2;
        x++;
        ll ans=n/x;
        if(n%x!=0) ans++;
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
X = int(input())
import math 
def get_prime(n):
    
    if n <=1:
        return []
    prime = [2]
    limit = int(math.sqrt(n))
    
    # 奇数のリストを作成
    data = [i+1 for i in range(2,n,2)]
    while limit > data[0]:
        prime.append(data[0])
        data = [j for j in data if j % data[0] !=0]
    return prime + data
for x in get_prime(2*X):
    if x >=X:
        print(x)
        break



Measured memory_bytes: 7576
#include<bits/stdc++.h>
using namespace std;
const int INF = 1e9+5;
int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //ios_base::sync_with_stdio(0); cin.tie(NULL);
    int n;
    cin >> n;
    int k;
    cin >> k;
    vector<int> a(n);
    for (int &x:a) {
        scanf("%d", &x);
    }
    
    vector<int> dp(n, INF);
    dp[0] = 0;
    for (int i=0; i<n; i++) {
        for (int j=i+1; j<=i+k; ++j) {
            if (j < n)
                dp[j] = min(dp[j], dp[i]+abs(a[i]-a[j]));
        }
    }
    cout << dp[n-1];
    //return 0;
}


Measured memory_bytes: 1024
from itertools import permutations

n = int(input())
p = tuple(int(v) for v in input().split())
q = tuple(int(v) for v in input().split())

def fact(n):
    return fact(n - 1) * n if n > 1 else 1

ap = dict(zip(permutations(range(1, n + 1), n), range(fact(n))))
print(abs(ap[p] - ap[q]))

Measured memory_bytes: 51056
//g++ -std=c++14 test.cpp -o test.out
 
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N;
LL A[200000],B[200000];

string ans = "No";

void solve(){
	vector<LL> counter(N+1,0);
	for(int i=0;i<N;i++){
		counter[A[i]]++;
		counter[B[i]]++;
	}
	for(int i=1;i<=N;i++){
		if(counter[i]>=N+1) return;
	}

	ans = "Yes";
	sort(B,B+N,greater<LL>());
	LL match_left = -1; LL match_right = N;
	LL match_num = -1;
	for(int i=0;i<N;i++){
		if(A[i]==B[i]){
			match_num = A[i];
			if(match_left==-1) match_left = i;
			match_right = i;
		}
	}
	if(match_num==-1) return;

	LL left_index = match_left - 1;
	LL right_index = match_right + 1;
	for(LL i=0;i<N;i++){
		if(match_num==A[i] || match_num==B[i]){
			left_index = min(left_index,i-1);
			right_index = max(right_index,i+1);
		}
	}

	for(int i=match_left;i<=match_right;i++){
		if(left_index>=0){
			swap(B[i],B[left_index]);
			left_index--;
		}else if(right_index<=N-1){
			swap(B[i],B[right_index]);
			right_index++;
		}
	}
}
 
int main(){
	cin >> N;
	for(int i=0;i<N;i++) cin >> A[i];
	for(int i=0;i<N;i++) cin >> B[i];
 
    solve();

	cout << ans << endl;
	if(ans=="Yes"){
		for(int i=0;i<N;i++) cout << B[i] << " ";
		cout << endl;
	}
    return 0;
}

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

int main(void) {
  unsigned long long k, a, b;
  cin >> k >> a >> b;
  unsigned long long ans;

  if (b <= a + 2 || k - 1 < a) {
    ans = k + 1;
  } else if ((k - a + 1) % 2 == 0) {
    ans = a + (k - a + 1) / 2 * (b - a);
  } else {
    ans = a + (k - a + 1) / 2 * (b - a) + 1;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = 1100100100100100ll;
const llong mod = 1e9+7;

struct data{
	llong place;
	llong cost;

	data(){};
	data(llong place, llong cost) :
		place(place),
		cost(cost)
	{}

	bool operator<(const data &ri) const{
		return cost < ri.cost;
	}
	bool operator>(const data &ri) const{
		return cost > ri.cost;
	}
};

llong N;
vector<vector<P> > edges;
vector<llong> dis;

llong Dijkstra(int start, int goal){
	priority_queue<data, vector<data>, greater<data> > q;
	dis.resize (edges.size(),inf);
	dis[start] = 0;

	q.push(data(start, 0));
	while(q.size()){
		data now = q.top(); q.pop();
		// if(now.place == goal) return now.cost;
		if(dis[now.place] < now.cost) continue;

		for(int i = 0; i < edges[now.place].size(); i++){
			P edge = edges[now.place][i];
			data next(edge.first, now.cost + edge.second);
			if(dis[next.place] <= next.cost) continue;
			dis[next.place] = next.cost;
			q.push(next);
		}
	}

	return -1;
}


int main(){
	cin >> N;
	edges.resize(N+1);
	llong from, to, cost;
	for (int i = 0; i < N-1; ++i) {
		cin >> from >> to >> cost;
		edges[from].push_back(P(to, cost));
		edges[to].push_back(P(from, cost));
	}

	Dijkstra(1,1);
	vector<int> ans(N+1);
	for (int i = 1; i <= N; i++) {
		ans[i] = dis[i]&1;
	}

	for (int i = 1; i <= N; i++)
		cout << ans[i] << endl;

	return 0;
}

Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
const int N=100010;
int n,m;
double ans=0,power[N];
int main()
{
	cin>>n>>m;
	double tmp=0.5;
	for(int i=1;i<=100000;++i)
	{
		power[i]=tmp;
		tmp/=2.0;
	}
	for(int i=1;i<=n;++i)
	{
		int cnt=0,now=i;
		while(now<m)now*=2,++cnt;
		if(!cnt)ans+=1.0/n;
		else ans+=1.0/n*power[cnt];
	}
	printf("%.12lf\n",ans);
}

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

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

using namespace std;


int main()
{
int N,K;
cin>>N>>K;
if(N%K==0){
    cout<<"0"<<endl;
}else
{
    cout<<"1"<<endl;
}

}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;


const LL inf=1e9;
LL mem[18][1<<18];
vector<LL> a,b;
int n;
LL g(int r,int f,int c,int h){
	if(c==n){
		return 0;
	}
	if(c>0&&mem[r][f]!=-1){
		return mem[r][f];
	}
	int od=0;
	LL ret=inf;
	for(int i=0;i<n;i++){
		if(f&(1<<i))continue;
		int v;
		if(i%2==c%2){
			v=a[i];
		}
		else{
			v=b[i];
		}
		if(h<=v){
			ret=min(ret,od+g(i,f|(1<<i),c+1,v));
		}
		od++;
	}
	if(c>0){
		mem[r][f]=ret;
	}
	//cerr << r << ", " << f << ", " << c << ", " << h << ": " << ret << endl;
	return ret;
}
void solve(long long N, std::vector<long long> A, std::vector<long long> B){
	a=A;
	b=B;
	n=N;
	LL v=g(-1,0,0,0);
	if(v==inf){
		cout << -1 << endl;
	}
	else{
		cout << v << endl;
	}


}

int main(){
	memset(mem,-1,sizeof(mem));
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    std::vector<long long> B(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&B[i]);
    }
    solve(N, std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 37120
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>

using namespace std;

long long int powmod(long long int a,long long int n,long long int m) {
    if(n == 0)
        return 1;

    if(n % 2 ==0){
        long long int r = powmod(a,n/2,m);
        return r*r % m;
    }

    return a*powmod(a,n-1,m)%m;
}

int main(){

  long long int m,n;
  cin >> m >> n;
  cout << powmod(m,n,1000000007) << endl;

}


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

using namespace std;

const int N = 1100, MODD = 1e9 + 7;

char g[N][N];

int dp[N][N];

int main() {
	int h, w;
	cin >> h >> w;
	for (int i = 0; i < h; ++i)
		for (int j = 0; j < w; ++j)
			cin >> g[i][j];
	dp[0][0] = 1;
	for (int i = 0; i < h; ++i)
		for (int j = 0; j < w; ++j) {
			if (g[i][j] == '#')
				continue;
			if (i - 1 >= 0)
				dp[i][j] += dp[i - 1][j];
			if (j - 1 >= 0)
				dp[i][j] += dp[i][j - 1];
			dp[i][j] %= MODD;
		}
	cout << dp[h - 1][w - 1] << '\n';
}


Measured memory_bytes: 5632
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#include <fstream>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LLI long long int
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POS(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
#define Pos(i) cout<<(i?"Possible":"Impossible")<<endl
#define co(i) cout<<i<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//
int main(){
    int a,b,c,d; cin>>a>>b>>c>>d;
    Yes(abs(a-c)<=d||(abs(a-b)<=d&&abs(b-c)<=d));
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>

// ===============================================================

using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;

// ===============================================================

ll gcd(ll a, ll b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}
//最大公約数
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
//最小公倍数
ll box(double a)
{
	ll b = a;
	return b;
}
//切り捨て
ll fff(double a)
{
	ll b = a + 0.5;
	return b;
}
//四捨五入
ll sum(ll n) {
	return (1 + n) * n / 2;
}
//1から整数nまでの合計
bool prime(ll a)//素数判定、primeならtrue,違うならfalse
{
	if (a < 2) return false;
	else if (a == 2) return true;
	else if (a % 2 == 0) return false;
	double m = sqrt(a);
	for (int i = 3; i <= m; i += 2)
	{
		if (a % i == 0)
		{
			return false;
		}
	}

	// 素数である
	return true;
}
//素数判定

// ===============================================================

int main() {
	ll n; cin >> n;
	vector<pair<ll, ll>> a(n);
	for (int i = 0; i < n; i++) {
		ll ai, au; cin >> ai >> au;
		a[i] = make_pair(au, ai);
	}
	sort(a.begin(), a.end());
	ll cnt = 0;
	ll count = 0;
	ll ans = true;
	for (int i = 0; i < n; i++) {
		cnt += a[i].second;
		if (i == n - 1) {
			if (cnt <= a[i].first - count) {
				count += cnt;
			}
			else {
				ans = false;
				break;
			}
			cnt = 0;
		}
		else {
			if (a[i].second != a[i + 1].second) {
				if (cnt <= a[i].first - count) {
					count += cnt;
				}
				else {
					ans = false;
					break;
				}
				cnt = 0;
			}
		}
	}
	if (ans) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

int dsum(string s){
  int ret = 0;
  for(int i=0; i<(int)s.length(); i++){
    ret += s[i]-'0';
  }
  return ret;
}

int main(){
  string s;
  cin >> s;
  int n = stoi(s);
  if(n%dsum(s) == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

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

int main(){
	int a,b;
	cin>>a>>b;

	if(a==1)a+=13;
	if(b==1)b+=13;

	if(a>b)
		cout<<"Alice"<<endl;
	else if(b>a)
		cout<<"Bob"<<endl;
	else 
		cout<<"Draw"<<endl; 
}

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

void solve(const int n, const int y)
{
  for (int i = 0; i <= n; ++i) {
    for (int k = 0; k <= n; ++k) {
      if (i + k > n) break;
      int j = n - i - k;
      if (j < 0 || j > n) j = 0;
      if (i * 10000 + k * 5000 + j * 1000 == y) {
        cout << i << " " << k << " " << j << endl;
        return;
      }
    }
  }
  cout << "-1 -1 -1\n";
}

int main()
{
  int n, y;
  cin >> n >> y;
  solve(n, y);
}


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

int main() {
  int N;
  cin>>N;
  vector<int>c(N-1);
  vector<int>s(N-1);
  vector<int>f(N-1);
  rep(i,N-1){
    cin>>c.at(i)>>s.at(i)>>f.at(i);
  }
  vector<int>a(N);
  a.at(N-1)=0;
  rep(i,N-1){
    a.at(i)+=s.at(i);
    rep2(j,i,N-2){
      a.at(i)+=c.at(j);
      
      if(s.at(j+1)>a.at(i)){
        a.at(i)=s.at(j+1);
      }
      else{
        if((a.at(i)-s.at(j+1))%f.at(j+1)!=0){
          a.at(i)+=f.at(j+1)-(a.at(i)-s.at(j+1))%f.at(j+1);
        }
      }
    }
    a.at(i)+=c.at(N-2);
  }
  for(int i=0; i<N;i++){
    cout<<a.at(i)<<endl;
  }
}

Measured memory_bytes: 256
def isok(arg):
    count = 0
    for i in range(N):
        count += -(-A[i]//arg)-1
    if count <= K:
        return True
    else:
        return False

def bisect(ng, ok):
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if isok(mid):
            ok = mid
        else:
            ng = mid
    return ok

N,K = map(int,input().split())
A = list(map(int,input().split()))
print(bisect(0,10**9))

Measured memory_bytes: 93848
uses math;
var
	ans,n,Ma,Mb,i,j,a,b,c,x,mp,mm:Longint;
	p,m:array[0..300]of Longint;
begin
	read(n,Ma,Mb);
	ans:=10000;
	for i:=1 to 200 do begin
		p[i]:=ans;
		m[i]:=ans;
	end;
	for i:=1 to n do begin
		read(a,b,c);
		x:=Ma*b-Mb*a;
		if x>0 then begin
			for j:=mp downto 0 do p[j+x]:=min(p[j+x],p[j]+c);
			mp:=min(mp+x,200);
		end else if x<0 then begin
			for j:=mm downto 0 do m[j-x]:=min(m[j-x],m[j]+c);
			mm:=min(mm-x,200);
		end else ans:=min(ans,c);
	end;
	for i:=1 to 200 do ans:=min(ans,p[i]+m[i]);
	if ans<10000 then writeln(ans)else writeln(-1);
end.

Measured memory_bytes: 128
#include <iostream>
#include <utility>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

template <typename T>
T gcd(T a, T b){
    if(b == 0){
        return a;
    }
    if(a<b) swap(a, b);
    return gcd(b, a%b);
}

template <typename T>
T lcm(T a, T b){
    return a*b/gcd(a, b);
}

int main(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll tmpa, tmpb;
    --a;
    tmpa = a - (a/c + a/d -a/lcm(c,d));
    tmpb = b - (b/c + b/d -b/lcm(c,d));
    cout << tmpb - tmpa << endl;
}


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

void Main()
{
  int cnt[26] = {0};
  int n; cin >> n;
  rep(i,n) {
    string S;
  	cin >> S;
    int cntNow[26] = {0};
    for (char c : S) {
      cntNow[c - 'a']++;
    }
    if (i == 0) {
      rep(i,26) cnt[i] = cntNow[i];
    } else {
      rep(i,26) cnt[i] = min(cnt[i], cntNow[i]);
    }
  }
  rep(i,26) {
    rep(j, cnt[i]) cout << (char)('a' + i);
  }
  cout << "\n";
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#define N 22
using namespace std;
const int Mod = 1e9 + 7;

int n, a[N][N];
long long f[1 << N];

int main() {
#ifdef whyqx
    freopen("work.in", "r", stdin);
    freopen("work.out", "w", stdout);
#endif
    cin >> n;
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= n; ++j)
            scanf("%d", &a[i][j]);
    f[0] = 1;
    for (int S = 0; S < 1 << n; ++S) {
        int T = S, cnt = 0;
        while (T) T -= T & (-T), ++cnt;
        for (int i = 1; i <= n; ++i) {
            if (((1 << (i - 1)) & S) == 0 || a[cnt][i] == 0) continue;
            (f[S] += f[S ^ (1 << (i - 1))]) %= Mod;
        }
    }
    cout << f[(1 << n) - 1];
    return 0;
}


Measured memory_bytes: 18688
#include <iostream>
#include<vector>
#include<stdlib.h>
#include<algorithm>
#include<string>
using namespace std;



int main(void){

	int a, b, sum = 0, count;

	for (; 	cin >> a >> b;){//??°????????????????????°?????????
		count = 0;
		sum = a + b;
		if (sum == 0){ cout << 0 << endl; }
		else if (sum != 0){

			while (sum > 9){

				sum /= 10;
				count++;

			}
			//?????°???count?????°
			cout << count + 1 << endl;
		}
	}


	return 0;
}

Measured memory_bytes: 1160
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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; }

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll H, W, K;
std::string c[10];
ll ans;

int main()
{
  std::cin >> H >> W >> K;

  rep( i, H )
    std::cin >> c[i];

  rep( bit1, 1<<H ) rep( bit2,  1<<W ) {
    std::set<ll> hs, ws;

    rep( i, H ) if( bit1>>i&1 )
      hs.emplace(i);
    rep( i, W ) if( bit2>>i&1 )
      ws.emplace(i);

    ll sum = 0;

    rep( i, H ) rep( j, W ) if( !hs.count(i) && !ws.count(j) ) {
      sum += c[i][j]=='#';
    }

    if( sum == K )
      ++ans;
  }

  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> auto compare = [](T x, T y) -> bool{return (x < y);};
const int MOD = 1000000007;

signed main(){
    int N, K, a, d;
    int A[101] = {0};
    cin >> N >> K;
    REP(i, K){
        cin >> d;
        REP(j, d){
            cin >> a;
            a--;
            A[a]++;
        }
    }
    int ans = 0;
    REP(i, N) if(A[i] == 0) ans++;
    PRINT(ans);
    return 0;
}

Measured memory_bytes: 3636
n = int(input())
a = list(map(int,input().split()))
mod = 10**9+7
ans = 0
for i in range(60):
    x = 1<< i
    l = len([1 for j in a if j & x])
    ans += x * l * (n-l) % mod
    ans %= mod
print(ans)

Measured memory_bytes: 50924
#include<stdio.h>

int A[50];

int fibonacci(int n){
  if(n==0 ||n==1)return A[n]=1;
  else if(A[n]!=-1)return A[n];
  else return A[n] = fibonacci(n-1)+fibonacci(n-2);
}


int main(){
  int n,fib,i;
  
  for(i=0;i<50;i++)A[i]=-1;

  
  scanf("%d",&n);
  fib = fibonacci(n);
  printf("%d\n",fib);

  return 0;
}



Measured memory_bytes: 2060
Bingos = Array.new(8) { |_i| [] }
A1s = gets.split.map(&:to_i)
Bingos[0] << A1s[0]
Bingos[0] << A1s[1]
Bingos[0] << A1s[2]
Bingos[3] << A1s[0]
Bingos[4] << A1s[1]
Bingos[5] << A1s[2]
Bingos[6] << A1s[0]
Bingos[7] << A1s[2]
A2s = gets.split.map(&:to_i)
Bingos[1] << A2s[0]
Bingos[1] << A2s[1]
Bingos[1] << A2s[2]
Bingos[3] << A2s[0]
Bingos[4] << A2s[1]
Bingos[5] << A2s[2]
Bingos[6] << A2s[1]
Bingos[7] << A2s[1]
A3s = gets.split.map(&:to_i)
Bingos[2] << A3s[0]
Bingos[2] << A3s[1]
Bingos[2] << A3s[2]
Bingos[3] << A3s[0]
Bingos[4] << A3s[1]
Bingos[5] << A3s[2]
Bingos[6] << A3s[2]
Bingos[7] << A3s[0]

hits = (0..7).map { |i| [i, 0] }.to_h

N = gets.to_i

N.times do |i|
  b = gets.to_i
  (0..7).each do |x|
    hits[x] += 1 if Bingos[x].find_index(b)
  end
end

hits.values.each do |v|
  next unless v == 3
  puts 'Yes' 
  exit
end

puts 'No'


Measured memory_bytes: 1788
import sys
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

A, B, C, D = map(int, read().split())
taka = (A + D-1) // D
ao = (C+B-1) // B

if taka >= ao:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 9180
import sys,queue,math,copy
from fractions import gcd
input = sys.stdin.readline
INF = 10**4
EPS = 10 ** (-8)
LI = lambda : [int(x) for x in input().split()]
_LI = lambda : [int(x)-1 for x in input().split()]

N = int(input())
for _ in range(N):

    a,b,c,d = LI()
    if a < 0:
        a = -a
        b = -b
        c = -c
        d = -d
    f = lambda x: a*x*x*x + b*x*x + c*x + d

    a_plus = 0
    a_minus = 0
    D = b * b - 3 * a * c

    def count(x, y):
        global a_plus,a_minus
        if x > 0:
            a_plus += y
        elif x < 0:
            a_minus += y

    if D < 0:
        # 単調増加/減少
        count(-d,1)
    elif D == 0:
        if f(-b/(3*a)) == 0: #３重解
            count(-b,3)
        else: # 単調増加
            count(-d,1)
    else:
        x1 = (- b - math.sqrt(D)) / (3*a)
        x2 = (- b + math.sqrt(D)) / (3*a)

        def bs(h,l):
            if min(h,l) <= 0 <= max(h,l)  and f(0) == 0:
                return 0
            while f(h) > f(l) + EPS:
                m = (h + l)/2
                if f(m) > 0:
                    h = m
                else:
                    l = m
            return l

        if f(x1) > 0:
            a1 = bs(x1,-INF)
            count(a1,1)
            if f(x2) < 0:
                a1 = bs(x1,x2)
                count(a1,1)
                a1 = bs(INF,x2)
                count(a1,1)

            elif f(x2) == 0:
                count(x2,2)
        elif f(x1) == 0:
            count(x1,2)
            a1 = bs(INF,x2)
            count(a1,1)
        else: #f(x1) < 0
            a1 = bs(INF,x2)
            count(a1,1)

    print (a_plus, a_minus)



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

int a[200010];
 int ans[200010];

 int main(){
 int n;
 scanf("%d",&n);
 for(int i=2;i<=n;i++)scanf("%d",&a[i]);
 for(int i=2;i<=n;i++)ans[a[i]]++;
 for(int i=1;i<=n;i++)printf("%d\n",ans[i]);
 }


Measured memory_bytes: 5280
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define Mod 1000000007
#define ll long long
#define dd double
#define pb push_back
#define ff first
#define ss second
#define Mp make_pair
#define INF 999999999999999999
#define NN (ll)(1e6+5)
int mod(string s,int a) 
{ 
    int ans=0; 
    for (int i=0;i<s.length();i++) 
         ans=(ans*10+(int)s[i]-'0')%a; 
    return ans; 
}
ll min(ll x,ll y){if(x<y) return x;return y;}
ll max(ll x,ll y){if(x>y) return x;return y;}
ll power(ll x,unsigned ll y) 
{ 
    if (y==0) 
        return 1; 
    else if (y%2==0) 
        return power(x,y/2)*power(x,y/2); 
    else
        return x*power(x,y/2)*power(x,y/2); 
}
ll hcf(ll a,ll b) 
{ 
    if(b==0) 
        return a; 
    return hcf(b,a%b);  
}
int main()
{
   fio;
   /*#ifndef ONLINE_JUDGE 
    	freopen("input.txt", "r", stdin); 
    	freopen("output.txt", "w", stdout); 
    	freopen("error.txt", "w", stderr); 
   #endif*/
   ll TT=1;
   //cin>>TT;
   while(TT--)
   {    
      ll n,m,i,j,x,k;
      cin>>n>>m>>k;
      vector <ll> cost(n),grid[n],sum(m,0);
      for(i=0;i<n;i++)
      {
          cin>>cost[i];
          for(j=0;j<m;j++)
          {
              cin>>x;
              sum[j]+=x;
              grid[i].pb(x);
          }
      }
      for(i=0;i<m;i++)
       if(sum[i]<k)
        {
            cout<<"-1\n";
            return 0;
        }
      bitset <13> bs;
      ll ans=INF;
      for(i=1;i<power(2,n);i++)
      {
          bitset <13> bs1(i);
          bs=bs1;
          ll cst=0,f=0;
          vector <ll> vtemp(m,0);
          for(j=0;j<n;j++)
          {
              if(bs[j])
              {
                  cst+=cost[j];
                  for(ll ii=0;ii<m;ii++)
                  {
                      vtemp[ii]+=grid[j][ii];
                  }
              }
          }
          for(j=0;j<m;j++)
           if(vtemp[j]<k)
           {
               f=1;
               break;
           }
          if(f==0)
           ans=min(ans,cst); 
      }
      cout<<ans<<"\n";
   }
}

Measured memory_bytes: 3664
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <string>
#include <iostream>
#include <stack>
#include <tuple>
#include <map>
#include <cassert>

using namespace std;
typedef long long ll;

#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)

int main(){
    ll n;
    cin >> n;
    const ll ABSMAX = 100000000;
    const ll LBVAL = - ABSMAX - 1;
    const ll UBVAL = ABSMAX + 1;
    ll v[2][2][3]; // xy, min-max, dec-const-inc
    for(int xy = 0; xy < 2; ++xy){
        for(int minmax = 0; minmax < 2; ++minmax){
            for(int k = 0; k < 3; ++k){
                v[xy][minmax][k] = (minmax == 0) ? UBVAL : LBVAL;
            }
        }
    }
    map<char, ll> x_c2i = {{'U', 1}, {'D', 1}, {'L', 0}, {'R', 2}};
    map<char, ll> y_c2i = {{'U', 2}, {'D', 0}, {'L', 1}, {'R', 1}};
    for(ll i = 0; i < n; ++i){
        ll x, y; char d;
        cin >> x >> y >> d;
        mins(v[0][0][x_c2i[d]], x);
        maxs(v[0][1][x_c2i[d]], x);
        mins(v[1][0][y_c2i[d]], y);
        maxs(v[1][1][y_c2i[d]], y);
    }
    vector<double> times(1, 0);
    for(ll xy = 0; xy < 2; ++xy){
        for(ll minmax = 0; minmax < 2; ++minmax){
            const int DEC = (minmax == 0) ? 2 : 0;
            const int INC = (minmax == 0) ? 0 : 2;
            const ll NAVAL = (minmax == 0) ? UBVAL : LBVAL;
            const ll SIGN = (minmax == 0) ? -1 : 1;
            if(v[xy][minmax][DEC] != NAVAL && v[xy][minmax][1] != NAVAL){
                times.push_back(SIGN * ((double)v[xy][minmax][DEC] - (double)v[xy][minmax][1]));
            }
            if(v[xy][minmax][DEC] != NAVAL && v[xy][minmax][INC] != NAVAL){
                times.push_back(SIGN * ((double)v[xy][minmax][DEC] - (double)v[xy][minmax][INC]) / 2.0);
            }
            if(v[xy][minmax][1] != NAVAL && v[xy][minmax][INC] != NAVAL){
                times.push_back(SIGN * ((double)v[xy][minmax][1] - (double)v[xy][minmax][INC]));
            }
        }
    }
    sort(times.begin(), times.end());
    double ans = -1;
    for(double t : times){
        if(t < 0){ continue; }
        double w[2][2] = {{UBVAL, LBVAL}, {UBVAL, LBVAL}};
        for(int xy = 0; xy < 2; ++xy){
            for(int k = 0; k < 3; ++k){
                mins(w[xy][0], v[xy][0][k] + (k - 1) * t);
                maxs(w[xy][1], v[xy][1][k] + (k - 1) * t);
            }
        }
        double area = (w[0][1] - w[0][0]) * (w[1][1] - w[1][0]);
        if(ans < 0 || ans > area){ ans = area; }
    }
    printf("%.10f\n", ans);
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <limits.h>
using namespace std; 
int main(int argc,char const* argv[])
{
  int n;
  cin >> n;
  vector<long long>a(3*n,0);
  long long answer=0;
  for(int i=0;i<3*n;i++)
    {
      cin >> a[i];
    }
  sort(a.begin(),a.end());
  for(int i=3*n-2;i>=n;i-=2)
    {
      answer+=a[i];
    }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n;
    string s;
    cin >> n >> s;

    set<int> st[26];
    for (int i = 0; i < n; i++) {
        s[i] -= 'a';
        st[s[i]].insert(i);
    }

    int q;
    cin >> q;

    for (int h = 0; h < q; h++) {
        int t;
        cin >> t;

        if (t == 1) {
            int i;
            char c;
            cin >> i >> c;
            i--;
            c -= 'a';

            if (s[i] == c) continue;
            st[s[i]].erase(i);
            st[s[i] = c].insert(i);

        } else {
            int l, r;
            cin >> l >> r;
            l--;

            int k = 0;
            for (int j = 0; j < 26; j++) {
                auto it = st[j].lower_bound(l);
                if (it != st[j].end() && *it < r) k++;
            }
            cout << k << '\n';
        }
    }

    return 0;
}

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

using namespace std;

constexpr int ms = 303;

double dp[ms][ms][ms];

void solve() {
    int n;
    cin >> n;

    vector<int> sushi(4, 0);
    for (int i = 0; i < n; ++i) {
        int k;
        cin >> k;
        ++sushi[k];
    }

    for (int i = 0; i < ms; ++i)
        for (int j = 0; j < ms; ++j)
            for (int k = 0; k < ms; ++k)
                dp[i][j][k] = -1.0;

    function<double(int, int, int)> calc_dp = [&] (int one, int two, int three) {
        if (one == 0 && two == 0 && three == 0) {
            return 0.0;
        }

        if (dp[one][two][three] != -1) {
            return dp[one][two][three];
        }

        double total = (double) (one+two+three);
        double num_op = ((double) n) / total;
        double ans = num_op;

        if (one > 0) {
            ans += (((double) one) / total) * calc_dp(one-1, two, three);
        }
        if (two > 0) {
            ans += (((double) two) / total) * calc_dp(one+1, two-1, three);   
        }
        if (three > 0) {
            ans += (((double) three) / total) * calc_dp(one, two+1, three-1);   
        }

        dp[one][two][three] = ans;
        return ans;
    };
    
    printf("%.10lf\n", calc_dp(sushi[1], sushi[2], sushi[3]));
}

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

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int t = 1;
    // cin >> t;

    for (int i = 0; i < t; ++i) {
        solve();
    }

    return 0;
}


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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    ll n = in(), a = in(), b = in();
    vll h = in(n);

    auto is_ok = [&](ll x) {
        ll cnt = 0;
        rep(i, n)
        {
            ll cur_h = max((ll)0, h[i] - b * x);
            cnt += dup(cur_h, a - b);
        }
        return cnt <= x;
    };

    ll ok = 1000000001, ng = 0;
    while (abs(ok - ng) > 1)
    {
        ll mid = (ok + ng) / 2;
        (is_ok(mid) ? ok : ng) = mid;
    }
    cout << ok << endl;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

using ll = long long;

const ll inf = 1LL << 60;

struct Edge {
    int to;
    ll w;
};

vector<ll> dijkstra(int s, const vector<vector<Edge>>& graph) {
    int n = graph.size();
    
    vector<ll> dist(n, inf);
    
    dist[s] = 0;
    
    using P = pair<ll, int>; // cost, vertex
    
    priority_queue<P, vector<P>, greater<P>> que;
    
    que.emplace(0, s);
    
    while(!que.empty()) {
        ll c;
        int v;
        
        tie(c, v) = que.top();
        que.pop();
        
        if (c != dist[v]) {
            continue;
        }
        
        for (auto e : graph[v]) {
            if (dist[e.to] > c + e.w) {
                dist[e.to] = c + e.w;
                que.emplace(c + e.w, e.to);
            }
        }
    }
    
    return dist;
}

int main()
{
    ios_base::sync_with_stdio(false);
    
    int n, m, s, t;
    cin >> n >> m >> s >> t;
    
    s--;
    t--;
    
    vector<vector<Edge>> graphS(n), graphT(n);
    
    for (int i = 0; i < m; i++) {
        int u, v;
        ll a, b;
        cin >> u >> v >> a >> b;
        
        u--;
        v--;
        
        graphS[u].push_back(Edge{v, a});
        graphS[v].push_back(Edge{u, a});
        
        graphT[u].push_back(Edge{v, b});
        graphT[v].push_back(Edge{u, b});
    }
    
    auto distS = dijkstra(s, graphS);
    auto distT = dijkstra(t, graphT);
    
    vector<ll> ans(n);
    
    ans[n - 1] = distS[n - 1] + distT[n - 1];
    
    for (int i = n - 2; i >= 0; --i) {
        ans[i] = min(distS[i] + distT[i], ans[i + 1]);   
    }
    
    for (int i = 0; i < n; i++) {
        cout << 1000000000000000 - ans[i] << endl;
    }
}


Measured memory_bytes: 19016
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    ll K, A, B;
    cin >> K >> A >> B;
    if (A + 2 < B)
    {
        cout << 1 + (A - 1) + ((K - (A - 1)) / 2) * (B - A) + ((K - (A - 1)) % 2) << endl;
    }
    else
    {
        cout << 1 + K << endl;        
    }
}


Measured memory_bytes: 256
use std::io;
use std::io::BufRead;
use std::io::BufReader;

fn main() {
    let reader = io::stdin();
    let mut reader = BufReader::new(reader.lock());

    let mut s = String::new();

    let _ = reader.read_line(&mut s);

    let xs: Vec<i32> = s.split_whitespace().map(|x| x.parse().unwrap()).collect();

    let x1 = xs[0];
    let y1 = xs[1];
    let x2 = xs[2];
    let y2 = xs[3];

    let dis_x = x2 - x1;
    let dis_y = y2 - y1;

    println!("{} {} {} {}", x2 - dis_y, y2 + dis_x, x1 - dis_y, y1 + dis_x);
}


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

int main() {
  int N,A;
  cin >>N;
  A=N%10;
  if(A==3){
    cout << "bon" <<endl;
  }
  else if(A==0||A==1||A==6||A==8){
    cout << "pon" <<endl;
  }
  else{
    cout << "hon" <<endl;
  }
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, a, b;
	cin >> n >> a >> b;
	int ans1 = min(a, b);
	int ans2;
	if (a + b >= n) {
		ans2 = (a + b) - n;
	}
	else {
		ans2 = 0;
	}
	cout << ans1 << ' ' << ans2 << endl;
	return 0;
}

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

vector<bool> isPrime(100001, true);
vector<int> like(100001);

int main() {
	isPrime[0]=false;
	isPrime[1]=false;
	for (int i=2; i<100001; i++) {
		if (isPrime[i])
			for (int j=2; i*j<100001; j++)
				isPrime[i*j]=false;
	}

	for (int i=1; i<100001; i++) {
		if (isPrime[i-1] and isPrime[(i)/2]) like[i]=like[i-1]+1;
		else like[i]=like[i-1];
	}
	
	int q; cin>>q;
	while (q--) {
		int l,r; cin>>l>>r;
		cout << like[r+1]-like[l] << endl;
	}
	return 0;
}

Measured memory_bytes: 1024
package main
import (
   "fmt"
   "os"
   "bufio"
   "strconv"
)
var sc = bufio.NewScanner(os.Stdin)

func main() {
  sc.Split(bufio.ScanWords)
  f := nextInt()
  s := nextInt()
  t := nextInt()

  if f == 5 && s == 7 && t == 5 {
	  fmt.Println("YES")
  } else if f == 5 && s == 5 && t == 7 {
	  fmt.Println("YES")
  } else if f == 7 && s == 5 && t == 5 {
	  fmt.Println("YES")
  } else {
	  fmt.Println("NO")
  }
}

func nextString() (string) {
	sc.Scan()
	v := sc.Text()
	return v
}

func nextInt() (int) {
	sc.Scan()
	v, e := strconv.Atoi(sc.Text())
    if e != nil { panic(e) }
    return v
}

func nextFloat() (float64) {
	sc.Scan()
	v, e := strconv.ParseFloat(sc.Text(), 64)
    if e != nil { panic(e) }
    return v
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int N;
    cin >> N;
    vector<int> A_m,A_p;
    rep(i,N){
        int A;
        cin >> A;
        if(A>=0) A_p.push_back(A);
        else A_m.push_back(A);
    }
    sort(A_m.begin(),A_m.end());
    sort(A_p.rbegin(),A_p.rend());
    if(A_m.size()==0){
        A_m.push_back(A_p.back());
        A_p.pop_back();
    }
    if(A_p.size()==0){
        A_p.push_back(A_m.back());
        A_m.pop_back();
    }
    vector<pair<ll,ll>> op;
    ll ans = A_m[0];
    rep(i,A_p.size()-1){
        op.push_back(make_pair(ans,A_p[i]));
        ans -= A_p[i];
    }
    op.push_back(make_pair(A_p.back(),ans));
    ans = A_p.back() - ans;
    for(int i=1;i<A_m.size();i++){
        op.push_back(make_pair(ans,A_m[i]));
        ans -= A_m[i];
    }
    cout << ans << endl;
    rep(i,N-1) cout << op[i].first << " " << op[i].second << endl;
    return 0;
}

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

int main() {
  long N,M;
  cin >> N>>M;
  if(2*N>M){
    cout<<M/2<<endl;
  }
  else{
    cout<<N+(M-2*N)/4<<endl;
  }
  
  
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        MyReader r = new MyReader(); 
        int K, S;
        {int[] a = r.ii(); K = a[0]; S = a[1];}
        int count = 0;
        for(int x = 0; x <= Math.min(K, S); x++)
            for(int y = 0; y <= Math.min(K, S-x); y++)
                if(0 <= S-x-y && S-x-y <= K)
                    count++;
        println(count);                    
    }
    static void print(Object o){
        System.out.print(o.toString());
    }

    static void println(Object o){
        System.out.println(o.toString());
    }

    static int Int(String s){
        return Integer.parseInt(s);
    }

    static long Long(String s){
        return Long.parseLong(s);
    }
    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s() throws IOException{
            return readLine();
        }

        String[] ss() throws IOException{
            return s().split(" ");
        }

        int i() throws IOException{
            return Int(s());
        }

        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }

        long l() throws IOException{
            return Long(s());
        }

        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long.parseLong(ss[j]);            
            return ll;
        }
    }
}

Measured memory_bytes: 21332
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
  int n,a,b,c;
  cin >> n >> a >> b >> c;
  vector<int> cal(n);
  for(int i=0; i<n; i++) cin >> cal[i];
  sort(cal.rbegin(),cal.rend());
  int cost = a;
  int calory = c;
  for(int i=0; i<n; i++){
    if(calory / (double)cost > (calory + cal[i]) / (double)(cost + b)) break;
    calory += cal[i];
    cost += b;
  }
  cout << calory / cost << endl;
  return 0;
}

Measured memory_bytes: 1200
hoge = str(input())
a = int(hoge[:2])
b = int(hoge[2:4])
result = None

if 0 < a and a <= 12:
  result = "MMYY"
  if 0 < b and b <= 12:
    result = "AMBIGUOUS"
if 0 < b and b <= 12:
  result = "YYMM"
  if 0 < a and a <= 12:
    result = "AMBIGUOUS"
if result == None:
  result = "NA"

print(result)

Measured memory_bytes: 3064
require 'matrix'

n, m, x = gets.split.map(&:to_i)
a = Matrix.zero(m + 1, n)
n.times do |i|
  b = gets.split.map(&:to_i)
  0.upto(m) do |j|
    a[j, i] = b[j]
  end
end
min = Float::INFINITY
[0, 1].repeated_permutation(n) do |bit|
  v = Vector.elements(bit)
  sum = a.minor(1, m, 0, n) * v
  if sum.min >= x
    ans = (a * v)[0]
    min = ans if min > ans
  end
end
puts (min == Float::INFINITY ? -1 : min)

Measured memory_bytes: 15140
#include <stdio.h>

int f(int x){
	return (x*x);
}

int main(){
	int d,s;

	while( scanf("%d", &d) != EOF ){
		s = 0;
		for(int i=1 ; (d*i)<=(600-d) ; i++){
			s += f(d*i)*d;
		}
		printf("%d\n", s);
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdlib>
#include <cmath>

using namespace std;

int main()
{
	int A, B;

	cin >> A; cin >> B;

	if (A <= 8 && B <= 8)
		cout << "Yay!" << endl;
	else
		cout << ":(" << endl;
	return 0;
}

Measured memory_bytes: 256
# 4/N=1/h+1/n+1/w
# 4w/N-w/h-w/n=1
# w(4/N-1/h-1/n)=1
# w(4hn-Nn-Nh)=Nhn
# w=Nhn/(4hn-Nn-Nh)

N=int(input())
for h in range(1,3501):
  for n in range(h,3501):
    if 4*h*n-N*n-N*h<1:
      continue
    w=N*h*n/(4*h*n-N*n-N*h)
    if float.is_integer(w):
      print(h,n,int(w))
      exit(0)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
typedef long long int ll;
const int N=105;
int n,m,a[N],sum,c;
double num;
int main(){
    cin.tie(NULL);
    cout.tie(NULL);
    ios_base::sync_with_stdio(false);
    cin>>n>>m;
    num=1.0 / (4.0*m);
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    num*=sum;
    for(int i=0;i<n;i++){
        if(a[i]>=num) c++;
    }
    if(c>=m)
        cout<<"Yes\n";
    else
        cout<<"No\n";
    return 0;
}


Measured memory_bytes: 256
#include <iomanip>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <utility>
#include <vector>
using namespace std;
typedef long long LL;
const int MAXN=1e5+5;
const int INF=0x3f3f3f3f;
int a[MAXN],b[MAXN];

bool cmp(const int &a,const int &b){
    return a>b;
}

int main(){
    int n,h;
    while(scanf("%d%d",&n,&h)!=EOF){
        int maxa=0;
        LL sumb=0;
        for(int i=1;i<=n;i++){
            scanf("%d%d",&a[i],&b[i]);
            maxa=max(maxa,a[i]);
        }
        for(int i=1;i<=n;i++){
            if(b[i]<maxa) b[i]=0;
        }
        sort(b+1,b+n+1,cmp);
        int ans=0;
        bool flag=false;
        for(int i=1;i<=n;i++){
            if(b[i]==0) break;
            ans++;
            sumb+=b[i];
            if(sumb>=h){
                flag=true;
                break;
            }
        }
        //cout<<"sumb: "<<sumb<<endl;
        if(flag) printf("%d\n",ans);
        else{
            ans+=(h-sumb)/maxa;
            if((h-sumb)%maxa!=0){
                ans++;
            }
            printf("%d\n",ans);
        }
    }
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using ll = long long;
// #define int ll
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, int(n) + 1)
#define rrep(i, n) RFOR(i, 0, n)
#define rrep1(i, n) RFOR(i, 1, int(n) + 1)
#define all(c) begin(c), end(c)
// const int MOD = 1000000007;

template <typename T>
void __print__(std::ostream &os, const char *, const char *tail, const T &fst) {
    os << fst << tail;
}
template <typename Fst, typename... Rst>
void __print__(std::ostream &os, const char *del, const char *tail, const Fst &fst,
               const Rst &... rst) {
    os << fst << del;
    __print__(os, del, tail, rst...);
}

#ifdef LOCAL
#define dump(...)                                         \
    do {                                                  \
        std::ostringstream os;                            \
        os << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; \
        __print__(os, ", ", "\n", __VA_ARGS__);           \
        std::cerr << os.str();                            \
    } while (0)
#else
#define dump(...)
#endif

template <typename Fst, typename... Rst>
void println(const Fst &fst, const Rst &... rst) {
    __print__(std::cout, "\n", "\n", fst, rst...);
}
template <typename Fst, typename... Rst>
void print(const Fst &fst, const Rst &... rst) {
    __print__(std::cout, " ", "\n", fst, rst...);
}

template <typename iter>
void println_(iter bgn, iter end) {
    while (bgn != end) println(*bgn++);
}

template <typename iter>
void print_(iter bgn, iter end) {
    while (bgn != end) {
        std::cout << *bgn++;
        std::cout << (bgn == end ? "\n" : " ");
    }
}

int _ = (std::cout.precision(10), std::cout.setf(std::ios::fixed), std::cin.tie(0),
         std::ios::sync_with_stdio(0), 0);

template <typename T>
std::vector<T> ndarray(int n, T v) {
    return std::vector<T>(n, v);
}
template <typename... Args>
auto ndarray(int n, Args... args) {
    auto val = ndarray(args...);
    return std::vector<decltype(val)>(n, move(val));
}

template <typename T>
bool umax(T &a, const T &b) {
    return a < b ? a = b, true : false;
}

template <typename T>
bool umin(T &a, const T &b) {
    return a > b ? a = b, true : false;
}

using namespace std;

ll solve(ll n) {
    vector<int> v(2, 1);
    rep(i, n - 1) {
        vector<int> w;
        w.push_back(1);
        rep(j, i + 1) {
            w.push_back(v[j] ^ v[j+1]);
        }
        w.push_back(1);
        v = move(w);
        // print_(all(v));
    }
    return find(all(v), 0) - v.begin();
}

int main() {
    uint64_t n;
    while (cin >> n) {
        ++n;
        print(n & -n);
    }
}

Measured memory_bytes: 3188