akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_ll.hpp>
//using boost::multiprecision::cpp_ll; // use cpp_ll as data type for large numbers 
using namespace std;

#define int ll
#define ll long long
#define pb push_back
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL); 
#define mod 1000000007
#define mp make_pair
#define ff first
#define ss second
#define vi vector<ll>
#define vll vector<long long>
#define log2(X) (63ll - __builtin_clzll(X))
#define test ll t; cin>>t; while(t--)
#define modInv(n) po(n,mod-2)%mod
#define ncr(n,r) (((fact[n]*modInv(fact[r]))%mod)*modInv(fact[n-r]))%mod

ll po(ll a, ll b)
{
    ll res=1;
    while(b)
    {
        if(b&1)
        {
            res=(res*a)%mod;
        }
        a=(a*a)%mod;
        b=b/2;
    }
    return res%mod;
}
int n;
int arr[3005];
int dp[3005][3005];

int go(int i, int j)
{
    if(dp[i][j]!=-1) return dp[i][j];
    
    if(i==j) dp[i][j]=arr[i];
    
    else dp[i][j]=max(arr[i]-go(i+1,j),arr[j]-go(i,j-1));
    
    return dp[i][j];
}

signed main() 
{
    fast()
    //test
    {
      cin>>n;
      for(int i=1; i<=n; i++) cin>>arr[i];
      
      memset(dp,-1,sizeof(dp));
      
      cout<<go(1,n)<<"\n";
    }   
}


