akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
typedef pair<long double, int> d_i;
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;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int N;
int x[105], y[105];
long double ans;
vector<d_i> v;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    for(int i = 1; i <= N; i++) {
        cin >> x[i] >> y[i];
        long double theta = atan2(x[i], y[i]);
        v.push_back({theta, i});
        v.push_back({theta + 2 * PI, i});
    }
    sort(v.begin(), v.end());
    for(int l = 0; l < v.size(); l++) {
        for(int r = l + 1; r < v.size(); r++) {
            if(r - l > N) break;
            long double now = 0;
            long double X = 0;
            long double Y = 0;
            for(int i = l; i < r; i++) {
                int index = v[i].second;
                X += x[index];
                Y += y[index];
            }
            chmax(ans, pow(X*X+Y*Y, 0.5));
        }
    }
    cout << fixed << setprecision(15) << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int a, b, c, d; cin >> a >> b  >> c >> d;
  cout << min(a, b) + min(c, d) << endl;
  return 0;
}

Measured memory_bytes: 3188
package main

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

func main() {
  input := Input{bufio.NewReaderSize(os.Stdin,1000)}
  n,k := input.NextInts()
  a := input.NextIntArray()
  for i:=0;i<n;i++ { a[i]-- }
  ans := 0
  if a[0] != 0 { ans++ }
  t := make([][]int,n)
  for i:=1;i<n;i++ { t[a[i]] = append(t[a[i]],i) }
  var dfs func(int,int) int
  dfs = func(u,p int) int {
    h := 0
    for _,v := range t[u] { h = max(h,dfs(v,u)) }
    if p != 0 && h == k-1 {
      ans++
      h = 0
    } else {
      h++
    }
    return h
  }
  dfs(0,0)
  fmt.Println(ans)
}
func max(n,m int) int {
  if n > m { return n }
  return m
}

