akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.StringJoiner;
import java.util.function.IntUnaryOperator;
import java.util.function.LongUnaryOperator;

class Main {
    static In in = new In();
    static Out out = new Out();
    static int mod = 10000000;
    static long inf = 0xfffffffffffffffL;

    void solve() {
        int h = in.nextInt();
        int a = in.nextInt();
        System.out.println((h + a - 1) / a);
    }

    public static void main(String[]$) {
        new Main().solve();
        out.flush();
    }
}

class In {
    private BufferedInputStream reader = new BufferedInputStream(System.in);
    private byte[] buffer = new byte[0x10000];
    private int i = 0;
    private int length = 0;

    private int read() {
        if (i == length) {
            i = 0;
            try {
                length = reader.read(buffer);
            } catch (IOException ignored) {
            }
            if (length == -1) {
                return -1;
            }
        }
        return buffer[i++];
    }

    String next() {
        StringBuilder builder = new StringBuilder();
        int b = read();
        while (b < '!' || '~' < b) {
            b = read();
        }
        while ('!' <= b && b <= '~') {
            builder.appendCodePoint(b);
            b = read();
        }
        return builder.toString();
    }

    int nextInt() {
        return (int)nextLong();
    }

    long nextLong() {
        int b = read();
        while (b < '!' || '~' < b) {
            b = read();
        }
        int i = 0;
        if (b == '-') {
            i = 1;
            b = read();
        }
        long n = 0;
        while ('0' <= b && b <= '9') {
            n = n * 10 + b - '0';
            b = read();
        }
        return i == 0 ? n : -n;
    }

    char[][] nextCharArray(int n, int m) {
        char[][] a = new char[n][m];
        for (int i = 0; i < n; i++) {
            a[i] = next().toCharArray();
        }
        return a;
    }

    int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    int[] nextIntArray(int n, IntUnaryOperator op) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsInt(nextInt());
        }
        return a;
    }

    long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextLong();
        }
        return a;
    }

    long[] nextLongArray(int n, LongUnaryOperator op) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsLong(nextLong());
        }
        return a;
    }
}

class Out {
    private static PrintWriter out = new PrintWriter(System.out);

    void println(Object... a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (Object obj : a) {
            joiner.add(String.valueOf(obj));
        }
        out.println(joiner);
    }

    void flush() {
        out.flush();
    }
}


Measured memory_bytes: 22612
"use strict";

const main = arg => {
    arg = arg.trim().split("\n");
    const X = parseInt(arg[0].split(" ")[0]);
    
    for(let i=-200; i<200; i++) {
        for(let j=-200; j<200; j++) {
            if(Math.pow(i, 5) - Math.pow(j, 5) === X) {
                console.log(i + " " + j);
                return;
            }
        }
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 33216
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int a,b,c,d,e,i,j;
cin>>a>>b>>c>>d;
i=a*c;
i=max(i,a*d);
i=max(i,b*c);
i=max(i,b*d);cout<<i<<endl;

}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
//#include <atcoder/all>

using namespace std;
//using namespace atcoder;
using usize = ::std::size_t;
using u64 = ::std::int_least64_t;
//using u64 = long long;
static constexpr u64 Inf = ::std::numeric_limits<u64>::max() / 2;

u64 gcd(u64 a, u64 b) { return a ? gcd(b % a, a) : b; }


int main(int argc, char *argv[])
{
    
    cin.tie(0) ;
    ios::sync_with_stdio(false) ;
    
    int N, M;
    cin >> N >> M;
    vector<u64> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    u64 lcm = (u64) a[0];
    for (int i = 1; i < N; i++) {
        lcm = (u64) lcm * a[i] / gcd((u64) a[i], lcm);
    }
    u64 base = lcm / a[0];
    for (int i = 1; i < N; i++) {
        u64 current = lcm / a[i];
        if (base % 2 != current % 2) {
            cout << 0 << endl;
            return 0;
        }
    }
    
    u64 max_value = (u64) 2*M;
    
    u64 ans;
    ans = max_value / lcm;
    ans = (ans % 2 == 0) ? (u64) ans/2 : (u64) ans/2 + 1;
    cout << ans << endl;
    
    return 0;
    
}


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

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

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;

long P = 10^^9+7;
long[10^^5+50] F, RF;

long pow(long x, long n) {
    long y = 1;
    while (n) {
        if (n%2 == 1) y = (y * x) % P;
        x = x^^2 % P;
        n /= 2;
    }
    return y;
}

long inv(long x)
{
    return pow(x, P-2);
}

void init()
{
    F[0] = F[1] = 1;
    foreach (i, ref x; F[2..$]) x = (F[i+1] * (i+2)) % P;

    {
        RF[$-1] = 1;
        auto x = F[$-1];
        auto k = P-2;
        while (k) {
            if (k%2 == 1) RF[$-1] = (RF[$-1] * x) % P;
            x = x^^2 % P;
            k /= 2;
        }
    }
    foreach_reverse(i, ref x; RF[0..$-1]) x = (RF[i+1] * (i+1)) % P;
}

long comb(N)(N n, N k)
{
    if (k > n) return 0;
    auto n_b = F[n];    // n!
    auto nk_b = RF[n-k]; // 1 / (n-k)!
    auto k_b = RF[k];    // 1 / k!

    auto nk_b_k_b = (nk_b * k_b) % P; // 1 / (n-k)!k!

    return (n_b * nk_b_k_b) % P;  // n! / (n-k)!k!
}

void main()
{
    init();
    auto N = readln.chomp.to!long;
    auto xs = readln.split.to!(long[]);

    long r, x;
    foreach (i; 1..N) {
        auto d = xs[i] - xs[i-1];
        (x += F[N-1] * inv(i)) %= P;
        (r += x * d) %= P;
    }
    writeln(r);
}

Measured memory_bytes: 7720
#include "bits/stdc++.h"

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl

typedef pair<int, int> P;
typedef long long ll;

int s, a, ans;
int i = 0;
vector<int> v;
bool flag = false;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>s;
    while(1){
        if(i == 0) {
            a = s;
            v.push_back(a);
            i++;
        }
        else{
            if(a%2 == 0) a = a/2;
            else a = 3*a + 1;
            v.push_back(a);
            for(int j = i-1; j>=0; j--){
                if(v[j] == v[i]){
                    ans = i + 1;
                    flag = true;
                }
                else continue;
            }
            i++;
        }
        if(flag == true) break;
    }
    print(ans);
    return 0;
}


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

