akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ld = long double;

int main()
{
	cout << fixed << setprecision(10);
	int N, K;
	cin >> N >> K;
	ld res = 0;
	for (int i = 1; i <= N; i++) {
		ld p = (ld)1 / N;
		int v = i;
		while (v < K) v *= 2, p /= 2.0;
		res += p;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = ((int)(s)); i < (int)(n); i++)
int main(){
    int card, point = 0;
    cin >> card;
    vector<int> number(card);
    rep(i, 0, number.size()){
        cin >> number.at(i);
    }
    sort(number.begin(), number.end(), greater<int>());
    rep(i, 0, number.size()){
        if((i + 1) % 2){
            point += number.at(i);
        }
        else{
            point -= number.at(i);
        }
    }
    cout << point << endl;
}

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

int main()
{
  int N, X, T;
  cin >> N >> X >> T;
  
  if(N % X == 0)
  {
	cout << (N / X) * T << endl;
  }
  else
  {
    cout << (N / X + 1) * T << endl;
  }
  return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;++i)




int main(){
  ll d,g,p[11],c[11];
  cin >> d >> g;
  rep(i,d) cin >> p[i] >> c[i];

  int ans = 1e9+5;
  //bit-mask!!!
  for(int mask=0;mask < (1<<d) ; ++ mask){//2^d上通りを考えている
    int res=0,num=0,rest_max=-1;//resはボーナスをとる物の合計
    rep(i,d){
      if(mask >> i & 1){//bit-maskの確認
        res+=100*(i+1)*p[i]+c[i];
        num+=p[i];
      }else{
        rest_max=i;
      }
    }
    if(res<g){
      int point=100*(rest_max+1);
      int need=(g-res+point-1)/point;
      if(need>=p[rest_max]){
        continue;
      }
      num+=need;
    }
    ans=min(ans,num);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define REP(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1<<x)-1)
#define DUP(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

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

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

  int N; cin >> N;
  vi x(N), y(N), h(N); REP(i,N) cin >> x[i] >> y[i] >> h[i];

  int H, Cx, Cy;
  int is;
  REP(i,N) {
    if (h[i] != 0) {
      is = i;
      break;
    }
  }

  REP(Cx,101) {
    REP(Cy,101) {
      FOR(H,h[is],h[is]+201) {
        bool flag = true;
        REP(i,N) {
          if (h[i]!= max(H-abs(x[i]-Cx)-abs(y[i]-Cy),0)) {
            flag = false;
            break;
          }
        }
        if (flag == true) {
          printf("%d %d %d\n",Cx,Cy,H);
          return 0;
        }
      }
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <utility>
#include <algorithm>
#include <set>
#include <cmath>
#include <array>
#include <bitset>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<n+1;i++)
int main(){
    int N;
    int sum=0,x[100];
    cin>>N;
    rep(i,N) {
        cin>>x[i];
        sum+=x[i];
    }
    int ave = sum / N;
    int ave_hoge = ave+1;
    int ans1=0,ans2=0;;
    rep(i,N){
        ans1 += (x[i]-ave)*(x[i]-ave);
        ans2 += (x[i]-ave_hoge)*(x[i]-ave_hoge);
    }
    cout<<min(ans1,ans2);
    return 0;
}

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

#pragma GCC optimize "O3"
#define rep(i,a,n) for(int i=a; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
const ll powll = 1LL<<1;

int main(void){
    string s; cin >> s;
    if(s[1] == 'B') cout << "ARC\n";
    else cout << "ABC\n";
}

Measured memory_bytes: 3620
using System;


namespace ConsoleApplication37
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            String s = Console.ReadLine();
            String[] ss = s.Split(' ');
            for (int i = n - 1; i >= 0 ; i-- )
            {
                int a = int.Parse(ss[i]);
                if(i == 0)
                {
                    Console.WriteLine(a);
                }
                else
                {
                    Console.Write(a + " ");
                }
            }
        }
    }
}

Measured memory_bytes: 9036
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	private	static	BufferedReader	br = null;

	static {
		br = new BufferedReader(new InputStreamReader(System.in));
	}
 
    /**
     * @param args
     */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		long[]	data = null;

		while ((data = parseData()) != null) {
			long	out = (data[0] / gcd(data[0], data[1])) * data[1];
			out = (out / gcd(out, data[2])) * data[2];
			System.out.println(out);
		}
	}

	private static long gcd(long n1, long n2) {
		long	min = Math.min(n1, n2);
		long	max = Math.max(n1, n2);
		long	ret = max;
 
		if (min != 0L) {
			ret = gcd(min, max % min);
		}

		return ret;
	}

    private static long parsePeriod(long a, long m) {
		long	p = 1L;
		long	b = a % m;
		long	x = b;

		while (x != 1) {
			x = (x * b) % m;
			p++;
		}

		return p;
	}

    private static long[] parseData() {
		long[]	data = null;
		String	str = null;

		if ((str = parseStdin()) != null) {
			if (!str.equals("0 0 0 0 0 0")) {
				String[]	lines = str.split(" ");

				data    = new long[3]; 
				data[0] = parsePeriod(Long.parseLong(lines[0]), Long.parseLong(lines[1]));
				data[1] = parsePeriod(Long.parseLong(lines[2]), Long.parseLong(lines[3]));
				data[2] = parsePeriod(Long.parseLong(lines[4]), Long.parseLong(lines[5]));
			}
		}

		return data;
	}

	private static String parseStdin() {
        String  stdin = null;
        
        try {
        	String  tmp = br.readLine();
        	if (tmp != null) {
            	if (!tmp.isEmpty()) {
            		stdin = tmp;
            	}
        	}
        }
        catch (IOException e) {}
 
        return stdin;
	}
}

