akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
public class Hello{
    public static void Main(){
        // Your code here!
        int[] hoge=System.Console.ReadLine().Trim().Split(' ').Select(x=>int.Parse(x)).ToArray();
        if(hoge[1]-hoge[0]>=hoge[2]*2){
        for(int i=0;i<hoge[2];i++){
            System.Console.WriteLine(hoge[0]+i);
        }
        for(int j=hoge[2]-1;j>=0;j--){
            System.Console.WriteLine(hoge[1]-j);
        }
        }
        else{
        for(int i=hoge[0];i<=hoge[1];i++){
            System.Console.WriteLine(i);}
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
 
int main(void){
    int N;
    ll num, sum, ans, MOD;
    vector<ll> A;
    sum = 0;
    ans = 0;
    MOD = 1e9+7;
    
    cin >> N;
    for (int i = 0; i < N; i++){
        cin >> num;
        sum += num;
        A.push_back(num);
    }
    
    for (int i = 0; i < N - 1; i++){
        ll temp;
        sum -= A[i];
        temp = sum % MOD;
        ans += A[i] * temp;
        ans %= MOD;
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 5304
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#if __cplusplus >= 201103L
#include <chrono>
using namespace std::chrono;
#endif
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fi first
#define se second
#ifdef LOCAL
#define prln(x) (cout << #x << ' ' << x << endl)
#define pr(x) (cout << #x << ' ' << x << ' ' )
#define prv(x) (cout << x << ' ')
#else
#define prln(x) 
#define pr(x)
#define prv(x)
#endif
#define clr(x) memset((x), 0, sizeof((x)))
#define clr1(x) memset((x), -1, sizeof((x)))
#define endl "\n"
#define pi acos(-1)
#define rep(i, st, ed) for (int i = (st); i <= (ed); ++i)
#define rep0(i, st, ed) for (int i = (st); i < (ed); ++i)
#define per0(i, st, ed) for (int i = (st); i > ed; --i)
#define per(i, st, ed) for (int i = (st); i >= ed; --i)
#define chmin(a, b) (a = a > b ? b : a)
#define chmax(a, b) (a = a < b ? b : a)
template<class T> void _sf(T &x) {cin >> x;}
void _sf(int &x) {scanf("%d", &x);}
void _sf(ll &x) {scanf("%lld", &x);}
void _sf(double &x) {scanf("%lf", &x);}
void _sf(char &x) {scanf(" %c", &x);}
void _sf(char *x) {scanf("%s", x);}
void sf() {}
template <class T, class...U> void sf(T & head, U&... tail) { _sf(head); sf(tail...);}
template <class T> void out(const T &val) { cout << val << endl; }
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

int read() {
    int x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}


int main(){
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        #if __cplusplus >= 201103L
        auto start = steady_clock::now();
        #endif
    #endif
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0, j = s.size() - 1; i < j; ++i, --j) {
        if (s[i] != s[j]) ++ans;
    }
    out(ans);
    #ifdef LOCAL
        #if __cplusplus >= 201103L
        auto end = steady_clock::now();
        duration<double> time_span = duration_cast<duration<double>>(end - start);;
        printf("Total time: %.6fs\n", time_span.count());
        #endif
    #endif
    return 0;
}

Measured memory_bytes: 256
#include <bits//stdc++.h>
using namespace std;
#define int long long
#define rep(i,n,k) for(int i=n;i<k;i++)
#define P make_pair
#define F first
#define S second
#define M LLONG_MAX
signed main(void){
    int n,m,ans,p,q;
    ans=0;
    string s,s1,s2;
    vector<int> v;
    cin>>n;
    m=0;
    p=100;
    while(1){
        m++;
        p=p+p/100;
        if(n<=p){
            cout<<m<<endl;
            break;
        }
    }
}


Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
using namespace std;
string s1,s2;
int a[1000];
int ans=0;
int x,y,o;
int main()
{
	cin>>x>>y;
	for(int i=1;i<=x;i++)
	{
		cin>>o;
		a[i]=o;
	}
	sort(a+1,a+1+x);
	for(int i=x;i>=x-y+1;i--)
	{
		ans+=a[i];
	}
	cout<<ans<<endl;
	return 0;
}
//朱旭大傻逼

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  string s; cin >> s;
  int n = (int)s.length();
  if(n % 2 == 1){
    cout << "No" << endl;
    return 0;
  }
  bool f = true;
  for(int i = 0; i < n; i+=2){
    if(s.substr(i, 2) != "hi")f = false;
  }
  if(f)cout << "Yes\n";
  else cout << "No\n";
  return 0;
}


Measured memory_bytes: 256
def main():
    H, W, D = map(int, input().split())
    field = [list(map(int, input().split())) for _ in range(H)]

    c = [0] * (H * W)
    for i in range(H):
        for j in range(W):
            c[field[i][j] - 1] = (i, j)
    
    d = [0] * (H * W)
    for l in range(H * W - D):
        i, j = c[l]
        x, y = c[l + D]
        d[l+D] = d[l] + abs(x - i) + abs(y - j)
    
    Q = int(input())
    for _ in range(Q):
        L, R = map(int, input().split())
        print(d[R-1]-d[L-1])


main()

Measured memory_bytes: 57692
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//



int main(void) {
    
    ll a, b, c; cin >> a >> b >> c;
    ll ab = a * b * abs(c / 2 * 2 - c);
    ll bc = b * c * abs(a / 2 * 2 - a);
    ll ca = c * a * abs(b / 2 * 2 - b);
    ll ans = ab;
    ans = min(ans, bc);
    ans = min(ans, ca);
    out(ans);
    
    return 0;
}






Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
	int s[40] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };

	int k;
	cin >> k;

	cout << s[k - 1];

	return 0;


}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        int i,j,t,m,k,count=0;
        for(i=0; i<n; i++)
        {
            scanf("%d",&j);
            m=sqrt(j);
            k=1;
            for( t= 2; t<=m; t++)
                if(j%t==0)
                    k=0;
            if(k==1)
            {
                count++;
            }
        }
        printf("%d\n",count);
    }
}



