akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	sort(a.rbegin(), a.rend());
	ll sum = 0;
	for (int i = k; i < n; ++i) {
		sum += a[i];
	}
	cout << sum << '\n';
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
int main(){
    int a,b;
    int ans = 0;
    cin >>a >> b;
    for(int i = a;i<=b;i++){
        string s = to_string(i);
        string t = s;
        reverse(t.begin(),t.end());
        if(s==t){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
D = gets.to_i
C,*S = (0..D).map{gets.split.map &:to_i}
L,M,N = [-1]*27,2,10
1 < (I=(0..25).select{C[_1]==0}).size and S.each {|s;z|
  I.each {|i| if i!=(z||=i); s[z]<s[i] ? z = i+s[z]=0 : s[i]=0 end }
}
def calc(d,n)
  s,x = S[d],0
  n = D-d  if n > D-d
  t = (0..25).map { C[_1]*(d-L[_1])*n+s[_1] }
  i = (0..25).max_by(n){t[_1]}
  i = n==1 ? i[0] : [i[0],i[(n+1)/3]].max_by {|i|
    l,L[i] = L[i],d
    c = t[i] + (calc(d+1,n-1) >> 5)
    L[i] = l
    x < c ? x=c : c
  }
  ((x>0 ? x : t[i]) << 5) + i
end
D.times { p 1 + i=calc(_1,N)&31; L[i]=_1 }

Measured memory_bytes: 15192
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

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

    int ans = 1;
    for(int i=1; i<n; ++i){
        if(s[i-1] != s[i])
            ++ ans;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>

#pragma region _define

#define f(i,a,b) for(LL i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl;
#define all(a) a.begin(),a.end()
#define size(s) s.size()
#define endl "\n"
#define y() cout<<"Yes"<<endl
#define Y() cout<<"YES"<<endl
#define n() cout<<"No"<<endl
#define N() cout<<"NO"<<endl

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vs = vector<st>;
using vb = vector<bool>;
using si = stack<LL>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using v_pi = vector<pi>;

#pragma endregion

#pragma region _graph

#define node 50  //グラフの最大位数　適宜変更
bool graph[node][node];
bool visited[node] = { false };
#define link(a,b,m) f(i,0,m){cin>>a[i]>>b[i]; a[i]--; b[i]--; graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;}

#pragma endregion

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b)*b);
}

/************************************************************************/

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

	st s, t;
	cin >> s >> t;
	bool f;
	int memo = -1;
	f(i, 0, size(s)-size(t)+1) {
		f = true;
		f(j, 0, size(t)) {
			if (s[i + j] != t[j] && s[i + j] != '?') {
				f = false;
				break;
			}
		}
		if (f) {
			memo = i;
		}
	}
	if (memo < 0) {
		cout << "UNRESTORABLE";
		return 0;
	}
	//cout << memo;
	f(i, 0, memo) {
		if (s[i] == '?') {
			cout << 'a';
		}else{
			cout << s[i];
		}
	}
	cout << t;
	f(i, memo + size(t), size(s)){
		if (s[i] == '?') {
			cout << 'a';
		}
		else {
			cout << s[i];
		}
	}
	return 0;
}

Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>  
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000000000000000000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
#define int long long 
	while (true) {
		int h, w;
		cin >> h >> w;
		if (h == 0) return 0;
		int now_max_h = 1000;
		int now_max_w = 1000;
		for (int i = 2; i * i <= 2 * (h * h + w* w); ++i) {
			for (int q = 1; q < i; ++q) {
				int calc = i * i + q * q;
				if (calc >= (h * h + w * w)) {
					int neko = now_max_h * now_max_h + now_max_w * now_max_w;
					if (calc < h * h + w * w) continue;
					if (calc == h * h + w * w) {
						if (q <= h) {
							continue;
						}
					}
					if (neko > calc) {
						now_max_w = i;
						now_max_h = q;
					}
					else if (neko == calc && now_max_h > q) {
						now_max_w = i;
						now_max_h = q;
					}
				}
			}
		}
		cout << now_max_h << " " << now_max_w << endl;
	}
}



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

int main(){
while(1){
int H,W;
cin>>H>>W;

if(H==0 && W==0)break;

for(int i=0; i<H; i++){
for(int j=0; j<W; j++){
if((i+j)%2 ==0) cout<<"#";
else cout<<".";
}
cout<<endl;
}
cout<<endl;
}
return 0;
}










Measured memory_bytes: 3068
#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))