int main()
{
  int A, B;
  cin >> A >> B;

  if (1 <= A && A <= 9 && 1 <= B && B <= 9)
  {
    cout << A * B << endl;
  }
  else
  {
    cout << -1 << endl;
  }
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    int a, b; cin >> a >> b;
    int q; cin >> q; 
    vector<ll> s(a), t(b);
    for(int i = 0; i < a; i++){
        cin >> s.at(i);
    }
    for(int i = 0; i < b; i++){
        cin >> t.at(i);
    }
    for(int i = 0; i < q; i++){
        int sh, ch;
        ll dist; cin >> dist;
        sh = lower_bound(s.begin(), s.end(), dist) - s.begin();
        ch = lower_bound(t.begin(), t.end(), dist) - t.begin();
        ll ans = 1001001001001;
        for(int j = 0; j <= 1; j++){
            for(int k = 0; k <= 1; k++){
                int sht = sh - j;
                int cht = ch - k;
                if(sht < 0 || cht < 0 || sht >= a || cht >= b) continue;
                ans = min(ans, abs(dist - s.at(sht)) + abs(s.at(sht) - t.at(cht)));
                ans = min(ans, abs(dist - t.at(cht)) + abs(s.at(sht) - t.at(cht)));
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 4784
/****************************************************************************************
	test003.c: #003 ITP1_1_C
	  function: Rectangle

 ****************************************************************************************/
#include <stdio.h>          // printf(), scanf()

int
main(int argc, char** argv)
{
	int a, b;

	scanf("%d %d", &a, &b);
	printf("%d %d\n", a * b, (a + b) * 2);
	return 0;
}

Measured memory_bytes: 596
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Transformation
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            List<string> inputList = new List<string>();

            foreach (char item in input)
            {
                inputList.Add(item.ToString());
            }

            int row = int.Parse(Console.ReadLine());

            for (int i = 0; i < row; i++)
            {
                string[] temp = Console.ReadLine().Split(' ');
                int idx1 = int.Parse(temp[1]);
                int idx2 = int.Parse(temp[2]);

                if (temp[0].Equals("replace"))
                {
                    int count = idx1;
                    foreach (char item in temp[3])
                    {
                        inputList.Insert(count, item.ToString());
                        ++count;
                    }
                    
                    for (int j = 0; j <= idx2 - idx1; ++j)
                    {
                        inputList.RemoveAt(idx2+1);
                    }
                }
                else if (temp[0].Equals("reverse"))
                {
                    for (int j = 0; j <= 2*(idx2 - idx1); j+=2)
                    {
                        inputList.Insert(idx1, inputList[idx1 + j]);
                    }

                    for (int j = 0; j <= idx2 - idx1; ++j)
                    {
                        inputList.RemoveAt(idx2+1);
                    }
                }
                else
                {
                    for (int j = idx1; j <= idx2; ++j)
                    {
                        Console.Write(inputList[j]);
                    }
                    Console.WriteLine();
                }
            }
        }
    }
}



Measured memory_bytes: 17964
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(ll i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
#define INF 1000000000000000LL
const ll MOD = 1000000007;
const double PI = acos(-1);
//or-> ||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl

signed main(){
	IO_STREAM;
	ll N,K;
	cin>>N>>K;
	int digit;
	rep(i,0,100){
		if(N<pow(K,i)){
			digit=i;
			break;
		}
	}
	DBG("","","","");
	cout<<digit<<endl;
	return 0;
}


Measured memory_bytes: 512
/*********************
*  Author: xuziyuan  * 
*********************/

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

LL n,t,a[110],dp[110][100010],sum[100010];

int main()
{
  cin>>n>>t;
  rep(i,n) cin>>a[i];
  dp[0][t]=1;
  rep(i,n)
  {
    memset(sum,0,sizeof(sum));
    repn(j,t+1) sum[j]=(sum[j-1]+dp[i][j-1])%MOD;
    rep(j,t+1) dp[i+1][j]=(sum[min(t+1,j+a[i]+1)]-sum[j]+MOD)%MOD;
  }
  cout<<dp[n][0]<<endl;
  return 0;
}

Measured memory_bytes: 79360
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
long long mx(long long a,long long b){if(a>b)return a;else return b;}
long long mn(long long a,long long b){if(a<b)return a;else return b;}
long long cei(long long a,long long b){if(a%b==0)return a/b;else return (a/b+1);}
const int MOD=1e9+7;
long long po(long long a,long long b){long long res=1;while(b>0){res=(res*a);res%=MOD;b--;}return res;}


int main()
{
int x;
cin>>x;
if(x>=30)cout<<"Yes"<<endl;
else
cout<<"No"<<endl;



}

Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
#include<time.h>
#include<string>
#include<stack>
#include<cmath>
#include<map>
#include<set>
#define int long long
//#define double long double
using namespace std;
#define PI  3.1415926535898 
#define eqs 1e-6
const long long max_ = 2e5 + 7;
const int mod = 1e9 + 7;
const int inf = 1e9;
const long long INF = 1e18;
int read() {
	int s = 0, f = 1;
	char ch = getchar();
	while (ch<'0' || ch>'9') {
		if (ch == '-')
			f = -1;
		ch = getchar();
	}
	while (ch >= '0'&&ch <= '9') {
		s = s * 10 + ch - '0';
		ch = getchar();
	}
	return s * f;
}
int min(int a, int b) {
	return a < b ? a : b;
}
int max(int a, int b) {
	return a > b ? a : b;
}
int n, k, zhen[max_], fu[max_], zn, fn, zeronum = 0;;
bool solzhen(int stander) {
	int num = zeronum * (zn + fn);
	if (zeronum >= 2)num += (((zeronum - 2) * (zeronum - 1)) / 2) + (zeronum - 1);
	for (int i = 2; i <= zn; i++) {
		if (zhen[i] > stander)break;
		if (zhen[i] * zhen[i] <= stander) {
			num += i - 1; continue;
		}
		int wei = upper_bound(zhen + 1, zhen + 1 + i - 1, stander / zhen[i]) - zhen;
		if (wei == i || zhen[wei] * zhen[i] > stander)wei--;
		num += wei;
	}
	//正正算完了

	num += fn * zn;//负正算完了

	for (int i = 1; i < fn; i++) {
		if (-fu[i] > stander)continue;
		if (fu[i] * fu[i] <= stander) {
			num += (fn - i); continue;
		}
		int wei = lower_bound(fu + i + 1, fu + 1 + fn, stander / fu[i]) - fu;
		/*int t =stander / fu[i];
		if(t * fu[i] )
		int wei = lower_bound(fu + i, fu + 1 + fn, t) - fu;*/
		num += (fn - wei + 1);
	}
	//负负
	if (num >= k)return true;
	return false;
}
bool solfu(int stander) {
	int num = 0;//只需要算负数与正数的
	for (int i = 1; i <= fn; i++) {
		if (fu[i] <= stander) {
			num += zn; continue;
		}
		int wei = lower_bound(zhen + 1, zhen + 1 + zn,stander / fu[i]) - zhen;
		while (wei <= zn && zhen[wei] * fu[i] > stander) wei++;
		num += (zn - wei + 1);
	}
	if (num >= k)return true;
	return false;
}
bool judge(int stander) {
	if (stander >= 0) {
		return solzhen(stander);
	}
	else {
		return solfu(stander);
	}
}
int erfen(int L, int R) {
	if (L == R)return L;
	if (L > R)return L - 1;
	int mid = L + (R - L) / 2;
	if (judge(mid)) {
		//能够满足大于等于第k大
		return erfen(L, mid);
	}
	else {
		return erfen(mid + 1, R);
	}
}
signed main() {
	n = read(), k = read();

	for (int i = 1; i <= n; i++) {
		int t = read();
		if (t == 0) {
			zeronum++;
		}
		else
			if (t > 0) {
				zhen[++zn] = t;
			}
			else {
				fu[++fn] = t;
			}
	}
	sort(zhen + 1, zhen + 1 + zn);
	sort(fu + 1, fu + 1 + fn);
	//cout << erfen(4, 5);
	printf("%lld", erfen(-INF, INF));
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
using namespace std;
int n, s, a[205];
int main() {
	int i;
	cin>>n;
	for(i=0; i<2*n; i++) cin>>a[i];
	sort(a, a+2*n);
	for(i=0; i<2*n; i+=2) s += a[i];
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
using namespace std;

#define INF (1ll<<60)


long long M = 1000000007;


int main(int argc, char const *argv[]) {
    int n;cin>>n;
    vector<long long> a(n),b(n);
    for(int i=0;i<n;++i)cin>>a[i];
    long long res = 0;
    map<long long,int> ma;
    for(int i=0;i<n;++i){
        ma[a[i]]=i;
    }
    sort(a.begin(),a.end());
    for(int i=0;i<n;++i){
        b[ma[a[i]]]=i;
    }
    for(int i=0;i<n;++i)res+=(i+b[i])%2;
    cout<<res/2<<endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;

const int MM = 1e9 + 7;
const double eps = 1e-8;
const int MAXN = 2e6 + 10;

int n, m;

void prework(){

}

void read(){

}

int a[MAXN], b[MAXN];

void solve(int casi){
//	cout << "Case #" << casi << ": ";
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	scanf("%d", &m);
	for (int i = 1; i <= m; i++)
		scanf("%d", &b[i]);
	sort(a + 1, a + n + 1);
	sort(b + 1, b + m + 1);
	for (int i = 1, j = 1; i <= m; i++){
		while(j <= n && a[j] != b[i]){
			j++;
		}
		if (j > n){
			puts("NO");
			return ;
		}
		j++;
	}
	puts("YES");
}

void printans(){

}


int main(){
//	std::ios::sync_with_stdio(false);
	prework();
	int T = 1;
//	cin>>T;
	for(int i = 1; i <= T; i++){
		read();
		solve(i);
		printans();
	}
	return 0;
}

Measured memory_bytes: 5120
#include <iostream>
using namespace std;
int main(){
	int n,a,b,max,min;
	cin>>n>>a>>b;
	max=b-a;
	min=a;
	if (a>b)min=b;
	for (int i=1;i<n-1;i++) {
		cin>>a;
		if (max<a-min)max=a-min;
		if (min>a)min=a;
	}
	cout<<max<<endl;
	return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int x;
	int ans=0;

	cin >>x;
	cout<<solve(x >=30)<<endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll m,n;cin>>m>>n;
  vi A(n);
  for(auto &a:A)cin>>a;
  ll ans=0;
  ll now=A[0];
  ll cnt=1;
  if(m==2){
    ll ans=llINF;
    ll sum=0;
    for(int i=0;i<n;i++){
      if(i%2)sum+=(A[i]==1);
      else sum+=(A[i]==2);
    }
    ans=sum;
    sum=0;
    for(int i=0;i<n;i++)
      if(i%2)sum+=(A[i]==2);
      else sum+=(A[i]==1);
    ans=min(ans,sum);
    cout<<ans<<endl;return 0;
  }
  for(int i=1;i<n;i++){
    if(A[i]==now){cnt++;
    }else{
      ans+=cnt/2;
      now=A[i];
      cnt=1;
    }
  }
  if(cnt>1)ans+=cnt/2;
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3632
#include <stdio.h>

int main(void)
{
  // n players
  int n;
  scanf("%d", &n);

  int a[n][n-1];
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < n-1; j++) {
      scanf("%d", &a[i][j]);
    }
  }

  int progress[n];
  int progress_temp[n];
  for(int i = 0; i < n; i++) {
    progress[i] = 0;
  }

  int is_there_a_match_today = 1;
  int day = 0;

  while(is_there_a_match_today) {

    is_there_a_match_today = 0;

    for(int i = 0; i < n; i++) {
      progress_temp[i] = progress[i];

      if(progress[i] > n-2) {
        continue;
      }

      int opponent = a[i][progress[i]] - 1;

      if(progress[opponent] > n-2) {
        continue;
      }

      if(a[opponent][progress[opponent]] == i+1) {
        progress_temp[i] = progress[i] + 1;
        is_there_a_match_today = 1;
      }
    }

    for(int i = 0; i < n; i++) {
      progress[i] = progress_temp[i];
    }

    day++;
  }

  day--;

  for(int i = 0; i < n; i++) {
    if(progress[i] < n-2) {
      printf("-1\n");
      return 0;
    }
  }

  printf("%d\n", day);
  return 0;
}


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

int main()
{
	int a, b, c, d, e, k;
	int ca=0;
	cin >> a >> b >> c >> d >> e >> k;
	int p[10] = { b - a,c - a,d - a,e - a,c - b,d - b,e - b,d - c,e - c,e - d };
	for (int i = 0; i < 10;i++ ) {
		if (p[i] <= k) {
			ca++;
		}
		else { 
			cout << ":(" << endl; 
			break;
		}
	}
	if(ca==10){ cout << "Yay!" << endl; }
		
	return 0;
	
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <map>
#include <numeric>
#include <sstream>
#include <queue>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()
#define print(s) cout << (s) << endl
#define printV(v) for(int zxc=0;zxc<v.size()-1;zxc++){cout << v[zxc] << " ";} cout << v.back() << endl;

typedef pair<int, int> t;

int main() {
    vector<int> v;
    PUSH(3,v);
    sort(ALL(v));
    
    if (v[0] == v[2]) {
        print(1);
    }else if (v[0] == v[1] || v[1] == v[2]) {
        print(2);
    }else {
        print(3);
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
 
#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) < (b) ? (a) : (b))
 
int main(){
    int i,n,a[100],t[100],u[100],ch,s,total;
        while(1){
        scanf("%d",&n);
        if(n==0) break;
                for(total=0,i=0;i<n;i++){
                        scanf("%d",&a[i]);
                }
                        memcpy(t,a,sizeof(a[0]) * 100);
                        memcpy(u,a,sizeof(a[0]) * 100);
                for(i=0;i<n-1;i++){
                        t[i+1] = max(t[i],t[i+1]);
                        u[i+1] = min(u[i],u[i+1]);
                }
                for(i=0;i<n;i++) total+=a[i];
                printf("%d\n",(total-t[n-1]-u[n-1])/(n-2));
        }
        return 0;               
}

Measured memory_bytes: 600
(defun split-string (str)                                                                     
  (let ((string-position (position #\Space str)))
    (cond
      ((null string-position) (list str))
      (t (cons (subseq str 0 string-position) (split-string (subseq str (1+ string-position)))))
      )))

(defun readline-to-list ()
  (let ((str (read-line *standard-input* nil)))
    (cond
      ((null str) nil)
      ((string= str "") nil)
      (t (cons str (readline-to-list))))))


(defun MaximumSum (k a b c)
  (let* ((sortedList (sort (list (parse-integer c) (parse-integer b) (parse-integer a)) #'>)) (m (car sortedList)))
    (dotimes (i (parse-integer k)) (setf m (* 2 m)))
     (format t "~A~%" (+ m (cadr sortedList) (caddr sortedList)))))

(let* ((r-list (readline-to-list))
       (tmp (split-string (car r-list)))
       (real-list (cons (cadr r-list) tmp)))
  (apply #'MaximumSum real-list))



Measured memory_bytes: 16104
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    vector<P> red, blue;
    vector<ll> used;
    REP(i,n) {
        int a,b;
        cin >> a >> b;
        red.emplace_back(a,b);
    }
    REP(i,n) {
        int c, d;
        cin >> c >> d;
        blue.emplace_back(c,d);
    }

    sort(red.begin(), red.end());
    sort(blue.begin(), blue.end());

    int ans = 0;
    // x座標が小さい順に見ていく
    REP(i,n) {
        vector<ll> ymax;
        REP(j,n) {
            if (red[j].first >= blue[i].first) break;
            if (blue[i].second >= red[j].second) {
                ymax.push_back(red[j].second);
            }
        }
        sort(ymax.begin(), ymax.end(), greater<>());
        sort(used.begin(), used.end());
        for (auto&& e:ymax) {
            if (!binary_search(used.begin(), used.end(), e)) {
                ++ans;
                used.push_back(e);
                break;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<deque>
#include<sstream>
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<bitset>
#include<time.h>
#include<cstdlib>
#include<cassert>
#define ll long long
#define fi first
#define se second
using namespace std;
                   
int n,m;
string s;
map<int,int> mp;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout<<fixed;
#ifdef LOCAL_DEFINE
    freopen("in", "r", stdin); 
    freopen("out","w",stdout);
#endif
  cin>>s;
  n=(int)s.length();
  string t="";
  int cont=0;
  for(int i=(int)s.length()-1;i>=0;i--){
    t+=s[i];
    if(s[i]!='x'){mp[cont]=i;cont++;}
  }
  if(s==t){
    cout<<0<<endl;
    return 0;
  }
  string test="";
  for(int i=0;i<n;i++){
    if(s[i]!='x')test+=s[i];
  }
  string rtest="";
  for(int i=(int)test.length()-1;i>=0;i--){
    rtest+=test[i];
  }
  if(test!=rtest){
    cout<<-1<<endl;
    return 0;
  }
  //int center=(int)test.length()/2;
  vector<bool> v[100001];
  int now=0;
  for(int i=0;i<n;i++){
    if(s[i]!='x'){
      now++;
    }else{
      v[now].push_back(1);
    }
  }
  int ans=0;
  //cout<<now<<endl;
  //for(int i=0;i<=now;i++){
   // cout<<v[i].size()<<endl;
 // }
  for(int i=0;i<=now;i++){
    ans+=abs((int)v[i].size()-(int)v[now-i].size());
  }
  cout<<ans/2<<endl;
  /*int cont;
  if((int)test.length()&1){
    cont=(int)test.length()/2;
  }else{
    cont=(int)test.length()/2;
  }
  bool flag1=0;
  if((int)test.length()&1){
    flag1=1;
  }
  stack<char> st;
  int last1=0,last2=0;
  int nowcont=0;
  //string stt="";
  for(int i=0;;i++){
    if(s[i]!='x'){
      if(nowcont+1==cont){
        last1=i;
      }
      if(nowcont==cont){
        last2=i;
        break;
      }
      nowcont++;
    }
  }
  //cerr<<1<<endl;
  int last;
  //bool flag=0;
  if((last1+last2)%2==0){
    //flag=1;
    last=(last1+last2)/2;
  }else{
    last=(last1+last2)/2;
  }
  if(flag1){
    last=last2;
  }
  for(int i=0;i<last;i++){
    //stt+=s[i];
    st.push(s[i]);
  }
  //cout<<stt<<endl;
  int ans=0;
  //cerr<<2<<endl;
  last++;
  //cout<<"last="<<last<<endl;
    for(int i=last;i<n;i++){
      if(st.size()==0 || st.top()!=s[i]){
        ans++;
      }else{
        st.pop();
      }
    }
  cout<<ans+st.size()<<endl;*/
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}

Measured memory_bytes: 8656
#include<bits/stdc++.h>
using namespace std;
int gcd(int x,int y)
{
	return (y==0?x:gcd(y,x%y));
}
typedef long long ll;
typedef pair<int,int> pii;
#define mp make_pair
const int N=2020;
const int V=40020;
int n,m;
int a[N];
bool b[N][N];
int ans[N];
bool inAns[N];
int ansSz=0;
int lastNotCoprime[N];
int minOnSuff[N];
int comp[V];
vector<int> g[V];
int C;
int bestForCol[N];
map<int,int> primeId;
int getId(int y)
{
	if(primeId.count(y)>0) return primeId[y];
	primeId[y]=m;
	return m++;
}
void dfs(int v)
{
	comp[v]=C;
	for(int u:g[v])
	{
		if(u<n&&inAns[u]) 
			continue;
		if(comp[u]!=-1) 
			continue;
		dfs(u);
	}
	return;
}
void color()
{
	for(int i=0;i<m;i++)
		comp[i]=-1;
	C=0;
	for(int i=0;i<n;i++)
	{
		if(inAns[i]) 
			continue;
		if(comp[i]!=-1) 
			continue;
		dfs(i);
		C++;
	}
	return;
}

int main()
{
	scanf("%d",&n);
	m=n;
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		int x=a[i];
		for(int y=2;y*y<=x;y++)
		{
			if(x%y!=0) 
				continue;
			int id=getId(y);
			g[id].push_back(i);
			g[i].push_back(id);
			while(x%y==0) 
				x/=y;
		}
		if(x!=1)
		{
			int id=getId(x);
			g[id].push_back(i);
			g[i].push_back(id);
		}
	}
	for(int i=0;i<n;i++) 
		for(int j=i+1;j<n;j++) 
			if(gcd(a[i],a[j])>1) 
				b[i][j]=b[j][i]=true;
	for(int i=0;i<n;i++) 
		minOnSuff[i]=1e9+2;
	for(int i=0;i<n;i++) 
		lastNotCoprime[i]=-1;
	while(ansSz!=n)
	{
		color();
		for(int i=0;i<C;i++)
			bestForCol[i]=-1;
		for(int i=0;i<n;i++)
		{
			if(inAns[i]) 
				continue;
			if(minOnSuff[lastNotCoprime[i]+1]<a[i]) 
				continue;
			if(bestForCol[comp[i]]==-1||a[bestForCol[comp[i]]]>a[i])
				bestForCol[comp[i]]=i;
		}
		int id=-1;
		for(int i=0;i<C;i++)
		{
			if(bestForCol[i]==-1) 
				continue;
			if(id==-1||a[bestForCol[i]]>a[id])
				id=bestForCol[i];
		}
		if(id==-1) 
			throw;
		inAns[id]=true;
		ans[ansSz++]=a[id];
		for(int i=0;i<ansSz;i++)
			minOnSuff[i]=min(minOnSuff[i],a[id]);
		for(int i=0;i<n;i++) 
			if(b[id][i])	
				lastNotCoprime[i]=ansSz-1;
	}
	for(int i=0;i<ansSz;i++)
		printf("%d ",ans[i]);
	printf("\n");
	return 0;
}


Measured memory_bytes: 5504
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  vector<int>P(N);
  for(int i=0;i<N;i++)
    cin>>P.at(i);
  map<int,int>M;
  for(int i=0;i<N;i++){
  if(!M.count(P.at(i)-1))
    M[P.at(i)]=1;
    else
      M[P.at(i)]=M.at(P.at(i)-1)+1;
  }int Max=0;
  for(auto p:M){
  auto k=p.first;
    auto v=p.second;
    if(Max<v)
      Max=v;
}int ans=N-Max;
  cout<<ans<<endl;
  
   return 0;
}

Measured memory_bytes: 10368
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=n-1; i>=m; i--)
#define SORT(v,n) do{sort(v,v+n);reverse(v,v+n);}while(0)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x%MOD,n/2);
  return x*POW(x,n-1)%MOD;
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}

ll ORD(ll x,ll n)
{
  if(x==0)return INF;
  if(x%n!=0)return 0;
  return 1+ORD(x/n,n);
}

int main()
{
  ll n;
  string s;
  cin >> s;
  n=s.length();
  FOR(i,1,n){
    if((n-i)%2==0){
      rep(j,(n-i)/2){
        if(s[j]!=s[j+(n-i)/2])goto A;
      }
      printf("%lld",n-i);
      return 0;
    }
    A:;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>

using namespace std;

const int INF = 1e9 + 239;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vector<int> a(n);
    for (auto &t : a) {
    	cin >> t;
    }
    vector<int> dp(n + 1, -INF);
    dp[0] = 0;
   	for (auto t : a) {
   		dp[t] = max(dp[t], dp[t - 1] + 1);
   	}
   	int ans = *max_element(dp.begin(), dp.end());
   	if (ans == 0) {
   		cout << -1 << endl;
   	} else {
   		cout << n - ans << endl;
   	}
}


Measured memory_bytes: 1792
function main(input){
  const A = parseInt(input.split(" ")[0],10);
  const B = parseInt(input.split(" ")[1],10);
  if(A>B){
    console.log(2*A-1);
  }else if(A<B){
    console.log(2*B-1);
  }else{
    console.log(2*A);
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int n = Integer.parseInt(sc.next());

        List<Integer> list = new ArrayList<>();
        for(int i=0; i<n; i++){
            list.add(Integer.parseInt(sc.next()));
        }
        
        int count=0;
        int flag=1;
        int i=0;
        
        while(flag==1){
            flag = 0;
            for(int j = n-1; j>=i+1; j--){
                if(list.get(j) < list.get(j-1)){
                    int temp1=list.get(j);
                    int temp2=list.get(j-1);
                    list.set(j,temp2);
                    list.set(j-1,temp1);
                    flag=1;
                    count++;
                }
            }
            i++;
        }
        
        //output
        StringBuilder sb = new StringBuilder();
        for(Integer output:list){
            sb.append(output).append(" ");
        }
        sb.deleteCharAt(sb.length()-1);
        sb.append("\n").append(count);
        System.out.println(sb);
    }
}




Measured memory_bytes: 26340
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

int n, m, a;
struct Data {
    int h, p, q;
};

bool cmp(const Data &l, const Data &r) {
    return l.h > r.h;
}

int main() {
    while(1) {
        cin >> n >> m >> a;
        if(n == 0 && m == 0 && a == 0) break;
        a--;
        vector<Data> amida(m);
        for(int i = 0; i < m; ++i) {
            int ch, cp, cq;
            cin >> ch >> cp >> cq;
            cp--; cq--;
            Data indata; indata.h = ch; indata.p = cp; indata.q = cq;
            amida[i] = indata;
        }
        sort(amida.begin(), amida.end(), cmp);
        for(int i = 0; i < m; ++i) {
            if(amida[i].p == a) a = amida[i].q;
            else if(amida[i].q == a) a = amida[i].p;
        }
        cout << a+1 << endl;
    }
}


Measured memory_bytes: 3032
n, k = map(int, input().split())
s = input()

if s[k-1] == 'A':
  mid = 'a'

if s[k-1] == 'B':
  mid = 'b'

if s[k-1] == 'C':
  mid = 'c'

ans = s[:k-1]+ mid + s[k:] 
  
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const

template<typename... Types>
struct dynarr: std::vector<Types...> {
  using std::vector<Types...>::vector;
  using size_type = typename std::vector<Types...>::size_type;
  auto&& operator[](size_type i) { return this->at(i); }
  auto&& operator[](size_type i) const { return this->at(i); }
};

i64 ch(i64 a, i64 b) {
  return a / b;
}

int main() {
  i64 n, k;
  cin >> n >> k;
  vector<i64> a(n), f(n);
  rep(i,0,n) cin >> a[i];
  rep(i,0,n) cin >> f[i];
  sort(all(a));
  sort(all(f));
  reverse(all(f));
  i64 ok = 1e18;
  i64 ng = -1;
  while(ok - ng > 1) {
    i64 mid = (ok + ng) / 2;
    i64 VE = true;
    i64 now = k;
    for(i64 i = 0;i < n;i++) {
      i64 kk = a[i] - ch(mid, f[i]);
      kk = std::max(0ll, kk);
      if(kk <= now) {
        now -= kk;
      }
      else {
        VE = false;
        break;
      }
    }
    if(VE) {
      ok = mid;
    }
    else {
      ng = mid;
    }
  }
  cout << ok << endl;
}


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

// DPを使う方法
//  DP[i][j] : S[i:] と S[j:] の最長共通連続文字列

int main() {
  int N;
  string S;
  cin >> N >> S;
  vector< vector<int> > DP(N+2, vector<int>(N+2,0));

  int cmax = 0;
//  for( int i= N-1; i>=0; --i ) {
//    for( int j= N-1; j>i; --j ) {
//      if ( S[i] == S[j] ) DP[i][j] = max( DP[i][j], DP[i+1][j+1] + 1);
//      else DP[i][j] = 0;
//      cmax = max( cmax, min(DP[i][j],j-i) );
  for( int i=0; i<N; ++i ) {
    for( int j=i+1 ; j<N; ++j ) {
      if ( S[i] == S[j] ) DP[i+1][j+1] = max( DP[i+1][j+1], DP[i][j] + 1);
      else DP[i+1][j+1] = 0;
      cmax = max( cmax, min(DP[i+1][j+1],j-i) );
    }
  }
  cout << cmax << endl;
}


Measured memory_bytes: 98176
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        private static void Yes() { print("YES"); }
        private static void No() { print("NO"); }
        private static void print(object obj) { Console.WriteLine(obj); }

        static void Main(string[] args)
        {
            var a = ReadInts();
            if ((a[0] * 100 + a[1] * 10 + a[2]) % 4 == 0)
            {
                Yes();
            }
            else
            {
                No();
            }

        }
    }
}

Measured memory_bytes: 11092
#include <stdio.h>

int main() {

  int m, f, r;
  int x;
  while(1) {

    scanf("%d %d %d", &m , &f , &r);
    x = m + f;
    if(m == -1 && f ==-1 && r == -1) {
      break;
    }
    if(m == -1 || f == -1) {
      printf("F\n");
    } else if(x >= 80) {
      printf("A\n");
    } else if (x >= 65 && x <80) {
      printf("B\n");
    } else if(x >= 50 && x < 65 ) {
      printf("C\n");
    } else if ( x >=30 && x < 50) {
      if(r >= 50) {
	printf("C\n");
      } else {
	printf("D\n");
      }
    } else if (m + f < 30) {
      printf("F\n");
    }
  }
  return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rep2(i, a, b) for(int i = (a); i <= (b); ++i)

short a[550][550];
int b[550];
char buff;
array<short, 1 << 22> dp, nxt;
main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    while(1) {
        int n, m;
        cin >> n >> m;
        if(!n) return 0;
        rep(i, n) rep(j, m) {
            cin >> buff;
            a[i][j] = buff - '0';
        }
        if(n < m) {
            int ans = 0;
            rep(mask, 1 << n) {
                if(ans > __builtin_popcount(mask)) continue;
                rep(i, m) b[i] = 0;
                rep(i, n) {
                    if(1 << i & mask) { rep(j, m) b[j] ^= a[i][j]; }
                }
                rep(i, m) {
                    if(b[i]) break;
                    if(i == m - 1) ans = max(ans, (int)__builtin_popcount(mask));
                }
            }
            cout << ans << '\n';
        } else {
            rep(i, 1 << m) dp[i] = -1000;
            dp[0] = 0;
            rep(i, n) {
                int k = 0;
                rep(j, m) k ^= (1 << j) * a[i][j];
                rep(j, 1 << m) nxt[j] = dp[j];
                rep(mask, 1 << m) {
                    if(dp[mask] < 0) continue;
                    nxt[k ^ mask] = max<short>(nxt[k ^ mask], dp[mask] + 1);
                }
                swap(dp, nxt);
            }
            cout << dp[0] << '\n';
        }
    }
}


Measured memory_bytes: 20112
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iterator>
#include <functional>
#include <numeric>
using namespace std;

#define ll long long
#define forn(i,n)for(i=0;i<n;i++)
#define forc(i,c,n)for(i=c;i<=n;i++)
typedef list<ll> LST;
typedef vector<ll> VEC;
typedef map<ll, ll> MAP;

int main() {
	ifstream fin("Text.txt");
	ios_base::sync_with_stdio(false); cin.tie(0);

	ll i, j, q;
	ll n, m, p, k, t;
	ll a, b, c, d;
	ll x, y, z, l, r;
	ll one = 1, zero = 0, ans = 0;
	ll mod = 1000000007;
	string st1, st2, st3;
	char ch1, ch2, ch3;

	cin >> n >> m;
	cin >> st1;
	if (st1.size() == n + m + 1) {
		forn(i, n + m + 1) {
			if (i < n && (st1[i]<'0' || st1[i] > '9')) {
				cout << "No" << endl;
				return 0;
			}
			if (i == n && st1[i]!='-') {
				cout << "No" << endl;
				return 0;
			}
			if (i > n && (st1[i]<'0' || st1[i] > '9')) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	else {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class FModularness {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int k, q;
        cin >> k >> q;
        vector<int> d(k);
        REP(i, k) {
            cin >> d[i];
        }
        REP(i, q) {
            int n, x, m;
            cin >> n >> x >> m;
            int znum = 0;
            auto md = d;
            int sum = 0;
            REP(j, k) {
                md[j] %= m;
                sum += md[j];
                if (md[j] == 0) znum++;
            }

            int num = (n - 1) / k;
            int an = x + sum * num;
            int zero = znum * num;
            REP(j, (n - 1) % k) {
                an += md[j];
                if (md[j] == 0) zero++;
            }
            int p = an / m - x / m + zero;

            cout << n - 1 - p << endl;
        }
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    FModularness solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <math.h>
#include <array>
#include <list>
#include <set>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef tuple<ll,int,int> p;
typedef vector<int> vi;
typedef vector<ll> vll;
int n,x;
ll ope=0;
vll a(100005);
int main(int argc,char const* argv[])
{
  cin >> n >> x;
  for(int i=0;i<n;i++)
    {
      cin >> a[i];
    }
  for(int i=0;i<n-1;i++)
    {
      if((a[i]+a[i+1])>x)
	{
	  if((a[i+1]-(a[i+1]+a[i]-x))<0)
	    {
	      ope+=a[i+1];
	      a[i+1]=0;
	      if(a[i]>x)
		{
		  ope+=(a[i]-x);
		  a[i]-=(a[i]-x);
		}
	    }
	  else
	    {
	      ope+=(a[i+1]+a[i]-x);
	      a[i+1]-=(a[i+1]+a[i]-x);
	    }
	}
    }
  cout << ope << endl;
  return 0;
}


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

using namespace std;

int main(){
	
	int n;
	cin >> n;
	
	n %= 7;
	
	switch(n){
	case 0:
		cout << "thu" << endl;
		break;
	case 1:
		cout << "fri" << endl;
		break;
	case 2:
		cout << "sat" << endl;
		break;
	case 3:
		cout << "sun" << endl;
		break;
	case 4:
		cout << "mon" << endl;
		break;
	case 5:
		cout << "tue" << endl;
		break;
	case 6:
		cout << "wed" << endl;
		break;
		
	}
	return 0;
}


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

typedef long long int ll;
typedef string str;

ll merge(ll arr[][2],ll low,ll mid,ll high)
{
	ll p,q,i,j,k;
	p=mid-low+1;
	q=high-mid;
	ll a1[p+1][2],a2[q+1][2];
	for(i=0;i<p;i++)
	{
		a1[i][0]=arr[low+i][0];
		a1[i][1]=arr[low+i][1];
	}
	for(j=0;j<q;j++)
	{
		a2[j][0]=arr[mid+j+1][0];
		a2[j][1]=arr[mid+j+1][1];
	}
	i=0;
	j=0;
	k=low;
	while(i<p&&j<q)
	{
		if(a1[i][0]<a2[j][0])
		{	
			arr[k][0]=a1[i][0];
			arr[k][1]=a1[i][1];
			k++;
			i++;
		}
		else
		{
			arr[k][0]=a2[j][0];
			arr[k][1]=a2[j][1];
			k++;
			j++;
		}
	}
	while(i<p)
	{
		arr[k][0]=a1[i][0];
		arr[k][1]=a1[i][1];
		i++;
		k++;
	}
	while(j<q)
	{
		arr[k][0]=a2[j][0];
		arr[k][1]=a2[j][1];
		k++;
		j++;
	}
}
ll mergesort(ll arr[][2],ll low,ll high)
{
	if(low<high)
	{
		ll mid=low+(high-low)/2;
		mergesort(arr,low,mid);
		mergesort(arr,mid+1,high);
		merge(arr,low,mid,high);
	}
}


int main ()
{
	ll t,x,y,k,i,j,a,b,c,m,n,cnt;
	cin >> x >> y >> a >> b >> c;
	ll ans=0;
	ll arr[300004][2];

	for(i=0;i<a;i++)
	{
		cin >> arr[i][0];
		arr[i][1]=0;
	}
	for(i=i;i<a+b;i++)
	{
		cin >> arr[i][0];
		arr[i][1]=1;
	}
	for(i=i;i<a+b+c;i++)
	{
		cin >> arr[i][0];
		arr[i][1]=2;
	}
	mergesort(arr,0,a+b+c-1);
	i=a+b+c-1;
	cnt=0;
	m=0;n=0;
	while(cnt<x+y)
	{
		if(arr[i][1]==1)
			n++;
		else if(!arr[i][1])
			m++;
		// cout << arr[i][0] << " " << m << " " << n << endl;
		ans+=arr[i][0];
		i--;
		cnt++;
	}

	if(m>x)
	{
		cnt=0;
		i=a+b+c-1;
		m=0;
		ans=0;
		while(cnt<x+y && i>=0)
		{
			
			if(!arr[i][1])
			{
				if(m<x)
				{
					m++;
				}
				else
				{
					i--;
					continue;
				}
			}
			ans+=arr[i][0];
			cnt++;
			i--;
		}
	}

	if(n>y)
	{
		// cout << "yes\n";
		cnt=0;
		i=a+b+c-1;
		n=0;
		ans=0;
		while(cnt<x+y && i>=0)
		{
			// cout << "hi\n";
			if(arr[i][1]==1)
			{
				if(n<y)
				{
					n++;
				}
				else
				{
					i--;
					continue;
				}
			}
			ans+=arr[i][0];
			cnt++;
			i--;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 9600