Measured memory_bytes: 2076
import sys
sys.setrecursionlimit(20000000)

N = int(input())
Tree = [[] for i in range(N)]
for i in range(N-1):
    u, v, w = map(int, input().split())
    Tree[u-1].append([v-1, w])
    Tree[v-1].append([u-1, w])

ans = [-1]*N

def dfs(node, dist):
    for next_node, size in Tree[node]:
        if ans[next_node] == -1:
            ans[next_node] = ((dist+size)%2)
            dfs(next_node, dist+size)
dfs(0, 0)
print(*ans, sep='\n')

Measured memory_bytes: 87092
#include<bits/stdc++.h>
using namespace std;
#define int long long

int n, a[1000], ans;

signed main()
{
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(i > 0){
            if(a[i] == 1){
                a[i] = a[i - 1] + 1;
            }
        }
        ans = max(ans, a[i]);
    }
    cout << ans + 1 << endl;



    return 0;
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> radii(N);
  for(int i = 0; i < N; i++){
    cin >> radii.at(i);
  }
  sort(radii.begin(),radii.end());
  int ans = 0;
  int last;
  for(int i = 0; i < N; i++){
    if(i == 0){
      ans += 1;
    }else{
      if(radii[i] != last){
        ans += 1;
      }
    }
    last = radii[i];
  }
  cout << ans << endl;
  return 0;
}

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

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

#define fr first
#define sc second
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)

int main(){
	int a,b,c,x,y;
	cin>>a>>b>>c>>x>>y;
	
	int ret=1000000000;
	for(int z=0;z<=max(x,y);z++){
		chmin(ret,z*(2*c)+max(x-z,0)*a+max(y-z,0)*b);
	}
	cout<<ret<<endl;
}



Measured memory_bytes: 256
n, m = map(int, input().split())
p = list(map(int, input().split()))
xy = [list(map(int, input().split())) for _ in range(m)]


class UnionFind:
    def __init__(self, x):
        self.p = [e for e in range(x)]
        self.rank = [0] * x

    def same(self, u, v):
        return self.find_set(u) == self.find_set(v)

    def unite(self, u, v):
        self.link(self.find_set(u), self.find_set(v))

    def find_set(self, u):
        if u != self.p[u]:
            self.p[u] = self.find_set(self.p[u])

        return self.p[u]

    def link(self, u, v):
        if self.rank[u] > self.rank[v]:
            self.p[v] = u
        else:
            self.p[u] = v
            if self.rank[u] == self.rank[v]:
                self.rank[v] += 1


uf = UnionFind(n)

for x, y in xy:
    x -= 1
    y -= 1
    uf.unite(x, y)

cnt = 0
for e in p:
    e -= 1
    if uf.find_set(e) == uf.find_set(p[e] - 1):
        cnt += 1

print(cnt)


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

const int N = 1e6 + 100;