Measured memory_bytes: 74292
/*BISMILLAH
THE WHITE WOLF
NO DREAM IS TOO BIG AND NO DREAMER IS TOO SMALL*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<long long> vll;
typedef vector<int> vi;

#define io ios_base::sync_with_stdio(false)
#define pb push_back
#define eb emplace_back
#define mod    1000000007
#define PI 2*acos(0.0)
int dirx[] = {1, -1,0, 0}, diry[] = {0, 0, 1, -1};
//======================================ASIFAZAD==========================================//

bool ck(int n, int pos)
{
    return bool(n&(1<<pos));
}

int32_t main()
{
    io;
    int n;
    ll k;
    cin>>n>>k;
    vi adj(n+1);
    for(int i = 1; i<= n;i++)
        cin>>adj[i];
    vi vis(n+1), path;
    queue<int > q;
    q.push(1);
    vis[1] = 1;
    int ans;
    k++;
    while(k)
    {
        int ac =q.front();
        q.pop();
        if(vis[ac] && !path.empty())
        {
            int ind;
            for(ind = 0; ind < path.size(); ind++)
                if(path[ind] == ac)
                    break;
            int dev = path.size() - ind;
            //cout<<"k: " <<  k <<" dev: " << dev<<"\n";
            ans = path[(k-1)%dev + ind];
            break;
        }
        vis[ac] = 1;
        path.pb(ac);
        k--;
        q.push(adj[ac]);
    }
    cout<<(!k? path[path.size() - 1]: ans);
    return 0;
}


Measured memory_bytes: 5776
(n,m,*b),a,*q=[map(int,t.split())for t in open(0)]
t=[-1]*n
def r(x):
 while-1<t[x]:x=t[x]
 return x
def u(x):
 x,y=map(r,x)
 if x!=y:
  if t[x]>t[y]:x,y=y,x
  t[x]+=t[y];t[y]=x
[*map(u,q)]
i=c=0
k=j=n+~m<<1
*d,=eval('[],'*n)
for v in a:d[r(i)]+=v,;i+=1
for p in d:x,*y=sorted(p)+[0];c+=x;b+=y[:-1];j-=p>[]
print(k<1and'0'or(k>n)*'Impossible'or c+sum(sorted(b)[:j]))

Measured memory_bytes: 138604
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val p = readLine()!!.split(" ").map { it.toInt() }.toIntArray()
    var ans = 0
    for (i in 0 until n-1) {
        if (p[i]-1 == i) {
            val temp = p[i]
            p[i] = p[i+1]
            p[i+1] = temp
            ans++
        }
    }
    if (p[n-1] == n) ans++
    println(ans)
}

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

#define read(num) scanf("%d", &num)
#define readll(num) scanf("%lld", &num)
#define read2(num1, num2) scanf("%d%d", &num1, &num2)
#define read3(num1, num2, num3) scanf("%d%d%d", &num1, &num2, &num3)
#define reads(str) scanf("%s", str)
#define readc(ch) scanf("%c", &ch)

#define pb push_back
#define mp make_pair

#define pii pair<int, int>
#define vi vector<int>
#define ll long long
ll fact[200005],ifact[200005];
ll M=1e9+7;
ll power(ll a,ll b){
    if(b==0){
        return 1;
    }
    if(b==1){
        return a%M;
    }
    ll k=power(a,b/2)%M;
    if(b%2){
        return (k%M*k%M*a%M)%M;
    }
    return (k%M*k%M)%M;
}
ll ncr(ll n,ll r){
    int val=fact[n];
    val=(val%M*ifact[r]%M*ifact[n-r]%M)%M;
    return val;
}
void factorial(){
    fact[0]=fact[1]=1;
    for(int i=2;i<=200000;i++){
        fact[i]=(fact[i-1]%M*i%M)%M;
    }
    ifact[200000] = power(fact[200000],M-2)%M;
    for(int i=199999;i>=0;i--){
        ifact[i] = (ifact[i+1]%M*(i+1)%M)%M;
        // ifact[i] = power(fact[i],M-2)%M;
    }
}
int main()
{
  ll n,k;
  //factorial();
    cin>>n>>k;
    //cout<<power(10,100);

    ll pre[n+1]={0},post[n+2]={0};
    for(int i=0;i<=n;i++){
        if(i==0){
            continue;
        }
        pre[i]=pre[i-1]+i;
    }
    for(int i=n;i>=0;i--){
        post[i]=i+post[i+1];
    }
    ll ans=0;
    for(ll i=k;i<=n+1;i++){
       ans=(ans%M+(post[n-i+1]-pre[i-1]+1)%M+M)%M;
        
    }
    cout<<ans%M;
}


Measured memory_bytes: 6748
N = int(input())
a_list = []
b_list = []
c_list = []
for i in range(N):
    a, b, c = map(int, input().split())
    a_list.append(a)
    b_list.append(b)
    c_list.append(c)

dp = [[-1 for _ in range(3)] for _ in range(N + 1)]

for i in range(1, N + 1):

    if i == 1:
        dp[i][0] = a_list[i - 1]
        dp[i][1] = b_list[i - 1]
        dp[i][2] = c_list[i - 1]
    else:
        dp[i][0] = max(dp[i][0], dp[i - 1][1] + a_list[i - 1])
        dp[i][0] = max(dp[i][0], dp[i - 1][2] + a_list[i - 1])
        dp[i][1] = max(dp[i][1], dp[i - 1][0] + b_list[i - 1])
        dp[i][1] = max(dp[i][1], dp[i - 1][2] + b_list[i - 1])
        dp[i][2] = max(dp[i][2], dp[i - 1][0] + c_list[i - 1])
        dp[i][2] = max(dp[i][2], dp[i - 1][1] + c_list[i - 1])

print(max(dp[N]))


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

int main() {
    int N;
    cin >> N;
    vector<int> h(N+1);
    vector<int> dp(N+1);
    
    rep(i,N){
        cin >> h[i+1];    
    }
    h[0] = h[1];
    dp[0] = 0;
    dp[1] = 0;
    for(int i=2;i<N+1;i++){
        dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
    }
    
    cout << dp[N] << endl;
    
    return 0;
}

Measured memory_bytes: 3948
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		long nR = 0;
		long nG = 0;
		long nB = 0;
		for (int i = 0; i < N; i++) {
			switch (S.charAt(i)) {
				case 'R':
					nR++;
					break;
				case 'G':
					nG++;
					break;
				case 'B':
					nB++;
					break;
			}
		}
		int err = 0;
		for (int j = 1; j < N - 1; j++) {
			for (int i = 1; i < Math.min(j + 1, N - j); i++) {
				char Si = S.charAt(j - i);
				char Sj = S.charAt(j);
				char Sk = S.charAt(j + i);
				if ((Si != Sj) && (Si != Sk) && (Sj != Sk)) {
					err++;
				}
			}
		}
		System.out.println(nR * nG * nB - err);
	}

}

Measured memory_bytes: 36636
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

// #define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9;

using P = pair<int, int>;


vector<int> to[100005];
int cost[100005];
signed main(){
    int n;
    cin >> n;

    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n-1);

    rep(i,n) {
        cin >> a[i];
        a[i]--;
    }
    rep(i,n) cin >> b[i];
    rep(i,n-1) cin >> c[i];

    int ans = b[a[0]];
    FOR(i, 1, n) {
        if(a[i-1]+1==a[i]) {
            ans += c[a[i]-1];
        }
        ans += b[a[i]];
        //cout << ans << endl;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
    char a;
    cin >> a;
    if(a == 'a' || a == 'e' || a == 'i' || a == 'u' || a == 'o')
    {
        cout << "vowel" << endl;
    }else
    {
        cout << "consonant" << endl;
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'

//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

using namespace std;
template<class T, class T2> inline int chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline int chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const int MAXN = (1 << 20);

int n;
map<int64_t, int> id;
int64_t d[MAXN];

void read()
{
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		cin >> d[i];
		id[d[i]] = i;
	}
}

vector<pair<int, int> > ans;
vector<int> adj[MAXN];
int tr_sz[MAXN];

int64_t solve(int u)
{
	int64_t ret = tr_sz[u] - 1;
	for(auto i: adj[u])
		ret += solve(i);
	return ret;
}

void solve()
{
	for(int i = 1; i <= n; i++) tr_sz[i] = 1;

	while(id.size() > 1)
	{
		auto it = id.rbegin();
		int i = it->second;

		int64_t d_par = d[i] - n + 2 * tr_sz[i];

		if(!id.count(d_par) || d_par == d[i])
		{
			cout << -1 << endl;
			return;
		}

		int par = id[d_par];

		ans.push_back({par, i});
		adj[par].push_back(i);

		tr_sz[par] += tr_sz[i];
		id.erase(--id.end());
	}

	int root = id.begin()->second;
	if(solve(root) != d[root])
	{
		cout << -1 << endl;
		return;
	}

	for(auto it: ans) cout << it.first << " " << it.second << endl;
}

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

	read();
	solve();
	return 0;
}



Measured memory_bytes: 37112
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int MOD = 1000000007;
//const int MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const double pi = acos(-1.0);
const double EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

struct Graph{
    vector<vector<int>> es;
    const int n;

    Graph(int n) : n(n){
        es.resize(n);
    }

    void add_edge(int from, int to, bool directed = false){
        es[from].pb(to);
        if(!directed) es[to].pb(from);
    }
};

struct Strongly_Connected_Components{
    vector<vector<int>> es, rs;
    vector<int> vs, comp;
    vector<bool> used;
    const int n;

    Strongly_Connected_Components(int n) : n(n){
        es.resize(n), rs.resize(n);
        vs.resize(n), comp.resize(n), used.resize(n);
    }

    void add_edge(int from, int to, bool directed = false){
        es[from].pb(to), rs[to].pb(from);
        if(!directed) es[to].pb(from), rs[from].pb(to);
    }

    void dfs(int now){
        used[now] = true;
        for(auto &e: es[now]) if(!used[e]) dfs(e);
        vs.pb(now);
    }

    void rdfs(int now, int cnt){
        used[now] = true, comp[now] = cnt;
        for(auto &e: rs[now]) if(!used[e]) rdfs(e, cnt);
    }

    Graph decompose(){
        fill(all(used), false);
        rep(i, n) if(!used[i]) dfs(i);
        fill(all(used), false), reverse(all(vs));
        int cnt = 0;
        for(auto &e: vs) if(!used[e]) rdfs(e, cnt++);
        Graph G(cnt);
        rep(i, n){
            for(auto &e: es[i]){
                int u = comp[i], v = comp[e];
                if(u != v) G.add_edge(u, v, true);
            }
        }
        return G;
    }

    int operator [] (int k) const {return comp[k];}
};

int main(){
    int N, M;
    cin >> N >> M;
    Strongly_Connected_Components scc(N);
    rep(i, M){
        int u, v; cin >> u >> v;
        scc.add_edge(u, v, true);
    }
    Graph G = scc.decompose();
    int n = G.n;
    vector<int> vs[n];
    rep(i, N) vs[scc[i]].pb(i);
    cout << n << endl;
    rep(i, n){
        cout << sz(vs[i]);
        for(auto &e: vs[i]) cout << ' ' << e;
        cout << endl;
    }
}

Measured memory_bytes: 103144
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
	string s,t;
	cin>>s>>t;
	reverse(s.begin(),s.end());
	if(s==t){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
A = []
A_t = []
for i in range(3):
    A.append(list(map(int, input().split())))
    A_t.append([None] * 3)
for i in range(3):
    for j in range(3):
        A_t[j][i] = A[i][j]
n = int(input())
B = [None] * n
for i in range(n):
    B[i] = int(input())
ans = A + A_t + [[A[0][0], A[1][1], A[2][2]], [A[0][2], A[1][1], A[2][0]]]
for i in range(len(ans)):
    if (all([
        ans[i][0] in B,
        ans[i][1] in B,
        ans[i][2] in B
    ])):
        print('Yes')
        exit()
else:
    print('No')


Measured memory_bytes: 38492
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define INF LLONG_MAX
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    while (b != 0) {
        ll x = a, y = b;
        a = y, b = x % y;
    }
    return a;
}

int main()
{
    ll n, x; cin >> n >> x;
    ll g; cin >> g;
    g = abs(g - x);
    REP(i, n-1) {
        ll num; cin >> num;
        num = abs(num - x);
        g = gcd(g, num);
    }
    cout << g << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
a,b=0,0
ans=[]

def pl(a,b):
    asum,bsum=0,0
    for i in range(len(a)):
        asum+=int(a[i])
    for i in range(len(b)):
        bsum+=int(b[i])
    return asum+bsum
        
for i in range(1,n):
    a=i ; b=n-i
    a=str(a) ; b=str(b)
    ans.append(pl(a,b))

print(min(ans))

Measured memory_bytes: 3864
import math
import sys

input = sys.stdin.readline


def read_i():
    return list(map(int, input().split()))


a, b, x = read_i()
if 2 * x <= a**2 * b:
    rad = math.atan2(a * b**2, 2 * x)
else:
    rad = math.atan2(2 * (a**2 * b - x), a**3)
print(rad * 180 / math.pi)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
using namespace std;
// 型シノニム
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
// 定数
constexpr ll INF   = 1e16;
constexpr ll INM   = 114514;
constexpr ll MOD   = 1e9 + 7;
constexpr ld EPS   = 1e-12;
constexpr ll dx[4] = {1, 0, -1, 0};
constexpr ll dy[4] = {0, 1, 0, -1};
// 便利関数
void IOS() { ios::sync_with_stdio(false), cin.tie(0); }
template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, ll t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
vector<string> split(const string &s, char delim) {
	vector<string> elems;
	string item;
	for (char ch : s) {
		if (ch == delim) {
			if (!item.empty())
				elems.push_back(item);
			item.clear();
		} else {
			item += ch;
		}
	}
	if (!item.empty())
		elems.push_back(item);
	return elems;
}
ll powm(ll a, ll b, ll m) {
	if (b == 0) {
		return 1;
	} else if (b % 2 == 0) {
		ll d = powm(a, b / 2, m);
		return (d * d) % m;
	} else {
		return (powm(a, b - 1, m) * a) % m;
	}
}

// 本体

void updatemp(map<P, P> &mp, P key, bool is1) {
	if (mp.find(key) == mp.end()) {
		mp[key] = P(0, 0);
	}
	if (is1) {
		mp[key].first++;
	} else {
		mp[key].second++;
	}
}

int main() {
	IOS();
	ll n;
	cin >> n;
	map<P, P> mp;
	ll zero = 0;
	for (int i = 0; i < n; i++) {
		ll a, b;
		cin >> a >> b;
		if (a == 0 && b == 0) {
			zero++;
		} else if (a == 0) {
			updatemp(mp, P(1, 0), true);
		} else if (b == 0) {
			updatemp(mp, P(1, 0), false);
		} else {
			ll za = abs(a), zb = abs(b);
			ll na = za / gcd(za, zb), nb = zb / gcd(za, zb);
			if ((a > 0 && b > 0) || (a < 0 && b < 0)) { // 第1or第3象限
				updatemp(mp, P(na, nb), true);
			} else { // 第2or第4象限
				updatemp(mp, P(nb, na), false);
			}
		}
	}
	ll nonzero = 1;
	for (const auto &[_, val] : mp) {
		nonzero *= (powm(2, val.first, MOD) + powm(2, val.second, MOD) - 1) % MOD;
		nonzero %= MOD;
	}
	if (zero == 0) {
		dump((nonzero - 1 + MOD) % MOD);
	}else {
		dump((nonzero + zero - 1 + MOD) % MOD);
	}
}

Measured memory_bytes: 19164
/*input
 
*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,D;cin>>n>>D;
  	int ans=0; 
  	for(int i=0;i<n;i++)
    {
      long long int x,y;cin>>x>>y;
      ans+=((x*x+y*y)<=D*D);
    }
  	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long q = sc.nextLong();
		long h = sc.nextLong();
		long s = sc.nextLong();
		long d = sc.nextLong();

		long n = sc.nextLong();
		long target = q *4;
		if(target > h *2) {
			target = h *2;
		}
		if(target > s) {
			target =s;
		}
		if(target > (double)d /2.0 && n >=2 ) {
			long answer = (d * (n/2)) +(target * (n%2));
			System.out.println(answer);
		}else {
			System.out.println(target * n);
		}

	}
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define ll long long
using namespace std;
void euler(ll n)
{
    ll i,c=1,j;
    for(i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            c++;
            while(n%i==0)
                n/=i;
        }
    }
    if(n>1)c++;
    cout<<c;
}
int main()
{
   ll a,b,n;
    cin>>a>>b;
    n=__gcd(a,b);
    euler(n);
}


Measured memory_bytes: 256
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <numeric>
#include <string>
#include <vector>
using namespace std;

#define FOR(i, s, e) for(int i=s; i<e; i++)
#define REF(i, s, e) for(int i=s; i>e; i--)
typedef long long ll;

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

	int n;
	cin >> n;

	vector<ll> a(n);
	int countMinus = 0;
	FOR(i, 0, n) {
		cin >> a[i];
		//マイナスの数数える
		if (a[i] < 0) countMinus++;
	}

	//aの絶対値和を計算
	ll sum1 = 0;
	FOR(i, 0, n) sum1 += abs(a[i]);
	//cout << "sum:" << sum1 << endl;

	//cout << "count[-] :" << countMinus << endl;
	//マイナスの数が偶数なら
	//ans = sum1
	if (countMinus % 2 == 0) cout << sum1 << endl;
	
	//マイナスの数が奇数なら
	//ans = sum1 - 2*min(a[i]の絶対値)
	//2倍してるのはsum1の中にmin(a[i]の絶対値)が含まれてるため
	else {
		//min(a[i]の絶対値)計算
		ll min_a = 1LL<<30;
		FOR(i, 0, n) min_a = min(min_a, abs(a[i]));
		//cout << "min_a:" << min_a << endl;
		
		cout << sum1 - 2*min_a << endl;
	}
}

Measured memory_bytes: 1024
N = int(input())
past = []
last = ""
Success = True
for i in range(N):
    W = input()
    # print("past:", past)
    # print("W[0]:", W[0])
    # print("last[-1]:", last[-1:])
    if last == "":
        past.append(W)
        last = W
    elif W in past or W[0] != last[-1:]:
        Success = False
    else:
        past.append(W)
        last = W

if Success == True:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
primes = 2 : 3 : 5 : primes'
  where
    isPrime (p:ps) n = p*p > n || n `rem` p /= 0 && isPrime ps n
    primes' = 7 : filter (isPrime primes') (scanl (+) 11 $ cycle [2,4,2,4,6,2,6,4])

main = do
  l <- getContents
  let i = map read $ lines l :: [Int]
      m = maximum i
      p = takeWhile (<=m) primes
      o = map (\a -> length $ takeWhile (<=a) p) i
  mapM_ print o


Measured memory_bytes: 13172
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N, H, ans= 0;
	static int A[100000], B[100000];
	cin >> N >> H;
	for (int i = 0; i < N; i++) {
		cin >> A[i] >> B[i];
	}
	sort(A, A + N, greater<int>()), sort(B, B + N);
	int maxA = A[0];
	int L = 0, R = N;
	while (R - L > 0) {
		int mid = (L + R) / 2;
		if (B[mid] < maxA) L = mid + 1;
		else R = mid;
	}
	int minB = R;
	for (int i = N - 1; i >= minB; i--) {
		H -= B[i];
		ans++;
		if (H <= 0) break;
	}
	if (H > 0) {
		if (H % maxA != 0) ans++;
		ans += H / maxA;
	}
	cout << ans;
}

Measured memory_bytes: 1024
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func solve(n int64) float64 {

	return float64((n + 1) / 2) / float64(n)
}

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	n := nextInt()
	res := solve(n)
	fmt.Fprintln(out, res)
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextStringAsBytes(n int64) []byte {
	sc.Scan()
	return []byte(sc.Text())
}

func nextInt() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int64) []int64 {
	ret := make([]int64, n)
	for i := int64(0); i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}

func nextFloats(n int64) []float64 {
	ret := make([]float64, n)
	for i := int64(0); i < n; i++ {
		ret[i] = nextFloat()
	}
	return ret
}
func nextStrings(n int64) []string {
	ret := make([]string, n)
	for i := int64(0); i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func containStr(arr []string, target string) bool {
	for _, v := range arr {
		if v == target {
			return true
		}
	}
	return false
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "orz")
	}
}

// mapからkeysとvaluesを返す
func splitKeyValue(m map[interface{}]interface{}) (keys, values []interface{}) {
	switch reflect.TypeOf(m).Kind() {
	case reflect.Map:
		s := reflect.ValueOf(m)
		for _, v := range s.MapKeys() {
			keys = append(keys, v)
			values = append(values, s.MapIndex(v))
		}
	default:
		fmt.Fprintln(out, "orz")
	}
	return
}


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


def cmb(n, r, p):
  if (r < 0) or (n < r):
    return 0
  r = min(r, n - r)
  return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
N = 2*(10 ** 5 ) # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p) 階乗のmod
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用 

for i in range(2, N + 1):
  fact.append((fact[-1] * i) % p)
  inv.append((-inv[p % i] * (p // i)) % p)
  factinv.append((factinv[-1] * inv[-1]) % p)

#0の数がmin(n-1,k)
MAX=min(n-1,k)

dp=[0]*(MAX+1)
dp[0]=1
ans=1
for i in range(1,MAX+1):
    ans+=cmb(n,i,p)*cmb(n-i+i-1,i,p)
    ans%=p
    #print(ans)

print(ans)


Measured memory_bytes: 28628
#include<bits/stdc++.h>
using namespace std;
#define int long
signed main(){
  int k;
  cin>>k;
  vector<int> a(k);
  for(int i=0;i<k;++i)cin>>a[i];
  auto manip = [=](int x){
    for(int i=0;i<k;++i)x-=x%a[i];
    return x;
  };
  int limu=2,liml,maxn,minn,l,r;
  while(manip(limu)<=2)limu<<=1;
  liml=limu;
  while(manip(liml)>=2)liml-=max(1L,liml/100);
  liml=max(1L,liml);
  
  l=liml,r=limu;
  while(l-r){
    int mid,mid0;
    mid0=(l+r)/2;
    mid=manip(mid0);
    if(mid<2)l=mid0+1;
    else if(2<mid)r=mid0-1;
    else r=mid0;
  }
  minn=l;
  
  l=minn,r=limu;
  while(l-r){
    int mid,mid0;
    if(r-l==1)mid0=r;
    else mid0=(l+r)/2;
    mid=manip(mid0);
    if(mid<2)l=mid0+1;
    else if(2<mid)r=mid0-1;
    else l=mid0;
  }
  maxn=l;
  
  if(minn==maxn){
    if(manip(minn)==2)cout<<minn<<" "<<minn<<endl;
    else cout<<-1<<endl;
  }
  else cout<<minn<<" "<<maxn<<endl;
  
  return 0;
}

Measured memory_bytes: 1792
#include<queue>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
int main(){
  long long int i,n,k;
  vector<long long int> a;
  cin >> n;
  k=n;
  for(i=2;i*i<=n;i++){
    if(n%i==0){
      a.push_back(i);
      while(n%i==0){
        n=n/i;
      }
    }
  }
  if(n!=1){
    a.push_back(n);
  }
  n=k;
  for(i=0;i<a.size();i++){
    n=n/a[i];
    n=n*(a[i]-1);
  }
  printf("%lld\n",n);
  return 0;
}


Measured memory_bytes: 3296
import std.stdio, std.string, std.conv, std.algorithm, std.range, std.math;

void main() {
  dchar[] a = readln.chomp.to!(dchar[]), b = readln.chomp.to!(dchar[]);

  sort(a);
  sort!((x, y) { return x > y; })(b);
  if (a < b) {
    writeln("Yes");
  } else {
    writeln("No");
  }
}


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

#define ll long long
#define INF 99999999
#define INF_LL 1LL << 60
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

int main()
{
    int H,W;
    cin >> H >> W;
    vector<vector<string> >S(H, vector<string>(W));
    rep(i,H)
    {
        rep(j,W)
        {
            cin >> S[i][j];
        }
    }

    rep(i,H)
    {
        rep(j,W)
        {
            if( S[i][j] == "snuke" )
            {
                cout << (char)('A'+j) << i+1 << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 256
// https://vjudge.net/contest/257174#problem/A

// Maximize The Formula 

#include<bits/stdc++.h>

using namespace std;

int main(){
	
	int a, b, c;
	cin >> a >> b >> c;
	
	int arr[3]  = {a, b, c};

	sort(arr, arr+3);
	
	int iniSum = ((arr[2])*10) + arr[1];
	int sum = iniSum + arr[0];
	
	cout << sum << "\n";
	
	
}
	




Measured memory_bytes: 256
N = int(input())
A = [int(_) for _ in input().split()]
count = {}
for a in A:
    count[a] = count.get(a, 0) + 1
res = 0
for k, v in count.items():
    res += v - 1
print(N - 2 * ((res + 1) // 2))


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

int main()
{
    long long int n,a,b,x,y;
    cin>>n>>a>>b;
    if(a==0)
        cout<<0<<endl;
    else{
            x=n/(a+b);
    y=n%(a+b);
        if(y<a)
            cout<<x*a+y<<endl;
        else
            cout<<x*a+a<<endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>

void select_myself(int x[],int y);

int main()
{
  int a,i;
  int in[100];

  scanf("%d",&a);
  if(1<=a&&a<=100){
    for(i=0;i<a;i++){
      scanf("%d",&in[i]);
    }
    select_myself(in,a);
  }
  return 0;
}

void select_myself(int x[],int y){
  int i,j,small,change,keep;
  int count=0;

  for(i=0;i<y-1;i++){
    small=i;
    for(j=i+1;j<y;j++){
      if(x[small]>x[j]){
	small=j;
    }
    }
    if(small != i){
      keep=x[i];
      x[i]=x[small];
      x[small]=keep;
      count++;
    }
  }

    for(j=0;j<y;j++){
      if(j>0) printf(" ");
      printf("%d",x[j]);
    }
    printf("\n%d\n",count);
}
      



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

int main() {
	string s, t;
	getline(cin, s);
	getline(cin, t);
	int ans = 0;
	int len = (int) s.length();
	for(int i = 0;i < len;i++){
		if(s[i] != t[i]) ans++;
	}
	printf("%d\n", ans);
	return 0; 
}


Measured memory_bytes: 3916
#encoding:utf-8 No.0538 2015.1.5
until (n = gets.chomp.to_i) == 0
  str_length = gets.chomp.to_i
  str = gets.chomp
  io = "IO"*n + "I"
  count = 0

  str_length.times do |i|
    if str[i,io.length] == io
      count += 1
    end
  end

  puts count
end

Measured memory_bytes: 54664
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	private static FastScanner sc = new FastScanner();

	public static void main(String[] args) {
		int N = sc.nextInt();
		int Q = sc.nextInt();

		long[] a = new long[N+1];
		a[0] = 0;
		for(int i=1; i<=N; i++) {
			a[i] = a[i-1] + sc.nextLong();
		}

		StringBuilder ans = new StringBuilder();
		for(int i=0; i<Q; i++) {
			long x = sc.nextLong();
			long count = 0;
			int k = 1;
			for(int j=0; j<N; j++) {
				if(a[N] - a[j] <= x) {
					count += N - j;
					continue;
				}
				
				
				while(k <= N) {
					if(a[k] - a[j] > x) {
						count += k - j - 1;
						break;
					}
					k++;
				}

			}
			
			ans.append(count);
			ans.append("\n");
		}
		
		System.out.print(ans);
	}

	static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            }else{
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
    }
}

Measured memory_bytes: 42568
let lim, inf = 400, 10101010101010
let () =
  Scanf.scanf "%d %d %d" @@ fun n ma mb ->
  let x = Array.init n (fun _ -> Scanf.scanf " %d %d %d" (fun a b c -> a,b,c)) in
  let dp = Array.make_matrix (lim+1) (lim+1) inf in
  dp.(0).(0) <- 0;
  x |> Array.iter (fun (a,b,c) ->
    for i = 400 downto a do
      for j = 400 downto b do
        dp.(i).(j) <- min dp.(i).(j) (dp.(i-a).(j-b) + c)
    done done);
  Array.init (lim / max ma mb) (fun i -> dp.((i+1)*ma).((i+1)*mb))
  |> Array.fold_left min inf
  |> fun c -> Printf.printf "%d\n" (if c = inf then -1 else c)

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

int main() {
	long long n;
	cin >> n;
	vector<long long> a(n-1);
	for (long long i = 0; i < n-1; i++) {
		cin >> a.at(i);
	}
	
	vector<long long> b(n);
	for (long long i = 0; i < n-1; i++) {
		b.at(a.at(i)-1)++;
		}
  for (long long i = 0; i < n; i++) {
		cout << b.at(i) << endl;
	}
}

Measured memory_bytes: 6428
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,i,y,b,r,t,mx,mi,j,kin;

	while(1)	{
		scanf("%d",&n);
		if(n==0)	break;
		scanf("%d",&y);
		mx=10000;
		for(i=0;i<n;i++)	{
			scanf("%d %d %d",&b,&r,&t);
			if(t==1)	{
				kin=10000+10000*y*r/100;
			}
			else {
				kin=10000;
				for(j=0;j<y;j++)	{
					kin=kin+kin*r/100;
				}
			}
			if(mx<kin)	{
				mx=kin;
				mi=b;
			}
		}
		printf("%d\n",mi);
	}
	return 0;
}


Measured memory_bytes: 2672
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
using namespace std;
using ll = unsigned long long;
using p = pair<int, int>;

int main()
{
    ll K;
    string S;
    cin >> K;
    cin >> S;

    if (K >= S.size())
    {
        cout << S << endl;
    }
    else
    {
        cout << S.substr(0, K) << "..." << endl;
    }

    return 0;
}


Measured memory_bytes: 3628
package main

import (
	"fmt"
)

func main() {
	var s int
	fmt.Scan(&s)

	mp := make(map[int]bool)
	ans := 1
	mp[s] = true

	for {
		if s%2 == 0 {
			s = s / 2
		} else {
			s = 3*s + 1
		}
		ans++
		if _, v := mp[s]; v {
			fmt.Println(ans)
			return
		}
		mp[s] = true
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
    int64_t X, T;
    cin >> X >> T;
    int64_t res = X - T;
    if (res > 0) {
        cout << res << endl;
    } else {
        cout << "0" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
n, x = map(int, input().split())
li = list(map(int, input().split()))

total = 0
count = 1
for i in li:
  total += i
  count += 1
  if total == x:
    print(count)
    exit()
  if total > x:
    print(count-1)
    exit()
  
print(len(li)+1)

Measured memory_bytes: 3060
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever while (true)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
using namespace std;
// clang-format on

main {
  string s;
  priority_queue<int> q;
  while (cin >> s, s != "end") {
    if (s == "insert") {
      int k;
      cin >> k;
      q.push(k);
    }
    if (s == "extract") {
      cout << q.top() << endl;
      q.pop();
    }
  }
}

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

using P = pair<int, int>;   // (????????°, ???????????????)

const int MAX_N = 1 << 8;

bool dns[MAX_N];

int n, m;

P fun(int lb, int ub) {
    int team = -1,
        num = 0;
    if (ub - lb <= 1) {
        int id = lb;
        if (dns[id]) return make_pair(0, -1);
        else return make_pair(0, lb);
    } else {
        P left = fun(lb, (lb + ub) / 2),
          right = fun((lb + ub) / 2, ub);

        num = left.first + right.first;
        team = max(left.second, right.second);

        if (min(left.second, right.second) >= 0) {
            num++;
        }

        return make_pair(num, team);
    }
}

int main() {
    cin >> n >> m;

    for (int i = 0; i < m; i++) {
        int a;
        cin >> a;
        dns[a] = true;
    }

    cout << fun(0, n).first << endl;

    return 0;
}

Measured memory_bytes: 3092
N = int(input())
count_eq = 0
count_df = 0
for i in range(1,N):
  for j in range(i,N):
    if i*j <= N-1:
      if i == j:
        count_eq += 1
      else :
      	count_df += 1
    else :
      break
print(count_eq + 2*count_df)

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

typedef long long int ll;

using namespace std;

ll calc(vector<int> &v)
{
    ll sum = 0;
    for(int i = 0;i < v.size();i++)
	sum = sum*10 + v[i];

    return sum;
}

ll Solve(string T)
{
    ll sum = 0;
    int lim = pow(2,T.size()-1);

    for(int bit_use = 0;bit_use < lim;bit_use++)
    {
	string s = T;
	vector<int> position;
	
	for(int i = 0;i < s.size();i++)
	{
	    if(bit_use & 1 << i)
		position.push_back(s.size()-1-i);
	}

	for(int i = 0;i < position.size();i++)
	    s.insert(s.begin()+position[i],'+');

	vector<int> v;

	for(int i = 0;i < s.size();i++)
	{
	    if(s[i] != '+')
	    {
		v.push_back(s[i]-'0');
	    } else {
		sum += calc(v);
		v.clear();
	    }
	}
	sum += calc(v);
    }

    return sum;
}

int main(void)
{
    string s;

    cin>>s;
    cout<<Solve(s);

    return 0;
}



Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
	long long n,i=1;
	string k ="";
	cin >> n;
	while(n!=0){
		k+=char('a'+((n-1)%26));
		n--;
		n/=26;
	
	};
	reverse(k.begin(),k.end());
	cout <<  k << endl;
	return 0;
}

Measured memory_bytes: 3132
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int K = sc.nextInt();
        StringBuilder ans = new StringBuilder();
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            int diff = 26-(c-'a');
            if (i  < s.length()-1) {
                if (c != 'a' && K >= diff) {
                    K -= diff;
                    ans.append('a');
                } else {
                    ans.append(c);
                }
            } else {
                ans.append((char)('a'+(c-'a'+K)%26));
            }
        }

        System.out.println(ans.toString());
    }
}



Measured memory_bytes: 26028
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
double pi = 3.141592653589793;
ll mod = 1000000007;
ll INF = 1000000001;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;



int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a!=b&&b!=c&&c!=a||a==b&&b==c){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    } 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
//typedef tree<int,null_type,less<int >,rb_tree_tag,tree_order_statistics_node_update>indexed_set;
template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);
#define debug(a) cerr<<#a<<" --> "<<(a)<<endl;
#define fastInput ios_base::sync_with_stdio(false);cin.tie(0)
#define INPUT freopen("input.txt","r",stdin)
#define OUTPUT freopen("output.txt","w",stdout)
#define ERROR  1e-9
#define pi (2*acos(0))
const ll mod = 998244353;
const int N = 1e5 +5;

void SOLVE(int cas)
{
    int n;
    scanf("%d",&n);
    vector<int>a(n), tmp(n);
    map<int,int>pos;
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        tmp[i]= a[i];
        pos[a[i]] = i;
    }
    sort(tmp.begin(),tmp.end());
    int cnt= 0;
    for(int i=0;i<n;i++)
    {
        int now= tmp[i];
        if(i%2 != pos[now]%2)
        {
            cnt++;
        }
    }
    printf("%d\n",cnt/2);
}


/*


*/



