akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>

#define max_number 100000
#define NIL -1

typedef struct {
	int parent, left, right;
} node;

node array[max_number];
int depth[max_number];

int GetDepth(int i) {
	if (array[i].parent == NIL) {
		return 0;
	}
	return GetDepth(array[i].parent) + 1;
}

int main() {
	int i, j, k, ID, temp, m, array_size;
	scanf("%d", &array_size);

	//set values to NIL for scanning later on
	for (i = 0; i != array_size; i++) {
		array[i].parent = array[i].left = array[i].right = NIL;
	}

	//assigning values from input
	for (i = 0; i != array_size; i++) {
		scanf("%d %d", &ID, &k);
		for (j = 0; j != k; j++) {
			scanf("%d", &m);
			if (j == 0) {
				array[ID].left = m;
				array[m].parent = ID;
				temp = m;
			}
			else {
				array[temp].right = m;
				array[m].parent = ID;
				temp = m;
			}
		}
	}

	//get depth
	for (i = 0; i != array_size; i++) {
		depth[i] = GetDepth(i);
	}

	//printing
	for (i = 0; i != array_size; i++) {
		printf("node %d: parent = %d, depth = %d, ", i, array[i].parent, depth[i]);
		if (array[i].parent == NIL) {
			printf("root, [");
		}
		else if (array[i].left == NIL) {
			printf("leaf, [");
		}
		else
			printf("internal node, [");
		if (array[i].left != NIL) {
			printf("%d", array[i].left);
			temp = array[i].left;
			while (1) {
				if (array[temp].right == NIL) {
					break;
				}
				printf(", %d", array[temp].right);
				temp = array[temp].right;
			}
		}
		printf("]\n");
	}

	return 0;

}


Measured memory_bytes: 3296
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

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

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
// nCkを求める
// # nが1e7未満になりそうなら
// init_max_nはnの取りうる最大値を入れる(初回呼び出し時のみ)
// その後、(n,k)で呼び出せる 初回O(N)その後O(1)
// # nが1e7以上になりそうなら
// (n,k,<-1以外の値>)で呼び出す。 初回O(K)その後O(1)
// この場合、nが変更された場合は対応できない。
long long combination(int n, int k,int init_max_n = -1){
    static vector<ll> fac,finv,inv,big_n_tbl;
    static const int mod = 1e9+7;
    static bool big_n = false;
    static bool created = false;
    if (big_n) cerr << "big_n: trueのため、nは初期化時に使用した値になります" << endl;
    if (created && init_max_n != -1) cerr << "初期化済みのためinit_max_nの値は無視されます" << endl;
    if (!created) {
        if (init_max_n == -1) {
            cerr << "初期化に失敗しました。" << endl;
            exit(1);
        }
        if ( max(init_max_n,n) < 1e7+1) { // O(n) tbl
            fac.resize(init_max_n,0);
            finv.resize(init_max_n,0);
            inv.resize(init_max_n,0);
            fac[0] = fac[1] = 1;
            finv[0] = finv[1] = 1;
            inv[1] = 1;
            for (int i = 2; i < init_max_n; i++){
                fac[i] = fac[i - 1] * i % mod;
                inv[i] = mod - inv[mod%i] * (mod / i) % mod;
                finv[i] = finv[i - 1] * inv[i] % mod;
            }
        }
        else { // O(k) table (nは変更不可)
            chmin(k,n-k);
            big_n_tbl.resize(k+1,1);
            inv.resize(k+2,1);
            FOR(i,1,k+1){
                inv[i+1] = mod - inv[mod%(i+1)] * (mod/(i+1)) % mod;
                big_n_tbl[i] = (i == 1) ? n : ((n-i+1)*inv[i])%mod * big_n_tbl[i-1];
                if (i==1) cerr<< "i:1 " << big_n_tbl[i] << endl;
                big_n_tbl[i]%=mod;
            }
            big_n = true;
        }
        created = true;
    }
    if (big_n) return big_n_tbl[k];
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
// 偶数の袋と奇数の袋にわける
// 奇数のパターン1,3,5,....で出せる。

ll powll(ll a,ll n) {
    ll ans = 1;
    REP(i,n) ans*=a;
    return ans;
}

void solve() {
    int N,P;
    cin >> N >> P;
    int odd = 0,even = 0;
    REP(i,N) {
       int a;
       cin >> a;
        ((a%2 == 0) ? even : odd) ++;
    }
    ll all = powll(2,N);
    // 余りが0になる組み合わせ
    ll x = powll(2,even);
    ll y = 1; // 奇数袋を使わない
    // comb init
    REP(i,odd) y += ((i+1)%2==0) ? combination(odd,i+1,1e5) : 0;
    if (P==0) cout << x*y << endl;
    else cout << all-(x*y) << endl;

}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 2560
import collections
import itertools

N = int(input())
ss = [input() for _ in range(N)]
s = [i[0] for i in ss if i[0] in ["M", "A", "R", "C", "H"]]
c = collections.Counter(s)

# print(c)

l = list(itertools.combinations(c,3))

# print(l)

ans = sum([c[i[0]] * c[i[1]] * c[i[2]] for i in l])

print(ans)

Measured memory_bytes: 10860
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		for(;;)
		{
			int N=in.nextInt();
			if(N==0)
				return;
			
			int f[][]=new int[21][21];
			int nx=10,ny=10;
			
			for(int i=0;i<N;i++)
			f[in.nextInt()][in.nextInt()]=1;
			
			int M=in.nextInt();
			f[10][10]=0;
			for(int i=0;i<M;i++)
			{
				String s=in.next();
				int go=in.nextInt();
				if(s.equals("N"))
				{
					while(go-->0)
					{
						ny++;
						f[nx][ny]=0;
					}
				}
				else if(s.equals("E"))
				{
					while(go-->0)
					{
						nx++;
						f[nx][ny]=0;
					}
				}
				else if(s.equals("S"))
				{
					while(go-->0)
					{
						ny--;
						f[nx][ny]=0;
					}
				}
				else if(s.equals("W"))
				{
					while(go-->0)
					{
						nx--;
						f[nx][ny]=0;
					}
				}
			}
			
			boolean judge=true;
			for(int i=0;i<21;i++)
				for(int j=0;j<21;j++)
				{
					if(f[i][j]==1)
						judge=false;
				}
			System.out.println(judge ? "Yes" : "No");
		}
	}
}

