akhauriyash/Code-Regression huggingface dataset:
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, n) for(int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<60);
const ld pi=acosl(1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};

using P=pair<ll,ll>;

bool check(P p,ll sx,ll gx,ll sy,ll gy){
  ll x=p.first;
  ll y=p.second;
  return sx<=x and x<=gx and sy<=y and y<=gy;
}

ll mycount(vector<P>v,ll sx,ll gx,ll sy,ll gy){
  ll n=v.size();
  ll ret=0;
  rep(i,n){
    if(check(v[i],sx,gx,sy,gy))ret++;
  }
  return ret;
}

void solve(){
  ll n,k;cin>>n>>k;
  vector<P>v(n);
  ll ans=__LONG_LONG_MAX__;
  rep(i,n)cin>>v[i].first>>v[i].second;
  rep(a,n)rep(b,n)rep(c,n)rep(d,n){
    ll sx=v[a].first;
    ll gx=v[b].first;
    ll sy=v[c].second;
    ll gy=v[d].second;
    if(mycount(v,sx,gx,sy,gy)>=k){
      ans=min(ans,abs(sx-gx)*abs(sy-gy));
    }
  }
  cout<<ans<<endl;
}

signed main(){
	ios::sync_with_stdio(false);
  cin.tie(nullptr);cout<<fixed;
  cout<<setprecision(30);
	solve();
}


Measured memory_bytes: 256
N= int(input())
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7

L = [0] * N
L[0] = A[0]
for i in range(1, N):
  L[i] = L[i - 1] + A[i]

ans = 0
for i in range(1, N):
  ans = (ans + A[i] * L[i - 1]) % MOD 
print(ans)

Measured memory_bytes: 94024
from collections import deque


def print_list(que):
    for i, q in enumerate(que):
        if i != len(que)-1:
            print(q, end=' ')
        else:
            print(q)


def main():
    List = deque()
    n = int(input())
    for i in range(n):
        order = input().split()
        if order[0] == "insert":
            List.appendleft(order[1])
        elif order[0] == "delete":
            try:
                List.remove(order[1])
            except ValueError:
                pass
        elif order[0] == "deleteFirst":
            List.popleft()
        elif order[0] == "deleteLast":
            List.pop()
    print_list(List)


if __name__ == "__main__":
    main()



Measured memory_bytes: 69816
open System

// prelude
let readStr () = stdin.ReadLine()

let read f () = readStr() |> f
let reads f () = readStr().Split() |> Array.map f

let pair = function
| [|a; b|] -> (a, b)
| _ -> failwith "owatta"

let triple = function
| [|a; b; c|] -> (a, b, c)
| _ -> failwith "owatta"

let readPair f g () =
  let (a,b) = readStr().Split() |> pair
  (f a, g b)

let readTriple f g h () =
  let (a,b,c) = readStr().Split() |> triple
  (f a, g b, h c)

let inc n = n + 1
let dec n = n - 1

let inline flip f a b = f b a
let rec fix f = fun x -> (f (fix f)) x

module Option =
  let getOr defaultValue = function
  | Some x -> x
  | None -> defaultValue

module Array =
  let modify (arr: _ []) i f =
    arr.[i] <- f arr.[i]

module Array2D =
  let modify (arr: _ [,]) i j f =
    arr.[i, j] <- f arr.[i, j]

// start
let (A,B,N) = readTriple int64 int64 int64 ()
let r = A/B
let s = A%B
let q = min (B-1L) N
printfn "%d" (q*r+(q*s)/B)

Measured memory_bytes: 29964
#include<bits/stdc++.h>
#define ll long long
using namespace std;
struct node
{
    int v,id;
}a[100010];
bool cmp(node x,node y){return x.v<y.v;}
int main()
{
    int n;
    cin>>n;
    int ans=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i].v;
        a[i].id=i+1;
    }
    sort(a,a+n,cmp);
    for(int i=0;i<n;i++)
    {
        if(abs(a[i].id-(i+1))%2==1) ans++;
    }

    cout<<ans/2;
}





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

string s;
int main() {
  cin >> s;
  cout << s[0];
  cout << s.size() - 2;
  cout << s[s.size() - 1];
  cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int d;
    cin >> d;
    if( d==25){
        cout<< "Christmas" << endl;
    }else if(d == 24){
        cout << "Christmas Eve" << endl;
    }else if( d==23 ){
        cout << "Christmas Eve Eve" << endl;
    }else if( d ==22){
        cout << "Christmas Eve Eve Eve" << endl;
    }

}



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