Measured memory_bytes: 18320
#include <iostream>
#include <climits>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <map>
#include <algorithm>

#define ll long long
#define pii pair<int, int>
#define pll pair<long, long>

using namespace std;

int main(){
	int n, k; cin >> n >> k;
	vector<int> h(n); 

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

	vector<int> dp(n);

	for(int i = n-2; i >= 0; i--){
		int minCost = INT_MAX;

		for(int j = 1; j <= k; j++){
			if(i+j < n) minCost = min(minCost, abs(h[i+j] - h[i]) + dp[i+j]);
		}

		dp[i] = minCost;
	}

	cout << dp[0] << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
string a;
string b;
int main()
{
    cin>>a;
    for(int i=0;i<a.size();i+=2)
    {
        b+=a[i];
    }
    cout << b << endl;
    //cout << "Hello world!" << endl;
    return 0;
}
//atcoder


Measured memory_bytes: 512
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B, K = MAP()

for i in range(K):
	if A%2 == 1:
		A -= 1
	B += A//2
	A //= 2

	A, B = B, A

if K%2 == 1:
	A, B = B, A
print(A, B)


Measured memory_bytes: 5192
N,*as=$<.read.split.map(&:to_i)
MOD=10**9+7

ret = 0

60.times do |i|
    x = y = 0
    as.each do |a|
        a[i]==1 ? x+=1 : y+=1
    end
    ret += (x*y) * (2**i) % MOD
end

puts ret % MOD



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

signed main() {
  int a,b,c,k;
  cin >> a >> b >> c >> k;

  int odd = (b - a);
  int even = (a - b);

  if(k % 2 == 0) cout << even << '\n';
  else cout << odd << '\n';
}


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

string k = "..................";
int main() {
	string a;
	while (cin >> a, a!="#") {
		a += "/";
		string b;
		vector<string>c;
		for (char d : a) {
			if (d == '/') {
				c.push_back(b);
				b = "";
			}
			else b += d;
		}
		vector<string>e;
		for (string d : c) {
			string g;
			for (char f : d) {
				if (f == 'b')g += f;
				else g += k.substr(0, f - '0');
			}
			e.push_back(g);
		}
		int n, m, x, y; cin >> n >> m >> x >> y; n--; m--; x--; y--;
		e[n][m] = '.'; e[x][y] = 'b';
		for (int i = 0; i < e.size(); i++) {
			if (i)cout << "/";
			for (int j = 0; j < e[i].length(); j++) {
				if (e[i][j] == 'b')cout << 'b';
				else {
					int l = j;
					for (; l < e[i].length() - 1; l++) {
						if (e[i][l+1] == 'b')break;
					}
					cout << l - j + 1;
					j = l;
				}
			}
		}
		cout << endl;
	}
}

Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    ll r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}
int main (){
    int n;
    ll mx1=0;
    ll mx2=0;
    cin >> n;
    map<ll,ll>mp;
    rep(i,n){
        ll a;
        cin >> a;
        mp[a]++;
    }
    vector<pair<ll,ll>>hen(mp.size());
    int i=0;
    for(auto p:mp){
        hen[i]=make_pair(p.first,p.second);
        i++;
    }
    reverse(hen.begin(),hen.end());
    rep(i,mp.size()){
        if(hen[i].second>1) {
            mx1=hen[i].first;
            hen[i].second-=2;
            break;
        }
    }
    rep(i,mp.size()){
        if(hen[i].second>1){
            mx2=hen[i].first;
            break;
        }
    }
    cout << mx1*mx2 <<endl;
    return 0;
}



Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define int ll
#define Endl endl