Measured memory_bytes: 34820
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

ll inf=9223372036854775806,mod=1000000007;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	ll n;
	cin>>n;
	n=sqrt(n);
	cout<<n*n;
	return 0;
}

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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int x, y;
  while(cin >> x >> y, x || y) {
    int used[1000010];
    memset(used, -1, sizeof(used));
    int i;
    used[x] = 0;
    x *= 10;
    for(i = 1; used[x%y] == -1; i++) {
      x %= y;
      used[x] = i;
      if(x == 0) break;      
      x *= 10;
    }
    cout << used[x%y] << " " << i-used[x%y] << endl;
  }

  return 0;
}

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

using namespace std;

typedef long long ll;

ll a, v;
ll b, w;
ll t;

int main(){
    scanf("%lld %lld %lld %lld %lld", &a, &v, &b, &w, &t);
    if(v<w) printf("NO");
    else{
        ll tmp = v-w;
        if(tmp * t < abs(a - b)) printf("NO");
        else printf("YES");
    }
}


Measured memory_bytes: 3752
#include <iostream>
#include <string>

using namespace std;

int main(){
    string s;
    cin >> s;

    int year = stoi(s.substr(0, 4));
    int month = stoi(s.substr(5, 2));

    if (year < 2019){
        cout << "Heisei" << endl;
    } else if (year == 2019 && month < 5){
        cout << "Heisei" << endl;
    } else {
        cout << "TBD" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<bool> vb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

template<typename T>vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value != 0>::type
fill_v(U& u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value == 0>::type
fill_v(U& u, const V... v) { for (auto& e : u) fill_v<T>(e, v...); }
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int K, X;
	cin >> K >> X;
	for (int i = X - K + 1; i <= X + K - 1; i++) {
		if (i != X - K + 1) {
			cout << " ";
		}
		cout << i;
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef vector<int> vi;
typedef pair<int, int> P;
const int INF = 1 << 30;
const int dx[] = { -1,0,1,0 }, dy[] = { 0,1,0,-1 };
int main() {
	int N;
	cin >> N;
	int s[100];
	int sum = 0;
	rep(i, N) {
		cin >> s[i];
		sum += s[i];
	}
	if (sum % 10 != 0) {
		cout << sum << endl;
	}
	else {
		sort(s, s + N);
		bool NG = 1;
		rep(i, N) {
			if (s[i] % 10 != 0) {
				sum -= s[i];
				NG = 0;
				break;
			}
		}
		if (NG) sum = 0;
		cout << sum << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector<ll> vi;
typedef vector<pi> vpi;
#define f first
#define pb push_back
#define s second
#define mp make_pair
#define SZ(x) (int)x.size()
ll INF = 1e9;

string st;
ll hist[30], odd, N;
deque<ll> dq[30];
ll fw[200100];
pi frontwgt[30], backwgt[30];
ll ans;

void update(ll x){
  // cout<<"Update " << x<<'\n';
  ++x;
  for (;x<=N+10;x+=x&(-x))fw[x] ++;
}
ll sum(ll x){
  // cerr<<"Sum " << x << '\n';
  ++x;
  ll res = 0;
  for (;x;x-=x&(-x))res +=fw[x];
  return res;
}

int main(){
  // freopen("in.txt","r",stdin);
  cin >> st;
  N = st.size();
  for (auto i : st){
    hist[i-'a']++;
  }
  for (ll i=0;i<N;++i){
    dq[st[i]-'a'].pb(i);
  }
  for (ll i=0;i<26;++i){
    if (hist[i]%2){
      ++odd;
    }
  }
  if (odd > 1){
    cout<<-1;
    return 0;
  }
  for (ll i=0;i<26;++i)frontwgt[i] = backwgt[i] = mp(INF, INF);
  for (ll i=0;i<26;++i){
    if (SZ(dq[i])){
      frontwgt[i] = mp(dq[i][0], dq[i][0]);
      backwgt[i] = mp(N - dq[i].back() - 1, dq[i].back());
    }
  }
  ll L = N/2;
  while(L--){
    ll wgt = INF, opt=-1;
    for (ll i=0;i<26;++i){
      if (wgt > frontwgt[i].f + backwgt[i].f){
        wgt = frontwgt[i].f + backwgt[i].f;
        opt = i;
      }
    }
    for (ll i=0;i<26;++i){
      if (frontwgt[i].s > frontwgt[opt].s && frontwgt[i].f != INF){
        --frontwgt[i].f;
      }
      if (frontwgt[i].s > backwgt[opt].s && frontwgt[i].f != INF){
        --frontwgt[i].f;
      }
    }
    ll t = 0;
    for (ll i=0;i<26;++i){
      t += SZ(dq[i]);
      if (backwgt[i].s < backwgt[opt].s && backwgt[i].f != INF){
        --backwgt[i].f;
      }
      if (backwgt[i].s < frontwgt[opt].s && backwgt[i].f != INF){
        --backwgt[i].f;
      }

      // if (opt == -1 && SZ(dq[i])){
        // cout<<backwgt[i].s<<' '<<frontwgt[i].s<<'\n';
      // }
    }
    // if(opt==-1)cout<<'\n';
    // cout<<L<<" Removing " << (char) ('a' + opt)<<' '<<t<<'\n';
    // cout<<wgt<<'\n';
    ans += wgt;
    update(frontwgt[opt].s);
    update(backwgt[opt].s);
    dq[opt].pop_front();
    dq[opt].pop_back();
    if (SZ(dq[opt])){
      frontwgt[opt] = mp(dq[opt][0] - sum(dq[opt][0]), dq[opt][0]);
      backwgt[opt] = mp(N-1-dq[opt].back()-sum(N)+sum(dq[opt].back()), dq[opt].back());
    }else{
      frontwgt[opt] = mp(INF,INF);
      backwgt[opt] = mp(INF,INF);
    }
    // for (ll i=0;i<26;++i){
      // if (frontwgt[i].f != INF){
        // cout<<frontwgt[i].f<<' '<<frontwgt[i].s<<' '<<backwgt[i].f<<' '<<backwgt[i].s<<'\n';
      // }
    // }
  }
  cout<<ans;
}


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

#define int long long

using namespace std;

main() {
    int n,w,z;
    cin >> n >> w >> z;
    vector<int>v(n);
    for(int i = 0;i < n;i++)
        cin >> v[i];
    if(n == 1){
        cout << abs(v[0] - z)<<endl;
    }
    else{
        cout<<max(abs(v[n-2]-v[n-1]),abs(v[n-1]-z))<<endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,c,t;
    scanf("%d%d%d",&a,&b,&c);
     if(a < b)
    {
        t = a;

        a = b;

        b = t;

    }

    if(b < c)
    {
        t = b;;

        b = c;

        c = t;

    }
    if(a < b)
    {

        t = a;

        a = b;

        b = t;

    }
    if(a==b && a==b){
        printf("%d\n",c,b,a);
    }
    else if(b==c || b==c){
        printf("%d\n",a,c,b);
    }
return 0;
}


Measured memory_bytes: 128
#include <math.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
// scanf("%d", &x); => std::cin >> x;
// printf("%d\n", x); => std::cout << x << "\n";

int main() {
    long double d, t, s;
    scanf("%Lf%Lf%Lf", &d, &t, &s);

    long double IsTime = t - (d / s);
    if (IsTime >= 0) {
        puts("Yes");
        return 0;
    }

    puts("No");
    return 0;
}

Measured memory_bytes: 3700
# /usr/bin/python
# -*- coding: utf-8 -*-
import math



def nine(n):
  ret = 0
  for r in range(6,0,-1):
    p,n = divmod(n,9**r)
    ret += p
  return ret+n

def six(n):
  ret = 0
  for r in range(7,0,-1):
    p,n = divmod(n,6**r)
    ret += p
  return ret+n



if __name__ == "__main__":
  N = int(input())
  ans = N
  for l in range(N+1):
    ans = min(ans,nine(l)+six(N-l))
  print(ans)

Measured memory_bytes: 41580
n, s = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
mod = 998244353
dp = [0] * (s + 1)
dp[0] = 1
for i in a:
    dp2 = [0] * (s + 1)
    for j in range(s + 1):
        dp2[j] = dp[j] * 2
        if j >= i:
            dp2[j] += dp[j - i]
        dp2[j] %= mod
    dp = dp2
print(dp[-1])

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

bool isLeft(char c) {
    string left = "qwertasdfgzxcvb";
    bool res = false;
    for (int i = 0; i < left.length(); ++i) {
        if (c == left[i]) {
            res = true;
        }
    }
    return res;
}

int main(int argc, char *argv[])
{
    string line;
    bool cur, prev;
    int cnt;
    while (cin >> line, line != "#") {
        cnt = 0;
        for (int i = 0; i < line.length(); ++i) {
            if (i == 0) {
                cur = isLeft(line[i]);
            } else {
                prev = cur;
                cur = isLeft(line[i]);
                if (prev != cur)
                    cnt++;
            }
        }
        cout << cnt << endl;
    }

    return 0;
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  vector<int>a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  if(k==n)
  {
    cout<<1<<endl;
    return 0;
  }
  int ans=((n-k)/(k-1)) + 1 +(((n-k)%(k-1))!=0) ;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 640
def main():
    import sys
    input = sys.stdin.readline
    N,M = list(map(int,input().split()))
    a = []
    A = [0] * (1 + 10 ** 5)
    for _ in range(M):
        A[int(input())] = 1
    dp = [0] * (N + 1)
    dp[0] = 1
    if A[1]:
        dp[1] = 0
    else:
        dp[1] = 1
    for i in range(2,N + 1):
        if A[i]:
            dp[i] = 0
        else:
            dp[i] = dp[i-1] + dp[i-2]
            dp[i] %= 1000000007
    print(dp[N])
if __name__ == '__main__':
    main()   

Measured memory_bytes: 41692
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long

signed main() {
	
	string S;
	cin >> S;
	int res = 100000000;
	int d;
	int k;
	for (char c = 'a'; c <= 'z'; c++) {
		k = 0;
		d = -1;
		for (int i = S.size() - 1; i >= 0; i--) {
			if (S[i] == c) {
				k = 0;
			}
			else {
				k++;
			}
			d = max(d, k);
		}
		res = min(res, d);
	}
	cout << res << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> PP;
bool check(int n, int m, int x, int y) {return x>=0&&x<n&&y>=0&&y<m;}

int main() {
  int n,m,INF=1<<29,sx,sy,tx,ty,dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
  cin >> n >> m;
  string s[n];
  for(int i=0; i<n; i++) {
    cin >> s[i];
    for(int j=0; j<m; j++) {
      if(s[i][j]=='S') sx=i,sy=j;
      if(s[i][j]=='G') tx=i,ty=j;
    }
  }
  int d[n][m];
  for(int i=0;i<n;i++)for(int j=0;j<m;j++)d[i][j]=INF;
  d[sx][sy]=0;
  priority_queue<PP,vector<PP>,greater<PP> > que;
  que.push(PP(0,P(sx,sy)));
  while(!que.empty()) {
    PP p=que.top();que.pop();
    int nx=p.second.first,ny=p.second.second,c=p.first;
    if(d[nx][ny]<c) continue;
    for(int i=0; i<4; i++) {
      int x=nx+dx[i],y=ny+dy[i];
      if(!check(n,m,x,y)) continue;
      if(s[x][y]=='o' && d[x][y]>d[nx][ny]+1) {
        d[x][y]=d[nx][ny]+1;
        que.push(PP(d[x][y],P(x,y)));
      }
      if((s[x][y]=='.' || s[x][y]=='G') && d[x][y]>d[nx][ny]+2) {
        d[x][y]=d[nx][ny]+2;
        que.push(PP(d[x][y],P(x,y)));
      }
      for(int j=1; j<4; j++) {
        if(!check(n,m,x,y) || s[x][y]=='#') break;
        if(d[x][y]>d[nx][ny]+j+2) {
          d[x][y]=d[nx][ny]+j+2;
          que.push(PP(d[x][y],P(x,y)));
        }
        x+=dx[i],y+=dy[i];
      }
    }
  }
  cout << d[tx][ty] << endl;
  return 0;
}


Measured memory_bytes: 3240
#include<stdio.h>

int main()
{
  int n,i;
  int a[100];
  int cnt=0;

  scanf("%d",&n);
  for(i=0;i<n;i++)
  {
    scanf("%d",&a[i]);
    if(a[i]%2==1&&(i+1)%2==1)
      cnt++;
  }

  printf("%d",cnt);

  return 0;
}


Measured memory_bytes: 1736
#include <stdio.h>
 
using namespace std;
 
int main(){
   int m,f,r;
   char grade;
   while(true){
       scanf("%d %d %d",&m,&f,&r);
       if(m == -1 && f == -1 && r == -1) break;
       if(m == -1 || f == -1){
           grade = 'F';
       }else if(m+f >= 80){
           grade = 'A';
       }else if(m+f >= 65){
           grade = 'B';
       }else if(m+f >= 50){
           grade = 'C';
       }else if(m+f >= 30){
           grade = (r >= 50)? 'C':'D';
       }else{
           grade = 'F';
       }
       printf("%c\n",grade);
   }
}


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

int main(){
  int N;
  cin >> N;
  vector<int> X, Y;
  for(int i=0; i<N; i++){
    int x; cin >> x;
    X.push_back(x);
  }
  Y=X;
  sort(X.begin(), X.end());
  if(X[N/2-1]<X[N/2]){
    for(int i=0; i<N; i++){
      if(Y[i]<X[N/2]){
        cout << X[N/2] << endl;
      }else{
        cout << X[N/2-1] << endl;
      }
    }
  }
  else{
    for(int i=0; i<N; i++){
      cout << X[N/2-1] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3828
n = gets.to_i
fs = n.times.map { gets.split.map(&:to_i) }
ps = n.times.map { gets.split.map(&:to_i) }

ss = [0, 1].repeated_permutation(10).select {|s| s.reduce(&:+) > 0}

max_p = -1000000000
ss.each do |s|
  p = 0
  fs.each_with_index  do |f, i|
    t = s.zip(f).reduce(0) {|sum, (si, fi)| sum + si * fi}
    p += ps[i][t]
  end
  max_p = [max_p, p].max
end

puts max_p

Measured memory_bytes: 2300
package main

import (
	"fmt"
	"sort"
)

func main() {
	// Code for A - Maximize the Formula
	A := make([]int, 3)
	fmt.Scanf("%d %d %d", &A[0], &A[1], &A[2])

	sort.Ints(A)
	fmt.Println(A[2]*10 + A[0] + A[1])

}


Measured memory_bytes: 1836
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;

using System;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = Console.ReadLine().Reverse();
            var b = Console.ReadLine();
            Console.WriteLine(a.SequenceEqual(b)?"YES":"NO");
        }
    }
}


Measured memory_bytes: 13268
import java.util.Scanner;

public class Main {	
	
	public static void main(String[] args) {
		
		Scanner scan = new Scanner(System.in);
		long s = scan.nextLong();
		long c = scan.nextLong();
		long ans = 0;
		
		if (c >= 2 * s) {
			long x = (c / 2 - s) / 2;
			for (long temp = Math.max(x - 2 , 1);temp <= x + 2;temp ++) {
				if (temp <= c / 2) {
					long result = Math.min(c / 2 - temp , s + temp);
					if (result > ans)
						ans = result;
				}
			}
			System.out.println(ans);
		} else {	
			System.out.println(c / 2);
		}
		
	}
	
		
}














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


int n, tot = 0;
vector<int> gp[300];

int main() {
    scanf("%d", &n);
    if(n & 1) gp[++tot].push_back(n), n--;
    int hf = n / 2;
    for(int i = 1; i <= hf; ++i) {
        gp[++tot].push_back(i);
        gp[tot].push_back(n + 1 - i);
    }

    vector< pair<int, int> > ans;
    for(int i = 1; i <= tot; ++i) {
        for(int j = i + 1; j <= tot; ++j) {
            for(auto u : gp[i]) for(auto v : gp[j])
                ans.emplace_back(u, v);
        }
    }

    int sz = ans.size();
    printf("%d\n", sz);
    for(auto g : ans) printf("%d %d\n", g.first, g.second);
    
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }




using P = complex<double>;
double dot(P a, P b) { return real(conj(a) * b); }
double cross(P a, P b) { return imag(conj(a) * b); }
const double eps = 1e-8;


int main() {
    int query;
    cin >> query;
    while (query--) {
        
        double p0x, p0y, p1x, p1y, p2x, p2y, p3x, p3y;
        cin >> p0x >> p0y >> p1x >> p1y >> p2x >> p2y >> p3x >> p3y;
        P p0 = P(p0x, p0y), p1 = P(p1x, p1y), p2 = P(p2x, p2y), p3 = P(p3x, p3y);
        
        double d1 = abs(cross(p2 - p1, p0 - p1));
        double d2 = abs(cross(p1 - p0, p3 - p0));
        // cout << d1 << " " << d2 << endl;
        double t = d1 / (d1 + d2);
        P r = p2 + t * (p3 - p2);
        cout << fixed << setprecision(10);
        cout << real(r) << " " << imag(r) << endl;
    }
}



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

int main() {
    int64_t a, b, c;
    string Ans = "No";
    cin >> a >> b >> c;

    if (4 * a * b < (c - a - b) * (c - a - b) && c > a + b) {
        Ans = "Yes";
    }
    cout << Ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
int l[10];
const int INF = 1e9;

int N,A,B,C;

int dfs(int cur, int a, int b, int c)
{
	if (cur == N)
	{
		if (min(a,min(b,c)) > 0)
		{
			return abs(a-A) + abs(b-B) + abs(c-C) - 30;
		}
		else
		{
			return INF;
		}
	}

		int a1 = dfs(cur+1,a,b,c);
		int a2 = dfs(cur+1,a+l[cur],b,c) + 10;
		int a3 = dfs(cur+1,a,b+l[cur],c) + 10;
		int a4 = dfs(cur+1,a,b,c+l[cur]) + 10;
		return min(a1,min(a2,min(a3,a4)));
}

int main()
{
	cin >> N >> A >> B >> C;
	for (int i = 0; i < N; ++i)
	{
		cin >> l[i];
	}

	cout << dfs(0,0,0,0) << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

class Edge {
    int to;
    int cost;

    Edge(int to, int cost) {
        this.to = to;
        this.cost = cost;
    }
}

class Pair implements Comparable<Pair> {
    int dist;
    int index;

    Pair(int dist, int index) {
        this.dist = dist;
        this.index = index;
    }

    public int compareTo(Pair p2) {
        return dist - p2.dist;
    }
}
 
public class Main {
    static final int INF = 2000000000;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
 
        int n = sc.nextInt();
        List<List<Edge>> g = new ArrayList<>();
        for(int i = 0; i < n; i++) {
            List<Edge> tmp = new ArrayList<>();
            g.add(tmp);
        }
        for(int i = 0; i < n; i++) {
            int u = sc.nextInt();
            int k = sc.nextInt();
            for(int j = 0; j < k; j++) {
                int v = sc.nextInt();
                int c = sc.nextInt();
                g.get(u).add(new Edge(v, c));
            }
        }

        int[] d = new int[n];
        for(int i = 0; i < n; i++) {
            d[i] = INF;
        }
        d[0] = 0;

        PriorityQueue<Pair> que = new PriorityQueue<>();
        que.add(new Pair(0, 0));
        while(!que.isEmpty()) {
            Pair p = que.poll();
            int v = p.index;
            if(d[v] < p.dist) continue;

            for(int i = 0; i < g.get(v).size(); i++) {
                Edge e = g.get(v).get(i);
                if(d[e.to] > d[v] + e.cost) {
                    d[e.to] = d[v] + e.cost;
                    que.add(new Pair(d[e.to], e.to));
                }
            }
        }

        for(int i = 0; i < n; i++) {
            System.out.printf("%d %d\n", i, d[i]);
        }
 
        sc.close();
    }
}


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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

vi par,sz,vis,dis;
vector<vi> graph;
vector<vector<pair<li,li>>> wgraph;

void init(li n)
{
    par.resize(n);
    sz.resize(n);
    wgraph.resize(n);
    dis.resize(n);
    vis.resize(n);
    graph.resize(n);

    f(i,0,n-1)
    {
        par[i]=i;
        sz[i]=1;
        dis[i]=1e18;
    }
}

li root(li a)
{
    while(a!=par[a])
    {
        par[a]=par[par[a]];
        a=par[a];
    }

    return a;
}

void unio(li a,li b)
{
    li r_a=root(a);
    li r_b=root(b);

    if(par[r_a]!=r_b)
    { 
        if(sz[r_a]<sz[r_b])
        {
            par[r_a]=par[r_b];
            sz[r_b]+=sz[r_a];
            sz[r_a]=0;
        }
        else
        {
            par[r_b]=par[r_a];
            sz[r_a]+=sz[r_b];
            sz[r_b]=0;
        }
    }
}

int main()
{    
    

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    li n;

    cin>>n;

    li a[n];

    li sum=0;

    for(li i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }

    ld tp=(ld)sum/(ld)n;

    li tp1=floor(tp);
    li tp2=ceil(tp);

    li cnt1=0,cnt2=0;

    f(i,0,n-1)
    {
        cnt1+=pow(abs(tp1-a[i]),2);
        cnt2+=pow(abs(tp2-a[i]),2);
    }

    cout<<min(cnt1,cnt2);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;

struct Data {
	ll A;
	ll B;
};

struct Comp {
	bool operator()(Data &left, Data &right) {
		return (left.A < right.A);
	}
};

int main()
{
	int N, M;
	cin >> N >> M;
	vector<Data> D(N);
	for (int i = 0; i < N; ++i) {
		cin >> D[i].A >> D[i].B;
	}

	sort(D.begin(), D.end(), Comp());
	/*
	for (int i = 0; i < N; ++i) {
		cout << D[i].A << "," << D[i].B << endl;
	}
	*/

	ll cost = 0;
	int m = 0;
	int index = 0;
	while (m < M) {
		int b = 0;
		while (b < D[index].B && m < M) {
			b++;
			m++;
			cost += D[index].A;
		}
		index++;
	}
	cout << cost << endl;
	return 0;
}


Measured memory_bytes: 1920
#include<cstdio>
#include<functional>
#include<algorithm>
#include<cstring>
using namespace std;
void funch(int);
void funcw(int);
int h,w,k,h1[6],w1[6],cnt;
char c[6][7];
int main(void)
{
	int i;
	scanf("%d %d %d",&h,&w,&k);
	for(i=0;i<h;i++)	scanf("%s",c[i]);
	cnt=0;
	funch(0);
	printf("%d\n",cnt);
	return 0;
}
void funch(int nh)	
{
	if(nh==h)	{
		funcw(0);
	}
	else {
		h1[nh]=0;
		funch(nh+1);
		h1[nh]=1;
		funch(nh+1);
	}
}
void funcw(int nw)
{
	int i,j,cc;
	if(nw==w)	{
		cc=0;
		for(i=0;i<h;i++)	{
			for(j=0;j<w;j++)	{
				if(h1[i]==0 && w1[j]==0 && c[i][j]=='#') cc++;
			}
		}
		if(cc==k) cnt++;
	}
	else {
		w1[nw]=0;
		funcw(nw+1);
		w1[nw]=1;
		funcw(nw+1);
	}
}

Measured memory_bytes: 1712
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.TreeSet;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int A = scanner.nextInt();
		int B = scanner.nextInt();
		int K = scanner.nextInt();

		List<Integer> list1 = new ArrayList<>();

		//小さいほうからK番目以内
		for (int i = A; i < A + K; i++) {
			//A 以上 B 以下の整数
			if (i >= A && i <= B) {
				list1.add(i);
			}
		}

		List<Integer> list2 = new ArrayList<>();

		//大きいほうからK番目以内
		for (int i = B; i > B - K; i--) {
			//A 以上 B 以下の整数
			if (i >= A && i <= B) {
				list2.add(i);
			}
		}

		List<Integer> list = new ArrayList<>();
		list.addAll(list1);
		list.addAll(list2);

		//昇順に並び替え、重複削除
		List<Integer> x = new ArrayList<>(new TreeSet<>(list));

		for (int i : x) {
			System.out.println(i);
		}

	}
}

Measured memory_bytes: 21588
import queue
N, M = map(int, input().split())
E = [set() for i in range(N)]
for i in range(M):
  A, B = map(int, input().split())
  A, B = A-1, B-1
  E[A].add(B)
  E[B].add(A)
#print(E)
V = [-1]*N
q = queue.Queue()
q.put(0)
while not q.empty():
  p = q.get()
  s = E[p]
  for i in s:
    if V[i] < 0:
      V[i] = p
      q.put(i)
#print(V)
print("Yes")
for i in range(1, N):
  print(V[i]+1)


Measured memory_bytes: 62912
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
ans = 0
for _ in range(n):
    a = []
    a = list(map(int, input().split()))
    cal = c
    for i in range(m):
        cal += a[i] * b[i]
    
    if cal > 0:
        ans += 1
print(ans)

Measured memory_bytes: 3060
import math
N,M = list(map(int,input().split()))

ans_mod=10**9+7
ans=0
if N == M+1 or M == N+1:
    ans=(math.factorial(N)*math.factorial(M))%ans_mod
elif N == M:
    ans=(math.factorial(N)*math.factorial(M)*2)%ans_mod
    
print(ans)

Measured memory_bytes: 86384
# -*- coding : utf-8 -*-

def insertion_sort(list):
    for i in range(1, len(list)):
        key = list[i]
        j = i - 1
        show_list(list)
        while(j >= 0 and list[j] > key):
            list[j+1] = list[j]
            j = j - 1
        list[j+1] = key
    show_list(list)
    return list

def show_list(list):
    i = 0;
    while(i < len(list)-1):
        print(list[i], end=" ")
        i = i + 1
    print(list[i])

list_length = int(input())
list = [int(x) for x in input().split(" ")]
insertion_sort(list)

Measured memory_bytes: 8016
import itertools
import math
import sys
from collections import Counter
from fractions import gcd
from functools import reduce
import sys
sys.setrecursionlimit(4100000)
from functools import lru_cache

#ここから書き始める
s = input()
ans = 0

@lru_cache(maxsize=None)
def dfs(index, ret):
    if index == len(s) - 1:
        ret += s[index]
        ret2 = map(int, ret.split("+"))
        global ans
        ans += sum(ret2)
        return
    dfs(index + 1, ret + s[index]) or dfs(index + 1, ret + s[index] + "+")

dfs(0, "")
print(ans)


Measured memory_bytes: 67564
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define sz(a) (int)a.size()
#define de(a) cout<<#a<<" = "<<a<<endl
#define dd(a) cout<<#a<<" = "<<a<<" "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int P = 1e9 + 7;
inline int add(int a, int b) {if((a += b) >= P) a -= P; return a;}
inline int sub(int a, int b) {if((a -= b) < 0) a += P; return a;}
inline int mul(int a, int b) {return 1ll * a * b % P;}
inline int kpow(int a, int b) {int r=1;for(;b;b>>=1,a=mul(a,a)) {if(b&1)r=mul(r,a);}return r;}
//----
int n;
int main(){
	map<int, int> f;
	scanf("%d", &n);
	rep(i, 0, n) {
		int t;
		scanf("%d", &t);
		f[t]++;
	}
	int ans = 0;
	for(auto &it : f) {
		if(it.fi <= it.se)
			ans += it.se - it.fi;
		else
			ans += it.se;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 8228
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(), v.end()
#define PI 3.141592653589793238462643383279
typedef long long int ll;
typedef unsigned long long ull;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
typedef pair<ll,ll> P;
const long long MOD = 1e9+7;
const ll INF = 1LL << 60;

int main(){
    int n;
    cin >> n;
    int cnta = 0;
    int cntb = 0;
    for(int i = 0; i < n; i++){
        string a,b;
        cin >> a >> b;
        if(a < b){
            cntb += 3;
        }else if(b < a){
            cnta += 3;
        }else{
            cnta++;
            cntb++;
        }
    }
    cout << cnta <<" " << cntb << endl;
   

}


Measured memory_bytes: 3156
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<int> as(n + 1);
    for(int i = 0; i < n; i++){
        int a; cin >> a;
        as[a]++;
    }
    sort(as.rbegin(), as.rend());
    ll ans = 0;
    for(int i = k; i < n; i++){
        ans += as[i];
    }
    cout << ans << '\n';
}


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

#define int long long
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define DESYNC ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector< ii >
#define EPS 1e-9
#define INF 1e18
#define ROOT 1

using namespace std;

inline int mod(int n){ return (n%1000000007); }

int gcd(int a, int b){
  if(a == 0 || b == 0) return 0;
  if(b == 1) return b;
  else return gcd(b, a%b);
}

int32_t main(){
	DESYNC;
	int n;
	cin >> n;
	int mx = 0;
	for(int i=0; i<n; i++){
	  int x;
	  cin >> x;
	  mx += (x-1);
	}
	cout << mx << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#include<cmath>
#define mod 1000000007
#define ll long long int
#define int int64_t
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SORT(x) sort(all(x));
#define DSORT(x) sort(all(x), greater<>());
#define PI 3.14159265358979323846264338327950288
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
using namespace std;
bool prime(int n){for(int i=2;i<=sqrt(n);i++){if(n%i==0){return 0;}}return 1;}
void normal(int &a) {a=a%mod;(a<0)&&(a=a+mod);}
int Add(int a,int b) {a=a%mod,b=b%mod; normal(a),normal(b); return (a+b)%mod; }
int Sub(int a,int b) {a=a%mod,b=b%mod; normal(a),normal(b); a=a-b; normal(a); return a; }
int Mul(int a,int b) {a=a%mod,b=b%mod; normal(a),normal(b); return (a*b)%mod;}
int Pow(int n,int x){int res=1; while(x){ if(x&1) res=Mul(res,n); n=Mul(n,n); x=x>>1;} return res;} 
int modInverse(int n){return Pow(n,mod-2);}
int Div(int a,int b) { return Mul(a, modInverse(b));}
const int E3 = 1e3 + 7;
const int E4 = 1e4 + 7;
const int E5 = 1e5 + 7;
const int E6 = 1e6 + 7;
const int E9 = 1e9 + 7; 
signed main(){
    fio;
    string s;
    cin>>s;
    int n=s.size();
    int r=0;
    bool fl=false;
    int maxi=0;
    for(int i=0;i<n;i++){
        if(s[i]=='R'){
            r++;
            fl=true;
        }
        else{
            if(fl){
                maxi=max(maxi,r);
                r=0;
                fl=false;
            }
        }
    }
    if(fl){
                maxi=max(maxi,r);
                r=0;
                fl=false;
    }
    cout<<maxi;
    return 0;
}



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

int dp[100002], c, k, yukseklik[100002];

int mutlak(int e, int r){
	if(e>r)return e-r;
	else return r-e;
}


int main(void){
	cin>>c>>k;
	for(int i=1;i<=c;i++)cin>>yukseklik[i];
	memset(dp, 1e6, sizeof(int)*(c+1));
	dp[c]=0;
	if(k>c)k=c;
	for(int i=c-1;i>c-k;i--)for(int j=1;j<=c-i;j++)dp[i]=min(mutlak(yukseklik[i], yukseklik[i+j])+dp[i+j],dp[i]);
	for(int i=c-k;i>0;i--)for(int j=1;j<=k;j++)dp[i]=min(mutlak(yukseklik[i], yukseklik[i+j])+dp[i+j],dp[i]);
	cout<<dp[1];
	return 0;
}

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

int main(){
  const vector<string> results= {"AC", "WA", "TLE", "RE"};
  int N;
  cin >> N;

  unordered_map<string, int> data;
  for(auto result:results){
    data[result]= 0;
  }

  string buf;
  for(int i=0; i<N; i++){
    cin >> buf;
    data.at(buf)++;
  }
  
  for(auto result:results){
    cout << result <<" x "<< data.at(result) << endl;
  }
}

Measured memory_bytes: 3636
N,M = map(int,input().split())
s_num = N
cc_num = M // 2
# ccの方が少ない場合はその数が答え
if min(s_num,cc_num) == cc_num:
    print(cc_num)
    exit()
# sの方が少ない場合はいくつかのccをsに変えて補完したものが答え
scc_num = s_num
cc_remains = cc_num - scc_num
sep_2 = cc_remains // 2
scc_num += sep_2
print(scc_num)

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

int main() {
	int n;
	cin >> n;
	int cf = 0, c = 0;
	for (int i = 1; i <= n; i+=2) {
		for (int j = 1; j <= i; j++)
			if (i % j == 0)
				cf++;
		if (cf == 8)
			c++;
		cf = 0;
	}
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 256
import bisect
import math

n, m = map(int, input().split())
a = []
b = []
for i in range(n):
    aa, bb = map(int, input().split())
    a.append(aa)
    b.append(bb)

ma = max(a)
b = sorted(b)
mab = bisect.bisect_left(b, ma)
sb = sum(b[mab:])


def cut_throw(ma, sb):
    res = math.ceil((m - sb) / ma)
    return res

cnt = 0
if sb <= m:
    print(cut_throw(ma, sb) + n - mab)
else:
    for x in range(n - 1, -1, -1):
        m = m - b[x]
        cnt += 1
        if m <= 0:
            print(cnt)
            exit()


Measured memory_bytes: 12088
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 111;
int n;
int a[N];
int ans[N];

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", &a[i]);
	for (int k = n - 1; k >= 0; k--) {
		//cerr << k << endl;
		bool fnd = false;
		for (int i = k; i >= 0; i--) {
		//	cerr << i << " " << a[i] << endl;
			if (a[i] == i + 1) {
				//cerr << i + 1 << endl;
				fnd = true;
				ans[k] = i + 1;
				for (int j = i; j < k; j++)
					a[j] = a[j + 1];
				break;
			}
		}
		if (!fnd) {
			printf("-1\n");
			return 0;
		}
	}
	for (int i = 0; i < n; i++)
		printf("%d\n", ans[i]);

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int s;
  scanf("%d",&s);
  int a,b;
  a=s/100;
  b=s%100;

  if(1<=a && a<=12){
    if(1<=b && b<=12) puts("AMBIGUOUS");
    else puts("MMYY");
  }
  else if(1<=b && b<=12) puts("YYMM");
  else puts("NA");
  return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 256;
const int MAX_SAC = 15;

const double DINF = 1e70;

/* typedef */

typedef unsigned char uchar;

/* global variables */

int n;
uchar is[MAX_N];
int cnts[256];
double xs[MAX_N];

/* subroutines */

double entropy(int s, int a, int c) {
  uchar r = a * s + c;
  memset(cnts, 0, sizeof(cnts));

  for (int i = 0; i < n; i++) {
    uchar oi = is[i] + r;
    cnts[oi]++;
    r = a * r + c;
  }

  int k = 0;
  for (int i = 0; i < 256; i++)
    if (cnts[i] > 0)  {
      double d = (double)cnts[i] / n;
      xs[k++] = -d * log(d);
    }
  sort(xs, xs + k);
  
  double sum = 0.0;
  for (int i = 0; i < k; i++) sum += xs[i];

  return sum;
}

/* main */

int main() {
  for (;;) {
    cin >> n;
    if (n == 0) break;

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

    double min_e = DINF;
    int min_s, min_a, min_c;
    
    for (int s = 0; s <= MAX_SAC; s++)
      for (int a = 0; a <= MAX_SAC; a++)
	for (int c = 0; c <= MAX_SAC; c++) {
	  double e = entropy(s, a, c);
	  //printf("entropy(%d,%d,%d)=%.16lf\n", s, a, c, e);
	  if (min_e > e) {
	    min_e = e;
	    min_s = s, min_a = a, min_c = c;
	  }
	}

    printf("%d %d %d\n", min_s, min_a, min_c);
  }

  return 0;
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
LL M;
LL A[100001];
LL s[100001];
typedef pair<LL,int>P;
map<LL,int>m;
int main(){
	cin>>N>>M;
	LL ans=0;
	bool check=false;
	int cc=0;
	REP(i,N){
		cin>>A[i];
		/*if(A[i]%2==0){
			
		}*/
		if(i==0){
			s[i]=A[i];
			s[i]%=M;
		}else{
			s[i]=s[i-1]+A[i];
			s[i]%=M;
		}
		/*if(s[i]!=0){
			if(check==false){
				check=true;
				m[s[i]]+=cc;
			}
		}*/
		m[s[i]]++;
	}
	m[0]++;
	

	for(auto it:m){
		LL a=it.second;
		ans+=a*(a-1)/2;
	}
	cout<<ans<<endl;
	return(0);
}

Measured memory_bytes: 5760
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>

#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long

const int INF = 1e18;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;

//typedef pair<int, int> P;
//priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順
//cout << fixed << setprecision(10) << ans << endl;
//int gcd(int a,int b){return b?gcd(b,a%b):a;}

int a[100000];
signed main(){
    int n;
    cin >> n;
    for(int i=1;i<=100;i++){
        for(int j=1;j<=100;j++){
            for(int k=1;k<=100;k++){
                a[i*i+j*j+k*k+i*j+j*k+i*k] ++;

            }
        }
    }
    for(int i=1;i<=n;i++){
        cout <<a[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 4044
#include <stdio.h>

int main(){
	int N,M,C;
	int sum;
	int count =0;
	scanf("%d %d %d",&N,&M,&C);
	int B[M];
	for(int i=0;i<M;i++){
		scanf("%d",&B[i]);
	}
	
	int x;
	for(int i=0;i<N;i++){
		sum = 0;
		for(int j=0;j<M;j++){
			scanf("%d",&x);
			sum += x*B[j];
		}
		sum += C;
		if(sum>0)
			count++;
	}
	
	printf("%d",count);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k) for(int i=j; i<=k; i++)
#define FFOR(i, j, k) for(int i=j; i<k; i++)
#define DFOR(i, j, k) for(int i=j; i>=k; i--)
#define bug(x) cerr<<#x<<" = "<<x<<'\n'
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
template <typename T> inline void read(T &x){
    char c;
    bool nega=0;
    while((!isdigit(c=getchar()))&&(c!='-'));
    if(c=='-'){
        nega=1;
        c=getchar();
    }
    x=c-48;
    while(isdigit(c=getchar())) x=x*10+c-48;
    if(nega) x=-x;
}
template <typename T> inline void writep(T x){
    if(x>9) writep(x/10);
    putchar(x%10+48);
}
template <typename T> inline void write(T x){
    if(x<0){
        putchar('-');
        x=-x;
    }
    writep(x);
}
template <typename T> inline void writeln(T x){
    write(x);
    putchar('\n');
}
#define taskname "C"
char a[4];
int x[4];
int main(){
    #ifdef Megumin
        if(fopen(taskname".inp", "r"))
            freopen(taskname".inp", "r", stdin);
    #endif // Megumin
    FFOR(i, 0, 4){
        cin>>a[i];
        x[i]=a[i]-48;
    }
    FFOR(s, 0, 8){
        int ans=x[0];
        FFOR(j, 0, 3){
            if((s>>j)&1) ans-=x[j+1];
            else ans+=x[j+1];
        }
        if(ans==7){
            FFOR(j, 0, 3){
                cout<<a[j];
                if((s>>j)&1) cout<<'-';
                else cout<<'+';
            }
            cout<<x[3]<<"=7";
            return 0;
        }
    }
}

Measured memory_bytes: 256