int main()
{
    //INPUT;
    //OUTPUT;
    int t=1,cas=0;
    //scanf("%d",&t);
    while(t--)
    {
        SOLVE(++cas);
    }

    return 0;
}



//os.order_of_key(v): returns how many elements strictly less than v
//os.find_by_order()

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(int i=0; i<v.size(); i++)
    {
        os<<v[i]<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}


Measured memory_bytes: 5760
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[] args) {
        int n = scanner.nextInt();
        Pattern pattern = Pattern.compile(IntStream.range(0, scanner.nextInt()).mapToObj(i -> Integer.toString(scanner.nextInt())).collect(Collectors.joining("", "[^", "]+")));
        IntStream.iterate(n, i -> ++i).filter(i -> pattern.matcher(Integer.toString(i)).matches()).findFirst().ifPresent(System.out::println);
    }
}

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


using namespace std;

int main()
{long long int A,B;
cin>>A>>B;
if(A>0){
    cout<<"Positive"<<endl;
}if(A==0||B==0){
    cout<<"Zero"<<endl;
}if(A<0){
    if(B>0){
        cout<<"Zero"<<endl;
    }if(B<0){
        long long int D = abs(abs(A)-abs(B))+1;
        if(D%2==0){
            cout<<"Positive"<<endl;
        }else{
            cout<<"Negative"<<endl;
        }
    }
}
}