using namespace std;
int ans;
int now;
int n;
int main(){
  cin >> n;
  FOR(i,n){
    int k = i;
    int t = 0;
    while(k%2==0){
      k /= 2;
      t ++;
    }
    if(now<t){
      now = t;
      ans = i;
    }
  }
  if(n==1) ans = 1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
 
#define mod(cans) cans%10**9+7
#define debug(x) cout << "Debug" << x << "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define cin_pl(n,x) rep(i,n){cin>>x[i];}
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define prians(Answer) cout<<Answer<<"\n"
#define TF(X) X==1?cout<<"Yes\n":cout<<"No\n"
#define elcon else{continue;}
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vector<int> > matrix;
typedef pair<int,int> pii;
typedef vector<pii> vpi;
typedef greater<int> gi;
typedef vector<unsigned> vu;


ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
bool is_prime(const unsigned n){
    switch(n){
        case 0:
        case 1: return false;
        case 2: return true;
    }
 
 
    for(unsigned i=2;i<n;++i){
        if(n%i == 0) return false;
    }
 
    return true;
}

int main()
{
    string s,t,x;
    cin>>s>>t;
    x=t+s;
    cout<<x;
} 

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

int H, W;
string S[20];

int dx[] = {0, 0, -1, 1};
int dy[] = {-1, 1, 0, 0};
bool inside(int i, int j){
    return i>=0 && i<H && j>=0 && j<W && S[i][j] == '.';
}

int solve(int sx, int sy){
    int dist[20][20];
    for(int i=0; i<H; i++) for(int j=0; j<W; j++) dist[i][j] = 1e9;
    dist[sx][sy] = 0;
    queue<pair<int, int>> que;
    que.emplace(sx, sy);
    while(que.size()){
        auto p = que.front(); que.pop();
        int i = p.first, j = p.second;
        for(int k=0; k<4; k++){
            int x = i+dx[k], y = j+dy[k];
            if(inside(x, y) && dist[x][y] == 1e9){
                dist[x][y] = dist[i][j] + 1;
                que.emplace(x, y);
            }
        }
    }
    int ret = 0;
    for(int i=0; i<H; i++) for(int j=0; j<W; j++) if(dist[i][j] != 1e9) ret = max(ret, dist[i][j]);
    return ret;
}

int main(){
    cin >> H >> W;
    for(int i=0; i<H; i++) cin >> S[i];
    int ans = 0;
    for(int i=0; i<H; i++) for(int j=0; j<W; j++) if(inside(i, j)) ans = max(ans, solve(i, j));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    ll x,y;
    cin>>x>>y;

    ll p[13];

    p[1]=p[3]=p[5]=p[7]=p[8]=p[10]=p[12]=1;
    p[4]=p[6]=p[9]=p[11]=2;
    p[2]=3;

    if(p[x]==p[y]){
        cout<<"Yes"<<endl;
    }
    else
        cout<<"No"<<endl;
}


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

int n,A[21];

int solve(int i,int x){
  
    if(x == 0) return true;
    else if(i >= n) return false;
    int res = solve( i+1 , x - A[i]) || solve(i + 1, x);
    return res;
    
}

int main(){
    int q,Q;
    scanf("%d",&n);
    for(int i = 0; i < n; i++){
        scanf("%d",&A[i]);
    }
    scanf("%d",&q);
    for(int i = 0; i < q; i ++){
        scanf("%d",&Q);
        if(solve(0,Q)) printf("yes\n");
        else printf("no\n");
    }
    return 0;
}


Measured memory_bytes: 3164
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <map>
#include <utility>

std::map<intmax_t, intmax_t> factor(intmax_t n) {
  std::map<intmax_t, intmax_t> res;
  for (intmax_t i = 2; i*i <= n; ++i) {
    while (n % i == 0) {
      ++res[i];
      n /= i;
    }
  }
  if (n > 1) ++res[n];
  return res;
}

template <class Tp>
Tp modpow(Tp base, intmax_t iexp, Tp mod) {
  Tp res = 1;
  for (Tp dbl = base; iexp; iexp >>= 1) {
    if (iexp & 1) res = res * dbl % mod;
    dbl = dbl * dbl % mod;
  }
  return res;
}

template <class Tp>
Tp gcd(Tp m, Tp n) {
  while (n) std::swap(m %= n, n);
  return m;
}

template <class Tp>
Tp lcm(Tp m, Tp n) {
  return m / gcd(m, n) * n;
}

intmax_t ord(intmax_t g, intmax_t p, const std::map<intmax_t, intmax_t>& f) {
  intmax_t q = p-1;
  for (const auto& pp: f) {
    for (intmax_t i = 0; i < pp.second; ++i) {
      intmax_t e = pp.first;
      if (modpow(g, q/e, p) == 1)
        q /= e;
    }
  }
  return q;
}

int main() {
  intmax_t P;
  int T;
  scanf("%jd %d", &P, &T);

  auto f = factor(P-1);
  for (int i = 0; i < T; ++i) {
    size_t g;
    scanf("%zu", &g);

    intmax_t ords = 1;
    for (size_t j = 0; j < g; ++j) {
      intmax_t gi;
      scanf("%jd", &gi);
      ords = lcm(ords, ord(gi, P, f));
    }

    intmax_t a;
    scanf("%jd", &a);

    printf("%d\n", (ords % ord(a, P, f) == 0));
  }
}



Measured memory_bytes: 2800
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define all(obj) obj.begin(), obj.end()
#define db(x) cerr << #x << ":" << x << " "
#define dbl(x) cerr << #x << ":" << x << "\n"
#define dbv(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define dbgvv(vv) cerr << #vv << ":\n"; for (auto vec : vv) { for (auto e : vec) cerr << e << " "; cerr << endl; }
#define YN(f) cout << (f ? "YES" : "NO") << endl
#define Yn(f) cout << (f ? "Yes" : "No") << endl
#define yn(f) cout << (f ? "yes" : "no") << endl
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

const int MOD = 1000000007;

ll modmul(ll x, ll y) {
	return x * y % MOD;
}

// power(mod) x^n
ll modpow(ll x, ll n) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = modmul(res, x);
		x = modmul(x, x);
		n >>= 1;
	}
	return res;
}