type Input struct { reader *bufio.Reader }
func(i *Input) NextLine() string {
  var buffer []byte
  for {
    line,isPrefix,err := i.reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func(i *Input) NextInts() (int,int) {
  s := strings.Fields(i.NextLine())
  x,_ := strconv.Atoi(s[0])
  y,_ := strconv.Atoi(s[1])
  return x,y
}
func(i *Input) NextIntArray() []int {
  s := strings.Fields(i.NextLine())
  a := make([]int,len(s))
  for i:=0;i<len(s);i++ { a[i],_ = strconv.Atoi(s[i]) }
  return a
}

Measured memory_bytes: 37120
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  string s;
  cin>>s;
  
  for(int i = 0; i < s.size() - 1; i++)
  {
    if(s[i] == 'A' && s[i + 1] == 'C') {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define REP_AB(i, a, b) for (ll i = ll(a); i < ll(b); i++)
#define REP_IN(i, n, x) for (ll i = 0; i < n; i++)in>>x;
#define REP_OUT(i, n, x) for (ll i = 0; i < n; i++)out<<x<<endl;
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
#define REVERSE(v) reverse(ALL(v))
// true / false
#define BIN_SEARCH(v, a) binary_search(ALL(v), a)
// index
#define BIN_LEFT(v, a) (lower_bound(ALL(v), a) - v.begin())
#define BIN_RIGHT(v, a) (upper_bound(ALL(v), a) - v.begin())
#define BIN_INSERT(v, a) (v.insert(v.begin() + BIN_LEFT(v, a), a))
#define DEL(v, i) v.erase(v.begin() + i)
#define INSERT(v, i, a) v.insert(v.begin() + i, a)
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 dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
#define endl '\n'
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; }
// template end
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    //vector<ll> X(N);
    //string s;
    //in >> s;
    //vector<string> s;
    //s.resize(N);
    ll N,K;
    in >> N >>K;
    ll d,a;
    ll ans=0;
    vector<ll> A(N);

    REP(i,N){
        A[i]=0;
    }

    REP(i,K){
        in >> d;
        REP(j,d){
            in>>a;
            A[a-1]=1;
        }
    }

    ll c=0;
    REP(i,N){
        if(A[i]==0)c++;
    }
    out<<c<<endl;
    

    
    
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define rep(var,cnt) for(int (var)=0; (var)<(int)(cnt); ++(var))
#define Rep(var,init,cnt) for(int (var)=(init); (var)<(int)(cnt); ++(var))
#define ran(var,vec) for(auto &(var):(vec))
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(rall(v))
#define SUM(v) accumulate(all(v),0)
#define tget(tp,idx) get<idx>(tp)
#define TF(flag) ((flag)?1:0)
#define YN(flag) cout<<(flag?"YES":"NO")<<endl;
#define Yn(flag) cout<<(flag?"Yes":"No")<<endl;
#define yn(flag) cout<<(flag?"yes":"no")<<endl;
#define Cout(v) cout<<(v)<<endl
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pi = pair<int,int>;
using pl = pair<ll,ll>;
using ti = tuple<int,int,int>;
using tl = tuple<ll,ll,ll>;

template<typename T>
using vec = vector<T>;
template<typename T>
using mat = vector<vec<T>>;
template<typename T>
using cub = vector<mat<T>>;
template<typename T>
using val = valarray<T>;

template<typename T>
using pq = priority_queue<T>;
template<typename T>
using rpq = priority_queue<T,vec<T>,greater<T>>;

template<typename T1,typename T2>
ostream &operator<<(ostream &os, const pair<T1,T2> &p){
  os<<"P("<<p.first<<", "<<p.second<<") ";
  return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is, pair<T1,T2> &p){
  is>>p.first>>p.second;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, vector<T> &v){
  for(T &in:v) is>>in;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const valarray<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, valarray<T> &v){
  for(T &in:v) is>>in;
  return is;
}

// Usual Template End ===================

// Template End =========================

int main(void){
  char b; cin>>b;
  switch(b){
      case 'A' : Cout('T'); break;
      case 'C' : Cout('G'); break;
      case 'G' : Cout('C'); break;
      case 'T' : Cout('A'); break;
  }
}












Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i, a, b) for (ll i = a; i < (ll)b; ++i)
#define digit(a) to_string(a).size()
#define INF 10e12
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
using namespace std;
int main(void)

{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, s = 0;
    cin >> n;
    vector<int> a(n), x(n);
    rep(i, 0, n)
    {
        cin >> a[i];
        if (i % 2 == 1)
            s += a[i];
    }
    x[0] = accumulate(all(a), 0) - 2 * s;
    rep(i, 1, n) x[i] = 2 * a[i - 1] - x[i - 1];
    rep(i, 0, n) cout << x[i] << " ";
    cout << endl;
}


Measured memory_bytes: 3976
#include <stdio.h>

typedef long long int ll;

int n;
ll ugo[15];
int iti[15];

ll kai(int w)
{
	ll all = 0;
	int b = w;
	for(int i = 0; i < n; i++)
	{
		if(b == iti[i])
		{
			continue;
		}
		if(iti[i] == 1)
		{
			all += 1 + ugo[n - i - 1] * 2;
			if(b == 0)
			{
				b = 2;
			}
			else
			{
				b = 0;
			}
		}
		else if(b == 1)
		{
			all += 1 + ugo[n - i - 1];
			if(iti[i] == 0)
			{
				b = 2;
			}
			else
			{
				b = 0;
			}
		}
		else
		{
			all += 2 + ugo[n - i - 1] * 4;
		}
	}
	return all;
}

int main()
{
	while(1)
	{
		ll ma;
		scanf("%d %lld",&n,&ma);
		if(n == 0)
		{
			break;
		}
		ugo[0] = 0;
		for(int i = 1; i < n; i++)
		{
			ugo[i] = ugo[i - 1] * 3 + 1;
		}
		for(int k = 0; k < 3; k++)
		{
			int m;
			scanf("%d",&m);
			for(int i = 0; i < m; i++)
			{
				int w;
				scanf("%d",&w);
				iti[w - 1] = k;
			}
		}
		ll o;
		if(iti[0] == 1)
		{
			ll w1 = kai(0);
			ll w2 = kai(2);
			if(w1 < w2)
			{
				o = w1;
			}
			else
			{
				o = w2;
			}
		}
		else
		{
			o = kai(iti[0]);
		}
		if(o > ma)
		{
			o = -1;
		}
		printf("%lld\n",o);
	}
	return 0;
}

Measured memory_bytes: 1028
n,m,x=map(int,input().split())
a=list(map(int,input().split()))	

ans1=0
ans2=0

for i in range(x,n+1):
    if i in a:
        ans1+=1

for j in range(x,-1,-1):
    if j in a:
        ans2+=1

print(min(ans1,ans2))
    

Measured memory_bytes: 3060
while True:
    h,w=map(int,input().split())
    if h==0 and w==0:
        break
    for i in range(h):
        for j in range(w):
            if i==0 or i==h-1 or j==0 or j==w-1:
                print('#',end='')
            else:
                print('.',end='')
        print()

    print()



Measured memory_bytes: 7004
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;

struct RMQRUQ {
  int n;
  vector<int> dat, lazy;
 
  RMQRUQ(){}
  RMQRUQ(int n_) {
    n = 1; while(n < n_) n *= 2;
    dat.assign(n*2, INT_MAX);
    lazy.assign(n*2, INT_MAX);
  }
 
  void eval(int len, int k) {
    if(lazy[k] == INT_MAX) return;
    if(k*2+1 < n*2-1) {
      lazy[2*k+1] = lazy[k];
      lazy[2*k+2] = lazy[k];
    }
    dat[k] = lazy[k];
    lazy[k] = INT_MAX;
  }
 
  // [a, b)
  ll update(int a, int b, ll x, int k, int l, int r) {
    eval(r-l, k);
    if(b <= l || r <= a) return dat[k];
    if(a <= l && r <= b) {
      lazy[k] = x;
      return lazy[k];
    }
    return dat[k] = min(update(a, b, x, 2*k+1, l, (l+r)/2), update(a, b, x, 2*k+2, (l+r)/2, r));
  }
  ll update(int a, int b, ll x) { return update(a, b, x, 0, 0, n); }
 
  // [a, b)
  ll query(int a, int b, int k, int l, int r) {
    eval(r-l, k);
    if(b <= l || r <= a) return INT_MAX;
    if(a <= l && r <= b) return dat[k];
    ll vl = query(a, b, 2*k+1, l, (l+r)/2);
    ll vr = query(a, b, 2*k+2, (l+r)/2, r);
    return min(vl, vr);
  }
  ll query(int a, int b) { return query(a, b, 0, 0, n); }
};

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

	ll N,Q;
	cin >> N >> Q;
	RMQRUQ tr(Q+8);
	tr.update(0,Q+7,INF);
	vector< pair<ll, pair<ll,ll> > > xst(N);
	FOR(i,0,N){
		ll s,t,x;
		cin >> s >> t >> x;
		xst[i] = {x,{s,t}};
	}
	vector<ll> D(Q);
	FOR(i,0,Q){
		cin >> D[i];
	}
	D.push_back(INF);
	SORT(xst);
	REV(xst);
	FOR(i,0,N){
		ll s_x = xst[i].second.first - xst[i].first;
		ll t_x = xst[i].second.second - xst[i].first;
		ll a = POSL(D,s_x);
		ll b = POSU(D,t_x-1);//含まない
		tr.update(a,b,xst[i].first);
	}
	FOR(i,0,Q){
		ll ans = tr.query(i,i+1);
		if(ans==INF||ans<0) ans = -1;
		cout << ans << endl;
	}
}


Measured memory_bytes: 13668
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(){
  int i,j;
  int m;
  int y=0;
  int l=0;
  int n;
  int x;

  scanf("%d %d",&n,&x);

  int a[n];

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

  for(i=0; i<=n-1; i++){
    for(j=i+1; j<=n-1; j++){
      if(a[i]>a[j]){
        m = a[i];
        a[i] = a[j];
        a[j] = m;
      }
    }
  }

  i=0;
  while(i<=n-1){
    y = y + a[i];
    l++;
    if(y>x){
      l--;
      break;
    }
    if(i==n-1){
      if(y!=x){
        l--;
      }
      break;
    }
    i++;
  }
  printf("%d\n",l);

  return 0;
}


Measured memory_bytes: 128
<?php
fscanf(STDIN, '%d', $n);
$a = array_map('intval', explode(' ', trim(fgets(STDIN))));
$b = array_map('intval', explode(' ', trim(fgets(STDIN))));
$c = array_map('intval', explode(' ', trim(fgets(STDIN))));
$ans = 0;
for ($i = 0; $i < $n; $i++) {
    $ans += $b[$a[$i] - 1];
    if ($i < $n - 1 && $a[$i + 1] - $a[$i] === 1) {
        $ans += $c[$a[$i] - 1];
    }
}
echo $ans . PHP_EOL;

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

int main() {
	int R;
	cin >> R;
	if (R < 1200) {
		cout << "ABC";
	}
	else if (R < 2800) {
		cout << "ARC";
	}
	else {
		cout << "AGC";
	}

	return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	N := nextInt()
	X := nextInt()
	L := nextInts(N)
	count := 1
	current := 0
	for _, l := range L {
		current += l
		if current <= X {
			count += 1
		} else {
			break
		}
	}
	fmt.Println(count)
}

func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}