Measured memory_bytes: 256
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace __init {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
#include "../debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

using BS = bitset<16>;

int main() {
    ll N, M;
    cin >> N >> M;
    V<BS> lamp;
    for(ll i = 0; i < M; i++) {
        ll K;
        cin >> K;
        BS b(0);
        for(ll j = 0; j < K; j++) {
            ll s;
            cin >> s;
            s--;
            b.set(s, 1);
        }
        lamp.push_back(b);
    }

    V<ll> p(M);
    for(ll &e : p) cin >> e;

    ll upper = 1;
    ll ans = 0;
    for(ll i = 0; i < N; i++) upper *= 2;
    for(ll S = 0; S < upper; S++) {
        BS bs(S);
        bool ok = true;
        for(ll i = 0; i < M; i++) {
            BS band = bs & lamp[i];
            if(band.count() % 2 != p[i]) ok = false;
        }
        ans += ok;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
// https://serhatgiydiren.github.io

#include <bits/stdc++.h>

using namespace std;

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(char c) {
  return to_string(string(1,c));
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define D(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define D(...) 404
#endif

void solve(const int &test_id)
{
 int a,b,c,d,e;
 cin >> a >> b >> c >> d >> e;
 int q=(60*c+d)-(60*a+b);
 cout << q-e << endl;
}
            
void solve_cases()
{
 int test_cases=1;
 //cin >> test_cases;
 for(int i=1;i<=test_cases;i++) solve(i);
}

void fast_io()
{
 ios::sync_with_stdio(false);
 srand(time(NULL));
 cin.tie(0);
 cout.tie(0);
 cout << fixed << setprecision(15);
 cerr << fixed << setprecision(15);
}

int main()
{
 fast_io();
 solve_cases();
 return EXIT_SUCCESS;
}



Measured memory_bytes: 3640
from collections import Counter

H, W = map(int, input().split())

raw = ""
for i in range(H):
    raw = raw + input()
words = Counter(list(raw))

if H*W % 2 == 1:
    flag = 0
    two_sum = (H-1) + (W-1)
elif H%2 == 1:
    flag = 1
    two_sum = W
elif W%2 == 1:
    flag = 1
    two_sum = H
else:
    flag = 1
    two_sum = 0

for value in words.values():
    if value % 2 == 1:
        flag += 1
    if flag > 1:
        print("No")
        break

if flag < 2 and two_sum > -1:
    for key, value in words.items():
        N_key = value
        while N_key > 0:
            if 1 < N_key < 4:
                N_key -= 2
                two_sum -= 2
            else:
                N_key -= 4

if flag < 2 and two_sum > -1:
    print("Yes")
elif two_sum < 0:
    print("No")


Measured memory_bytes: 3444
N, M = map(int, input().split())
key = []
for i in range(M):
    a, b = map(int, input().split())
    c = list(map(int, input().split()))
    s = 0
    for j in range(b):
        s |= 1<<(c[j]-1)
    key.append([s, a])

INF = 10**8
dp = [INF] * (1<<N)
dp[0] = 0
for s in range(1<<N):
    for i in range(M):
        t = s | key[i][0]
        cost = dp[s] + key[i][1]
        dp[t] = min(dp[t], cost)
ans = dp[-1]
if ans == INF:
    ans = -1
print(ans)

Measured memory_bytes: 45800
package main

import (
	"fmt"
)

func main() {
	var k, s int
	fmt.Scan(&k, &s)

	count := 0
	for x := 0; x <= k; x++ {
		for y := 0; y <= k; y++ {
			z := s - x - y
			if z >= 0 && z <= k {
				count++
			}

		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 512
#include <bits//stdc++.h>
using namespace std;
int main() {
	string s;
	cin>>s;
	int n=s.size();
	int ans=1;
	for(int i=0;i<n-1;i++){
		if(s[i]==s[i+1])ans=0;
	}
	if(ans==0)cout<<"Bad";
	else cout<<"Good";
	return 0;
}


Measured memory_bytes: 256