int main(){
  int a,b,c,x,y;
  cin >> a >> b >> c >> x >> y;
  c = 2*c;
  long long min = 1000000000000;
  for (int i=0; i<=x; i++){
    int cost=0;
    if(y>x-i) cost = a*i + (x-i)*c + (y-(x-i))*b;
    else cost = a*i + (x-i)*c;
    min = cost<min?cost:min;
  }
  for (int j=0; j<=y; j++){
    int cost=0;
    if(x>y-j) cost = b*j + (y-j)*c + (x-(y-j))*a;
    else cost = b*j + (y-j)*c;
    min = cost<min?cost:min;
  }
  cout << min << endl;
}

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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

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

	if(s == "Sunny") cout << "Cloudy";
	else if(s == "Cloudy") cout << "Rainy";
	else cout << "Sunny";

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>

using namespace std;
int main() {
    char string[100000],ans[100000];
    int stringlong,j;
    cin >> string;
    stringlong = strlen(string);
    j = 0;
    for (int i = 0; i < stringlong; ++i) {
        if (i % 2 == 0){
            ans[j] = string[i];
            j++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<string.h>
#define pb push_back
#define all(v) v.begin(),v.end()
#define see(x) cout<<#x<<" : "<<(x)<<endl;
#define ya cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define ff first
#define sc second
typedef  long long ll;
using namespace std;
const ll N=1e5+7;
ll n,k,i,j,ans;
int main()
{
//    ios::sync_with_stdio(false);
//    cin.tie(NULL),cout.tie(NULL);
    cin>>n>>k;
    if((n==k) || k==1 || n==0)
    {
        cout<<0<<endl;
        return 0;
    }
    if(n<k)
    {
        k=n-k;
        if(k<0)k=-k;
        cout<<(ll)min(n,k)<<endl;
    }
    else
    {
        ll p=n%k;
        k=k-p;
        if(k<0)k=-k;
        cout<<(ll)min(n,k)<<endl;
    }
    return 0;
}


Measured memory_bytes: 3540
#include <iostream>
#include <cassert>
#include <cstring>
#include <string>
#include <algorithm>
#include <stack>
#include <vector>
#include <set>
#include <fstream>
#include <map>

#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define x first
#define y second

using namespace std;

const int INF = int(2e9) + 7;
const int N = int(1e5) + 11;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            if (i * j == n) {
                cout << "Yes";
                return 0;
            }
        }
    }
    cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>//random,NULL
#include <string.h>
#include <time.h>
#include <unistd.h>//sleep()
#include <math.h>
#include <stdbool.h>

#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)
#define INF 1000000000
const int mod = INF+7;

int main(){
  char buf[1024];
  int N,L;

  fgets(buf,sizeof(buf),stdin);
  sscanf(buf, "%d %d", &N, &L);

  int sum=0;
  rep(i,N){
    sum+=L+i;
  }

  int ans;
  if(L<=0 && L+N-1>=0){
    ans=sum;
  }
  else if(L+N-1<0){
    ans=sum-(L+N-1);
  }
  else{
    ans=sum-L;
  }

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

  return 0;
}


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

namespace Atcoder
{
    public class Program
    {
        static void Main(string[] args)
        {
            var r1 = ReadSplit();
            var n = r1[0].ToLong();
            var h = new long[110000][];
            var dp = new long[110000][];
            var INF = 9999999999999;

            for (int i = 0; i < 110000; i++)
            {
                dp[i] = new long[3];
                h[i] = new long[3];
            }

            for (int i = 0; i < n; i++)
            {
                var r = ReadSplit();
                for (int j = 0; j < 3; j++)
                {
                    h[i][j] = r[j].ToLong();
                }
            }

            dp[0][0] = 0;
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    for (int k = 0; k < 3; k++)
                    {
                        if (j == k) continue;
                        ChangekMax(ref dp[i + 1][k], dp[i][j] + h[i][k]);
                    }
                }
            }
            long ans = 0;
            for (int i = 0; i < 3; i++)
            {
                ChangekMax(ref ans, dp[n][i]);
            }
            WriteRead(ans);
        }

        public static string Read()
        {
            return Console.ReadLine();
        }

        public static string[] ReadSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        public static void WriteRead(object str)
        {
            Console.WriteLine(str);
            Read();
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
        }

        private static bool ChangeMin<T>(ref T a, T b) where T : IComparable
        {
            if (a.CompareTo(b) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }

        private static bool ChangekMax<T>(ref T a, T b) where T : IComparable
        {
            if (b.CompareTo(a) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }
    }
}


public static class Extentions
{
    public static int ToInt32(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static long ToLong(this object obj)
    {
        return long.Parse(obj.ToString());
    }

    public static decimal ToDecimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double ToDouble(this object obj)
    {
        return double.Parse(obj.ToString());
    }

    public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key) where T2 : struct
    {
        T2 value;
        if (d.TryGetValue(key, out value))


        {
            return value;
        }
        return new T2();
    }
}



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

int main(void)
{
    string a, b, c;

    cin >> a >> b >> c;
    if (a.back() == b.front() && b.back() == c.front())
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int h[n];
  int cost[n] = {};
  for(int i=0;i<n;i++){
    cin >> h[i];
  }
  for(int i=0;i<n;i++){
    if(i == 0) continue;
    if(i == 1) {
      cost[i] = abs(h[i-1]-h[i]);
      continue;
    }
    cost[i] = min(abs(h[i-1]-h[i])+cost[i-1], abs(h[i-2]-h[i])+cost[i-2]);
  }
  cout << cost[n-1] << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9+ 7;
const int INF = 2e18;

template< typename T >
struct BinaryIndexedTree {
    vector< T > data;

    BinaryIndexedTree(int sz) {
        data.assign(++sz, 0);
    }

    T sum(int k) {
        T ret = 0;
        for(++k; k > 0; k -= k & -k) ret += data[k];
        return (ret);
    }

    void add(int k, T x) {
        for(++k; k < data.size(); k += k & -k) data[k] += x;
    }
};


signed main() {
    int N, K;
    cin >> N >> K;
    vector<int> a(N), explore(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        a[i] -= K;
        explore[i] = a[i];
        if (i > 0) explore[i] += explore[i - 1];
    }
    sort(explore.begin(), explore.end());
    map<int, int> eraseIdx;
    for (int i = 0; i < N; i++) eraseIdx[explore[i]] = -1;
    for (int i = 0; i < N; i++) {
        int temp = eraseIdx[explore[i]];
        if (temp == -1) eraseIdx[explore[i]] = i;
    }
    auto removeSum = BinaryIndexedTree<int>(N);
    int ans = 0, sum = 0;
    auto update  = [&]() {
        auto itr = lower_bound(explore.begin(), explore.end(), sum);
        int dist = distance(explore.begin(), itr);
        int minus = removeSum.sum(N - 1);
        if (dist > 0) minus -= removeSum.sum(dist - 1);
        dist = N - dist;
        ans += dist - minus;
    };
    for (int i = 0; i < N; i++) {
        update();
        sum += a[i];
        removeSum.add(eraseIdx[sum], 1);
        eraseIdx[sum]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 17408
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		int[] array = new int[N];
		{
			char[] input = sc.next().toCharArray();
			for(int i = 0; i < N; i++){
				array[i] = Character.getNumericValue(input[i]);
			}
		}
		final int D = sc.nextInt();
		
		int[] output = new int[N];
		System.arraycopy(array, 0, output, 0, N);
		{
			int count = D;
			for(int i = 0; i < N; i++){
				if(count > 0 && array[i] == 0){
					count--;
					output[i] = 1;
				}
			}
			
			for(int i = N - 1; i >= 0; i--){
				if(count > 0 && array[i] == 1){
					count--;
					output[i] = 0;
				}
			}
		}
		
		for(int i = 0; i < N; i++){
			System.out.print(output[i]);
		}
		System.out.println();
		
		
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() {
			try {
				while (!hasNext()) {
					tok = new StringTokenizer(br.readLine());
				}
			} catch (IOException e) { /* ignore */
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public void close() {
			try {
				br.close();
			} catch (IOException e) { /* ignore */
			}
		}
	}
}

Measured memory_bytes: 25336
s = input()
num = 0
if s[0] == "+":
  num += 1
else:
  num -= 1

if s[1] == "+":
  num += 1
else:
  num -= 1

if s[2] == "+":
  num += 1
else:
  num -= 1

if s[3] == "+":
  num += 1
else:
  num -= 1

print(num)

Measured memory_bytes: 3060
H, W = map(int, input().split())
A = []
for i in range(H):
  A.append(input())
  
for i in range(H):
  for j in range(W):
    if A[i][j] == '#':
      print('#', end='')
    else:
      count = 0
      for k in range(max(0, i-1), min(i+1, H-1)+1):
        for l in range(max(0, j-1), min(j+1, W-1)+1):
          if A[k][l] == '#':
            count += 1
      print(count, end='')
  print()

Measured memory_bytes: 3444
#include <math.h>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <iomanip>
#include <iterator>
#include <algorithm>
#include <functional>
#include <typeinfo>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>

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 mp(a, b) make_pair(a, b)
#define all(vec) (vec).begin(), (vec).end()
#define yn(formula) (formula) ? (cout << "Yes" << endl) : (cout << "No" << endl)
#define YN(formula) (formula) ? (cout << "YES" << endl) : (cout << "NO" << endl)
#define MIN(a, b) ((a) < (b)) ? (a) : (b)
#define LLONG_MAX     9223372036854775807i64

typedef long long ll;
typedef pair<int, int> pii;
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<pii> vp;
typedef vector<pll> vpl;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vp> vvp;
typedef vector<vpl> vvpl;

constexpr double PI = 3.14159265358979323846;
constexpr ll INF = 1 << 29;
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-7;
constexpr int dy[4] = { 0, 1, 0, -1 };
constexpr int dx[4] = { 1, 0, -1, 0 };

struct edge { ll to; ll cost; };

ll Pow(ll a, ll b) {
	ll x = 1;
	while (b > 0) {
		if (b & 1) x = x * a;
		a = a * a;
		b = b >> 1;
	}
	return x;
}

/*<ここから>***********************************************************/


int main()
{
	int N;
	cin >> N;
	vll a(N);
	rep(i, N) cin >> a[i];

	ll two[32];
	two[0] = 1;
	rep(i, 32 - 1) two[i + 1] = two[i] * 2;


	ll ans = 0;
	rep(i, N) {

		rep(j, 32) {
			if ((a[i] / two[j]) % 2 == 1) {
				ans += j;
				break;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <stdio.h>

using namespace std;
typedef long long ll;

ll S;

int main() {
  cin >> S; 
  int n = 4;
  vector<int> A;
  for(int i=n-1;i>=0;i--){
    A.push_back(S/((int)pow(10,i)));
    S = S - S/((int)pow(10,i))* pow(10,i);
  }
  ll a=0;
  char F[3];
  for (int bit = 0; bit < (1<<(n-1)); ++bit) {
    ll ans =0;
    ll curr = 0;
    for (int i = 0; i < n; ++i) {
      curr = curr+A[i];
      F[i]='+';
      //cout << " " << curr << endl;
      if (bit & (1<<i)) { // i が bit に入るかどうか
	curr -= 2*A[i+1];
	F[i]='-';
	//cout << "curr " << curr << endl;
      }
    }
    if(curr==7){
      cout<<A[0]<<F[0]<<A[1]<<F[1]<<A[2]<<F[2]<<A[3]<<"="<<7<<endl;
      break;
      //printf("%d%c%d%c%d%c%d\n",A[0],F[0],A[1],F[1],A[2],F[2],A[3]);
    }
    //cout << curr << endl;
  }
  
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;
typedef long long LL;

const int MAXN = 4e5 + 5;

int other[MAXN + 5], pre[MAXN + 5], last[MAXN + 5];
int f[MAXN + 5], deep[MAXN + 5], father[MAXN + 5];

int all = -1, N;

void build(int u, int v)
{
	pre[++all] = last[u];
	last[u] = all;
	other[all] = v;
}

int dfs(int ans, int fa, int d)
{
	f[ans] = 1, deep[ans] = d, father[ans] = fa;
	int dt = last[ans];
	while(dt != -1){
		int dr = other[dt];
		if(dr != fa) f[ans] += dfs(dr, ans, d + 1);
		dt = pre[dt];
	}
	return f[ans];
}

int main()
{
	memset(last, -1, sizeof(last));
	scanf("%d", &N);
	for(int i = 1; i < N; i++){
		int u, v;
		scanf("%d %d", &u, &v);
		build(u, v);
		build(v, u);
	}
	dfs(N, 0, 0);	
	int tot = 1, head = 1;
	while(head <= deep[1] - head) tot = father[tot], head++;
	//printf("%d\n", deep[1]);
	//printf("%d\n", tot);
	if(f[N] - f[tot] < f[tot]) printf("Fennec\n");
	else printf("Snuke\n");
}

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

int main(){
  int x, s;
  int a[100009][2];
  for(int i = 2; i < 100009; i++){
    a[i][0] = i;
    a[i][1] = 0;
  }
  for(int i = 2; i < 100009; i++){
    if(a[i][1] == 0){
      a[i][1] = 2;
      s = 2;
      while(i * s < 100009){
        a[i * s][1] = 1;
        s++;
      }
    }
  }
  s = 0;
  cin >> x;
  while(s == 0){
    if(a[x][1] == 2){
      cout << x << endl;
      s++;
    }
    else
      x++;
  }
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
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; }
const ll INF = 1LL << 60;
int main(){
    string s;
    cin >> s;
    int n = s.size();
    rep(i,n){
        if(s[i]=='7'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 3620
#encoding:utf-8

N = int(input())
t,a = map(int,input().split())
h = list(map(int, input().split()))
# print(h)

diff = 10000
for i in range(N):
    tem_diff = abs(t-h[i]*0.006-a)
    if tem_diff < diff:
        diff = tem_diff
        place = i+1


print(place)


Measured memory_bytes: 3060
function Main(input) {
	var W = parseInt(input.split(" ")[0]);
	var a = parseInt(input.split(" ")[1]);
	var b = parseInt(input.split(" ")[2]);
 
	var ans;
 
	if ((b - a - W) > 0) {
		ans = b - a - W;
	} else if ((a - b - W) > 0) {
		ans = a - b - W;
	} else {
		ans = 0;
	}
 
	console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));process.stdin.resume();

Measured memory_bytes: 21320
#include <iostream>
#include <sstream>
#include <regex>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>

using namespace std;
using ll = long long int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)
#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define elif else if
#define itn ll
#define int ll
//const int INF = 100100100;
const int INF = (1LL<<32);
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;

static const int MAX = 100000;

bool V[MAX];
vector<int> G[MAX];
list<int> out;
int N;
int indeg[MAX];

void bfs(int s) {
	queue<int> q;
	q.push(s);
	V[s] = true;
	while (!q.empty()) {
		int u = q.front();
		q.pop();
		out.pb(u);
		rep(i, G[u].size()) {
			int v = G[u][i];
			indeg[v]--;
			if (indeg[v] == 0 and !V[v]) {
				V[v] = true;
				q.push(v);
			}
		}
	}
}


void tsort() {
	rep(i, N) indeg[i] = 0;
	rep(u, N) {
		rep(j, G[u].size()) {
			int v = G[u][j];
			indeg[v]++;
		}
	}
	rep(u, N) {
		if (!V[u] and indeg[u]==0) {
			bfs(u);
		}
	}
	for (auto l : out) {
		cout << l << '\n';
	}
}

signed main() {
	ios::sync_with_stdio(false);
	int e;
	cin >> N >> e;
	rep(i, N) V[i] = false;
	rep(i, e) {
		int s, t;
		cin >> s >> t;
		G[s].pb(t);
	}
	tsort();
	return 0;
}




Measured memory_bytes: 6508
import java.util.Scanner;

public class Main {

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

	    int N=gi();
	    int x=Math.floorDiv(N, 200);
	    
	    if (x>2) {
	    	//System.out.println(11-x);
	    }


	    System.out.println(10-x);
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35600
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	int n; cin >> n;
	string s; cin >> s;
	vector<int> sum(n + 1);
	sum[0] = 0;
	rep(i, n)
	{
		sum[i + 1] = sum[i];
		if (s[i] == '#')++sum[i + 1];
	}
	int res = 1e9;
	rep(i, n + 1)
	{
		res = min(res, sum[i] + n - i - sum[n] + sum[i]);
	}
	cout << res << endl;
}

Measured memory_bytes: 1412
#include <iostream>
using namespace std;
int main()
{
  string s;
  cin >> s;
  for (int i = 0; i < s.length() - 1; i++)
  {
    if (s.at(i) == s.at(i + 1)) // XX
    {
      cout << i + 1 << " " << i + 2 << endl;
      return 0;
    }
  }
  for (int i = 0; i < s.length() - 2; i++)
  {
    if (s.at(i) == s.at(i + 2)) // XYX
    {
      cout << i + 1 << " " << i + 3 << endl;
      return 0;
    }
  }
  cout << -1 << " " << -1 << endl;
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
const int M = 1e5+10;
int p[M];
int main(){
    int n;
    while(cin>>n){
        for(int i=1;i<=n;++i) cin>>p[i];
        int ans=0;
        for(int i=1;i<n;++i){
            if(p[i]==i){
                ++ans;
                swap(p[i],p[i+1]);
            }
        }
        if(p[n]==n) ++ans;
        cout<<ans<<endl;
    }
    return 0;
}

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

int main() {
    long long N;
    cin >> N;
    long long ans = 1;
    for (long long i = 1; i*i <= N; i++) {
        ans = max(ans, i*i);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int a,b;
	char op;
	while(1){
		cin>> a >> op >> b;
		if(op == '?') break;
		else if(op=='+') cout<< a+b <<endl;
		else if(op=='-') cout<< a-b <<endl;
		else if(op=='*') cout<< a*b <<endl;
		else if(op=='/') cout<< a/b <<endl;
	
	}
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
bool  mySort(const pair <int,int> &a , const pair <int,int> &b)
{
    return a.second < b.second;
}
int main()
{
    int n , x;
    vector < pair <int,int> > attend;
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        cin >> x;
        attend.push_back(make_pair(i , x));   // <student ID , # of students exist when student i comes>
    }

    sort(attend.begin(), attend.end(), mySort);

    for (int i = 0; i < n; i++)
    {
        cout << attend[i].first << " ";
    }

    return 0;
}


Measured memory_bytes: 1780
let () =
    let split s =
        let rec loop i cur flag acc =
            if i = String.length s then ( if flag then cur :: acc else acc) else (
                match flag, s.[i] with
                | true,  ' ' -> loop (i + 1) "" false (cur :: acc)
                | false, ' ' -> loop (i + 1) "" false acc
                | true,  v   -> loop (i + 1) (Printf.sprintf "%s%c" cur v) true acc
                | false, v   -> loop (i + 1) (Printf.sprintf "%s%c" cur v) true acc
            )
        in
        List.map int_of_string (List.rev (loop 0 "" false []))
    in
    let main () =
        let n = int_of_string (read_line ()) in
        let d = split (read_line ()) in
        let s1 = List.fold_left (+) 0 d in
        let s2 = List.fold_left (fun acc v -> acc + v * v) 0 d in
        Printf.printf "%d\n" (((s1 * s1) - s2) / 2)
    in
    main ()

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
using ll = long long;

unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    int n, k;
    cin >> n >> k;
    string b;
    cin >> b;
    b.at(k - 1) += ('a' - 'A');
    cout << b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
//#define ll __int128
#define ll long long
#define int long long
//#define int __int128
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define y1 y122

/*
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")

#pragma GCC target("avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")

#pragma comment(linker, "/STACK: 20000000005")
*/

using namespace std;


int shem (){
    int x, y;
    cin >> x >> y;
    return x * 60 + y;
}

main()
{
    ios_base::sync_with_stdio(0);
    int A, B, k;
    A = shem ();
    B = shem ();
    cin >> k;
    int N = 24 * 60;
    int n = (N + B - A) % N;
    n = n - k;
    if (n < 0)
        n = 0;
    cout << n << endl;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define ld long double
#define pii pair<int,int>
#define fi first
#define se second
#define mex 1000005
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//vector<int> adj[mex];
//a+b=a^b+2*(a&b)

int main(){
	fast
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	 cin>>a[i];
	unordered_map<int,int> m;
	long long s=0;
	for(int i=0;i<n;i++){
	 m[a[i]]+=1;
	 s=s+a[i];
    }
    int q;
    cin>>q;
    while(q--){
		int b,c;
		cin>>b>>c;
		if(m.find(b)==m.end())
		 cout<<s<<endl;
		else{
			auto it=m.find(b);
			int y=it->second;
			m.erase(it);
			m[c]+=y;
			s=s+(c-b)*y;
			cout<<s<<endl;
		}
	} 
	
	  
	
}


Measured memory_bytes: 6944
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
#include <functional>
 
using namespace std;
typedef long long ll;
const ll INF = 1e18;

# define rep(i, n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((int)(n)); i>0; --i)
# define all(x) (x).begin(), (x).end()
# define pb push_back
 
ll N, M;

bool isPalindrome(string s) {
  string t = s;
  reverse(t.begin(), t.end()); // t をひっくり返す
  return s == t; // 比較する
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int N, M;
    cin >> N >> M;
    int ans = N*(N-1)/2 + M*(M-1)/2 ;
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>

template<typename T>
std::vector<int> make_shift_table(const T& target) {
	std::vector<int> result(target.size());
	if (result.size() == 1) {
		result[0] = -1;
		return result;
	}
	int longest_prefix{ 0 };
	result[0] = -1; result[1] = 0;
	for (auto i = 2; i < target.size(); ++i) {
		while (longest_prefix >= 0 && target[i - 1] != target[longest_prefix]) {
			longest_prefix = result[longest_prefix];
		}
		result[i] = ++longest_prefix;
	}
	return result;
}
template<typename T>
std::vector<int> match_position(const T& target, const T& pattern) {
	const auto shift = make_shift_table(pattern);
	int it = 0;
	std::vector<int> result;
	for (auto iw = 0; iw < target.size(); ++iw) {
		while (it >= 0 && target[iw] != pattern[it]) {
			it = shift[it];
		}
		if (++it == pattern.size()) {
			result.push_back(iw - it + 1);
			it = shift.back();
			while (it >= 0 && target[iw] != pattern[it]) {
				it = shift[it];
			}
			++it;
		}
	}
	return result;
}
int main() {
	int n; std::cin >> n;
	std::vector<int> from(n), to(n);
	for (auto& a : from) std::cin >> a;
	for (auto& b : to) std::cin >> b;
	std::vector<int> pattern, target; pattern.reserve(n); target.reserve(2 * n);
	for (auto i = 0; i < n; ++i) {
		pattern.push_back(to[i] ^ to[(i + 1) % n]);
		target.push_back(from[i] ^ from[(i + 1) % n]);
	}
	for (auto i = 0; i < n - 1; ++i) target.push_back(target[i]);
	for (const auto k : match_position(target, pattern)) {
		std::cout << k << ' ' << (from[k] ^ to[0]) << '\n';
	}
}

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

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<Integer> b = new ArrayList<Integer>(n);
		for (int i = 0; i < n; i++) {
			b.add(sc.nextInt());
		}
		sc.close();

		List<Integer> ans = new ArrayList<Integer>(n);
		for (int i = n - 1; i >= 0; i--) {
			for (int j = i; j >= 0; j--) {
				if (b.get(j) == j + 1) {
					ans.add(j + 1);
					b.remove(j);
					break;
				}
			}
		}

		if (ans.size() == n) {
			for (int i = n - 1; i >= 0; i--) {
				System.out.println(ans.get(i));
			}
		} else {
			System.out.println(-1);
		}
	}

}


Measured memory_bytes: 23764
//083B
#include <bits/stdc++.h>
#define rep(i, n) for(int i=1; i<=n; i++)

using namespace std;
int main(void){
    int n,a,b,tmp;
    int c=0, ans=0;
    cin >> n >> a >> b;
    rep(i, n){
        tmp = i;
        c=0;
        while(tmp >0){
            c +=tmp%10;  //10で割ったときの余り
            tmp = tmp/10;
        }
        if(a<=c and c<=b) ans +=i;
        
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define to edge[i].v
#define mp make_pair
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
int d[10];
int main()
{	int x,y;
	cin>>x>>y; d[x]++; d[y]++;
	cin>>x>>y; d[x]++; d[y]++;
	cin>>x>>y; d[x]++; d[y]++;
	int s=0; for(rint i=1;i<=4;i++) s+=d[i]&1;
	if(s==2) cout<<"YES"; else cout<<"NO";
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	int a=0;
	int b=0;
	string t;
	int i=0;
	int d[10000];
	int x=0;
	while(1){
		cin>>a>>t>>b;
		if(t=="?"){
			break;
		}
		if(t=="+"){
			d[i]=a+b;
		}
		if(t=="-"){
			d[i]=a-b;
		}
		if(t=="*"){
			d[i]=a*b;
		}
		if(t=="/"){
			d[i]=a/b;
		}
		i++;
	}
	for(x=0;x<i;x++){
		cout<<d[x]<<endl;
	}
}

Measured memory_bytes: 1212
#include <stdio.h>

 int main(void)
 {

 int a[10000], min, max, n, i;
 long long sum = 0;
 
scanf("%d", &n);


for(i = 0; i < n; i++)
{
 	scanf("%d", &a[i]);
 	sum = sum +  a[i];
 }
	 max = min = a[0];

for(i = 1; i < n; i++)
{
	if(a[i] > max)
	{
		max = a[i];
	}
 	
	if(a[i] < min)
	{
		min = a[i];
	}

 }
	
	 printf("%d %d %lld\n", min, max, sum);

 	
	return 0;

 }

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

int ks[32] = {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 main()
{
  int k;
  while (scanf("%d", &k) != EOF)
    printf("%d\n", ks[k - 1]);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int a[101];
int main()
{
	int n,i,x,s=0;
	cin>>n;
	for (i=1;i<=n;i++)
	{
		cin>>x;
		a[x]=1;
	}
	for (i=0;i<=100;i++)  s+=a[i];
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int i64;
#define SZ(v) int((v).size())
#define ALL(vec) (vec).begin(),(vec).end()
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
 
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string>) {}
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << a << endl; err(++it, args...); }
template<typename T1,typename T2> ostream& operator<<(ostream& os, pair<T1,T2>& buf) {
  return os << "(" << buf.first << ": " << buf.second << ")"; }
#define DefOut(Con) template<typename T>ostream&operator<<(ostream&os,Con<T>&A){ bool f = false; os << "{"; \
  for (auto &e: A) { if (f) os << ", "; os << e; f = true; } return os << "}"; }
#define DefOut2(Con) template<typename K,typename V>ostream&operator<<(ostream&os,Con<K,V>&A) \
{ bool f = false; os << "{"; for (auto &e: A) { if (f) os << ", "; os << e; f = true; } return os << "}"; }
template<typename T>ostream &operator << (ostream &os,vector<vector<T>>& A) {
  for (auto &B: A) os << '\n' << B; return os; }
DefOut(vector) DefOut(set) DefOut(multiset) DefOut2(map) 
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
int const MOD = 1000000007;
long long const INF = 1e18;
#define PI 3.14159265358979323846
/***********************************************************************/

int32_t main() {

  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, m;
  cin >> n >> m;
  vector<vector<int>> a(m);
  for (int i = 0; i < m; ++i) {
    int k; cin >> k;
    while (k--) {
      int x; cin >> x;
      a[i].push_back(--x);
    }
  }
  vector<int> p(m);
  for (auto &z: p) cin >> z;
  int ans = 0;
  for (int i = 0; i < (1 << n); ++i) {
    int ok = 1;
    for (int j = 0; j < m && ok; ++j) {
      int cur = 0;
      for (int z : a[j]) {
        cur ^= (i >> z & 1);
      }
      if (cur ^ p[j]) ok = 0;
    }
    ans += ok;
  }
  kek(ans);
  
  return 0;
}


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

namespace ITP1_7_B
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int> map = new List<int>(161700);

            string[] input;
            int num;
            int total;

            while (!(input = Console.ReadLine().Split(' ')).All( s => s == "0"))
            {
                map.Clear();
                num = Convert.ToInt32(input[0]);
                total = Convert.ToInt32(input[1]);

                for (int i = num; i > 0; i--)
                {
                    for (int j = i - 1; j > 0; j--)
                    {
                        int sum1 = i + j;
                        for (int k = j - 1; k > 0; k--)
                        {
                            map.Add(sum1 + k);
                        }

                    }
                }

                Console.WriteLine(map.Count(i => i == total));
            }
        }
    }
}

Measured memory_bytes: 10252
using System.Text.RegularExpressions;
using static System.Console;
using static System.Convert;

class Program
{
    static void Main(string[] args)
    {
        var input = ReadLine().Split(' ');
        var num1 = ToInt32(input[0]);
        var num2 = ToInt32(input[1]);
        var str = ReadLine();
        var rgx = new Regex(@"(\d+)-(\d+)");
        if (rgx.IsMatch(str))
        {
            var match = rgx.Match(str);
            if (match.Groups[1].Length == num1 && match.Groups[2].Length == num2) WriteLine("Yes");
            else WriteLine("No");
        }
        else WriteLine("No");
    }
}


Measured memory_bytes: 15960
#include<stdio.h>
#define H 500000

int h, a[H+1];

int parent(int i){
  return i/2;
}

int left(int i){
  return 2*i;
}

int right(int i){
  return 2*i+1;
}

void maxHeapify(int* A, int i){
  int l, r, Max, n;
  l = left(i);
  r = right(i);
  if(l <= h && a[l] > a[i]) Max=l;
  else Max=i;
  if(r <= h && a[r] > a[Max]) Max=r;
  if(Max != i){
    n=a[i];
    a[i]=a[Max];
    a[Max]=n;
    maxHeapify(a, Max);
  }
}

void buildMaxHeap(int* A){
  int i;
  for(i=H/2; i>=1; i--){
    maxHeapify(A, i);
  }
}
  
int main(){
  
  int i;
  scanf("%d", &h);
  for(i=1; i<=h; i++) scanf("%d", &a[i]);
  buildMaxHeap(a);
  for(i=1; i<=h; i++){
    printf(" %d",a[i]);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 2552
#include <iostream>
#define SIZE 10000
using namespace std;

int main() {
	int n, max, min, a[SIZE], maxn = -1000000, minn = 1000000 ;
	long long sum = 0;
	cin >> n;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		if(a[i] > maxn) {
			maxn = a[i];
		}
		if(a[i] < minn) {
			minn = a[i];
		}
		sum += a[i];
	}
	cout << minn << " " << maxn << " " << sum << endl;
 	return 0;
}



Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
priority_queue <int> q;
long long a[100055],ans=0;
int main()
{
    int n,m;
    cin >>n>>m;
    for (int i=1;i<=n;i++)
    {
    	cin >>a[i];
    	q.push(a[i]);
	}
	for (int i=1;i<=m;i++)
	{
		ans+=q.top();
		q.pop();
	}
	cout <<ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using namespace std;
typedef long long LL;

int main() {
    int n;
    int l[110];
    cin >> n;
    int lmax = 1, lsum = 0;
    for (int i = 0; i<n; i++) {
        int tmp;
        cin >> tmp;
        lmax = max(lmax, tmp);
        lsum += tmp;
    }
    if (lmax < lsum - lmax) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;

int main(){
  int N, T, L, B;
  while(cin>>N>>T>>L>>B && N){
    bool lose[105] = {};
    bool back[105] = {};
    REP(i, L) {
      int k; cin>>k;
      lose[k] = true;
    }
    REP(i, B) {
      int k; cin>>k;
      back[k] = true;
    }
    double dp[105][105] = {};
    dp[0][0] = 1;
    REP(t, T + 1){
      REP(x, N)if(dp[t][x] > 0){
        for(int d = 1; d <= 6; d++){
          int next = x + d;
          if(next > N) next = N - (next - N);
          if(lose[next]){
            dp[t + 2][next] += dp[t][x] * 1.0 / 6.0;
          }else if(back[next]){
            dp[t + 1][0] += dp[t][x] * 1.0 / 6.0;
          }else{
            dp[t + 1][next] += dp[t][x] * 1.0 / 6.0;
          }
        }
      }
      //dp[t + 1][N] += dp[t][N];
    }
    double ans = 0;
    REP(t, T) ans += dp[t + 1][N];
    printf("%.10lf\n", ans);
    //cout<<dp[T][N]<<endl;
  }
  return 0;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n, m;
	cin >> n >> m;

	vvl adj(n);
	while (m--) {
		ll a, b;
		cin >> a >> b;
		a--, b--;
		adj[a].pb(b);
		adj[b].pb(a);
	}

	vl dist(n,oo), pred(n,-1);
	queue<ll> q;

	dist[0] = 0, q.push(0);

	while (sz(q)) {
		ll i = q.front();
		q.pop();
		for (ll j: adj[i]) if (dist[j] == oo) {
			dist[j] = dist[i]+1, pred[j] = i, q.push(j);
		}
	}

	cout << "Yes" << endl;
	FOR(i,1,n) cout << pred[i]+1 << endl;
}



Measured memory_bytes: 13652