func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}

func nextString() string {
	return nextReader()
}

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

func nextInt64s(n int) []int64 {
	r := make([]int64, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt64()
	}
	return r
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}

func Min(a int, b int) int {
	if a > b {
		return b
	}
	return a
}

func Max(a int, b int) int {
	if a > b {
		return a
	}
	return b
}

func MinA(arg ...int) int {
	var s = arg[0]
	for _, v := range arg {
		s = Min(s, v)
	}
	return s
}

func MaxA(arg ...int) int {
	var s = arg[0]
	for _, v := range arg {
		s = Max(s, v)
	}
	return s
}

func Abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}


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

int main() {
  int x,y,c = 0;
  cin >> x >> y;
  for(int i = 0; 0 <= y - (i * 4); i++){
    if((y - (i * 4)) %2== 0 && (((y - (i * 4)) / 2) + i) - x == 0){
      c += 1;
    }
  }
  if(c == 1){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
 
using namespace std;
 
struct P{
    string a,b,c;
    P(){}
    P(string &a,string &b,string &c) : a(a),b(b),c(c) {}
};
 
vector<P> rules,ans;
map<string,bool> mp;
 
bool check(P p){
    for(int i = 0 ; i < (int)rules.size() ; i++){
	P rule = rules[i];
	bool flg = false;
	for(int j = 0 ; j < 8 ; j++){
	    if((rule.b[j] != '?' && rule.b[j] != p.a[j]) ||
	       (rule.c[j] != '?' && rule.c[j] != p.b[j])){
		flg = true;
		break;
	    }
	}
	if(!flg) return mp[rule.a];
    }
    return false;
}
 
int main(){
    int N,M;
    mp["permit"] = true;
    mp["deny"] = false;
    while(cin >> N >> M, (N|M)){
	P in;
	rules.clear(); ans.clear();
	while(N--){
	    cin >> in.a >> in.b >> in.c;
	    rules.push_back(in);
	}
	reverse(rules.begin(),rules.end());
	while(M--){
	    cin >> in.a >> in.b >> in.c;
	    if(check(in)){
		ans.push_back(in);
	    }
	}
	int s = ans.size();
	cout << s << endl;
	for(int i = 0 ; i < s ; i++){
	    cout << ans[i].a << " " << ans[i].b << " " << ans[i].c << endl;
	}
    }
    return 0;
}

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll n;
  cin >> n;
  ll cnt = 0;
  ll ans = 0;
  ll hi;
  cin >> hi;
  FOR(i,1,n){
    ll h;
    cin >> h;
    if(hi>=h){
      cnt ++;
      CHMAX(ans,cnt);
    }else{
      cnt = 0;
    }
    hi = h;
  }
  cout << ans<< endl;
  return 0;
}


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

using namespace std;

int main(void)
{
	int n;
	cin>>n;
	int a[n],i;
	for(i = 0; i < n; i++) cin>>a[i];
	for(i = 0; i < n; i++){
		if(a[i] % 2 == 0){
			if(a[i]%3 != 0 && a[i]%5 != 0){
				printf("DENIED\n");
				return 0;
			}
		}
	}
	printf("APPROVED\n");
	return 0;
}




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

int main()
{
	int x, y;
	for (int i = 1; ; i++) {
		cin >> x >> y;
		if (x == 0 && y == 0) break;

		if (x < y) cout << x << " " << y << "\n";
		else cout << y << " " << x << "\n";
	}
}


Measured memory_bytes: 3000
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func min(a int, b int) int {
	if a < b {
		return a
	} else {
		return b
	}
}

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)

	n := nextInt()
	a := make([]int, n+1)
	b := make([]int, n)

	for i := 0; i < n+1; i++ {
		a[i] = nextInt()
	}
	for i := 0; i < n; i++ {
		b[i] = nextInt()
	}

	s := 0
	for i := 0; i < n; i++ {
		if b[i] > a[i]+a[i+1] {
			s += a[i] + a[i+1]
			a[i] = 0
			a[i+1] = 0
		} else if b[i] > a[i] {
			s += b[i]
			a[i+1] -= b[i] - a[i]
			a[i] = 0
		} else {
			s += b[i]
			a[i] -= b[i]
		}
	}

	fmt.Println(s)
}


Measured memory_bytes: 6376
#include <stdio.h>