int main() {
    // freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int a, b;
    cin >> a >> b;
    cout << a * b << endl;

    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <sstream>
#include <cmath>
using namespace std;
typedef long long ll;

ll num[20];
ll lnum[20];
ll len[20];
ll s;
string ans;

ll C (ll n){
	n--;
	ll c=1,i=n;
	while(i>9)
		c++,i/=10;
	ll l=4*(n/3+n/5);
	l+=(n-n/3-n/5+n/15)*c;
	l-=num[c-1]*c;
	l+=len[c-1];
	l++;
	return  l;
}

int main(void){
	for(int i=1;i<=17;i++){
		ll n=pow(10,i)-1;
		num[i]=n-n/3-n/5+n/15;
		lnum[i]=num[i]-num[i-1];
		len[i]=lnum[i]*(i);
		len[i]+=len[i-1];
	}
	cin >> s;
	
	ll lb=1,ub=10e17;
	
	while(ub-lb>1){
		ll mid=(lb+ub)/2;
		if(C(mid)<=s)
			lb=mid;
		else
			ub=mid;
	}

	ll length=C(lb);
	ll diff=s-length;

	for(ll i=lb;i<lb+36;i++){
		if(i%15==0)
			ans+="FizzBuzz";
		else if(i%3==0)
			ans+="Fizz";
		else if(i%5==0)
			ans+="Buzz";
		else{
			stringstream ss;
			ss << i;
			ans+=ss.str();
		}
	//	cout << ans << endl;
	}
	cout << ans.substr(diff,20) << endl;
	//for(int i=0;i<18;i++)
	//	cout << i << " " << num[i] << " "<< lnum[i] << " " << len[i] << endl;
	return 0;
}

Measured memory_bytes: 1264
N, K = list(map(int, input().split()))
P = {i:n-1 for i, n in enumerate(list(map(int, input().split())))}
C = {i:n for i, n in enumerate(list(map(int, input().split())))}

cand = []
for i in range(N):
    current = i
    max_val = [C[P[current]]]
    sum_val = C[P[current]]
    while P[current]!=i:
        current = P[current]
        sum_val += C[P[current]]
        if sum_val>max_val[-1]:
            max_val.append(sum_val)
        else:
            max_val.append(max_val[-1])
    if K<=len(max_val):
        cand.append(max_val[K-1])
    else:
        if sum_val<=0:
            cand.append(max_val[-1])
        else:
            tmp_score = sum_val*(K//len(max_val))
            if K%len(max_val)>0:
                tmp_score += max_val[K%len(max_val)-1]
            cand.append(max(sum_val*(K//len(max_val)-1)+max_val[-1], tmp_score))
print(max(cand))

Measured memory_bytes: 78732
/*  Bismillahir Rahmanir Rahim  */

#include <bits/stdc++.h>

using namespace std;

const int N = 505;
const long long oo = 1e9;

long long n, m, h, w;
long long g[N][N];
long long sm[N][N];

int main(){
	scanf("%lld %lld %lld %lld", &n, &m, &h, &w);
	if(h == 1 && w == 1){
		printf("No\n");
		return 0;
	}
	long long mul = (h * w) - 1LL;
	long long put = (oo - 1LL) / (mul);
	for(int i = h; i <= n; i += h){
		for(int j = w; j <= m; j += w){
			g[i][j] = -((put * mul) + 1LL);
		}
	}
	long long sum = 0;
	for(int i = 1; i <= n; ++i){
		for(int j = 1; j <= m; ++j){
			if(g[i][j] == 0) g[i][j] = put;
			sum += g[i][j];
		}
	}
	long long neg = 0;
	for(int i = 1; i <= h; ++i){
		for(int j = 1; j <= w; ++j){
			neg += g[i][j];
		}
	}
	if(sum > 0 && neg < 0){
		printf("Yes\n");
		for(int i = 1; i <= n; ++i){
			for(int j = 1; j <= m; ++j){
				if(j != 1) printf(" ");
				printf("%lld", g[i][j]);
			}
			printf("\n");
		}
		return 0;
	}
	printf("No\n");
	return 0;
}



Measured memory_bytes: 4864
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=4002;
int n,i,j,k,a,b;
int h[N],t[N],v[N];
int f[N],g[N],sz[N],Ans=1<<30;
char s[N];
void add(int a,int b){
    t[++k]=h[a];
    h[a]=k;
    v[k]=b;
}
void init(){
    scanf("%d%s",&n,s+1);
    for(i=1;i<n;i++){
        scanf("%d%d",&a,&b);
        add(a,b);
        add(b,a);
    }
}
void dfs(int i,int fa){
    sz[i]=s[i]==49;
    for(int j=h[i];j;j=t[j])
        if(v[j]!=fa){
            dfs(v[j],i);
            if(f[i]>g[v[j]]+sz[v[j]])f[i]-=g[v[j]]+sz[v[j]];
            else if(f[v[j]]+sz[v[j]]>g[i])f[i]=f[v[j]]+sz[v[j]]-g[i];
            else f[i]=(g[i]+g[v[j]]+sz[v[j]])%2;
            sz[i]+=sz[v[j]];
            g[i]+=g[v[j]]+sz[v[j]];
        }
}
void work(){
    for(i=1;i<=n;i++){
        memset(f,0,sizeof(f));
        memset(g,0,sizeof(g));
        memset(sz,0,sizeof(sz));
        dfs(i,0);
        if(f[i]==0)
            Ans=min(Ans,g[i]/2);
    }
    if(Ans!=(1<<30))
        printf("%d",Ans);
    else
        printf("-1");
}
int main(){
    init();
    work();
    return 0;
}

Measured memory_bytes: 384
INF = 10**10

def main():
    n, k = map(int, input().split())
    hs = list(map(int, input().split()))

    dp = [INF]*n
    dp[0] = 0

    for i in range(1,n):
        from_ = max(i-k, 0)
        dp[i] = min(d + abs(hs[i]-h) for d, h in zip(dp[from_:i], hs[from_:i]))
    print(dp[-1])

if __name__ == "__main__":
    main()

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

int main() {
	int n,m;cin>>n>>m;
	vector<int> u(m),v(m);
	vector<vector<int>> uv(n);
	for(int i=0;i<m;i++){
		cin>>u[i]>>v[i];
		u[i]--;v[i]--;
		uv[u[i]].push_back(v[i]);
	}
	int s,t;cin>>s>>t;
	s--;t--;
	int hop=0;
	vector<vector<int>> used(n,vector<int>(3,0));
	vector<int> tempn;
	tempn.push_back(s);
	used[s][0]=1;
	while(tempn.size()){
		vector<int> nextn;
		hop++;
		for(int i=0;i<tempn.size();i++){
			for(int j=0;j<uv[tempn[i]].size();j++){
				if(used[uv[tempn[i]][j]][hop%3]==0){
					nextn.push_back(uv[tempn[i]][j]);
					used[uv[tempn[i]][j]][hop%3]=1;
					if(uv[tempn[i]][j]==t){
						if(hop%3==0){
							cout<<hop/3<<endl;
							return 0;
						}
					}
				}
			}

		}
		tempn=nextn;

	}
	cout<<-1<<endl;


	return 0;
}

Measured memory_bytes: 12032
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
	public static void main(String[] args) {
		var sc = new Scanner(System.in);
		var n = sc.nextInt();
		var a = IntStream.range(0, n).map(i -> sc.nextInt()).toArray();
		var b = IntStream.range(0, n).map(i -> sc.nextInt()).toArray();
		var c = IntStream.range(0, n - 1).map(i -> sc.nextInt()).toArray();
		sc.close();

		var result = Arrays.stream(b).sum();
		result += IntStream.range(0, n - 1).filter(i -> a[i] + 1 == a[i + 1]).map(i -> c[a[i] - 1]).sum();
		System.out.println(result);
	}
}


Measured memory_bytes: 36432
import java.util.Scanner;

public class Main {
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);

		int length = sc.nextInt();

		int argment[] = new int[length];

		for(int i = 0;i < length;i++) {
			argment[i] = sc.nextInt();
		}

		sc.close();

		int cnt = 0;

		for(int i = 0;i < length - 2;i++) {
			cnt += (
						(argment[i + 1] <= argment[i + 2] && argment[i + 1] >= argment[i]) ||
						(argment[i + 1] >= argment[i + 2] && argment[i + 1] <= argment[i])
					) ? 1 : 0;
		}

		System.out.println(cnt);
	}
}


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

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

    for(int i = 1;i<=n;i++){
        if(i % 3 == 0){
            cout << " " << i;
            continue;
        }
        int tmp = i;
        while(tmp != 0){
            if(tmp % 10 == 3){
                cout << " " << i;
                break;
            }
            tmp /= 10;
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
int main()
{
  int h,w; cin >> h >> w;
  vector<vector<char>> c(h, vector<char>(w));
  rep(i,h) rep(j,w) cin >> c[i][j];

  vector<vector<bool>> f(h, vector<bool>(w, true));
  rep(i,h) {
    bool ff = true;
    rep(j,w) {
      if(c[i][j] == '#') ff = false;
    }
    if(ff){
      rep(j,w) {
	f[i][j] = false;
      }
    }
  }

  rep(j,w) {
    bool ff = true;
    rep(i,h) {
      if(c[i][j] == '#') ff = false;
    }
    if(ff){
      rep(i,h) {
	f[i][j] = false;
      }
    }
  }

  rep(i,h) {
    bool fff = false;
    rep(j,w) {
      if(f[i][j]) {
	cout << c[i][j];
	fff = true;
      }
    }
    if(fff) cout << "\n";
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
// #define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(12);const int D=4,dx[]={+1,0,-1,0},dy[]={0,+1,0,-1};
const int N=3e5+5;
int a[N],b[N],c[N];
int32_t main(){
    int n,k;
    cin>>n>>k;
    int l=n/2;
    forn(i,n)c[i]=k+n+n+i;
    int j=0;
    if(n&1){
        for(int x=l;x>=0;--x,++j)a[j]=k+x;
        for(int x=n-1;x>l;--x,++j)a[j]=k+x;
        j=0;
        for(int x=0;x<n;x+=2,++j)b[j]=k+n+x;
        for(int x=1;x<n;x+=2,++j)b[j]=k+n+x;
    }else{
        j=0;
        for(int x=l-1;x>=0;--x,++j)a[j]=k+x;
        for(int x=n-1;x>=l;--x,++j)a[j]=k+x;
        j=0;
        for(int x=1;x<n;x+=2,++j)b[j]=k+n+x;
        for(int x=0;x<n;x+=2,++j)b[j]=k+n+x;
    }
    forn(i,n)if(a[i]+b[i]>c[i]){
        cout<<"-1\n";
        return 0;
    }
    forn(i,n)cout<<a[i]<<' '<<b[i]<<' '<<c[i]<<'\n';

    return 0;
}

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

typedef long long ll;

int main(){
  ll N;
  cin >> N;
  vector<ll> A(5);
  for (int i = 0; i < 5; i++) {
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());

  ll cnt=(N+A.at(0)-1)/A.at(0);
  cout << cnt+4 << endl;
}


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

int main (){
    string c;
    cin >> c;
    if(c == "a" || c == "e" || c == "i" || c =="o" || c=="u"){
        cout << "vowel" << endl;
    }else{
        cout << "consonant" << endl;
    }
}

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

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

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

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

const int INF = 1000000007;

bool contain(int bit, int pos) {
	if((bit & (1 << pos)) != 0) return true;
	else return false;
}

int main(void){
	string s; cin>>s;
	int n = s.size() - 1;
	ll sum = 0;

	for(int bit = 0;bit<(1<<n); bit++) {
		int l = 0;
		ll tmp = 0;
		int r;
		for(r = 0;r < n; r++) {
			if(contain(bit, r)) {
				string t = s.substr(l, r - l + 1);
				ll num = stoll(t);
				tmp += num;
				l = r + 1;
			}
		}
		string t = s.substr(l, r - l + 1);
		ll num = stoll(t);
		tmp += num;
		sum += tmp;
	}

	printf("%lld", sum);

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
  int n,x,i=0,min=2000000000,max=-2000000000;
  
  scanf("%d",&n);

  for(i=0;i<n;i++)
    {
      scanf("%d",&x);
      if(max <= x-min)max = x-min;
      if(min>=x)min=x;
      
    }
  printf("%d\n",max);

  return 0;
}



Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
int main(){
	int yen;
	cin>>yen;
	//cout<<yen%1000<<endl;
	if(yen%1000!=0){
		cout<<1000-(yen%1000)<<endl;
	}
	else
	cout<<0<<endl;
	
	return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int N, M;
  map<string, bool> m;

  cin >> N;
  for(int i=0; i<N; i++) {
    string U;
    cin >> U;
    m[U] = true;
  }

  cin >> M;
  int state = 0;
  for(int i=0; i<M; i++) {
    string T;
    cin >> T;
    if( m[T] && state == 0 ) cout << "Opened by " << T << endl, state = 1;
    else if( m[T] && state == 1 ) cout << "Closed by " << T << endl, state = 0;
    else cout << "Unknown " << T << endl;
  }
  
}

Measured memory_bytes: 3248
A, B, K = map(int, input().split())

output_list = []
output=[]

for i in range(K):
    output_list.append(A+i)
    output_list.append(B-K+i+1)

for num in output_list:
    if A <= num <= B:
        output.append(num)
    else:
        continue
output_set = set(output)
output_list = list(output_set)
output_list.sort()

for num in output_list:
    print(num)


Measured memory_bytes: 3060
import java.util.Scanner;


public class Main {


//	final int MOD = 1000000007;

//	public static int min = 3000000;

	public static void main(String[] args) {

		int ans = 0;
		Scanner sc = new Scanner(System.in);
		boolean f = false;

//		long k = sc.nextLong();

		int n = sc.nextInt();



		//-------------------------------------------------------------------------------------

		ans = n + (n*n) + (n*n*n);

		//-------------------------------------------------------------------------------------

//		if(f) {
//			System.out.println("Yes");
//		} else {
//			System.out.println("No");
//		}

		System.out.println(ans);

		sc.close();
	}



}

Measured memory_bytes: 35580
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        
		Judgment(A, B, C);
        
    }
    
    static void Judgment(int A, int B, int C) {
    	if (A == 5 && B == 7 && C == 5) {
			System.out.println("YES");
    	} else if (A == 5 && B == 5 && C == 7) {
    		System.out.println("YES");
    	} else if (A == 7 && B == 5 && C == 5) {
    		System.out.println("YES");
		} else {
			System.out.println("NO");
		}
    }
}

Measured memory_bytes: 23764
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define mod 1000000007
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;

vector<int> ve[100010];
int de[100010];

void dfs(int v, int d) {
    if (de[v] == -1) {
        de[v] = d;
    }
    else {
        return;
    }
    for (auto x : ve[v]) {
        dfs(x, d + 1);
    }
}

int main() {
    int n, a;
    cin >> n;
    imfor(i, n) {
        cin >> a;
        a--;
        ve[i].push_back(a);
    }
    fill(de, de + n, -1);
    dfs(0, 0);
    cout << de[1] << endl;
}

Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  int n=s.length();
  for(int i=0;i<n;i++)
    if(s[i]=='7')
    {
      cout<<"Yes";
      return 0;
    }
  cout<<"No";
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <math.h>
#include <queue>
#include <stdio.h>
#include <sstream>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)

int main()
{   
    int c[3][3];
    rep(i,3) rep(j,3) cin >> c[i][j];

    string ret = "Yes";
    rep(i,2)
        rep(j,2)
        {
            if(c[i+1][j+1]-c[i][j+1] != c[i+1][j]-c[i][j])
                ret = "No";
        }
    rep(i,2)
        rep(j,2)
        {
            if(c[i+1][j+1]-c[i+1][j] != c[i][j+1]-c[i][j])
                ret = "No";
        }

    cout << ret << endl;
    return 0;
}

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




public class Main {

    public static void main(String[] args) {
       
        Scanner sc = new Scanner(System.in);
        
        List<Index> pie = new ArrayList<>();
        
        for(int i=1; i<=13; i++) pie.add(new Index("S",i));
        for(int i=1; i<=13; i++) pie.add(new Index("H",i));
        for(int i=1; i<=13; i++) pie.add(new Index("C",i));
        for(int i=1; i<=13; i++) pie.add(new Index("D",i));
        
        int n = sc.nextInt();
        
        
        for(int j=0; j<n; j++){
            String mo = sc.next();
            int bu = sc.nextInt();
         for(Index ewq : pie){
          if(ewq.x.equals( mo )  && ewq.y == bu){
                 ewq.exist = true;
          }}}
        for(Index ewq : pie){
            if(!ewq.exist){
                System.out.println(ewq.x +" "+ ewq.y);
            }
        }
    }
    
    public static class Index {
        
         boolean exist;
         String x;
         int y;
         
         Index(String x, int y){
         this.x = x;
         this.y = y;
         exist = false;
        
        }
    }
}



        
    

       

   




Measured memory_bytes: 26204
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10 ** 9

def dfs(cur, a, b, c):
    if cur == N:
        return abs(a-A) + abs(b-B) + abs(c-C) - 30 if min(a, b, c) > 0 else INF
    ret0 = dfs(cur+1, a, b, c)
    ret1 = dfs(cur+1, a+l[cur], b, c) + 10
    ret2 = dfs(cur+1, a, b+l[cur], c) + 10
    ret3 = dfs(cur+1, a, b, c+l[cur]) + 10
    return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#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 ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using P = pair<int, int>;
using D = double;
using LD = long double;
const int mod = 1e9+7;
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; }
int main(){
    int h,a; cin >> h >> a;
    cout << (h+a-1) / a << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){

  int n,m,x,a[110],b[110]={};
  cin>>n>>m>>x;
  for(int i=0;i<m;i++){
     cin>>a[i];
     if(a[i]==x) continue;
     b[a[i]]++;
  }
  int sum1=0,sum2=0;
  for(int i=x;0<=i;i--) sum1+=b[i];

  for(int i=x;i<=n;i++) sum2+=b[i];
  cout<<min(sum1,sum2);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

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

signed main()
{
    int N,X; cin>>N>>X;
    vint x(N);
    REP(i,N) cin>>x[i];

    int ans=abs(x[0]-X);
    REP(i,N){
        ans=gcd(ans,abs(x[i]-X));
    }
    cout<<ans<<endl;

}


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

# AtCoder Beginner Contest
# Problem B


def count_operation(numbers):
    is_even = True
    count = 0

    while is_even is True:
        elements = divided_by(2 ** (count + 1), numbers)

        if elements.count(0) == number_count:
            count += 1
        else:
            is_even = False
    return count


def divided_by(number, numbers):
    return [element % number for element in numbers]


if __name__ == '__main__':
    number_count = int(input())
    numbers = list(map(int, input().split()))

    result = count_operation(numbers)
    print(result)


Measured memory_bytes: 2940
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
#define MAX 100005
#define DEBUG 0 
#define LIMIT (LONG_MAX / 10)
#define POSITIVE_LAST_D (LONG_MAX % 10)
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;


int main(){
    ll a;
    double b;
    cin>>a>>b;
    ll c=b*100+0.9;
    ll d=(a*c)/100;
    cout<<d<<endl;
    return 0;
}


Measured memory_bytes: 3692
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 3
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	a := getNextInt(scanner)
	b := getNextInt(scanner)
	c := getNextInt(scanner)
	mm := map[int]int{}
	mm[a] = mm[a] + 1
	mm[b] = mm[b] + 1
	mm[c] = mm[c] + 1
	if len(mm) == 2 {
		fmt.Fprintln(writer, "Yes")
		return
	}
	fmt.Fprintln(writer, "No")
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
char a[100005];

int main()
{
    int i,j,m,n;
    int b[27];
    ios::sync_with_stdio(false);
    while(cin>>a)
    {
        memset(b,0,sizeof(b));
        for(i=0;i<strlen(a);i++)
            b[a[i]-'a']++;
            for(i=0;i<26;i++)
            {
                if(b[i]==0)
                {
                    cout<<(char)('a'+i)<<endl;
                    break;
                }
            }
            if(i==26)
            {
                cout<<"None"<<endl;
            }
    }
    return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	string s1, s2, s3;

	cin>>s1>>s2>>s3;

	s1=s1+s2+s3;

	int n=stoi(s1);

	cout<<YN(n%4==0)<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef vector<ll> vll;
struct Solution {
    void solve(std::istream& in, std::ostream& out) {
        ll n;
        in >> n;
        vll c(n), s(n), f(n);
        for (int i = 0; i < n; i++) {
            in >> c[i] >> s[i] >> f[i];
        }
        for (int i = 0; i < n; i++) {
            ll t = 0;
            for (int j = i; j < n - 1; j++) {
                if (t < s[j]) {
                    t = s[j];
                }
                else if (t % f[j] != 0) {
                    t = t + f[j] - t % f[j];
                }
                t += c[j];
            }
            out << t << '\n';
        }
    }
};
void solve(std::istream& in, std::ostream& out) {
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}
#include <fstream>
#include <iostream>
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    istream& in = cin;
    ostream& out = cout;
    solve(in, out);
    return 0;
}


Measured memory_bytes: 256
/*
@author: sharrad99
*/
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int n;
	cin >> n;
	string s;
	cin >> s;
	int res = 0, l = 0, r = s.length() - 1;
	while(true) {
		while(l < s.length() and s[l] == 'R') l++;
		while(r >= 0 and s[r] == 'W') r--;
		if(r >= 0 and l < n and l < r) res++, l++, r--;
		else break;
	}

	cout << res << '\n';
}

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

int main()
{
    int x = 0;
    int n;
    string s;
    cin >> n >> s;
    int ma = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == 'I'){
            x++;
        }else{
            x--;
        }
        ma = max(x,ma);
    }
    cout << ma << endl;
}

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

int fact(int N) {
	if (N == 0) return 1;
	return N*fact(N - 1);
}

int main() {
	int N;
	cin >> N;
	vector<int> P(N), Q(N);
	for (int i = 0; i < N; i++) cin >> P.at(i);
	for (int i = 0; i < N; i++) cin >> Q.at(i);

	int dica = 0, dicb = 0, cnta = 0, cntb = 0;
	vector<int> useda(N, 1), usedb(N, 1);
	for (int i = 0; i < N; i++) {
		useda.at(P.at(i) - 1) = 0;
		usedb.at(Q.at(i) - 1) = 0;
		for (int j = 0; j < P.at(i) - 1;j++) {
			cnta += useda.at(j);
		}
		for (int j = 0; j < Q.at(i) - 1;j++) {
			cntb += usedb.at(j);
		}
		dica += cnta*fact(N - i - 1);
		cnta = 0;
		dicb += cntb*fact(N - i - 1);
		cntb = 0;
	}
	cout << abs(dica - dicb) << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
using namespace std;
int main(){
    int n,a[10];
    scanf("%d",&n);
    for(int ix=0;ix<n;ix++){
        for(int jx=0;jx<10;jx++){
            scanf("%d",&a[jx]);
        }
        bool is=false;
        for(int i=0;i<(1<<10);i++){
            vector<int> b,c;
            for(int j=0;j<10;j++){
                if(i&(1<<j))b.push_back(a[j]);
                else c.push_back(a[j]);
            }
            bool isb=true,isc=true;
            if(!b.empty()){
                for(int j=1;j<b.size();j++){
                    if(b[j-1]>b[j]){
                        isb=false;
                        break;
                    }
                }
            }
            if(!c.empty()){
                for(int j=1;j<c.size();j++){
                    if(c[j-1]>c[j]){
                        isb=false;
                        break;
                    }
                }
            }
            if(isb&&isc){
                is=true;
                break;
            }
        }
        if(is)printf("YES\n");
        else printf("NO\n");
    }
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <string>
#include <deque>
#include <queue>
#include <unordered_map>
#include <assert.h>
using namespace std;
typedef long long ll;
#define pi pair<int, int>
#define pii pair<pi, pi>

const int MOD = 1e9 + 7;
const int mxn = 2e6 + 7;
ll p25[mxn], p26[mxn];

ll exp(ll x, ll n) {
	if (n == 1) {
		return x;
	}
	ll ans = exp(x, n >> 1) % MOD;
	if (n & 1) {
		return ans * ans % MOD * x % MOD;
	}
	else {
		return ans * ans % MOD;
	}
}

int main() {
	int K, N;
	string S;
	cin >> K;
	cin >> S;
	N = S.size();

	p25[0] = 1;
	p26[0] = 1;
	for (int i = 1; i <= N + K; i++) {
		p25[i] = (p25[i - 1] * 25) % MOD;
		p26[i] = (p26[i - 1] * 26) % MOD;
	}

	ll ans = 0;
	ll M = 1;
	for (int i = N; i <= N + K; i++) {
		ans = (ans + M * p25[i - N] % MOD * p26[N + K - i] % MOD) % MOD;
		M = M * i % MOD * exp((ll)i - N + 1, MOD - 2) % MOD;
		assert(M >= 0);
	}
	cout << ans << '\n';
}

Measured memory_bytes: 35632
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int main(){
  string s;
  int k;
  cin >> s >> k;
  int n = s.size();
  vector<string> data;
  set<string> st;
  rep(i,n){
    string tmp = {};
    tmp += s.at(i);
    if(!st.count(tmp)) data.push_back(tmp);
    st.insert(tmp);
    if(i+1 >= n) continue;
    tmp += s.at(i+1);
    if(!st.count(tmp)) data.push_back(tmp);
    st.insert(tmp);
    if(i+2 >= n) continue;
    tmp += s.at(i+2);
    if(!st.count(tmp)) data.push_back(tmp);
    st.insert(tmp);
    if(i+3 >= n) continue;
    tmp += s.at(i+3);
    if(!st.count(tmp)) data.push_back(tmp);
    st.insert(tmp);
    if(i+4 >= n) continue;
    tmp += s.at(i+4);
    if(!st.count(tmp)) data.push_back(tmp);
    st.insert(tmp);
  }
  sort(data.begin(),data.end());
  cout << data.at(k-1) << endl;
}

Measured memory_bytes: 1792
// 標準入力
var fs = require('fs'),
length = fs.fstatSync(process.stdin.fd).size,
buffer = new Buffer(length),
bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
input = buffer.toString('utf8', 0, bytesRead).split('\n');
main();

function main(){
  // 26と互いに素の値
  var multiply = new Int8Array([1,3,5,7,9,11,15,17,19,21,23,25]);

  // 対象
  FIRST:for(var i = 1, len = +input[0]; i <= len; i++){
    var inp = input[i];
    for(var j = 0, lenj = multiply.length; j < lenj; j++){
      var alpha = multiply[j];
      for(var beta = 26; beta--;){
        var alphabets = new Int8Array(26);
        for(var conv = 26; conv--;){
          alphabets[conv] = (conv * alpha + beta) % 26 + 97;
        }

        var thChar = String.fromCharCode(alphabets[19], alphabets[7]);
        var atChar = String.fromCharCode(alphabets[0], alphabets[19]);
        var isChar = String.fromCharCode(alphabets[8], alphabets[18]);

        if(new RegExp(thChar + "("+atChar+"|"+isChar+")").test(inp)){
          console.log(inp.replace(/[a-z]/g,function(a){for(var b = 26, c=a.charCodeAt(0); b--;)if(c==alphabets[b]){return String.fromCharCode(b+97)}}));
          continue FIRST;
        }
      }
    }
  }
}
     

Measured memory_bytes: 10692
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cout<<(#v)<<":";for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;
#define printVS(vs) cout<<(#vs)<<":"<<endl;for(auto(s):(vs)){cout<<(s)<< endl;}
#define printVV(vv) cout<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;}
#define printP(p) cout<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cout<<(#vp)<<":"<<endl;for(auto(p):(vp)){cout<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cerr << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cerr << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 2e9;
const int mod = 1e9 + 7;

const int MAX = 7368800;
bool alive[MAX];

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

    int m, n;
    while (cin >> m >> n, m) {
        fill(alive, alive + MAX, true);

        rep2(i, m, MAX) {
            if (!alive[i]) continue;
            if (n == 0) {
                cout << i << endl;
                break;
            }
            n--;
            for (int j = 2 * i; j < MAX; j += i) {
                alive[j] = false;
            }
        }
    }

}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007




int main(){
  
  int h,w;
  cin >> h>> w;
  vector<string> s(h);
  rep(i,h)cin >> s[i];
  vector<vector<ll>> dp(h,vector<ll>(w,0));
  rep(i,w){
    if(s[0][i] == '#')break;
    dp[0][i] = 1;
  }
  rep(i,h){
    if(s[i][0] == '#')break;
    dp[i][0] = 1;
  }
  rep(i,h-1)rep(j,w-1){
    if(s[i+1][j+1] == '#')continue;
    dp[i+1][j+1] = (dp[i+1][j]+dp[i][j+1])%MOD;
  }
  cout << dp[h-1][w-1] << endl;






  

  return 0;
}

Measured memory_bytes: 9216
def examA():
    A, P = LI()
    ans = (A*3+P)//2
    print(ans)
    return

def examB():
    N = I()
    SP = [[]for _ in range(N)]
    for i in range(N):
        SP[i] = LSI()
        SP[i][1] = int(SP[i][1])
        SP[i].append(i)
#    print(SP)
    SP = sorted(SP,key = lambda x:x[1], reverse = True)
    SP = sorted(SP,key = lambda x:x[0])
#    print(SP)
    for v in SP:
        print(v[2]+1)
    return

def examC():
    N, M = LI()
    S = [LI() for _ in range(M)]
    P = LI()
    ans = 0
    loop = 2**N
    for i in range(loop):
        flag = True
        d = defaultdict(bool)
        for j in range(N):
            if i&(1<<j)==(1<<j):
                d[j+1] = True
        for l,j in enumerate(S):
            cur = 0
            for k in range(1,j[0]+1):
                if d[j[k]]:
                    cur +=1
            if cur%2!=P[l]:
#                print(cur,l,i)
                flag = False
                break
        if flag:
            ans +=1
    print(ans)

    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examC()


Measured memory_bytes: 3572
#include <stdio.h>

//素数列挙
//pには充分な要素数の配列のアドレス、返り値は個数
#include <stdbool.h>
#define n0 500000 //上限/2
#define n1 500    //sqrt(上限)/2

int prime(long *p){
  bool fp[n0]={};
  int i,j,np=1,s;
  for(i=0;i<n1;i++){
    if(fp[i]) continue;
    s=(i<<1)+3;
    for(j=(i+1)*3;j<n0;j+=s){
      fp[j]=1;
    }
  }
  p[0]=2;
  for(i=0;i<n0;i+=1){
    if(fp[i]^1){
      p[np]=(long)(i<<1)+3;
      np++;
    }
  }
  return(np);
}

int main(){
  bool b[2][80000]={};
  int i,j,np,m=1;
  long a,p[80000];
  np=prime(&p);
  for(i=0;i<2;i++){
    scanf("%ld",&a);
    for(j=0;j<np;j++){
      while(a%p[j]==0){
        a/=p[j];
        b[i][j]=1;
      }
    }
    if(a!=1){
      p[np]=a;
      b[i][np]=1;
      np++;
    }
  }
  for(i=0;i<np;i++){
    m+=b[0][i]&b[1][i];
  }
  printf("%d",m);
  return(0);
}

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

int main()
{
    char a[26]={'a','b','c','d','e','f','g','h','i','j','k','l','n','m','o','p','q','r','s','t','u','v','w','x','y','z'};

    char x;
    cin>>x;
    for(int i=0;i<26;i++)
    {
        if(x==a[i])
        {
            cout<<a[i+1]<<endl;
        } 
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

const int N = 51;

int n, k, s, t;
ll C[N][N], ways[N];
vector <int> a;

ll solve(vector <int> &b){
    ll ret = 0;
    for(int mask = 0 ; mask <= (t ^ s) ; mask++){
        if((mask & (t ^ s)) != mask) continue;
        int sign = (__builtin_popcount(mask) % 2 ? -1 : 1);
        int cnt = 0;
        for(auto &i : b){
            cnt += (i & mask) == 0;
        }
        ret += sign * ways[cnt];
    }
    return ret;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    C[0][0] = 1;
    for(int i = 1 ; i < N ; i++){
        for(int j = 0 ; j < N ; j++){
            C[i][j] = (j == 0 ? 0 : C[i - 1][j - 1]) + C[i - 1][j];
        }
    }
    cin >> n >> k >> s >> t;
    k--;
    if((s & t) != s) finish(0);
    for(int i = 0 ; i < n ; i++){
        int x;
        cin >> x;
        if((x & s) != s) continue;
        if((x | t) != t) continue;
        a.push_back(x);
    }
    n = a.size();
    for(int i = 0 ; i < N ; i++){
        for(int j = 0 ; j <= k ; j++){
            ways[i] += C[i][j];
        }
    }
    ll ans = 0;
    for(int i = 0 ; i < n ; i++){
        vector <int> b;
        for(int j = i + 1 ; j < n ; j++){
            b.push_back(a[i] ^ a[j]);
        }
        ans += solve(b);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  long long A, B;
  cin >> A >> B;
  long long ans = 0;
  long long x;
  cin >> x;
  for (int i = 0; i < N - 1; i ++) {
    long long k = 0;
    cin >> k;
    ans += min((k - x) * A, B);
    x = k;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3572