int main () {
	int X; cin >> X;
	ll ans = 1;
	rep2(b, 2, 32) {
		// dbl(b);
		if (b * b > X) break;
		rep2(p, 2, 10) {
			// db(p); dbl(modpow(b, p));
			if (modpow(b, p) <= X) ans = max(ans, modpow(b, p));
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n; cin >> n;
  ll nv=0, ne=0;
  rep(i, n-1) {
    ll u, v;
    cin >> u >> v;
    u--; v--;
    ne += (min(u, v)+1)*(n-max(u, v));
  }
  rep(i, n) nv += (i+1)*(n-i);
  cout << nv - ne << "\n";
  return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
#include<cmath>
using lint=int64_t;
using namespace std;

int main()
{
	lint N,P;
	lint A;
	lint cnt[2]={};
	
	cin >> N >> P;
	for(int i=0;i<N;i++)
	{
		cin >> A;
		cnt[A%2]++;
	}
	
	if(cnt[0]==N)
	{
		if(P==0)
			cout << (lint)pow(2,N);
		else
			cout << 0;
		cout << endl;
		return 0;
	}
	
	cout << (lint)pow(2,N-1) << endl;
	return 0;
}



Measured memory_bytes: 892
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc *bufio.Scanner

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

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	a, b := nextInt(), nextInt()

	switch {
	case a <= 5:
		fmt.Println(0)
	case a <= 12:
		fmt.Println(b / 2)
	default:
		fmt.Println(b)
	}
}


Measured memory_bytes: 640
rc=list(map(int,input().split()))
sheet=[list(map(int,input().split()))+[0] for i in range(rc[0])]
sheet.append([0 for i in range(rc[1]+1)])
for s in sheet:
    s[-1]=sum(s[0:-1])
for i in range(rc[1]+1):
    r=sum([n[i] for n in sheet[0:-1]])
    sheet[-1][i]=r
for sh in sheet:
    print(*sh)

Measured memory_bytes: 8396
import scala.io.StdIn._

object Main extends App {

  val n = readInt()
  val h = readLine().split(" ").map(_.toInt)
  def solve() = {
    val dp = Array.fill(n)(0)
    for(i <- 1 until n) {
      if(i == 1) dp(i) = (h(i) - h(i-1)).abs
      else dp(i) = Math.min(dp(i-1) + (h(i) - h(i-1)).abs, dp(i-2) + (h(i) - h(i-2)).abs)
    }
    dp(n-1)
  }

  println(solve())

}



Measured memory_bytes: 62208
N, M = map(int, input().rstrip().split())
li = [[int(_) for _ in input().rstrip().split()] for _ in range(N)]
for i in range(N):
    del li[i][0]

ans = 0
for i in range(M):
    Flag = "OK"
    for j in range(N):
            if not i+1 in li[j]:
                Flag = "NG"
    if Flag == "OK":
        ans += 1

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define reprev(i, n) for (int i = n - 1; i >= 0; i--)
using ll = long long;
using namespace std;
using P = pair<int, int>;

int main(){
    int N, K;
    vector<int> d(100);
    vector<bool> A(100, false);
    cin >> N >> K;
    rep (i, K){
        cin >> d.at(i);
        rep(j, d.at(i)){
            int temp_A;
            cin >> temp_A;
            A.at(temp_A-1) = true;
        }
    }
    int count = 0;
    rep(i, N) if(A.at(i) == false) count++;
    cout << count << endl;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 998244353;

struct mint {
  ll x;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
      mint a = pow(t>>1);
      a *= a;
    if (t&1) a *= *this;
      return a;
  }
   mint inv() const { return pow(MOD-2);}
   mint& operator/=(const mint a) { return *this *= a.inv();}
   mint operator/(const mint a) const { return mint(*this) /= a;}
};
typedef vector<mint> vm;
typedef vector<vm> vvm;
  
int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  vvm dp(c,vm(d,1));
  srep(i,b,d) {
    dp[a-1][i]=dp[a-1][i-1]*a;
  }
  srep(i,a,c) {
    dp[i][b-1]=dp[i-1][b-1]*b;
  }
  srep(i,a,c) {
    srep(j,b,d) {
      dp[i][j]=dp[i-1][j]*(j+1)+dp[i][j-1]*(i+1)-dp[i-1][j-1]*i*j;
    }
  }
  cout << dp[c-1][d-1].x << endl;
  return 0;
}

Measured memory_bytes: 73596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define loop(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define rep(i, n) loop(i, 0, n)
#define rep1(i, n) loop(i, 1, n + 1)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << (x) << endl
int _ = (cin.tie(0), ios::sync_with_stdio(0), cout.precision(20), cout.setf(ios::fixed));

const int MOD = 1000000007;
int n, l;
int x[5010], a[5010];

int dp[5010][5010];

int main(){
    cin >> n >> l;
    rep(i, n) cin >> x[i], ++x[i];
    rep(i, n) cin >> a[i], a[i] ? 0 : a[i] = l;
    memset(dp, 0, sizeof dp);
    rep(i, l+1) dp[0][i] = 1;
    rep1(i, n){
        int a = ::a[i-1], x = ::x[i-1];
        loop(j, x, l+1){
            if((j-x)%a == 0) dp[i][j] += dp[i-1][j-1];
            if(j != x) dp[i][j] += dp[i][j-1];
            dp[i][j] %= MOD;
        }
    }
    cout << dp[n][l] << endl;
}

Measured memory_bytes: 101188
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200010;
int64_t N, K, per;
vector<int> to(MAXN);
vector<int> steps(MAXN, -1);

void dfs(int v, int step)
{
  if (steps[v] != -1)
  {
    per = step - steps[v];
    int64_t k = (K - steps[v]) % per;
    for (int i = 0; i < N; i++)
    {
      if (steps[i] == k + steps[v])
      {
        cout << i + 1 << endl;
      }
    }
    return;
  }
  if (step == K)
  {
    cout << v + 1 << endl;
    return;
  }
  steps[v] = step;
  dfs(to[v], step + 1);
}

int main()
{
  cin >> N >> K;
  for (int i = 0; i < N; i++)
  {
    cin >> to[i];
    to[i]--;
  }
  dfs(0, 0);
}

Measured memory_bytes: 4676
// Why am I so dumb? :c
#include<bits/stdc++.h>

#define pb push_back
#define mp make_pair

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

#define fi first
#define se second

using namespace std;

typedef long long ll;

const int mod = (int)1e9 + 7;
const int mod2 = (int)1e9 + 9;
const int P = (int)31;
const int P2 = (int)37;

vector<pair<int, int>> cnt[20];

char s[40];

int pw[20];

ll ans;

int n;

void pre() {
	pw[0] = 1;

	for (int i = 1; i < 20; ++i) {
		pw[i] = (pw[i - 1] << 1);
	}
}

pair<int, int> h(string s) {
	pair<int, int> ret;

	int curP = 1, curP2 = 1;

	for (int i = 0; i < s.size(); ++i) {
		ret.fi = (ret.fi + curP * 1ll * (s[i] - 'a' + 1)) % mod;
		ret.se = (ret.se + curP2 * 1ll * (s[i] - 'a' + 1)) % mod2;
		curP = (curP * 1ll * P) % mod; 
		curP2 = (curP2 * 1ll * P2) % mod2;
	}

	return ret;
}

void solve() {
	scanf("%d %s", &n, s);

	for (int m = 0; m < pw[n]; ++m) {
		string a, b;

		for (int i = 0; i < n; ++i) {
			if (m & pw[i]) {
				a += s[n + i];
			}
			else {
				b += s[n + i];
			}
		}

		reverse(all(b));
		cnt[b.size()].pb(h(b + a));
	}

	for (int i = 0; i <= n; ++i) {
		sort(all(cnt[i]));
	}

	for (int m = 0; m < pw[n]; ++m) {
		string a, b;

		for (int i = 0; i < n; ++i) {
			if (m & pw[i]) {
				a += s[i];
			}
			else {
				b += s[i];
			}
		}

        reverse(all(b));                                    
		auto it = equal_range(all(cnt[n - b.size()]), h(a + b));
		ans += (it.se - it.fi);
	}

	printf("%lld\n", ans);
}

int main() {
    int tt = 1;

    pre();

    while (tt--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 2656
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt(),a=sc.nextInt(),b=sc.nextInt();
    	if((b-a)%2==0) {
    		System.out.println("Alice");
    	}else {
    		System.out.println("Borys");
    	}
  }
	public static boolean check(long a,long b,long c) {
		return true;
	}
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
#define forinc(i,a,b) for(int i=a;i<=b;i++)
#define fordec(i,a,b) for(int i=a;i>=b;i--)
#define pii pair<int,int>
#define int long long
#define fi first
#define se second


const int maxn=105,maxk=1e5+5,mod=1e9+7;
int n,k,a[maxn],s[maxk];
int f[maxn][maxk];
main()
{
    cin>>n>>k;
    forinc(i,1,n) cin>>a[i];
    forinc(i,1,k+1) s[i]=1;
    forinc(i,1,n)
    {
        forinc(j,1,k+1) f[i][j]=(s[j]-s[max(0ll,j-a[i]-1)]+mod)%mod;
        forinc(j,1,k+1) s[j]=(f[i][j]+s[j-1])%mod;
    }
    cout<<f[n][k+1]%mod;
}


Measured memory_bytes: 80128
l_ary = 4.times.map{0}
r_ary = 4.times.map{0}
while line = gets
l,r = line.split.map(&:to_f)
  if l >= 1.1
      l_ary[0] += 1
      elsif l >= 0.6
      l_ary[1] += 1
      elsif l >= 0.2
      l_ary[2] += 1
    elsif l < 0.2
    l_ary[3] += 1
  end
  
  if r >= 1.1
    r_ary[0] += 1
    elsif r >= 0.6
    r_ary[1] += 1
    elsif r >= 0.2
    r_ary[2] += 1
  elsif r < 0.2
  r_ary[3] += 1
  end
end
result = []

for i in 0..3
result.push([l_ary[i],r_ary[i]])
end

result.each do |v|
  puts v.join(" ")
end


Measured memory_bytes: 6892
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int> > piii;
#define pb push_back
#define NeedForSpeed ios_base::sync_with_stdio(0), cin.tie(0)
#define PI acos(-1)
#define all(c) c.begin(), c.end()
#define SET(x, y) memset((x), y, sizeof(x))
const int MOD = 1e9 + 7;
const int INF = 1e9 + 5;
const ll INF64 = 1e18;

template <typename T>
string to_string(const vector<T> &v) {
  string ret = "<";
  for (auto it : v)
    ret += to_string(it) + ", ";
  ret.pop_back(); ret.pop_back();
  ret += ">";
  return ret;
}

string to_string(const string &s) {
  return '"' + s + '"';
}

string to_string(bool b) {
  return b ? "true" : "false";
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

void debug_print() { cerr << endl; }

template <typename T, typename ...U>
void debug_print(T t, U... u) {
  cerr << " " << to_string(t);
  debug_print(u...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_print(__VA_ARGS__)
const int N = 1e5 + 5;

ll root[5005];
ll sum[5005];
ll len[5005];

ll find_root(ll x) {
  return root[x] == x ? x : root[x] = find_root(root[x]);
}

void uni(ll a, ll b) {
  ll root_a = find_root(a);
  ll root_b = find_root(b);
  if (root_a != root_b) {
    sum[root_a] += sum[root_b];
    root[root_b] = root_a;
    len[root_a] += len[root_b];
  }
}

void init() {
  for (int i = 0; i < 5005; i++) {
    root[i] = i;
    sum[i] = 0;
    len[i] = 1;
  }
}

ll c[5005];
ll p[5005];
ll nxt[5005];

int main() {
  init();
  ll n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    ll a;
    cin >> a;
    p[i] = a;
    nxt[i] = a;
  }
  for (int i = 1; i <= n; i++) {
    cin >> c[i];
    sum[i] = c[i];
  }
  for (int i = 1; i <= n; i++) {
    uni(i, p[i]);
  }
  ll ret = -INF64;
  for (int i = 1; i <= n; i++) {
    ll m = k;
    ll cur = -INF64;
    ll root_i = find_root(i);
    ll t = m / len[root_i];
    if (t > 1) {
      cur = max(cur, sum[root_i] * (t - 1));
      m -= ((t - 1) * len[root_i]);
    }     
    ll now = 0ll;
    ll node = i;
    ll prev = max(0ll, cur);
    for (int j = 1; j <= m; j++) {
      now += c[node];
      node = nxt[node];
      cur = max(cur, prev + now);
    }
    ret = max(ret, cur);
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 3832
/*
 * WelcomeToAtCoder.cpp
 *
 *  Created on: 2020/02/19
 *      Author: black
 */

#include <iostream>
#include <string>
#include <stdio.h>
using namespace std;

#define MAX 500000
#define INFTY 2000000000


int L[MAX/2+2];
int R[MAX/2+2];
int iCount;

void merge(int A[], int left, int mid, int right){
	int n1 = mid - left;
	int n2 = right - mid;
	for(int i=0; i< n1; ++i){
		L[i] = A[left+i];
	}
	for(int i=0; i< n2; ++i){
		R[i] = A[mid+i];
	}
	L[n1] = INFTY;
	R[n2] = INFTY;

	int i= 0;
	int j= 0;

	for(int k=left; k<right; ++k){
		if (L[i] <= R[j]){
			A[k] = L[i];
			i++;
		}
		else{
			A[k] = R[j];
			j++;
		}
		iCount++;
	}
}

void mergeSort(int A[], int left, int right){
	if ((left+1) < right){
		int mid = (left+right)/2;
		mergeSort(A, left, mid);
		mergeSort(A, mid, right);
		merge(A, left, mid, right);
	}
}

int main(){
	int A[MAX];
	int n;
	iCount = 0;

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

	mergeSort(A, 0, n);

	for(int i= 0; i< n; ++i){
	    if(i){
	        cout << " ";
	    }
		cout << A[i];
	}
	cout << endl;
	cout << iCount << endl;


	return 0;

}



Measured memory_bytes: 7016
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
//1 2 5 10 25 50
int main() {
  ll n; cin>> n;
  ll x=sqrt(n);
  ll m=10000000000000000000000000000000000000;
  for(ll a=1; a<=x; a++) {
    if(n%a==0) {
      m=min(m, a+n/a-2);
    }
  }
  cout << m << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int count =0;
    for(int i=1;i<n+1;i++){
     if(i%2==1)count++;
    }
    float k = (float)count/(float)n;
    cout<<k;
}

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

int main()
{
	int a, b;
	cin >> a >> b;
	if (a == b)cout << a + b << endl;
	else {
		if (a > b)cout << 2 * a - 1 << endl;
		else cout << 2 * b - 1 << endl;
	}
}

Measured memory_bytes: 256
# import numpy as np
# from itertools import permutations
# from itertools import combinations
# from itertools import combinations_with_replacement
# import queue
# import heapq


def main():
    N, K = map(int, input().split())

    sunuke = [True for _ in range(N)]

    for i in range(K):
        d = input()
        ds = list(map(int, input().split()))

        for s in ds:
            sunuke[s-1] = False

    print(sum(sunuke))


if __name__ == "__main__":
    main()


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

typedef long long ll;

ll gcd(
  ll a
  , ll b
)
{
  ll r;
  while (0 != (r = a%b))
  {
    a = b;
    b = r;
  }
  return b;
}

ll lcm(
  ll a
  , ll b
)
{
  return a/gcd(a, b)*b;
}

int main()
{
  int N;
  cin >> N;
  vector<ll> T(N);
  for (auto & t : T)
    cin >> t;
  sort(T.rbegin(), T.rend());
  auto total = T[0];
  for (int i = 1; i < N; ++i)
    total = lcm(total, T[i]);
  cout << total;
  return 0;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
x=list(map(int,input().split()))
ans=float("inf")
for i in range(n-k+1):
    l=x[i]
    r=x[i+k-1]
    if l*r==0:
        t=max(abs(l),abs(r))
    if l*r>0:
        t=max(abs(l),abs(r))
    if l*r<0:
        if abs(l)>abs(r):
            t=2*abs(r)+abs(l)
        if abs(r)>=abs(l):
            t=2*abs(l)+abs(r)
    if t<ans:
        ans=t
print(ans)

Measured memory_bytes: 85560
#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 <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << "0\n"; return;}
#define mkp make_pair

void solve() {
    vector <pi> num;
    int a; cin >> a;
    loop(i, 121) {
        num.pb({ i, i * i * i * i * i });
        num.pb({ -i, -i * i * i * i * i });
    }
    for (pi x : num)
        for (pi y : num)
            if (x.S - y.S == a) {
                cout << x.F << " " << y.F;
                return;
            }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}

Measured memory_bytes: 3616
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;

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

        int s = sc.nextInt();
        int w = sc.nextInt();

        if(w >= s){
            System.out.println("unsafe");
        }else{
            System.out.println("safe");
        }
        
        

        






    }
}

Measured memory_bytes: 35788
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import qualified Data.List as L

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
  [n, k] <- getIntList
  h <- getIntList
  print $ solve k h

solve k h = sum $ L.drop k $ L.reverse $ L.sort h

Measured memory_bytes: 32124
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
#define sz(x) (int)(x).size();
#define all(x) x.begin(), x.end()
#define trav(i,a) for(auto &i:a) 
inline int in(){int x;scanf("%lld",&x);return x;}
int32_t main()
{
	int n=in();int x;
	vector<int> rt;
	int cur=0;
	vector<int> a(3*n);
	trav(i,a)i=in();
	priority_queue<int> mn;//minus minus
	for(int i=0;i<n;i++){cur+=a[i];mn.push(-a[i]);}
	rt.push_back(cur);
	for(int i=n;i<2*n;i++)
	{
		x=a[i];
		if(x>-mn.top())
		{
			cur+=mn.top();
			cur+=x;
			mn.pop();
			mn.push(-x);
			rt.push_back(cur);
		}
		else rt.push_back(cur);
	}
	priority_queue<int> mx;//plus plus
	//trav(i,rt)cout<<i<<' ';
	vector<int> lt;
	cur=0;
	for(int i=3*n-1;i>=2*n;i--){cur+=a[i];mx.push(a[i]);}
	lt.push_back(cur);
	for(int i=2*n-1;i>=n;i--)
	{
		x=a[i];
		if(x<mx.top())
		{
			cur-=mx.top();
			cur+=x;
			mx.pop();
			mx.push(x);
			lt.push_back(cur);
		}
		else lt.push_back(cur);
	}
	reverse(all(lt));
	int ans=-1e18;
	for(int i=0;i<lt.size();i++)ans=max(ans,rt[i]-lt[i]);
	cout<<ans;
	
	
	
	
}

Measured memory_bytes: 9524
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<ll, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int ch[30][225816];

int main(void){
	int n,m,i,j,s,t,c,tmp,ans=0;
	fill(ch[0],ch[30],0);
	cin >> n >> m;
	for(i=0; i<n; ++i){
		cin >> s >> t >> c;
		++ch[c-1][2*s-1];
		--ch[c-1][2*t+1];
	}
	for(i=0; i<200000; ++i){
		for(j=0; j<m; ++j){
			ch[j][i+1] += ch[j][i];
		}
	}
	for(i=0; i<200001; ++i){
		tmp = 0;
		for(j=0; j<m; ++j){
			if(ch[j][i]){
				++tmp;
			}
		}
		ans = max(tmp,ans);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 26752
#include <algorithm>
#include <array>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;

int main(int argc, char** argv) {
	int n;

	cin >> n;

	if (n < 10) {
		cout << n << endl;
	}
	else if (n < 100) {
		cout << 9 << endl;
	}
	else if (n < 1000) {
		cout << 9 + (n - 100 + 1) << endl;
	}
	else if (n < 10000) {
		cout << 909 << endl;
	}
	else if (n < 100000) {
		cout << 909 + (n - 10000 + 1) << endl;
	}
	else if (n < 1000000) {
		cout << 90909 << endl;
	}

	return 0;
}


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

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0509


public class Test
{
	public static void Main()
	{
		while(true){
		  string[] str1 = Console.ReadLine().Split(' ');
		  int n = int.Parse(str1[0]); 
		  int r = int.Parse(str1[1]); 

		  if(n == 0) break;
		
		  int[][] rects = new int[n][];
		  for(int i=0;i<n;i++) {
			string[] str2 = Console.ReadLine().Split(' ');
			rects[i] = Array.ConvertAll(str2, new Converter<string,int>(s => int.Parse(s)));
		  }
		
			int[][] brects = omit(rects);
		
		  //Console.WriteLine("???????????? N = {0} P = {1} Ai = {2}", n, p, a);
		  Console.WriteLine(calc(n,r,brects));
		
		
		}

	}
  
  public static int[][] omit(int[][] rects) {
	//Console.WriteLine("omit1=" + rects.Length.ToString());
	Array.Sort(rects,
    (x, y) => ((y[2]-y[0])*(y[3]-y[1])).CompareTo(((x[2]-x[0])*(x[3]-x[1]))));
	
	List<int[]> arect = new List<int[]>();
	foreach(int[] or in rects){
		bool insert = true;
		foreach(int[] ar in arect){
			if((ar[0] <= or[0]) && (ar[1] <= or[1]) && (or[2] <= ar[2]) && (or[3] <= ar[3])) {
				insert = false;
				break;
			
			}
		}
		if(insert) arect.Add(or);
	}
	//Console.WriteLine("omit2=" + arect.Count.ToString());
	List<int[]> brect = new List<int[]>();
	foreach(int[] or in arect){
		int[] br = {or[0], or[1], or[2], or[3]};
		foreach(int[] ar in brect){
			if((ar[0] <= br[2]) && (br[2] <= ar[2]) && (ar[1] <= br[1]) && (br[3] <= ar[3])) {
				br[2] = ar[0];
			}
			if((br[0] <= ar[2]) && (ar[0] <= br[0]) && (ar[1] <= br[1]) && (br[3] <= ar[3])) {
				br[0] = ar[2];
			}
			if((ar[1] <= br[3]) && (br[3] <= ar[3]) && (ar[0] <= br[0]) && (br[2] <= ar[2])) {
				br[3] = ar[1];
			}
			if((br[1] <= ar[3]) && (ar[1] <= br[1]) && (ar[0] <= br[0]) && (br[2] <= ar[2])) {
				br[1] = ar[3];
			}
		}
		if((br[0]<br[2]) && (br[1]<br[3])) brect.Add(br);
	}
	
	
	//Console.WriteLine("omit3=" + brect.Count.ToString());
    return brect.ToArray();
  }
  
  public static string calc(int n, int r, int[][] rects) {
	bool[,] area = new bool[10002,10002];
	
	int r1 = 0;
	int r2 = 0;
	foreach(int[] or in rects){
		for(int x=or[0]+1;x<=or[2];x++){
		for(int y=or[1]+1;y<=or[3];y++){
			if(!area[x,y]) {
			  area[x,y] = true;
			  
			  int cnt = -2;
			  if(!area[x-1,y]) cnt++;
			  if(!area[x+1,y]) cnt++;
			  if(!area[x,y-1]) cnt++;
			  if(!area[x,y+1]) cnt++;
			  r1 += 2*cnt;
			  
			  r2++;
			}
		}
		}
		
	}
	
	return r2.ToString() + ((r==2) ? "\n" + r1.ToString() : "");
  }
  


}

Measured memory_bytes: 209540
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
dp = [[-1 for i in range(2)] for i in range(51)]
dp[50][0] = 0
for i in range(49, -1, -1):
  mask = 1<<i
  ones = 0
  for e in a:
    if e&mask:
      ones+= 1
  for e in a:
    if dp[i+1][0]!=-1:
      if k&mask:
        dp[i][0] = max(dp[i][0], dp[i+1][0] + mask*(n-ones))
        dp[i][1] = max(dp[i][1], dp[i+1][0] + mask*ones)
      else:
        dp[i][0] = max(dp[i][0], dp[i+1][0] + mask*ones)
    if dp[i+1][1]!=-1:
      dp[i][1] = max(dp[i][1], dp[i+1][1] + mask*max(ones, n-ones))
print(max(dp[0][0], dp[0][1]))

Measured memory_bytes: 70252
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define random_shuffle asdasdd

const int MAXN = 105000;

int n, m;
int a[MAXN];
long long lcm;

long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}

int main() {

  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    a[i] /= 2;
  }

  lcm = a[0];

  for (int i = 1; i < n; i++) {
    long long g = gcd(lcm, a[i]);
    lcm /= g;
    lcm *= a[i];
    if (lcm > m) {
      cout << 0 << endl;
      return 0;
    }
  }

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

  long long mx = m / lcm;

  if (mx == 0) {
    cout << 0 << endl;
  } else {
    cout << (mx + 1) / 2 << endl;
  }

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
 
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------

int main(){
    string s;
     int n,k;
     cin>>k;
     cin>>s;
     n=s.size();
     if(n<=k)cout<<s<<endl;
     else{
         rep(i,k){
             cout<<s.at(i);
         }
         cout<<"..."<<endl;
     }
}
   
    

   



Measured memory_bytes: 3628
n,k = gets.split.map(&:to_i)
a = n.times.map{|i|gets.split.map(&:to_i).push(i)}.sort_by{|i,j,k|-j}
v = 0
ans = 0
ret = 0
used = Hash.new(-1)
for i in 0..k-1
    ans += a[i][1]
    if used[a[i][0]] == -1
        v += 1
        used[a[i][0]] = a[i][2]
    end
end
ans += v**2
l = k-1
ret = ans
for i in k..n-1
    if used[a[i][0]] == -1
        while used[a[l][0]] == a[l][2]
            l -= 1
        end
        break if l < 0
        used[a[i][0]] = a[i][2]
        ret += a[i][1]-a[l][1]+2*v+1
        v += 1
        l -= 1
    end
    ans = ret if ans < ret
end
puts ans

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

int main() {
	int n;cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;++i)cin>>a[i];
	int m;cin>>m;
	vector<int> b(m);
	for(int i=0;i<m;++i)cin>>b[i];

	vector<int> ans;
	set_difference(begin(a),end(a),begin(b),end(b),inserter(ans, end(ans)));

	for(auto &&ai: ans){
		cout<<ai<<endl;
	}
  return 0;
}



Measured memory_bytes: 5456
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define rep(i,a) for(int i = 0 ; i < a; i ++)
int main(void){
  int N,M;
  cin>>N>>M;
  vector<int> a(N);
  vector<int> sum(N,0);
  vector<int> b(M);
  
  rep(i,N)cin>>a[i];
  rep(i,M)cin>>b[i];
  
  rep(i,M)
    rep(j,N)
      if(a[j]<=b[i]){
        sum[j]++;
        break;
      }
  
  int maxx = 0;
  int num;
  
  rep(i,N){
    if(maxx<sum[i]){
      maxx = sum[i];
      num = i;
    }
  }
  cout<<num+1<<endl;
  return 0;
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
using namespace std;
#define rep(i ,a, n) for (long long int i=a;i<=n;i++)
#define pb  push_back
#define mp make_pair
#define fp first
#define sp second
#define be(v) v.begin(),v.end()
typedef long long ll;
typedef vector<ll> vi ;
typedef vector<pair<ll , ll > >  vpi ;
const int ma1=3e5+5;
string no="NO",yes="YES";
#define MOD 1000000007
int max_char=26;
ll dp[100005][3]={0};
vector<ll> v;
int main()
{
      ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
    while(t--)
    {
        ll n,m;
        cin>>n>>m;
        ll val[n],wt[n];
        for(int i=0;i<n;i++)
        {
            cin>>wt[i]>>val[i];
        }
        ll dp[n+1][m+1];
        for(int i=0;i<=n;i++)
        {
            for(int j=0;j<=m;j++)
                if(i==0 || j==0)
                dp[i][j]=0;
        }
        for(int i=1;i<=n;i++)
        {
            for(int j=1;j<=m;j++)
            {
                if(wt[i-1]<=j)
                {
                    dp[i][j]=max(val[i-1]+dp[i-1][j-wt[i-1]],dp[i-1][j]);
                }
                else dp[i][j]=dp[i-1][j];
            }
        }
        cout<<dp[n][m];
    }
    return 0;
}
















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


def main():
    s = input()
    prev, cur = '', ''
    ans = 0

    for si in s:
        cur += si  # KeyInsight: curに1文字加える

        # prevとcurが異なる
        if cur != prev:
            ans += 1

            # prevとcurを更新
            prev = cur
            cur = ''

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3500
#include <bits/stdc++.h>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
using vstr=vector<string>;
void yes(bool c) { if (c)print("Yes"); else print("No"); };

// 入力された整数の約数を列挙する
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++)
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    sort(ret.begin(), ret.end());
    return ret;
}

void solve() {
    ll X; cin >> X;
    // A^5-B^5=(A-B)×Q(x)なので、Xの約数を順にA-Bの候補として調べる
    vll ds = divisor(X);
    for(auto d:ds)
        // ↓たぶんA^5-B^5がXの上限を超えるくらいの範囲
        rng(a,1,100000){
            int b = a-d;
            ll left = pow(a,5)-pow(b,5);
            // 条件を満たす組み合わせが見つかったら出力して終了
            if(left == X) {
                cout << a << " " << b << endl;
                return;
            } 
        }
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}


Measured memory_bytes: 4120
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <deque>
#include <iostream>
#include <iomanip>
#include <locale>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int INT_MAX_SQRT = sqrt(INT_MAX);
int pwi(int x, int p) {
    if (p == 0) return 1;
    if (p == 1) return x;
    int tmp = pwi(x, p / 2);
    if (tmp > INT_MAX_SQRT) return 0;  // overflow
    if (p % 2 == 0)
        return tmp * tmp;
    else
        return tmp * tmp * x;
}

long LONG_MAX_SQRT = sqrt(LONG_MAX);
long pwl(long x, long p) {
    if (p == 0) return 1;
    if (p == 1) return x;
    long tmp = pwl(x, p / 2);
    if (tmp > LONG_MAX_SQRT) return 0;  // overflow
    if (p % 2 == 0)
        return tmp * tmp;
    else
        return tmp * tmp * x;
}

map<long, long> factorization(long N) {
    map<long, long> res;
    long SQRT_N = ceil(sqrt(N));
    for (long i = 2; i < SQRT_N; i++) {
        while (N % i == 0) {
            if (res.find(i) == res.end()) {
                res[i] = 1;
            } else {
                res[i] += 1;
            }
            N /= i;
        }
    }
    if (N > SQRT_N) res[N] = 1;
    return res;
}

void debug_vec(string name, vector<int> vec) {
    cout << name << endl;
    for (auto e: vec) cout << e << endl;
}

void debug_vec(string name, vector<long> vec) {
    cout << name << endl;
    for (auto e: vec) cout << e << endl;
}

void debug_mat(string name, vector<vector<long>> mat) {
    cout << name << endl;
    for (auto vec: mat) {
        for (auto e: vec) cout << e << "   ";
        cout << endl;
    }
}

int main() {
    long N;
    cin >> N;

    vector<int> res;

    while (N > 0) {
        N--;
        res.push_back(N % 26);
        N = N / 26;
    }

    for (int i = res.size(); i > 0; i--) {
        cout << (char) ('a' + res[i - 1]);
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3720
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include "math.h"
#include <set>
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--)
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
int N;
vector <int > A1,A2;





int main()
{

	cin >> N;

	A1.resize(N);
	A2.resize(N);

	REP(i,N){
		cin >> A1[i];
	}

	REP(i,N){
		cin >> A2[i];
	}
	int ans0 = 0;
	int ans = 0;
	REP(i,N){
		ans += A1[i];
		int ans1 = ans;
		FOR(j,i,N){
			ans1 += A2[j];
		}
		if(ans1 > ans0){
			ans0 = ans1;
		}
	}

	cout << ans0;

}







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

int main(){
    ll n; cin >> n;
    if(n%2) cout << 0 << "\n";
    else{
        ll k = n/2;
        ll p = 5LL;
        ll ans = 0LL;
        while(k/p > 0){
            ans += k/p;
            p *= 5;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 384
// Best practice
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <functional> // for less 
 
#define int         long long
#define pb          push_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> pbds; 
 
#define fbo find_by_order
#define ook order_of_key
 
signed main() {
   tezz
   
    int a,b,c;
    cin >> a >> b >> c;
    int t=a;
    a-=(min(a,c));
    c-=min(t,c);
    b-=min(b,c);
    cout << a << " " << b ;
    
   
   return 0;
}
 


Measured memory_bytes: 256
def main():
    n = int(input())
    a = list(map(int, input().split()))
    if 0 in a:
        print(0)
        return
    ans = 1
    for ai in a:
        ans *= ai
        if ans > 10**18:
            print(-1)
            return
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 21316