int main(){

    int n,m,l,i,j,k;
    long a[110][110],bb[110][110],c[110][110];
    
	 scanf("%d",&n);  	 
  	 scanf("%d",&m);
   	 scanf("%d",&l);
    
     for(i=1;i<=n;++i){
	  for(j=1;j<=m;++j){             
            scanf("%ld",&a[i][j]);
        }
      }
      
     for(i=1;i<=m;++i){
	  for(j=1;j<=l;++j){             
            scanf("%ld",&bb[i][j]);
        }
      }
     
     for(i=1;i<=n;++i){
	   for(j=1;j<=l;++j){
	    for(k=1;k<=m;++k){
	      c[i][j]+=a[i][k]*bb[k][j];       
		}
       
        if (j==1) {
		 printf("%ld",c[i][j]);
        }else{
	     printf(" %ld",c[i][j]);
        }
       } 
         printf("\n");
	  }
	    
    	  

	return 0;
}

Measured memory_bytes: 876
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <cstdlib>  // abs() for integer
#include <cmath>

using namespace std;

int main(void) {
    int n;
    cin >>n;
    vector <int> p(n);
    for (int i=0;i<n;i++)
    {
        cin >> p[i];
    }
    vector <int> d(n-1);
    for (int i=0;i<n-1;i++)
    {
        d[i] = p[i+1] - p[i];
        //cout <<d[i]<<endl;
    }
    int count =0;
    for (int i = 0;i<n-2;i++)
    {
        if (d[i]>0 && d[i+1]>0){
            count = count+1;
        }
        else if (d[i]<0 && d[i+1]<0){
            count = count+1;
        }
    }
    cout <<count;
    return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<i64>();
    let (n, m) = (v[0] as usize, v[1]);
    let a = read_vec::<i64>();

    let mut a0 = a[0];
    let mut count = 0;
    while a0 % 2 == 0 {
        a0 >>= 1;
        count += 1;
    }
    for i in 1..n {
        let mut a0 = a[i];
        let mut temp_count = 0;
        while a0 % 2 == 0 {
            a0 >>= 1;
            temp_count += 1;
        }
        if count != temp_count {
            println!("0");
            return;
        }
    }

    let a = a.into_iter().map(|x| x >> 1).collect::<Vec<_>>();
    // let m = m >> count - 1;

    let mut lcmnum = a[0];
    for i in 1..n {
        let gcdnum1 = gcd(lcmnum, a[i]);
        lcmnum = lcmnum / gcdnum1 * a[i];
        if lcmnum > m * 2 + 10 {
            println!("0");
            return;
        }
    }
    let all = m / lcmnum;
    let ans = (all + 1) / 2;
    println!("{}", ans);
}