signed main(){
    int N,M;
    int E[114514]={};
    int a,b;
    cin >> N >> M;
    REP(i,M){
        cin >> a >> b;
        E[a-1]++;
        E[b-1]++;
    }
    REP(i,N){
        if(E[i]%2==1){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


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

int main(){
  ll N, K;
  cin >> N >> K;
  ll can = N % K;
  ll ans = min(can, abs(can - K));
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int , int >
#define F first
#define S second
#define endl '\n'
#define int long long
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#define kill(x) return cout<<x<<'\n', 0;
using namespace std;
const int N=2e3+100;
vector <int> g[N];
ll par[N];
ll getpar(ll v){
    if (par[v]==v) return v;
    return par[v]=getpar(par[v]);
}
ll a[N];
vector <int> mol[N];
vector <int> solve(vector <vector <int> > a){
    vector <int> ans;
    ll z=0;
    set <pii> s;
    for (int i=0;i<a.size();i++){
        z+=a[i].size();
        a[i].pb(-1),reverse(a[i].begin(),a[i].end());
        s.insert({a[i].back(),i});
    }
    for (int i=0;i<z;i++){
        pii u=*s.rbegin();
        ans.pb(u.F);
        a[u.S].pop_back();
        s.erase(u);
        s.insert({a[u.S].back(),u.S});
    }
    return ans;
}
ll vis[N];
void dfs(ll v){
    vis[v]=1;
    mol[v].pb(v);
    vector <vector <int> > aa;
    for (auto u : g[v]){
        if (vis[u]) continue;
        dfs(u);
        aa.pb(mol[u]);
    }
    vector <int> ans=solve(aa);
    for (auto u : ans) mol[v].pb(u);
    return ;
}
int32_t main(){
    ll n;
    cin >> n;
    for (int i=1;i<=n;i++){
        cin >> a[i];
    }
    sort(a+1,a+n+1);
    for (int i=1;i<=n;i++){
        for (int j=i+1;j<=n;j++){
            if (__gcd(a[i],a[j])!=1){
                g[i].pb(j);
                g[j].pb(i);
            }
        }
    }
    for (int i=1;i<=n;i++) sort(g[i].begin(),g[i].end());
    for (int i=1;i<=n;i++){
        par[i]=i;
    }
    vector <vector <int> > aa;
    for (int i=1;i<=n;i++){
        if (!vis[i]){
            dfs(i);
            aa.pb(mol[i]);
        }
    }
    vector <int> ans=solve(aa);
    for (auto u : ans) cout << a[u] << " " ;

}


Measured memory_bytes: 59864
#include<bits/stdc++.h>
using namespace std;
inline int read(){
	char ch=getchar(); int w=1,c=0;
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') w=-1;
	for (;isdigit(ch);ch=getchar()) c=(c<<1)+(c<<3)+(ch^48);
	return w*c;
}
int n;
int a[201201];
int main(){
  	n=read(); 
  	for (int i=1;i<=n;i++) a[i]=read();
  	int r=0, nans=0; long long A=0;
  	for (int i=1;i<=n;i++){
  		while ((nans^a[r+1])==nans+a[r+1] && r<n) nans+=a[++r];
  		A=A+r-i+1;
  		nans-=a[i];
	}
	cout<<A<<"\n";
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int h,w;
vector<vector<int>> fielda,fieldb;
bool memo[80][80][13000];
int MIN= 1000000000;

void search(int i,int j,int k){
  memo[i][j][k] = false;
  //cout << i << ' ' << j << ' ' << k << endl;
  int tmpk = abs(fielda.at(i).at(j)-fieldb.at(i).at(j));
  if(i==(h-1)&&j==(w-1)){MIN = min(MIN,min(abs(k-tmpk),abs(k+tmpk)));return;} 
  int ni = i+1;
  int nj = j+1;
  //cout << memo[ni][j][k-tmpk] << endl;
  if(ni<h){
    if(memo[ni][j][k-tmpk])search(ni,j,k-tmpk);
    if(memo[ni][j][k+tmpk])search(ni,j,k+tmpk);
  }
  if(nj<w){
    if(memo[i][nj][k-tmpk])search(i,nj,k-tmpk);
    if(memo[i][nj][k+tmpk])search(i,nj,k+tmpk);
  }
  return;
}
    

int main(){
  cin >> h >> w;
  int tmp;
  for(int i=0;i<h;i++){
    vector<int> vectmp;
    for(int j=0; j<w; j++){
      cin >> tmp;
      vectmp.push_back(tmp);
    }
    fielda.push_back(vectmp);
  }
  for(int i=0;i<h;i++){
    vector<int> vectmp;
    for(int j=0; j<w; j++){
      cin >> tmp;
      vectmp.push_back(tmp);
    }
    fieldb.push_back(vectmp);
  }
  //cout << "hoge" << endl;
  //int k=abs(fielda.at(0).at(0) - fieldb.at(0).at(0));
  memset(memo,true,sizeof(memo));
  search(0,0,0);
  cout << MIN << endl;
}
  

Measured memory_bytes: 81536
#include <bits/stdc++.h>
#define INF (1<<30)
#define INFLL (1ll<<60)
#define EPS (1e-10)
using namespace std;
map <int,int> mp;
typedef pair<int, int> P;
typedef long long ll;
static const int MAX=100000;
static const int NMAX=50;
static const int MMAX=50;
vector <char> S;

int main(){
    string s; cin>>s;
    
    for(int i=0;i<s.size();i++){
        if(s[i]=='0')S.push_back('0');
        else if(s[i]=='1')S.push_back('1');
        else if(S.size()) S.pop_back();
    }
    for(int i=0;i<S.size();i++)
        cout<<S[i];
    
    cout<<"\n";
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
        long a = sc.nextLong();
        long v = sc.nextLong();
        long b = sc.nextLong();
        long w = sc.nextLong();
        long t = sc.nextLong();
        long hole = Math.abs(a-b);
        long amax = v * t;
        long bmax = w * t;
        long tag = amax - bmax;
         if(hole > tag){
            System.out.println("NO");
            return;
          }
        
        
        System.out.println("YES");
    }
}

Measured memory_bytes: 35828
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  int n; rd(n);
  auto d=readln.split.to!(int[]);
  int m; rd(m);
  auto t=readln.split.to!(int[]);

  sort(d); sort(t);
  int j=0;
  foreach(e; t){
    while(j<n && d[j]<e) j++;
    if(j<n && d[j]==e) j++;
    else{writeln("NO"); return;}
  }

  writeln("YES");
}


void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}

Measured memory_bytes: 18212
import heapq

n = int(input())
a = list(map(int, input().split()))

red = a[:n]
sr = sum(red)
sum_red = {n: sr}
heapq.heapify(red)
# print(red)

blue = [-1 * i for i in a[2*n:]]
sb = sum(blue)
sum_blue = {2 * n: sb}
heapq.heapify(blue)
# print(blue)

for k in range(n, 2 * n):
    popped_red = heapq.heappushpop(red, a[k])
    sr += a[k] - popped_red
    sum_red[k + 1] = sr
    # print(popped_red, red, sr, sum_red)

for k in range(2 * n - 1, n - 1, -1):
    popped_blue = heapq.heappushpop(blue, -1  * a[k])
    sb += -1 * a[k] - popped_blue
    sum_blue[k] = sb
    # print(popped_blue, blue, sb, sum_blue)

ans = -1 * float('inf')
for k in range(n, 2 * n + 1):
    ans = max(ans, sum_red[k] + sum_blue[k])
    

print(ans)

    


Measured memory_bytes: 52736
#include<stdio.h>

int main(void){
  int n,a,b,c,d[101],i,j,t;

  scanf("%d %d %d %d",&n,&a,&b,&c);

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

  for(i=n-1;i>0;i--)
    for(j=0;j<i;j++)
      if(d[j]<d[j+1])
	t=d[j],d[j]=d[j+1],d[j+1]=t;
      
  for(i=0;i<n;i++)
    if((c+d[i])/(a+b)>=c/a)c+=d[i],a+=b;
    else break;
  
  printf("%d\n",c/a);

  return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstring>
int main(){
    char ch[100];
    std::scanf("%s",ch);
    int len=std::strlen(ch);
    for(int i=0;i<len;++i) if(ch[i]=='C') for(int j=i+1;j<len;++j) if(ch[j]=='F') return std::puts("Yes"),0;
    std::puts("No");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e18+10;

/*----------------------------------------------*/
signed main(){
  int n,m;
  cin>>n>>m;
  vi k(m);
  vector<vi> s(m,vi(n,0));
  rep(i,m){
    cin>>k[i];
    // k[i]--;
    rep(j,k[i]){
      int v;
      cin>>v;
      v--;
      s[i][v]=1;
    }
  }
  vi p(m);
  rep(i,m) cin>>p[i];

  // rep(i,m){
  //   rep(j,n) cout<<s[i][j]<<' ';
  //   cout<<endl;
  // }

  int ans=0;
  for(int bit=0;bit<(1<<n);bit++){
    int light=0;

    // cout<<bit<<':';

    rep(i,m){
      int cnt=0,tmp=bit;
      rep(j,n){
        if(s[i][j]&tmp) cnt++;
        tmp>>=1;
      }
      if(cnt%2==p[i]){
        light++;  
        // cout<<'o'<<' ';
      }else{
        // cout<<'x'<<' ';
      }
    

    }
    // cout<<endl;

    if(light==m) ans++;
    
  }
  cout<<ans<<endl;
  return 0;
}

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

#define For(i, j, k) for (int i = j; i <= k; i++)
#define Forr(i, j, k) for (int i = j; i >= k; i--)

using namespace std;

const int N = 1e5 + 10;
const int Mod = 1e9 + 7;

char S[N];
int a[N], n;
int nxt[N][3], dp[N];

int main() {

	scanf("%s", S + 1);
	n = strlen(S + 1);
	For(i, 1, n) a[i] = S[i] - 'a' + 1;

	bool flag = true;
	For(i, 2, n) flag &= a[i] != a[i - 1];
	if (flag) { puts("1"); return 0; }
	For(i, 1, n) a[i] = (a[i - 1] + a[i]) % 3;

	For(j, 0, 2) nxt[n + 1][j] = n + 1;
	Forr(i, n, 1) For(j, 0, 2) nxt[i][j] = a[i] == j ? i : nxt[i + 1][j];

	int ans = 0;
	dp[0] = 1;
	For(i, 0, n) {
		For(j, 1, 2) {
			int p = nxt[i + 1][(a[i] + j) % 3];
			if (p <= n) dp[p] = (dp[p] + dp[i]) % Mod;
		}
		if (i > 0 && a[i] == a[n]) ans = (ans + dp[i]) % Mod;
	}

	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 2304
#![allow(unused_imports)]
#![allow(unused_macros)]
use std::cmp::{max, min};
use std::collections::*;
use std::io::{stdin, Read};

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, $var:ident $($r:tt)*) => {
        let $var = parse_val!($it, usize);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: tt),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, u1) => {
        $it.next().unwrap().parse::<usize>().unwrap() -1
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

#[cfg(debug_assertions)]
macro_rules! debug {
    ($( $args:expr ),*) => { eprintln!( $( $args ),* ); }
}

#[cfg(not(debug_assertions))]
macro_rules! debug {
    ($( $args:expr ),*) => {
        ()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, n: usize, k: usize, p: [u1; n], c: [i128; n]);
    let mut points: Vec<i128> = vec![];
    let mut ret = std::i128::MIN;
    for i in 0..n {
        points.clear();
        assert_eq!(points.len(), 0);
        let mut cur = i;
        loop {
            cur = p[cur];
            points.push(*points.last().unwrap_or(&0) + c[cur]);
            if cur == i {
                break;
            }
        }
        let pret = if k <= points.len() {
            *points[..k].iter().max().unwrap()
        } else {
            let s: i128 = *points.last().unwrap();
            if s <= 0 {
                *points.iter().max().unwrap()
            } else {
                let l = k % points.len();
                let a = k / points.len();
                let x = s * ((a - 1) as i128);
                let res = *points.iter().max().unwrap();
                let res = max(res, s + *points[..l].iter().max().unwrap_or(&0));
                x + res
            }
        };
        ret = max(ret, pret);
    }
    println!("{}", ret);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


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

int main()
{
  int n;
  while(cin>>n && n){
    int res = 0;
    n = 1000 - n;
    res += n / 500; n %= 500;
    res += n / 100; n %= 100;
    res += n / 50;  n %= 50;
    res += n / 10;  n %= 10;
    res += n / 5;   n %= 5;
    res += n / 1;   n %= 1;

    cout<<res<<endl;
  }
}

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

num = [0]*n
for d in mat:
    if n == 1 and d[0] == 1 and d[1] == 0:
        continue
    
    if d[0] == 1 and d[1] == 0:
        print(-1)
        exit()
        
    if num[d[0]-1]== 0 or num[d[0]-1] == d[1]:
        num[d[0]-1] = d[1]

    else:
        print(-1)
        exit()

if n == 1:
    print(num[0])
    exit()
elif num[0] == 0:
    num[0] = 1

ans = ''
for n in num:
    ans += str(n)

print(ans)

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

long long extgcd(long long a, long long b, long long& x, long long& y){
    long long d = a;
    if(b != 0){
        d = extgcd(b, a%b, y, x);
        y -= (a/b) * x;
    }else{
        x = 1; y = 0;
    }
    return d;
}

const long long MOD = 1e9+7;
long long mod_inv(long long a){
    long long x, y;
    extgcd(a, MOD, x, y);
    return (MOD + x%MOD) % MOD;
}

const long long MAX = 5001;
long long dp[MAX][MAX];

int main(){
    long long i, j, k;
    long long N;
    cin >> N;
    string S;
    cin >> S;
    long long M = S.size();
    dp[0][0] = 1;
    for(i=0; i<N; i++){
        for(j=0; j<N; j++){
            dp[i+1][j+1] = (dp[i+1][j+1] + 2*dp[i][j]) % MOD;
            dp[i+1][max(j-1, 0LL)] = (dp[i+1][max(j-1, 0LL)] + dp[i][j]) % MOD;
        }
    }
    long long inv2 = mod_inv(2);
    long long ans = dp[N][M];
    for(i=0; i<M; i++) ans = ans * inv2 % MOD;
    cout << ans << endl;
    return 0;
}

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


int main(){
    long long int n;
    cin>>n;
    long long int nin=1,eig=1,ten=1;
    long long int mod=1e9+7;
    for(int i=0; i<n; i++){
        nin=(nin*9)%mod;
        eig=(eig*8)%mod;
        ten=(ten*10)%mod;
    }
    long long int ans = (ten+eig)%mod -(2*nin)%mod;
    cout<<(ans+mod)%mod<<endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000




int main(){
	long long Q,H,S,D;
	cin>>Q>>H>>S>>D;
	
	long long N;
	cin>>N;
	
	S = min({S,Q*4,H*2});
	
	cout<<min(S*N,(N/2)*D+(N%2)*S)<<endl;
	
	return 0;
}

Measured memory_bytes: 256
def check(s, S):
    for i in S:
        if (i != s):
            return True
    return False

S = str(input())
T = S

m = 1000
for s in S:
    num = 0
    T = S
    while (check(s, T)):
        num += 1
        K = []
        for i in range(0, len(T) - 1):
            if s == T[i+1]:
                K.append(T[i+1])
            else:
                K.append(T[i])
        T = K
    m = min(m, num)

print(m)


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

const int MAXN = 1300000;
int isP[MAXN];
vector<int> Prime, rPrime;

int main() {
  memset(isP, -1, sizeof(isP));
  isP[0] = isP[1] = false;
  for(int i = 2; i < MAXN; ++i) {
    if(!isP[i]) continue;
    Prime.push_back(i);
    for(int j = i*2; j < MAXN; j += i) isP[j] = false;
  }
  rPrime = Prime;
  reverse(rPrime.begin(), rPrime.end());
  for(int n; cin >> n && n;) {
    int a = *lower_bound(rPrime.begin(), rPrime.end(), n, greater<int>());
    int b = *lower_bound(Prime.begin(), Prime.end(), n);
    if(a == n || b == n) cout << 0 << endl;
    else cout << b - a << endl;
  }
  return 0;
}

Measured memory_bytes: 7064
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
int main(void) {
 
	int T[5];
	int i=0, min=0, d=10;
 
	while(i < 5){
	scanf("%d", &T[i]);
 
	if(T[i] % 10 != 0){
 
		if(T[i] % 10 <= d){
				d = T[i] % 10;
			}
 
		while(T[i] % 10 != 0){
			T[i]++;
		}
	}
	min += T[i];
	i++;
	}
 
	min = min - (10-d);
 
	printf("%d", min);
 
	return 0;
}

Measured memory_bytes: 128
package main

import (
	"fmt"
	"math"
)

func main() {
	var M, N, P int
	for {
		fmt.Scan(&N, &M, &P)
		if N == 0 && M == 0 && P == 0 {
			return
		}

		arr := make([]int, N)
		sum := 0
		for i := 0; i < N; i++ {
			var po int
			fmt.Scan(&po)
			arr[i] = po
			sum += po
		}

		if arr[M-1] == 0 {
			fmt.Println(0)
		} else {
			fmt.Println(math.Floor(float64(sum * (100 - P) / arr[M-1])))
		}
	}
}



Measured memory_bytes: 1600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e3+5,inf=0x3f3f3f3f;
char s[N][N];
int a,b,n=100;
int main()
{
	cin>>a>>b;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
		{
			if(j>50)
				s[i][j]='#';
			else
				s[i][j]='.';
		}
	for(int i=1;i<=n;i+=2)
		for(int j=1;j<50;j++)
		{
			if((i+j)%2&&b!=1)
				s[i][j]='#',b--;
		}
	for(int i=1;i<=n;i+=2)
		for(int j=51;j<=100;j++)
		{
			if((i+j)%2&&a!=1)
				s[i][j]='.',a--;
		}
	puts("100 100");
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
			printf("%c",s[i][j]);
		printf("\n");
	}
		
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define sz(v) (ll((v).size()))
#define forn(i,n) for(ll i=0;i<(n);i++)
#define forr(i,n) for(ll i=(n)-1;i>=0;i--)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
#define clr(x) memset(x,0,sizeof(x))


int main()
{
	ios_base::sync_with_stdio(false);

	ll a[4]={};
	ll n;cin>>n;
	while(n--){
		string s;cin>>s;
		if(s=="AC")a[0]++;
		else if (s=="WA")a[1]++;
		else if (s=="TLE")a[2]++;
		else a[3]++;
	}
			cout<<"AC x "<<a[0]<<endl;
		cout<<"WA x "<<a[1]<<endl;
		cout<<"TLE x "<<a[2]<<endl;
		cout<<"RE x "<<a[3]<<endl;

}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
 
using namespace std;
 
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl
const int N = 1e5;  // limit for array size
ll n;  // array size
ll t[2 * N];

int main(){
	int n;cin>>n;
	int t[n],x[n],y[n];
	for(int i=0;i<n;i++){
		cin>>t[i]>>x[i]>>y[i];
	}
	int g=1;
	if(t[0]-(x[0]+y[0])<0||(t[0]-(x[0]+y[0]))%2==1){
		cout<<"No"<<endl;return 0;
	}
	for(int i=1;i<n;i++){
		int h=(t[i]-t[i-1])-(abs(x[i]-x[i-1])+abs(y[i]-y[i-1]));
	    if(h<0||h%2==1){
	    	g=0;break;
		}	
	}
	if(g==0){
		cout<<"No"<<endl;
	}
	else{
		cout<<"Yes"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <math.h>
using namespace std;

int main()
{
    int S;
    int h;
    int m;
    int m_tmp;
    int s;
    cin >> S;
    h = S / 3600;
    m_tmp = S - h * 3600;
    m = m_tmp / 60;
    s = m_tmp - m * 60;
    cout << h << ':' << m << ':' << s << endl;

    return 0;
}



Measured memory_bytes: 3096
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] A = new long[N+2];

		for(int i = 1 ; i <= N ; i++){
			A[i] = sc.nextLong();
		}
		A[0] = 0;
		A[N+1] = 0;

		sc.close();

		long maxgcd = 0;
		long maxgcd2 = 0;

		long[] memo = new long[N+2];
		memo[0] = 0;
		memo[1] = A[1];
		memo[N] = A[N];
		memo[N+1] = 0;

		for(int i = N-1 ; i>=2 ; i--){
			memo[i] = gcd(memo[i+1],A[i]);
		}
/*
		for(int i = 0 ; i <= N+1 ; i++){
			System.out.println(memo[i]);
		}
*/
		long ans = 0;
		for(int i = 1 ; i <= N ; i++){
			if( i == 1){
				maxgcd = 0;
				maxgcd2 = memo[i+1];
			}
			else if(i == N){
				maxgcd = memo[i-1];
				maxgcd2 = 0;
			}
			else{
				memo[i] = gcd(memo[i-1],A[i]);
				maxgcd = memo[i-1];
				maxgcd2 = memo[i+1];

			}
			if(ans < gcd(maxgcd,maxgcd2)){
				ans = gcd(maxgcd,maxgcd2);
			}
		}
		System.out.println(ans);
	}


	static long gcd(long m, long n) {
	    if(m < n) return gcd(n, m);
	    if(n == 0) return m;
	    return gcd(n, m % n);
	}
}


Measured memory_bytes: 58344
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _015_NationalBudget
{
	class Program
	{
		static void Main ( string[] args )
		{
			int processCount = int.Parse (Console.ReadLine ());

			for (int lp = 0; lp < processCount; lp++)
			{
				string str1 = Console.ReadLine ();
				string str2 = Console.ReadLine ();

				if (str1.Length <= 80 && str2.Length <= 80)
				{
					string result;

					if (str1.Length < str2.Length)
						result = Add (str1, str2);
					else
						result = Add (str2, str1);

					if (result.Length <= 80)
						Console.WriteLine (result);
					else
						Console.WriteLine ("overflow");
				}
				else
				{
					Console.WriteLine ("overflow");
				}
			}

		}

		static string Add ( string smallerString, string biggerString )
		{
			StringBuilder result = new StringBuilder (biggerString.Length);

			int biggerIndex = biggerString.Length - 1;

			int add;
			int carry = 0;

			const int CharToInt = '0';

			for (int smallerIndex = smallerString.Length - 1; smallerIndex >= 0; smallerIndex--, biggerIndex--)
			{
				add = smallerString[smallerIndex] + biggerString[biggerIndex] + carry - CharToInt * 2;

				if (10 <= add)
				{
					add -= 10;
					carry = 1;
				}
				else
				{
					carry = 0;
				}

				result.Append (add);
			}

			while (0 <= biggerIndex && carry == 1)
			{
				add = biggerString[biggerIndex] + carry - CharToInt;

				if (10 <= add)
					add -= 10;
				else
					carry = 0;

				result.Append (add);
				biggerIndex--;
			}

			if (carry == 1)
				result.Append (carry);

			while (0 <= biggerIndex)
			{
				int item = biggerString[biggerIndex] - CharToInt;
				result.Append (item);
				biggerIndex--;
			}

			string returnStr = new string (result.ToString ().Reverse ().ToArray ());
			return returnStr;
		}
	}
}

Measured memory_bytes: 9324
#include<bits/stdc++.h>
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define F(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RF(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define MIN3(a,b,c) (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c))
#define MAX(a,b) (a)>(b)?(a):(b)
#define MIN2(a,b) (a)<(b)?(a):(b)
#define SIEVELIM 10000000+10
#define coud(a,b) cout<<fixed << setprecision((b)) << (a)
using namespace std;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
#define ull unsigned long long
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
inline int nextint(){ int temporary; scanf("%d",&temporary); return temporary; }
inline ll nextll(){ ll temporary; scanf("%lld",&temporary); return temporary; }
inline double nextdouble(){double temporary; scanf("%lf",&temporary); return temporary;}
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
ll leftChild(ll p ){return p<<1;}
ll rightChild(ll p ){return (p<<1)+1;}
inline ll mid(ll l, ll r){ return (l+r)/2;}
const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);
#define deb(x )     cerr << #x << " here "<< x; 
#define endl    "\n"
#define pb push_back
#define mp make_pair
#define all(cc) (cc).begin(),(cc).end()

inline bool is_palindrome(const string& s){ return std::equal(s.begin(), s.end(), s.rbegin()); }

template<typename T > void modulize(T & a, const T & b) { if (a >= b) { a %= b; } }
ll mulmod(ll a, ll b, ll m) { ll q = (ll)(((ld)a*(ld)b) / (ld)m); ll r = a*b - q*m; if (r>m)r %= m; if (r<0)r += m; return r; }
template <typename T, typename S>T expo(T e, S n) { T x = 1, p = e; while (n) { if (n & 1)x = x*p; p = p*p; n >>= 1; }return x; }
template <typename T>T power(T e, T n, T & m) { T x = 1, p = e; while (n) { if (n & 1)x = mod(x*p, m); p = mod(p*p, m); n >>= 1; }return x; }
template <typename T>T powerL(T e, T n, T & m) { T x = 1, p = e; while (n) { if (n & 1)x = mulmod(x, p, m); p = mulmod(p, p, m); n >>= 1; }return x; }
template <typename T> T InverseEuler(T a, T & m) { return (a == 1 ? 1 : power(a, m - 2, m)); }

inline int two(int n) { return 1 << n; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
/*----------------------------------------------------------------------*/

int main(){
    std::ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
    int n;
    cin>>n;
    int arr[n];

    int cnt = 0;
    F(i, 0, n){
    	cin>>arr[i];
    	while(!(arr[i]%2)){
    		cnt++;
    		arr[i]/=2;
    	}
    }
    cout<<cnt;

    return 0;          
}/*
    
*/
 

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;

int main()
{
    int h,a;
    cin>>h>>a;
    int k=h/a;
    if(h%a!=0)
    {
        k++;
    }
    cout<<k;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main( void )
{
	int t;
	cin >> t;

	for ( int i = 0; i < t; i++ )
	{
		int climb_up = 0;
		int climb_down = 0;
		int now;
		int n;

		cin >> n;
		cin >> now;

		for ( int j = 0; j < n - 1; j++ )
		{
			int next;
			cin >> next;

			if ( next > now )
				climb_up = max( climb_up, next-now );
			else
				climb_down = max( climb_down, now-next );

			now = next;
		}

		cout << climb_up << " " << climb_down << endl;
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		String line = null;

		try (Scanner sc = new Scanner(System.in)) {
			line = sc.nextLine();

			char[] tmpArray = line.toCharArray();

			int num0 = 0;
			int num1 = 0;
			for (int i = 0; i < tmpArray.length ; i++) {
				if (tmpArray[i] == '0') {
					num0++;
				} else {
					num1++;
				}
			}
			System.out.println(Math.min(num0, num1) * 2);

		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 27824
use proconio::input;

fn main() {
    input! {
        n: u64,
    }

    println!("{}", solve(n));
}

fn solve(n: u64) -> u64 {
    let mut res = 0;
    for a in 1..=n {
        for b in 1..=n {
            for c in 1..=n {
                res += gcd(gcd(a, b), c);
            }
        }
    }
    res
}

fn gcd(mut a: u64, mut b: u64) -> u64 {
    if b > a {
        let tmp = b;
        b = a;
        a = tmp;
    }
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}


Measured memory_bytes: 2176
package main

import (
	"fmt"
	"math"
	"sort"
)

// go run ./main.go < in

func main() {
	var x, n int
	fmt.Scan(&x, &n)

	if n == 0 {
		fmt.Println(x)
	} else {

		var inputMap = make(map[int]bool)
		for i := 0; i < n; i++ {
			var x int
			fmt.Scan(&x)
			inputMap[x] = true
		}

		var nums []int
		for i := -200; i <= 200; i++ {
			if !inputMap[i] {
				nums = append(nums, i)
			}
		}

		sort.Sort(sort.IntSlice(nums))

		var past float64
		var pastIndex int
		for i, v := range nums {
			now := math.Abs(float64(x - v))
			if now < past || i == 0 {
				past = math.Abs(float64(x - v))
				pastIndex = i
			}
		}
		fmt.Println(nums[pastIndex])
	}
}


Measured memory_bytes: 1864
#include<bits/stdc++.h>
using namespace std;using int32=int_fast32_t;using uint32=uint_fast32_t;using int64=int_fast64_t;using uint64=uint_fast64_t;using pi=pair<int32,int32>;using pll=pair<int64,int64>;using vi=vector<int32>;using vvi=vector<vector<int32>>;using vll=vector<int64>;using ll=int64;using ull=uint64;
#define all(x) x.begin(),x.end()
inline ll read(){ll x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return x*f;}
inline string read_s(){string s="";char c=getchar();while(c<'!'||c>'~'){c=getchar();}while(c>='!'&&c<='~'){s+=c;c=getchar();}return s;}
void Main(){
    int X=read(), Y=read(), Z=read(), K=read();
    vll A(X), B(Y), C(Z);
    priority_queue<ll> ABC;
    for(auto &a:A) a=read();sort(all(A), greater<ll>());
    for(auto &b:B) b=read();sort(all(B), greater<ll>());
    for(auto &c:C) c=read();sort(all(C), greater<ll>());
    for(int i=0;i<X;i++)for(int j=0;j<Y;j++)for(int k=0;k<Z;k++){
        if((i+1)*(j+1)*(k+1)>K)break;
        ABC.push(A[i]+B[j]+C[k]);
    }
    while(K--){
        printf("%ld\n", ABC.top());
        ABC.pop();
    }
}
int main(){cin.tie(nullptr);ios::sync_with_stdio(false);Main();return 0;}


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

int main(){
  char aph[26]{};
  string s;
  cin >> s;
  for(char c:s)aph[c-'a']++;
  for(int i=0; i<26; i++){
    if(!aph[i]){
      cout << (char)(i+'a');
      return 0;
    }
  }
  cout << "None";
  return 0;
}


Measured memory_bytes: 512
N = int(input())
s = [l for l in input().split()]
o = s[1::2]
e = s[0::2]
od = {'0':0}
ed = {'0':0}
for i in o:
    if i not in od.keys():
        od[i] = 1
    else:
        od[i] += 1

for i in e:
    if i not in ed.keys():
        ed[i] = 1
    else:
        ed[i] += 1

od = sorted(od.items(),key = lambda x: x[1],reverse=True)
ed = sorted(ed.items(),key = lambda x: x[1],reverse=True)


if od[0][0] != ed[0][0]:
    print((len(o)-od[0][1])+(len(e)-ed[0][1]))
else:
    print(min(len(o)-od[0][1]+len(e)-ed[1][1],len(o)-od[1][1]+len(e)-ed[0][1]))


Measured memory_bytes: 22620
import sys
from functools import reduce
from operator import xor
readline = sys.stdin.buffer.readline

n = int(readline())
a = tuple(map(int, readline().split()))

s = reduce(xor, a[1:], a[0])
# print(s)
b = tuple(str(s ^ v) for v in a)
print(' '.join(b))

Measured memory_bytes: 35960
#include<iostream>
using namespace std;
long n,p,ans=1;
main()
{
	cin>>n>>p;
	for(long i=2;i*i<=p;i++)
	{
		long cnt=0;
		while(p%i<1)cnt++,p/=i;
		if(cnt>=n)
		{
			for(int j=0;j<cnt/n;j++)ans*=i;
		}
	}
	if(p>1&&n==1)ans*=p;
	cout<<ans<<endl;
}


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

#define MOD (1000000007LL)
typedef long long ll;
int N,W;
int w[222];

ll dp[2][11111][211];
int main(){
  cin >> N >> W;
  for(int i=0;i<N;i++){
    cin >> w[i];
  }
  sort(w,w+N);
  w[N] = (1<<29);
  dp[0][0][N] = 1LL;
  ll res = 0;
  for(int i=0;i<N;i++){
    int id = i&1;
    int nd = (i+1)&1;
    memset(dp[nd],0,sizeof(dp[nd]));
    for(int j=0;j<=W;j++){
      for(int k=0;k<=N;k++){
	if( dp[id][j][k] == 0 ) continue;
	//	cout << i << " " << j << " " <<" " << k << " " << dp[id][j][k] << endl;
	if( j + w[i] <= W ) {
	  dp[nd][j+w[i]][k] += dp[id][j][k];
	  dp[nd][j+w[i]][k] %= MOD;
	} 
	int minid = w[k]>w[i]?i:k;
	dp[nd][j][minid] += dp[id][j][k];
	dp[nd][j][minid] %= MOD;
      }
    }
  }
  int id = N&1;
  for(int i=0;i<=W;i++){
    for(int j=0;j<=N;j++){
      if( dp[id][i][j] == 0 ) continue;
      //     cout << i << " " << j << " " << dp[id][i][j] << " " << w[j] << endl;
      res += (i + w[j] > W)? dp[id][i][j] : 0;
      res %= MOD;
    }
  }
  cout << res  << endl;    
  
}

Measured memory_bytes: 37816
package main

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

func main() {
	sc := NewScanner()

	n := sc.NextInt()
	m := sc.NextInt()
	x := sc.NextInt()
	y := sc.NextInt()

	for i := 0; i < n; i++ {
		tmp := sc.NextInt()
		if tmp > x {
			x = tmp
		}
	}
	for i := 0; i < m; i++ {
		tmp := sc.NextInt()
		if tmp < y {
			y = tmp
		}
	}
	//	fmt.Printf("%+v %d\n", x, y) // output for debug

	if x < y {
		fmt.Printf("No War\n") // output for debug
	} else {
		fmt.Printf("War\n") // output for debug
	}
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#50 ABC130E
n,m=map(int,input().split())
s=list(map(int,input().split()))
t=list(map(int,input().split()))
mod=10**9+7

import numpy as np
t=np.array(t,dtype=np.int64)
dp=np.ones(m+1,dtype=np.int64)

for a in s:
	dp[1:]=((dp[:-1]*(t==a)).cumsum()+dp[1:])%mod
print(dp[-1])

Measured memory_bytes: 21504
n, a, b = map(int, input().split())
s = input().strip()

sumy = 0
sumf = 0
for _s in s:
  if _s == 'c':
    print('No')
  elif _s == 'a':
    if sumy < a + b:
      print('Yes')
      sumy += 1
    else:
      print('No')
  else:
    if sumy < a + b and sumf < b:
      print('Yes')
      sumy += 1
      sumf += 1
    else:
      print('No')


Measured memory_bytes: 4016
import java.util.Arrays;
import java.util.Scanner;

class Main {
    public static void main(final String[] args) {
        
        Scanner scanner = new Scanner(System.in);
        String[] arr = new String[2];
        for(int i = 0;i < arr.length;i++) {
            arr[i] = scanner.nextLine();
        }

        String[] line1 = arr[0].split(" ");

        int n = Integer.parseInt(line1[0]);
        int m = Integer.parseInt(line1[1]);

        String[] line2 = arr[1].split(" ");

        int[] a = new int[line2.length];
        for (int i = 0; i < line2.length; i++) {
            a[i] = Integer.parseInt(line2[i]);
        }

        int sum = Arrays.stream(a).sum();

        if(sum > n){
            System.out.println(-1);
        }else{
            System.out.println(n - sum);
        }

        scanner.close();
    }
}

Measured memory_bytes: 39652