fn gcd(a: i64, b: i64) -> i64 {
    if b == 0 {
        return a;
    }
    gcd(b, a % b)
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 8444
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

constexpr static int MAXN = 1e6;

int n;
string s;
int a[MAXN], b[MAXN];

bool check(int start) {
    a[start] = 0;
    int i = start;
    while (true) {
        int j = (i + 3) % n;
        if (b[(i + 1) % n] == b[(i + 2) % n])
            a[j] = a[i];
        else
            a[j] = 1 - a[i];

        if (j == start)
            break;
        i = j;
    }
    return a[start] == 0;
}

string get_str() {
    string t;
    bool rev = false;
    if ((a[0] + a[1] + a[2]) % 2 != b[1])
        rev = true;
    for (int i = 0; i < n; i++)
        t += (a[i] ^ rev) ? 'W' : 'S';
    return t;
}

int main() {
    cin >> n >> s;
    for (int i = 0; i < n; i++)
        b[i] = (s[i] == 'x' ? 1 : 0);

    if (n % 3 == 0) {
        if (check(0) && check(1) && check(2)) {
            cout << get_str() << endl;
        }
        else {
            cout << -1 << endl;
            return 0;
        }
    }
    else {
        if (check(0)) {
            cout << get_str() << endl;
        }
        else {
            cout << -1 << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
const int max_n = 1e5 + 100;
int n, k;
long long a[max_n], b[max_n], c[max_n], ans, DP[2000][max_n];
int main() {
    cin >> n >> k;
    for (int i = 0; i < n; i++)
        cin >> b[i] >> a[i];
    for (int i = 0; i < n; i++)
        for (int j = 0; j <= max_n; j++)
            DP[i][j] = 1e10;
    for (int i = 0; i < n; i++)
        DP[i][a[i]] = b[i];
    for (int i = 1; i < n; i++) {
        for (int j = 0; j <= max_n; j++) {
            DP[i][j] = min(DP[i - 1][j], DP[i][j]);
            if (j >= a[i])
                DP[i][j] = min(DP[i][j], DP[i - 1][j - a[i]] + b[i]);
        }
    }
    for (int i = max_n; i + 1; i--) {
        if (DP[n - 1][i] <= k) {
            ans = i;
            break;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 82304
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top, S[1000];

void push(int x){
    S[++top] = x;
}

int pop(){
    top--;
    return S[top + 1];
}

int main(){
    int a,b;
    top = 0;
    char s[100];
    while( scanf("%s", s) != EOF ){
        if( s[0] == '+'){
            a = pop();
            b = pop();
            push(a + b);
        }else if( s[0] == '-' ){
            b = pop();
            a = pop();
            push(a - b);
        }else if( s[0] == '*'){
            a = pop();
            b = pop();
            push( a * b);
        }else{
            push(atoi(s));
        }
    }
    
    printf("%d\n", pop());
    
    return 0;
}


Measured memory_bytes: 2040
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>

using namespace std;

int main(){

int N,M;
cin>>N>>M;
multimap<long long,int>A;//数字の大きさ、枚数
long long s[N];
map<long long ,int>Ans;
long long x;

for(int i=0;i<N;i++){
cin >> s[i];
A.insert(make_pair(-s[i],i));
}

int b;
long long c;

for(int i=0;i<M;i++){
cin>>b>>c;
b+=A.count(-c);
auto it=Ans.find(-c);
if(it!=Ans.end()){
    it->second+=b;
    continue;
}
Ans.insert(make_pair(-c,b));
}

int l;
for(int i=0;i<N;i++){
if(Ans.count(-s[i])>0)continue;//すでにAnsに入っているなら挿入しない

Ans.insert(make_pair(-s[i],A.count(-s[i])));
}


long long sum=0;
auto iter=Ans.begin();
int t;

while(N>0){
t=min(N,iter->second);
sum+=(-iter->first)*t;
N-=t;
iter++;
}
cout<<sum<<endl;

 return 0;
}

Measured memory_bytes: 19840
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int main()
{
     long long a,b;
     cin>>a>>b;
     int m,sum;
     m=b-a;
     sum=(1+m)*m/2;
     int ans;
     ans=sum-b;
     cout<<ans<<endl;
     
     
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <utility>
#define llint long long

using namespace std;
typedef pair<llint, llint> P;

llint N;
P D[100005];
vector<llint> G[100005];
map<llint, vector<P> > mp;

P dfs(int v, int prev)
{
	llint d = 0, n = 1;
	for(int i = 0; i < G[v].size(); i++){
		if(G[v][i] == prev) continue;
		P res = dfs(G[v][i], v);
		n += res.second;
		d += res.first + res.second;
	}
	return make_pair(d, n);
}

int main(void)
{
	cin >> N;
	for(int i = 1; i <= N; i++) cin >> D[i].first;
	for(int i = 1; i <= N; i++) D[i].second = i;
	llint d1 = D[1].first;
	sort(D+1, D+N+1), reverse(D+1, D+N+1);
	
	for(int i = 1; i <= N; i++){
		llint d = D[i].first, id = D[i].second;
		if(mp.count(d) == 0){
			if(i != N){
				llint p = d-N+2;
				if(p > d) continue;
				mp[p].push_back(make_pair(id, 1));
			}
		}
		else{
			llint x = 0;
			for(int j = 0; j < mp[d].size(); j++){
				G[id].push_back(mp[d][j].first);
				G[mp[d][j].first].push_back(id);
				x += mp[d][j].second;
			}
			x++;
			if(i != N){
				llint p = d-N+2*x;
				if(p > d) continue;
				mp[p].push_back(make_pair(id, x));
			}
		}
		
		/*for(auto it = mp.begin(); it != mp.end(); it++){
			cout << it->first << " ";
		}
		cout << endl;*/
	}
	vector<P> ans;
	for(int i = 1; i <= N; i++){
		for(int j = 0; j < G[i].size(); j++){
			if(i < G[i][j]) ans.push_back(make_pair(i, G[i][j]));
		}
	}
	if(ans.size() < N-1) cout << "-1" << endl;
	else{
		if(dfs(1, -1).first != d1) cout << -1 << endl;
		else for(int i = 0; i < ans.size(); i++) cout << ans[i].first << " " << ans[i].second << endl;
	}
	
	return 0;
}

Measured memory_bytes: 28912
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(i=0;i<n;i++)
#define foreach(c,itr) for(__typeof(c)::iterator itr=c.begin();itr!=c.end();itr++)
typedef long long ll;
typedef long double ld;
int i,j;

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

    int n;
    cin>>n;
    int d1[n],d2[n];
    rep(i,n){
    	cin>>d1[i]>>d2[i];
	}
	rep(i,n-2){
		if(d1[i]==d2[i]&&d1[i+1]==d2[i+1]&&d1[i+2]==d2[i+2]){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3648
#include<stdio.h>
#include<stdlib.h>
int main(){
  int x=0,y=0,p=0,q=0;
  scanf("%d%d",&x,&y);

  p=x%y;
  while(1){
    if(p==0)break;
    q=y%p;
    y=p;
    p=q;
  }
  printf("%d\n",y);
  return 0;
}

Measured memory_bytes: 592
n, m = gets.chomp.split.map(&:to_i)
a = Array.new(n) { gets.chomp.chars }
b = Array.new(m) { gets.chomp.chars }
(0..n - m).each do |i|
  (0..n - m).each do |j|
    cnt = 0
    (0...m).each do |di|
      (0...m).each do |dj|
        cnt += 1 if a[i + di][j + dj] == b[di][dj]
      end
    end
    if cnt == m * m
      puts "Yes"
      exit
    end
  end     
end
puts "No"

Measured memory_bytes: 2044
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;

int main(void)
{
    int A, B;
    cin >> A >> B;

    string A_str, A_rev;
    int counter = 0;
    for (int i = A; i <= B; i++)
    {
        auto A_str = std::to_string(i);
        auto A_rev = std::to_string(i);
        reverse(A_rev.begin(), A_rev.end());

        if (A_str == A_rev)
        {
            // cout << A_str << endl;
            counter++;
        }
    }
    cout << counter << endl;
    return (0);
}

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

int main()
{
	int n;
	cin>>n;
	vector<int> arr1(n,0),arr2(n,0);

	for(int i=0;i<n;i++)
	{
		int x,y;
		cin>>x>>y;
		arr1[i]=x;
		arr2[i]=y;
	}
	 int len = arr1.size();
        vector<int> ppp1(len), ppn1(len), pnp1(len), pnn1(len);
        for(int i = 0; i<len; ++i)
        {
            ppp1[i] = arr1[i] + arr2[i] ;
            ppn1[i] = arr1[i] + arr2[i];
            pnp1[i] = arr1[i] - arr2[i];
            pnn1[i] = arr1[i] - arr2[i];
        }
        vector<int> possibleVals(4);
        possibleVals[0] = (*max_element(ppp1.begin(), ppp1.end())-*min_element(ppp1.begin(), ppp1.end()));
        possibleVals[1] = (*max_element(ppn1.begin(), ppn1.end())-*min_element(ppn1.begin(), ppn1.end()));
        possibleVals[2] = (*max_element(pnp1.begin(), pnp1.end())-*min_element(pnp1.begin(), pnp1.end()));
        possibleVals[3] = (*max_element(pnn1.begin(), pnn1.end())-*min_element(pnn1.begin(), pnn1.end()));
        int ans= *max_element(possibleVals.begin(), possibleVals.end());
        cout<<ans;
}


Measured memory_bytes: 7988
#include<bits/stdc++.h>
#define N 50000
using namespace std;
bool prime[N];

int main(){
  for(int i=0;i<N;i++)
    prime[i]=true;
  prime[0]=prime[1]=false;
  for(int i=0;i*i<N;i++){
    if(!prime[i])continue;
    for(int j=i*2;j<N;j+=i)
      prime[j]=false;
  }
  int n;
  while(1){
    cin>>n;
    if(!n)break;
    int ans=0,used[N];
    memset(used,0,sizeof(used));
    for(int i=0;i<n;i++){
      if(!prime[i])continue;
      if(used[i])continue;
      if(used[n-i])continue;
      used[i]=true;
      used[n-i]=true;
      if(prime[n-i])ans++;
    }
    cout<<ans<<endl;
  }
  return 0;
}

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

//solution:
signed main() {
  int n, k; cin >> n >> k;
  vector<int> a(n);
  for(int& i: a) cin >> i;
  auto valid = [&](int m) {
    int x = 0;
    for(int& i: a) x += (i - 1) / m;
    return x <= k;
  };
  int lo = 1, hi = 1e9, ans = hi;
  while(lo <= hi) {
    int mid = lo + ((hi - lo) >> 1);
    if(valid(mid)) ans = min(ans, mid), hi = mid - 1;
    else lo = mid + 1;
  }
  cout << ans;
  return 0;
} //farewell, until we meet again..

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

using namespace std;

int main(){

	int n,m;
	cin >> n;
	int count[n];

	for(int i = 0; i < n; i++){
		count[i] = 0;
		int j = i+1;
		while(1){
			if(j%2 == 0){
				j /= 2;
				count[i]++;
			}else{
				break;
			}
		}
	}
	int i_max = 0;
	int j_max = 1;
	for(int i = 0; i < n; i++){
		if(i_max < count[i]){
			i_max = count[i];
			j_max = i+1;
		}
	}
	cout << j_max << endl;
}

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

int main() {
  int N;
  cin >> N;
  bool judge = false;
  for (int i=1; i<=9; i++) {
    for (int j=1; j<=9; j++) {
      if (i * j == N) {
        judge = true;
      }
    }
  }
  
  cout << (judge ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s,t,u;
  cin>>s>>t;
  int a,b;
  cin>>a>>b;
  cin>>u;
  if(s.compare(u)==0)
  {
  	a--;
  }
  else
  {
  	b--;
  }
  cout<<a<<" "<<b<<endl;
  return 0;
}


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

int main(){
    int n;
    vector<int> gets;
    vector<int> isge(300001,1);
    isge[0]=0;
    isge[1]=0;
    for(int i=1;i*7-1<=300000;i++){
        int p=i*7-1;
        if(isge[p]){
            gets.push_back(p);
            for(int j=p*2;j<=300000;j+=p)
                isge[j]=0;

        }
        p=i*7+1;
        if(p>300000)
            break;
        if(isge[p]){
            gets.push_back(p);
            for(int j=p*2;j<=300000;j+=p)
                isge[j]=0;
        }
    }
    while(cin>>n,n!=1){
        cout<<n<<":";
        for(int j=0;j<gets.size();j++)
            if(n%gets[j]==0)
                cout<<" "<<gets[j];
        cout<<endl;


    }
}

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

struct StNode
{
  StNode* m_poParnt;
  StNode* m_poLeft;
  StNode* m_poRigt;
  int m_nKey;

  StNode(int nNo) :
    m_poParnt(nullptr), m_poLeft(nullptr), m_poRigt(nullptr), m_nKey(nNo)
  { }
};

void fnPreOrder(StNode* poNode)
{
  if (poNode == nullptr)  return;

  cout << " " << poNode->m_nKey;
  fnPreOrder(poNode->m_poLeft);
  fnPreOrder(poNode->m_poRigt);
}

void fnInOrder(StNode* poNode)
{
  if (poNode == nullptr)  return;

  fnInOrder(poNode->m_poLeft);
  cout << " " << poNode->m_nKey;
  fnInOrder(poNode->m_poRigt);
}

void fnInsert(StNode*& rpoRoot, StNode* poNewNod)
{
  StNode* poParnt = nullptr;
  StNode* poNode = rpoRoot;

  while (poNode != nullptr)
  {
    poParnt = poNode;
    if (poNewNod->m_nKey < poNode->m_nKey)
      poNode = poNode->m_poLeft;
    else
      poNode = poNode->m_poRigt;
  }

  poNewNod->m_poParnt = poParnt;
  if (poParnt == nullptr)
    rpoRoot = poNewNod;
  else if (poNewNod->m_nKey < poParnt->m_nKey)
    poParnt->m_poLeft = poNewNod;
  else
    poParnt->m_poRigt = poNewNod;
}

void fnBinSchTree(StNode*& rpoRoot)
{
  int nMaxSiz;
  cin >> nMaxSiz;

  for (int i = 0; i < nMaxSiz; ++i)
  {
    string sCmd;
    cin >> sCmd;
    if (sCmd[0] == 'i')
    {
      int nNo;
      cin >> nNo;
      StNode* poNewNod = new StNode(nNo);
      fnInsert(rpoRoot, poNewNod);
    }
    if (sCmd[0] == 'p')
    {
      fnInOrder(rpoRoot);
      cout << endl;
      fnPreOrder(rpoRoot);
      cout << endl;
    }
  }
}

void fnPstOrder(StNode* poNode)
{
  if (poNode == nullptr)  return;

  fnPstOrder(poNode->m_poLeft);
  fnPstOrder(poNode->m_poRigt);
  delete poNode;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  StNode* poRoot = nullptr;

  fnBinSchTree(poRoot);
//fnPstOrder(poRoot);
}

Measured memory_bytes: 26464
program sample
  implicit none
  integer N, a, k, t, i
  integer, allocatable :: x(:)
  read(*,*) N
  allocate(x(N))
  k = 1
  t = 1
  read(*,*) x
  do i = 1, N
   
   if ( mod(x(i), 2) == 0) then
    k = k * 2
   endif
   t = t * 3

  end do
  write(*,*) t - k
  
  stop
end program sample 

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;
 
#define pb push_back
#define popb pop_back
#define popf pop_front
#define pf push_front
#define si size()
#define mp make_pair 
#define mt make_tuple
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound

#define ask(i,m,n) for(lli i=m;i<n;i++)
#define anket ios::sync_with_stdio(0), cin.tie(0),cout.tie(0)
 
#define endl "\n"
#define o0(a) cout<<a<<" "
#define o1(a) cout<<a<<"\n"
#define o2(a,b) cout<<a<<" "<<b<<"\n"
#define o3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n"
#define o4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n"
using namespace std;

#define prime1 1000000007
#define prime2 998244353

lli modadd(lli n,lli m , lli mod){
    lli sum = ((n+m)%mod+mod)%mod;
    return sum;
}

lli modsub(lli n,lli m,lli mod){
    lli diff = ((n-m+mod)%mod+mod)%mod;
    return diff;
}

lli modpro(lli n,lli m, lli mod){
    lli pro = ((n*m)%mod+mod)%mod;
    return pro;
}

lli powmod(lli x,lli y,lli mod){
    x %= mod;
    y %= mod;
    lli res = 1;
    while (y > 0) {
        if (y & 1)
            res = modpro(res , x,mod);
        y = y >> 1;
        x = modpro(x , x,mod);
    }
    return res;
}

lli moddiv(lli n,lli m,lli mod){
    //return n/m mod (mod) or n*(m)^-1 mod (mod)
    lli a = powmod(m,mod-2,mod);
    //this is because of fermats thm i.e. a^-1 = a^p-2 mod(p) check
    //multiplying p on both sides
    lli res = modpro(a,n,mod);
    return res;
}




int main() {
	anket;
	lli n,m;
	cin>>n>>m;
	lli a[]={1,0,0,0,0};
	lli d[]={0,0,0,0,0};
	lli flag=0;
	lli ma=0;;
	ask(i,0,m){
	    lli b;
	    cin>>b;
	    lli c;cin>>c;
	    if(d[b-1]==1 && c != a[b-1]){
	        flag=1;
	    }
	    a[b-1]=c;
	    
	    ma =max(ma,b); 
	        d[b-1]=1;
	    
	}
	if(flag || (a[0]==0 && n!= 1) || ma>n)
	{
	    o1(-1);
	}
	else{
	    if(n==1){
	        
	        if(m>0){
	            o1(a[0]);
	        }
	        else{
	            o1(0);
	        }
	    }
	    else{
	   ask(i,0,n){
	       cout<<a[i];
	   }; 
	    };
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int a, b;
    char op;

    while(true){
        cin >> a >> op >> b;

        if(op == '?')
        break;

        if(op == '+')
            cout << (a+b) << endl;
        if(op == '-')
            cout << (a-b) << endl;
        if(op == '*')
            cout << (a*b) << endl;
        if(op == '/')
            cout << (a/b) << endl;
    }

    return 0;
}


Measured memory_bytes: 3092
gets.to_i
num = gets.split.map(&:to_i)
ans = 1
flag = true
if num.include?(0)
    puts(0)
else
    num.map do |n|
        ans *= n
        if ans > (10 ** 18)
            flag = false
            break
        end
    end
    flag ? puts(ans) : puts(-1)
    # puts(10 ** 18)
end

Measured memory_bytes: 21640
n,m = map(int,input().split())
k = []
s = []
for i in range(m):
    l = input().split()
    k.append(int(l[0]))
    s.append(list(map(int,l[1:])))

p = list(map(int,input().split()))

import itertools 
data = list(itertools.product(range(2), repeat = n))
ans = 0

for d in data:
    light = 0
    for i in range(m):
        s_cnt = 0
        for j in range(k[i]):
            s_no = s[i][j]-1
            if d[s_no]==1: s_cnt+=1
        if s_cnt%2==p[i]:
            light += 1
    if light == m:
        ans += 1

print(ans)


Measured memory_bytes: 9256
import sys
from numba import njit, i8


@njit(i8(i8), cache=True)
def solve(X):
    money = 100
    res = 0
    while (money < X):
        money *= 1.01
        money = int(money)
        res += 1
    return res


def main():
    input = sys.stdin.buffer.readline
    X: int = int(input())
    print(solve(X))


if __name__ == '__main__':
    main()


Measured memory_bytes: 106180
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#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 RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

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

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

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    lint n;
    vector<lint> fib(n, -1);
    cin >> n;
    fib[0] = 1;
    fib[1] = 1;
    for(int i=2; i<=n; ++i){
        fib[i] = fib[i-1] + fib[i-2];
    }
    cout << fib[n] << endl;
    return 0;
}


Measured memory_bytes: 35468
#include<bits/stdc++.h>
using namespace std;
int const nax = 1e6 + 10;
char s[nax];
int n;
int dp[nax][2];
int d;


int main () {
    scanf("%s", s + 1);
    n = strlen(s + 1);
    s[0] = '0';

    dp[n + 1][1] = 1;

    for (int i = n ; i >= 0 ; -- i) {
        d = s[i] - '0';
        dp[i][0] = min(dp[i + 1][1] + 10 - d, dp[i + 1][0] + d);
        dp[i][1] = min(dp[i + 1][0] + d + 1, dp[i + 1][1] + 9 - d);
    }

    printf("%d\n", dp[0][0]);
}


Measured memory_bytes: 12584
#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int N;
    scanf("%d", &N);
    while (N>=10) {
        N = N%10;
    }
    if (N==2||N==4||N==5||N==7||N==9) {
        printf("hon\n");
    }else if (N==0||N==1||N==6||N==8){
        printf("pon\n");
    }else{
        printf("bon\n");
    }
    
    return 0;
}

Measured memory_bytes: 1664
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())
def NIJIGEN(H): return [list(input()) for i in range(H)]
def bfs(place,dis):
  for i in tree[place]:
    a,b=i
    if a not in finish:
      finish.add(a)
      disli[a]=dis+b
      bfs(a,dis+b)
N=INT()
tree=[[] for _ in range(N)]
for i in range(N-1):
  a,b,c=MAP()
  tree[a-1].append([b-1,c])
  tree[b-1].append([a-1,c])
Q,K=MAP()#処理
disli=[0 for i in range(N)]
finish=set([K-1])
bfs(K-1,0)
for i in range(Q):
  a,b=MAP()
  print(disli[a-1]+disli[b-1])

Measured memory_bytes: 147884
def gi; gets.to_i end
def gs; gets.chomp end
def gli; gets.split(' ').map(&:to_i) end
def d(n); Math.log10(n).to_i + 1 end
class Integer
  # 約数の組み合わせを列挙する
  def divisor_combinations
    (1..Math.sqrt(self).to_i).
      select { |i| self % i == 0 }.
      map { |i| [i, self / i] }
  end
end

N, K = gli
h_n = gli
puts h_n.each.count { |h| h >= K }


Measured memory_bytes: 7940
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <math.h>
#include <complex>
#define LL long long int
using namespace std;

const int MOD = 1000000000 + 7;
// LL modInverse(int a, int m) {
//     a = a % m;
//     for (int x = 1; x < m; x++)
//         if ((a * x) % m == 1)
//             return x;
// }
// C function for extended Euclidean Algorithm 
int gcdExtended(int a, int b, int *x, int *y) 
{ 
    // Base Case 
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
  
    int x1, y1; // To store results of recursive call 
    int gcd = gcdExtended(b%a, a, &x1, &y1); 
  
    // Update x and y using results of recursive 
    // call 
    *x = y1 - (b/a) * x1; 
    *y = x1; 
  
    return gcd; 
} 
LL modInverse(int a, int m) 
{ 
    int x, y; 
    int g = gcdExtended(a, m, &x, &y); 
    // m is added to handle negative x 
    int res = (x%m + m) % m; 
    return res;
} 
  

LL pow2(LL n) {
    if (n == 1) {
        return 2;
    } else if (n % 2 == 0) {
        LL d = pow2(n/2); 
        return d*d % MOD;
    } else {
        LL d = pow2(n/2); 
        return (d*d*2) % MOD;
    }
}
LL je(LL from, LL to) {
    LL ret = 1;
    for (LL i = from; i <= to; i++) {
        ret *= i;
        ret %= MOD;
    }
    return ret;
}
LL comb(int n, int k) {
    int m = min(k, n-k);
    LL up = je(n - m + 1, n);
    LL down = je(1, m);
    // printf("up: %lld, down: %lld\n", up, down);
    LL ret = (up * modInverse(down, MOD)) % MOD;
    return ret;
}

int main() {
    int n, a, b;
    scanf("%d%d%d", &n, &a, &b);
    // XXX: 再 Mod 一次
    LL all = pow2(n);
    // printf("all %lld\n", all);
    LL n1 = comb(n, a);
    // printf("comb(n,a) %lld\n", n1);
    LL n2 = comb(n, b);
    // printf("comb(n,b) %lld\n", n2);
    LL ans = all - n1;
    if (ans < 0) { ans += MOD; }
    ans -= n2;
    if (ans < 0) { ans += MOD; }
    ans -= 1;
    printf("%lld\n", ans);
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::cin >> N;
  std::vector<std::string> s;
  tools::read(s, N);

  i64 AB = 0;
  i64 last_A = 0;
  i64 first_B = 0;
  for (const std::string& s_i : s) {
    for (auto it = ++s_i.begin(), prev_it = s_i.begin(); it != s_i.end(); prev_it = it, ++it) {
      if (*prev_it == 'A' && *it == 'B') ++AB;
    }
    if (s_i.back() == 'A') ++last_A;
    if (s_i.front() == 'B') ++first_B;
  }
  const i64 penalty = std::any_of(s.begin(), s.end(), [](const std::string& s_i) {
    return s_i.front() == 'B' && s_i.back() == 'A';
  }) && std::all_of(s.begin(), s.end(), [](const std::string& s_i) {
    return (s_i.front() == 'B') == (s_i.back() == 'A');
  }) ? 1 : 0;

  std::cout << AB + std::min(last_A, first_B) - penalty << std::endl;
  return 0;
}

Measured memory_bytes: 768
#include <iostream>
main(){
int nType, nNum;
int aPrice[4] = {6000, 4000, 3000, 2000};
for ( int i = 0; i < 4; i++ ){
std::cin >> nType >> nNum;
std::cout << aPrice[nType-1]*nNum << std::endl;
}
}

Measured memory_bytes: 1160
n, m = map(int, input().split())
sw = [list(map(int, input().split())) for i in range(m)]
p = list(map(int, input().split()))
ans = 2**n

for i in range(2**n):
  bin_str = format(i, '010b')[::-1]
  for j in range(m):
    sum = 0
    for k in range(sw[j][0]):
      sum += int(bin_str[sw[j][k+1]-1])
    if sum % 2 != p[j]:
      ans -= 1
      break
      
print(ans)

Measured memory_bytes: 3064