akhauriyash/Code-Regression huggingface dataset:
/*                    ___          |\    /|           ____   ____   ____  ____
   |     |    /\    /    \ |     | | \  / |    /\    |    \ |    \ |     |    \
   |_____|   /__\   \____  |_____| |  \/  |   /__\   |____/ |____/ |__   |____/
   |     |  /    \       \ |     | |      |  /    \  |      |      |     |   \
   |     | /      \ \____/ |     | |      | /      \ |      |      |____ |    \
*/
#include<bits/stdc++.h>
using namespace std;
#define lb lower_bound
#define ub upper_bound
#define pf push_front
#define pb push_back
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define pi pair<int,int>
#define pl pair<long,long>
#define pll pair<long long,long long>
#define pld pair<long double,long double>
#define gc getchar_unlocked
#define pc putchar_unlocked
#define endl '\n'
#define loop(i,n) for(ll i=0;i<n;i++)
#define mod 1e9+7
#define in(x) scanf("%lld",&x)
#define in2(x,y) scanf("%lld %lld",&x,&y)
#define vl vector<ll>
#define vpll vector<pair<ll,ll>>
#define INF 0x3f3f3f3f
#define mp make_pair

ll calc(vl &dp,vl v,ll cost,ll pos, ll n) {
    if(dp[pos] == -1) {
        if(pos == n) return  dp[pos] = cost;
        if(pos == n-1) return dp[pos] = calc(dp,v,cost+abs(v[pos-1]-v[pos]),pos+1,n);
        dp[pos] = cost + min(calc(dp,v,abs(v[pos-1]-v[pos]),pos+1,n), calc(dp,v,abs(v[pos-1]-v[pos+1]),pos+2,n));
    }
    return dp[pos];
}

int main()
{
    ll n;
    if(in(n)!=1) return 0;
    vl v(n),dp(n+1,-1);
    loop(i,n) in(v[i]);
    dp[n] = 0;
    dp[n-1] = abs(v[n-1]-v[n-2]);
    for(ll i=n-2;i>0;i--) {
        dp[i] = min(dp[i+1] + abs(v[i-1]-v[i]), dp[i+2] + abs(v[i-1]-v[i+1]));
    }
    cout<<dp[1]<<endl;
    // for(auto x:dp) cout<<x<<" ";
    return 0;
}

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

using namespace std;

int main(){
    string a;
    long long int po=-1;
    long long int end=0;
    cin >> a;
    for(long long int i=0;i<a.length();i++){
        if(a[i]=='A' && po == -1){po=i;}
        else if(a[i]=='Z'){end=i;}
    }
    cout<<end-po+1<<endl;

    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<stack>
#include<iostream>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define vec(a) vector<int>a
using namespace std;


int main()
{
#ifndef ONLINE_JUDGE
	freopen("output.txt", "w", stdout);
	freopen("input.txt", "r", stdin);
#endif
	fastio
	string str;
	ll n,i,j,k,l,m;
	cin>>n;
	ll arr[n];
	for(i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	l=0;
	for(i=1;i<n;i++)
	{
		if(arr[i]<arr[i-1])
		{
			l+=abs(arr[i]-arr[i-1]);
			arr[i]=arr[i-1];
		}
	}
	cout<<l<<"\n";
	return 0;
}
	

Measured memory_bytes: 5176
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

#include <bits/stdc++.h>

using namespace std;

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

	int N;
	cin >> N;

	int a[N];
	int sum = 0;
	for(int i = 0; i < N; i++) {
		cin >> a[i];
		sum += a[i];
	}

	int maxi = *max_element(a, a + N);
	cout << sum - maxi/2 << endl;
	return 0;
}

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

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int left = 0;
	int right = s.size()-1;
	int ans = 0;
	while(left<right){
		if(s[left]==s[right]){
			left++;
			right--;	
		}else if(s[left]=='x'){
			left++;
			ans++;
		}else if(s[right]=='x'){
			right--;
			ans++;
		}else{
			cout << -1 << endl;
			return 0;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
N, M, X = map(int, input().split())
sankosho = []
for n in range(N):
    input_data = list(map(int, input().split()))
    sankosho.append(input_data)
for j in range(1, M+1):
    summed = 0
    for i in range(N):
        summed += sankosho[i][j]
    if summed < X:
        print(-1)
        exit()
ans_opt = []
for bit in range(2**N):
    cost = 0
    gain = []
    for i in range(N):
        if ((bit >> i) & 1):
            cost += sankosho[i][0]
            for j in range(1, M+1):
                if len(gain) <= j-1:
                    gain.append(sankosho[i][j])
                else:
                    gain[j-1] += sankosho[i][j]
    if not(len(gain) == 0):
        if min(gain) >= X:
            ans_opt.append(cost)
print(min(ans_opt))

Measured memory_bytes: 9052
#include <iostream>
#include <cstring>
using namespace std;
const int maxn=1e5+5;
const int inf=0x3f3f3f3f;
int dp[maxn][4];
int a[maxn],b[maxn],c[maxn];
int main()
{
   int n;
   cin>>n;
   memset(dp,0,sizeof(dp));
   for(int i=1;i<=n;++i){
       cin>>a[i]>>b[i]>>c[i];
   }
   dp[1][1]=a[1];
   dp[1][2]=b[1];
   dp[1][3]=c[1];
   for(int i=2;i<=n;++i){
       dp[i][1]=max(dp[i-1][2]+a[i],dp[i-1][3]+a[i]);
       dp[i][2]=max(dp[i-1][1]+b[i],dp[i-1][3]+b[i]);
       dp[i][3]=max(dp[i-1][2]+c[i],dp[i-1][1]+c[i]);
   }
   cout<<max(dp[n][1],max(dp[n][2],dp[n][3]))<<endl;
   return 0;
}


Measured memory_bytes: 2944
#include<stdio.h>
#define MAX 10000
#define NIL -1

struct Node{
  int p, l, r;
};

struct Node T[MAX];
int n;
int D[MAX], H[MAX];

int getDepth(int u){
  int d = 0;
  while(1){
    u = T[u].p;
    if ( u == NIL ) break;
    d++;
  }
  return d;
}

int getSibling(int u){
  if ( T[u].p == NIL ) return NIL;
  if ( T[T[u].p].l != u && T[T[u].p].l != NIL ) return T[T[u].p].l;
  if ( T[T[u].p].r != u && T[T[u].p].r != NIL ) return T[T[u].p].r;
  return NIL;
}

void print(int u){
  printf("node %d: ", u);

  printf("parent = %d, ", T[u].p);
  printf("sibling = %d, ", getSibling(u));
  int deg = 0;
  if ( T[u].l != NIL ) deg++;
  if ( T[u].r != NIL ) deg++;
  printf("degree = %d, ", deg);
  printf("depth = %d, ", D[u]);
  printf("height = %d, ", H[u]);

  if ( T[u].p == NIL ){
    printf("root\n");
  } else if ( T[u].l == NIL && T[u].r == NIL ){
    printf("leaf\n");
  } else {
    printf("internal node\n");
  }
}


int main(){
  int i, v, l, r;
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ) {
    T[i].p = NIL;
  }

  for ( i = 0; i < n; i++ ){
    scanf("%d %d %d", &v, &l, &r);
    T[v].l = l;
    T[v].r = r;
    if ( l != NIL ) T[l].p = v;
    if ( r != NIL ) T[r].p = v;
  }

  for ( i = 0; i < n; i++ ){
    D[i] = getDepth(i);
    H[i] = 0;
  }

  for ( i = 0; i < n; i++ ){
    if ( T[i].l == NIL && T[i].r == NIL ) { // is leaf
      H[i] = 0;
      int p = T[i].p;
      int c = 1;
      while(1){
	if ( p == NIL ) break;
	if ( H[p] < c ) H[p] = c;
	c++;
	p = T[p].p;
      }
    }
  }

  for ( i = 0; i < n; i++ ) print(i);
  return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll solve() {
    ll N, M, a, s = 0;
    cin >> N >> M;
    vector<ll> A(M);
    for ( int i = 0; i < M; i++ ) {
        cin >> a;
        s += a;
    }
    if ( s > N ) return -1;
    return N-s;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

int main() {
  int h,w,n;cin>>h>>w>>n;
  int ans=max(h,w);
  cout<<(n+ans-1)/ans<<endl;
}

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

int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  int ans = 0;
  while (A >= B) {
    B *= 2;
    ans++;
  }
  while (B >= C) {
    C *= 2;
    ans++;
  }
  if (ans > K) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}

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

const int maxN = 2e5; int n;
const int mod = 2019;
char s[maxN + 1];
int acc[maxN + 1], cnt[mod + 1];

int main()
{
  while (scanf(" %s", s) != EOF)
  {
    memset(cnt, 0, sizeof(cnt));
    n = strlen(s);
    acc[n] = 0;
    for (int i = n - 1, p = 1; i >= 0; i--, p = (p * 10) % mod)
      acc[i] = (acc[i + 1] + p*(s[i] - '0')) % mod;

    cnt[0] = 1;
    for (int i = 0; i < n; i++)
      cnt[acc[i]]++;

    lli ans = 0;
    for (int i = 0; i < mod; i++)
    {
      DEBUG
        if (cnt[i])
          printf("\t%d %d\n", i, cnt[i]);
      ans += ((lli)cnt[i]*(cnt[i] - 1)) >> 1LL;
    }
    printf("%lld\n", ans);
  }
  return 0;
}

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

namespace ConsoleApplication1
{
    struct Card
    {
        internal int num, vol;
    }

    class Problem
    {
        readonly int MAX = 1000;
        readonly int m;

        Card[] cards;
        int[,] dp;

        public Problem(int m)
        {
            this.m = m;
            cards = new Card[m];
            dp = new int[m + 1, MAX + 1];
            dp[0, 0] = 1;
        }

        public void MakeMap()
        {
            for (int i = 0; i < m; i++)
            {
                string[] input = Console.ReadLine().Split(' ');
                cards[i].num = int.Parse(input[0]);
                cards[i].vol = int.Parse(input[1]);
            }

            for (int i = 0; i < m; i++)
            {
                for (int j = MAX; j >= 0; j--)
                {
                    if (dp[i, j] == 0) continue;

                    for (int k = 0; k <= cards[i].vol; k++)
                    {
                        int sum = j + cards[i].num * k;
                        if (sum > MAX) continue;
                        dp[i + 1, sum] += dp[i, j];
                    }
                }
            }
        }

        public int GetConmination(int n)
        {
            return dp[m, n];
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            while (true)
            {
                int m = int.Parse(Console.ReadLine());

                if (m == 0) break;

                Problem p = new Problem(m);
                p.MakeMap();

                int g = int.Parse(Console.ReadLine());

                while (g-- > 0)
                {
                    int n = int.Parse(Console.ReadLine());
                    sb.AppendLine(p.GetConmination(n).ToString());
                }
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 9364
def move(dice, order):
  if order == "E":
    temp = dice[0]
    dice[0] = dice[3]
    dice[3] = dice[5]
    dice[5] = dice[2]
    dice[2] = temp
  elif order == "N":
    temp = dice[0]
    dice[0] = dice[1]
    dice[1] = dice[5]
    dice[5] = dice[4]
    dice[4] = temp
  elif order == "S":
    temp = dice[0]
    dice[0] = dice[4]
    dice[4] = dice[5]
    dice[5] = dice[1]
    dice[1] = temp
  elif order == "W":
    temp = dice[0]
    dice[0] = dice[2]
    dice[2] = dice[5]
    dice[5] = dice[3]
    dice[3] = temp
  else:
    pass
  return dice

def roll(dice):
  temp = dice[1]
  dice[1] = dice[2]
  dice[2] = dice[4]
  dice[4] = dice[3]
  dice[3] = temp
  return dice

def judge(dice1, dice2):
  flag = True
  for i in range(6):
    if dice1[i] != dice2[i]:
      flag = False
      break
  return flag

def aresame(dice1, dice2):
  mvdice = dice2
  cnt = 0
  
  while True:
    mvdice = move(mvdice, "E")
    cnt += 1
    if dice1[0] == mvdice[0]:
      rolldice = mvdice
      cntroll = 0
      while True:
        rolldice = roll(rolldice)
        cntroll += 1
        if judge(dice1, rolldice) == True:
          return True
        if cntroll == 4:
          break
    if cnt == 4:
      break

  mvdice = dice2
  cnt = 0
    
  while True:
    mvdice = move(mvdice, "N")
    cnt += 1
    if dice1[0] == mvdice[0]:
      rolldice = mvdice
      cntroll = 0
      while True:
        rolldice = roll(rolldice)
        cntroll += 1
        if judge(dice1, rolldice) == True:
          return True
        if cntroll == 4:
          break
    if cnt == 4:
      break

  return False


import sys

n = int(input())
saikoro = [[] for i in range(n)]
for i in range(n):
  saikoro[i] = list(map(int, input().split()))

for i in range(n):
  for j in range(i+1, n):
    if aresame(saikoro[i], saikoro[j]) == True:
      print("No")
      sys.exit()
      
print("Yes")


Measured memory_bytes: 5624
import sys
import math as mt
#input=sys.stdin.buffer.readline  
#t=int(input())
t=1
for __ in range(t):
    #n,k=map(int,input().split())
    #l=list(map(int,input().split()))
    s=input()
    if ord(s[0])>=97:
        print('a')
    else:
        print('A')

Measured memory_bytes: 61924
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

vector<ll> yakusu(ll n){
    vector<ll> ret;
    for(ll i = 1; i*i <= n; i++){
        if(n % i != 0) continue;
        ret.push_back(i);
        if(i*i != n) ret.push_back(n/i);
    }
    sort(ret.begin(), ret.end());
    return ret;
}

int main(){
    ll k;
    cin >> k;
    ll cur = 7 % k;
    rep(i, 0, k){
        if(cur == 0) {
            cout << i+1 << endl;
            return 0;
        }
        cur *= 10 % k;
        cur += 7;
        cur %= k;
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <cmath>
#include <cstdio>
#include <vector>
#include <iterator>
#include <iostream>
#include <algorithm>
#include <queue>
#include <unordered_set>
#include <stdio.h>
#include <chrono>
using namespace std;

#define rep(i,s,n) for(ll i=s;i<(n);++i)
using ll = long long;
using pll = pair<ll, ll>;
constexpr ll INF = (1LL << 60);
//constexpr ll MOD = (1e9 + 7);
constexpr ll MOD = (998244353);

using vl = vector<ll>;
using vvl = vector<vector<ll>>;

template<class T>
vector<vector<T>> vvt(T init, ll m, ll n) {
	vector<vector<T>> ans = vector<vector<T>>(m, vector<T>(n, init));
	return move(ans);
}

template<class T>
vector<T> vt(T init,ll n) {
	vector<T> ans = vector<T>(n, init);
	return move(ans);
}

//template<class T>vector<T> vec(size_t a) { return vector<T>(a); }

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

ll maxVec(vector<ll> &v) {
	ll ans = -INF;
	rep(i,0, v.size()) {
		ans = max(ans, v[i]);
	}
	return ans;
}

ll moddiv(ll n, ll a,ll m) {
	if (a == 0)return 1;
	if (a % 2 == 0) {
		ll b = moddiv(n, a / 2, m);
		return (b * b) % m;
	}
	else if (a % 2 == 1) return (n * moddiv(n, a - 1, m)) % m;
}

// グラフは<頂点,コスト>
void Dijkstra(ll v, vector<vector<pll>> graph,ll s, vl& ans) {
	auto comp = [](const pll a, const pll b) { return a.first > b.first; };
	priority_queue<pll, vector<pll>, decltype(comp)> que(comp);
	ans = vl(v, INF);
	ans[s] = 0;
	que.push(pll{ 0, s });
	pll a;
	while (!que.empty()) {
		ll c = que.top().first, p = que.top().second;
		que.pop();
		rep(i,0, graph[p].size()) {
			a = graph[p][i];
			if (ans[a.first] > a.second + c) {
				ans[a.first] = a.second + c;
				que.push(pll{ a.second + c,a.first });
			}
		}
	}
}

// 素数判定
bool judge(ll n) {
	for (ll i = 2; i * i <= n; i++) if (n %= i)return false;
	return true;
}

// 素因数分解
void factorization(ll n, vector<pll> &ans) {
	for (ll i = 2; i * i <= n; i++) {
		if (n % i == 0)ans.push_back(make_pair(i, 0));
		while (n % i == 0) {
			ans.back().second++;
			n /= i;
		}
	}
	if (n != 1) ans.push_back(make_pair(n, 1));
}


template <class C>
void print(const C& c, std::ostream& os = std::cout)
{
	std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, ", "));
	os << std::endl;
}

ll count(ll n,ll r) {
	ll ans = 0,check = 1;
	rep(i,0, r) {
		if ((n & check) > 0) {
			ans++;
		}
		check = check << 1;
	}
	return ans;
}


int main() {
	ll n,k;
	cin >> n >> k;
	auto a = vt(ll(0), n);
	rep(i, 0, n) {
		cin >> a[i];
	}
	auto dp = vt(ll(0), k + 1);
	
	for (ll i = k; i >= 0; i--) {
		rep(j, 0, n) {
			if (i - a[j] >= 0 && dp[i] == 0)dp[i - a[j]] = 1;
			//if (i - a[j] >= 0 && i == 1)dp[i - a[j]] = 1;
		}
	}
	//print(dp);
	if (dp[0] == 1) {
		cout << "First\n";
	}
	else {
		cout << "Second\n";
	}
}

Measured memory_bytes: 1024
n,m,x=map(int,input().split())
a=list(map(int,input().split()))
a.append(x)
a.sort()
#print(a)
#print(a.index(x))
#print(a[a.index(x)])

#print(a[:a.index(x)])
#print(a[a.index(x)+1:])

print(min(len(a[:a.index(x)]),len(a[a.index(x)+1:])))



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

namespace AtCoder.Abc
{
    class QuestionC
    {
        public static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            var aArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

            int[] results = new int[n];
            for(int i = 0; i < n; i++)
            {
                int a = aArray[i];
                results[a - 1] = i + 1;
            }

            Console.WriteLine(string.Join(" ", results));
        }
    }
}


Measured memory_bytes: 28764
#include<iostream>
using namespace std;
int main()
{
  int n;
  cin>>n;
  string str;
  cin>>str;
  int m=0;
  int x=0;
  for(int i=0;i<n;i++)
  {
   if(str[i]=='I')
      {
          x++;
          m=max(m,x);
      }   
      else if(str[i]=='D'){
          x--;
          m=max(m,x);
       //   cout<<m<<endl;
      }
  }
  cout<<m;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s;cin >> s; int n = s.size();
    for (int i = 0; i + 1 < n; i++) {
        if (s[i] == s[i + 1]) {
            cout << i + 1 << ' ' << i + 2 << '\n';
            return 0;
        }
    }
    for (int i = 0; i + 2 < n; i++) {
        if (s[i] == s[i + 2]) {
            cout << i + 1 << ' ' << i + 3 << '\n';
            return 0;
        }
    }cout << -1 << ' ' << -1 << '\n';
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
#define double long double
using namespace std;

ll n, k, p;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> k;
    p = abs(n - k);
    p %= k;
    cout << min(p, k - p);
    return 0;
}


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

#define MAX_N 10002

bool table[MAX_N];

void init() {
    memset(table, 1, sizeof(table));
    table[0] = table[1] = 0;
    for (int i = 2; i < MAX_N; i++) {
        if (table[i]) {
            for (int j = i + i; j < MAX_N; j += i) {
                table[j] = false;
            }
        }
    }
}

int count_pair(int n) {
    int count = 0;
    for (int i = 1; i <= n; i++) {
        if (table[i] && table[n-i+1]) {
            count++;
        }
    }
    return count;
}

int main() {
    init();
    int n;
    while (cin >> n) {
        cout << count_pair(n) << endl;
    }
    return 0;
}

Measured memory_bytes: 0
/*COMPETITIVE PROGRAMMING C++ TEMPLATE */

#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <iostream>
#include <stack>
#include <queue>
#include <climits>
#include <iomanip>
#include <iterator>

#define all(x) x.begin(), x.end()
#define MOD 998244353
const unsigned int M = 1000000007;
const long double PI = 3.141592653589793236L;

typedef long long int ll;
typedef long double ld;

using namespace std;

void solve(){
   char c;
   cin>>c;
   if(c>=65&&c<=90){
       cout<<"A";
   }
   else{
       cout<<"a";
   }
}


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

    int T = 1;
    solve();

    return 0;
}

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

int main(){
    int N;
    cin >> N;
    
    string S;
    cin >> S;
    int sum = 0;
    for(int i = 0; i < N; i++) {
        if(S.substr(i, 3) == "ABC") { sum++; }
    }

    cout << sum;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }

bool isPrime(int n){
    for(int i=2; i*i<=n; i++){
        if(n%i == 0) return false;
    }
    return true;
}

int main(void){
    int N; cin >> N;
    int cnt = 0;
    for(int i=6; i<=55555; i+=5){
        if(isPrime(i)){
            if(cnt) cout << " ";
            cout << i;
            cnt++;
            if(cnt == N){
                cout << endl;
                return 0;
            }
        }
    }

    
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include "queue"
#include <deque>
#include <stack>
#include <numeric>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <complex>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include "fstream"
//#include <unordered_map>
using namespace std;
#define PI acos(-1)
#define MOD 1000000007
#define pii pair<long long ,long long >
#define ll  long long int
#define loop(i,n) for(ll i=0;i<n;i++)
#define loop2(i,n) for(ll i = 1;i<=n;i+=1)
#define pb push_back
#define EPS 1e-7
inline ll gcd(ll a, ll b){ ll t; while (b){ a = a%b; t = a; a = b; b = t; }return a; }
using namespace std;
//Jai Shree Krishna
///////////////////////////////////////StillHungry////////////////////////////////

/*
 Success is a journey not a destination a year from
 now you may wish you had started today.
 Every beginner is a winner. Success is not escaping problems but facing them creatively.
 There is no success without sacrifice.
 Great success always calls for great sacrifice.
 Even failure can become an important ingredient to success.
 Failure just means that you have not yet succeeded.
 */




int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll a,b;
    cin>>a;
    string s;
    cin>>s;
    cin>>b;
    if(s=="+")
    {
        cout<<a+b;
    }
    else{
        cout<<a-b;
    }
    
    
    
    return 0;
}


Measured memory_bytes: 256
N,A,B = map(int,input().split())
ans = 0
for i in range(1,N+1):
    psum = int(i/10000) + int(i/1000)%10 + int(i/100)%10 + int(i/10)%10 + i%10
    if psum >= A and psum <= B:
        ans = ans + i
print(ans)

Measured memory_bytes: 3060
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
# Aの先頭の桁と末尾の桁の組み合わせは9*10=90通りだけ
table = [[0] * 10 for i in range(10)]
for x in range(1, N+1):
    x = str(x)
    i = int(x[0])
    j = int(x[-1])
    table[i][j] += 1

table = np.array(table)
answer = (table * table.T).sum()
print(answer)


Measured memory_bytes: 12500
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <iterator>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <limits>
#include <iomanip>

#define rep(i, n) for(int i = 0, end = (int)(n); i < end; i++)

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

inline int ctoi(char c) {
    return (int)(c -'0');
}

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

int main() {
    int n;
    cin >> n;
    string ss, tt;
    cin >> ss >> tt;
    rep(i, n) {
        cout << ss[i] << tt[i];
    }
    cout << endl;
    return 0;
}


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

using namespace std;

void A() {
  char f, s, t;
  scanf("%c%c%c", &f, &s, &t);
  if (f == 'R' && s == 'R' && t == 'R') {
    printf("3");
  } else if (f == 'R' && s == 'R' || s == 'R' && t == 'R') {
    printf("2");
  } else if (f == 'R' || s == 'R' || t == 'R') {
    printf("1");
  } else {
    printf("0");
  }
  printf("\n");
}

int main() {
  A();
  return 0;
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  int N;
  cin >> N;
  ll ans = 0LL;
  for (int i=1; i<=N; i++) {
    if (i%3!=0&&i%5!=0) ans += i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int lli;
const lli mod = 1e9 +7;

int main(){
    string s,t;
    cin >> s >> t;
    int n = s.length();
    vector<char> a(256, -1);
    bool ok = true;
    for(int i=0; i<n; i++){
        if(a[s[i]] == -1){
            a[s[i]] = t[i];
        }
        if(a[s[i]] != t[i]){
            ok = false;
            break;
        }
    }
    vector<bool> used(256, false);
    for(int i=0; i<256; i++){
        if(a[i] != -1){
            if(used[a[i]]){
                ok = false;
                break;
            }
            used[a[i]] = true;
        }
    }
    if(ok){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 776
N = int(input())
S = input()

l = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ans = []

for s in S:
    x = l.index(s) + N
    if x > 25:
        ans.append(l[x - 26])
    else:
        ans.append(l[x])

print(''.join(ans))


Measured memory_bytes: 3060
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

printList [a] = print a
printList (a:as) = putStr ( show a ) >> putChar ' ' >> printList as

main = readInt >>= putStrLn . concat . flip replicate "ACL"

Measured memory_bytes: 3780
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <iterator>
#include <cmath>
#include <deque>
#include <stack>
#include <functional>
#include <queue>

#define int long long

signed main()
{
    {
        if (fopen("input.txt", "r")) {
            freopen("input.txt", "r", stdin);
            freopen("output.txt", "w", stdout);
        }
        std::ios_base::sync_with_stdio(false);
        std::cin.tie(NULL);
        std::cout.tie(NULL);
    }
    
    int a;
    std::string s;
    std::cin >> a >> s;
    int b = (s[0] - '0') * 100LL + (s[2] - '0') * 10LL + s[3] - '0';
    int p = a * b / 100;
    std::cout << p;
    return 0;
}

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

int main(){
  int N,M,X,inf=1001001001;
  cin >> N >> M >> X;
  vector<int> C(N);
  vector<vector<int>> A(N,vector<int>(M));
  for(int i=0;i<N;i++){
    cin >> C[i];
    for(int j=0;j<M;j++){
      cin >> A[i][j];
    }
  }
  
  int ans=inf;
  for(int tmp=0;tmp<(1<<N);tmp++){
    bitset<12> B(tmp);
    vector<int> V(M,0);
    int money = 0;
    
    for(int i=0;i<N;i++){
      if(B.test(i)){
        money += C[i];
        for(int j=0;j<M;j++) V[j] += A[i][j];
      }
    }
    
    bool ok = true;
    for(int i=0;i<M;i++){
      if(V[i]<X) ok = false;
    }
    
    if(ok) ans = min(ans,money);
  }
  
  if(ans==inf) cout << -1 << endl;
  else cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <deque>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
#include <functional>
#include <climits>
#include <bitset>
#include <random>
#include <tuple>
#include <initializer_list>
#include <fstream>


int main() {
	std::cin.tie(nullptr); std::cin.sync_with_stdio(false);
	int n; std::cin >> n;
	std::vector<int> balls(n); for (auto& b : balls) std::cin >> b;
	std::vector<long long int> count(n, 0);
	for (const auto b : balls) count[b - 1]++;
	long long int sum{ 0 };
	for (const auto c : count) sum += c * (c - 1) / 2;
	for (const auto b : balls) {
		const auto c = count[b - 1];
		std::cout << sum - (c * (c - 1) / 2) + ((c - 1) * (c - 2) / 2) << std::endl;
	}
}

Measured memory_bytes: 4992
s = input()
n = int(input())
b = ''
a = ''
h = 0
for i in range(n):
    qq = list(input().split())
    if qq[0] == '1':
        h += 1
    else:
        if qq[1] == '1':
            if h % 2 ==1:
                a = a + qq[2]
            else:
                b = qq[2] + b
        else:
            if h % 2 ==1:
                b = qq[2] + b
            else:
                a = a + qq[2]

s = b + s + a
if h % 2 ==1:
    s = s[::-1]
print(s)

Measured memory_bytes: 4372
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define repeat(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll int N, M;
    cin >> N >> M;
    LP R[N];
    rep(i, N){
        cin >> R[i].first >> R[i].second;

    }
    sort(R, R + N);
    int i = 0;
    ll int t = 0;
    while (M >0){
        if(M>R[i].second){
            t += R[i].first * R[i].second;
            M -= R[i].second;
        }
        else{
            t += M * R[i].first;
            M =0;
        }
        i ++;
    }
    cout << t << endl;

}

Measured memory_bytes: 1792
def main():
    
    n = int(input())
    p_list = list(map(int, input().split()))
    
    ans = 1
    tmp = p_list[0]
    for i in range(n-1):
        if tmp >= p_list[i+1]:
            ans += 1
            tmp = p_list[i+1]
    
    print(ans)


if __name__ == '__main__':
    main()



Measured memory_bytes: 24744
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define rep(i, n) for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, b, e) for (i64 i = (b), i##_limit = (e); i <= i##_limit; ++i)
#define repr(i, b, e) for (i64 i = (b), i##_limit = (e); i >= i##_limit; --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T> using MaxHeap = priority_queue<T>;
template <class T> using MinHeap = priority_queue<T, vector<T>, greater<>>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
inline i64 sigma(i64 n) { return n * (1 + n) >> 1; }
inline i64 updiv(i64 n, i64 d) { return (n + d - 1) / d; }
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

#ifndef DEBUG
#define dump(...)
#endif

inline void input() {}
template <class Head, class... Tail>
inline void input(Head&& head, Tail&&... tail) {
    cin >> head;
    input(forward<Tail>(tail)...);
}

inline void outs() { cout << "\n"; }
template <class Head, class... Tail>
inline void outs(Head&& head, Tail&&... tail) {
    cout << head << (sizeof...(tail) ? " " : "");
    outs(forward<Tail>(tail)...);
}

template <class T>
inline void outs(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e == &vec.back()]; }

template <class T>
inline void outs(vector<vector<T>> &df) { for (auto &vec : df) outs(vec); }

inline void outl() { cout << "\n"; }
template <class Head, class... Tail>
inline void outl(Head&& head, Tail&&... tail) {
    cout << head << (sizeof...(tail) ? "\n" : "");
    outl(forward<Tail>(tail)...);
}

template <class T>
inline void outl(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

inline void outn() {}
template <class Head, class... Tail>
inline void outn(Head&& head, Tail&&... tail) {
    cout << head;
    outn(forward<Tail>(tail)...);
}

template <class T>
inline void outn(vector<T> &vec) { for (auto &e : vec) cout << e; }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}
// }}} End

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    intmax_t N; cin >> N;

    if (N % 2 == 0) {
        intmax_t res = 0;
        intmax_t n = 5;
        while (n <= N) {
            res += N / n / 2;
            n *= 5;
        }
        outl(res);
    } else {
        outl(0);
    }

    return 0;
}


Measured memory_bytes: 256
#include <math.h>
#define PI 3.1415926535
main(){
    int a,b,C;
    double S,L,h;
    scanf("%d%d%d",&a,&b,&C);
    S=a*b*sin((double)C/180*PI)/2;
    L=a+b+sqrt(a*a+b*b-2*a*b*cos((double)C/180*PI));
    h=S*2/a;
    printf("%f\n%f\n%f\n",S,L,h);

}

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

int main(void){
  string o, e;
  cin >> o >> e;

  for(int i = 0; i < e.size(); i ++){
    cout << o.at(i) << e.at(i);
  }

  if(o.size() != e.size()) cout << o.at(o.size() - 1);

  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

#define INF 200000

int p[101];
int m[101][101];

void printMatrixChain(int a){
  printf("%d\n", a);
}

void matrixChainOrder(int n){
  int i, j, k, l, q;

  for(i = 1; i <= n; i++) m[i][i] = 0;

  for(l = 2; l <= n; l++){
    for(i = 1; i <= n - l + 1; i++){
      j = i + l - 1;
      m[i][j] = INF;
      for(k = i; k <= j - 1; k++){
	q = m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j];
	if(m[i][j] > q) m[i][j] = q;
      }
    }
  }

  printMatrixChain(m[1][n]);
}

int main(){
  int n, i, x;

  scanf("%d", &n);

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

  matrixChainOrder(n);

  return 0;
}

Measured memory_bytes: 636
### subroutines

def ndkey(r, is, n)
  (r << n) | is
end

def rinnd(nd, n)
  nd >> n
end

def isinnd(nd, n)
  nd & ((1 << n) - 1)
end

def neighbors(nd, n)
  r = rinnd(nd, n)
  is = isinnd(nd, n)

  nbrs = []

  for r0 in (0...n)
    if $edges[r][r0] && (is & (1 << r0)) != 0
      nbrs << ndkey(r0, is, n)
    end
  end

  for r0 in $sws[r]
    if r0 != r
      nbrs << ndkey(r, is ^ (1 << r0), n)
    end
  end

  nbrs
end

def step_str(n, nd0, nd1)
  r0 = rinnd(nd0, n)
  r1 = rinnd(nd1, n)

  if r0 != r1
    return "Move to room #{r1 + 1}."
  end

  is0 = isinnd(nd0, n)
  is1 = isinnd(nd1, n)
  b = 1

  for r in (0...n)
    sr0 = is0 & b
    sr1 = is1 & b

    if sr0 != sr1
      if sr0 != 0
        return "Switch off room #{r + 1}."
      else
        return "Switch on room #{r + 1}."
      end
    end

    b <<= 1
  end

  ""
end

### main

while true
  n, m = gets.strip.split(' ').map{|s| s.to_i}
  break if n == 0 && m == 0

  $edges = Array.new(n){Array.new(n){false}}

  m.times.each do
    s, t = gets.strip.split(' ').map{|s| s.to_i}
    s -= 1
    t -= 1
    $edges[s][t] = $edges[t][s] = true
  end

  is = gets.strip.delete(' ').reverse.to_i(2)
  #printf("%0*b\n", n, is)

  $sws = []

  n.times.each do
    rs = gets.strip.split(' ')
    rs.shift
    $sws << rs.map{|s| s.to_i - 1}.sort
  end
  #p sws

  sn = ndkey(0, is, n)
  en = ndkey(n - 1, 1 << (n - 1), n)
  #p [sn, en].map{|i| sprintf("%b", i)}

  prev = {}
  prev[sn] = sn
  queue = [sn]

  while ! queue.empty?
    nd = queue.shift

    for nd0 in neighbors(nd, n)
      if prev[nd0].nil?
        prev[nd0] = nd
        if nd0 == en
          queue = []
          break
        end
        queue << nd0
      end
    end
  end

  if prev[en].nil?
    goal = false
    en0 = ndkey(n - 1, 1 << (n - 1), n)
    en1 = ndkey(n - 1, (1 << n) - 1, n)

    for nd in (en0..en1)
      if ! prev[nd].nil?
        goal = true
        break
      end
    end

    if goal
      puts "You can not switch off all lights."
    else
      puts "Help me!"
    end
  else
    steps = [en]
    nd = en

    while prev[nd] != nd
      nd = prev[nd]
      steps.unshift nd
    end

    nsteps = steps.length - 1
    puts "You can go home in #{nsteps} steps."

    for i in (1..nsteps)
      puts step_str(n, steps[i - 1], steps[i])
    end
    #p steps
  end
end

Measured memory_bytes: 9768
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<P,int>
#define vpp vector<PP>
#define fi first
#define se second
#define INF (1<<30)
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
const int MAX_V=100000;
struct edge{int to,cost;};
int V;
vector<edge> G[MAX_V];
int d[MAX_V];
void dijkstra(int s){
    priority_queue<P,vector<P>,greater<P> > que;
    fill(d,d+V,INF);
    d[s]=0;
    que.push(P(0,s));
    while(!que.empty()){
        P p=que.top();que.pop();
        int v=p.se;
        if(d[v]<p.fi)continue;
        for(int i=0;i<G[v].size();i++){
            edge e=G[v][i];
            if(d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                que.push(P(d[e.to],e.to));
            }
        }
    }
}
int main(){
    cin>>V;
    REP(i,V){
        edge t;
        t.to=(i+1)%V;
        t.cost=1;
        G[i].pb(t);
    }
    REP(i,V){
        edge t;
        t.to=(i*10)%V;
        t.cost=0;
        G[i].pb(t);
    }
    dijkstra(1);
    cout<<d[0]+1<<endl;
    return 0;
}

Measured memory_bytes: 6780
#include <iostream>

int main(){
   int A, B, K;
   std::cin >> A >> B >> K;

   for(int i=A; i<=B; ++i){
      if(i-A<K || B-i<K)
	 std::cout << i << ' ';
   }
   std::cout << std::endl;
   return 0;
}	


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define DEBUG(x) cerr << #x << " = " << x << endl
signed main() {
  int a, b; cin >> a >> b;
  if(a <= 0 && b >= 0) {
    cout << "Zero" << endl;
  }
  else if(a < 0 && b < 0) {
    if((b - a) % 2 == 0) {
      cout << "Negative" << endl;
    }
    else {
      cout << "Positive" << endl;
    }
  }
  else if(a > 0 && b > 0) {
    cout << "Positive" << endl;
  }
  else {
    assert(false);
  }
}


Measured memory_bytes: 256
$\="\n";
$,=",";

($x,$y,$a,$b,$c)=glob<>;
@p=glob<>;
@q=glob<>;
@r=sort glob<>;
@apples=(
  (map{
    [0,$_]
  }@p),
  (map{
    [1,$_]
  }@q),
  (map{
    [2,$_]
  }@r)
);
#print@$_ for @apples;
#print'';
@apples=sort{$$b[1]<=>$$a[1]}@apples;
#print@$_ for@apples;
$all_eatable=$x+$y;
for(;0<$all_eatable;$i++){
  $e=$apples[$i][0];
  if($e==0){
    $x&&($x--,$all_eatable--,$d+=$apples[$i][1])
  }
  elsif($e==1){
    $y&&($y--,$all_eatable--,$d+=$apples[$i][1])
  }
  else{
    $d+=$apples[$i][1];$all_eatable--
  }
  #print"x=$x, y=$y, eat=$all_eatable, e=$e, i=$i"
}
print$d

Measured memory_bytes: 114696
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <string>
#include <cmath>

using ll = long long;
using namespace std;
#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1

class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    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);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        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)];
    }
};


int main() {

    int n, m, t1, t2, t3;
    cin >> n >> m;

    vector<vector<int> > v(m);
    vector<int> p(m);

    for (int i = 0; i < m; i++) {
        cin >> t1;
        for (int j = 0; j < t1; j++) {
            cin >> t2;
            v[i].push_back(t2 - 1);
        }
    }

  	/*
  	for(int i=0;i<m;i++) {
    	for(int j=0;j<v[i].size();j++) {
        	cout << v[i][j] << " ";
        }
      	cout << endl;
    }
    */
	
    for (int i = 0; i < m; i++)  cin >> p[i];

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

        int t = i;
		int tmp = 0;
        int sw[n];

        for (int j = 0; j < n; j++) sw[j] = 0;


        for (int j = 0; j < n; j++) {
            sw[j] = t % 2;
            t = t >> 1;
        }

        for (int j = 0; j < m; j++) {
            int light = 0;
            for (int k = 0; k < v[j].size(); k++) {
              
                light += sw[v[j][k]];
            }
            if(p[j] == light%2) tmp += 1;
        }
        
      if(tmp == m) ans += 1;
    }
  	cout << ans << endl;
}

Measured memory_bytes: 3616
#include <stdio.h>

typedef struct Node{

  int parent;
  int left;
  int right;
}Node;

#define NIL -1

#define nil -1

#define Nil -1

#define MAX 10000

Node tree[MAX];

int n, depth[MAX], height[MAX];

int kyoudai(int u){

  if(tree[u].parent==NIL) return NIL;
  if(tree[tree[u].parent].left!=u && tree[tree[u].parent].left!=NIL){

    return tree[tree[u].parent].left;
  }
  if(tree[tree[u].parent].right!=u && tree[tree[u].parent].right!=NIL){

    return tree[tree[u].parent].right;
  }
 
    
  return NIL;
  
}

int takasa(int root){

  int h1=0, h2=0;
  if(tree[root].left!=NIL){
    
    h1=takasa(tree[root].left)+1;
  }
  if(tree[root].right!=NIL){
    
    h2=takasa(tree[root].right)+1;
  }

  if(h1>h2) height[root]=h1;
  else height[root]=h2;

  return height[root];
}

  
int horu(int root, int d){

  if(root==NIL){
    
    return NULL;
  }
  depth[root]=d;
  
  if(root!=NIL){
    
  horu(tree[root].left, d+1);
  horu(tree[root].right, d+1);
  }
  
}


int main(){

  int i, oya, hidari, migi, root=0;

  int degree=0;

  scanf("%d",&n);

  for(i=0;i<n;i++) tree[i].parent=tree[i].left=tree[i].right=-1;

  
  for(i=0;i<n;i++){

    scanf("%d",&oya);
    scanf("%d%d",&hidari,&migi);
    
    tree[oya].left=hidari;
    tree[oya].right=migi;

    if(hidari!=NIL) tree[hidari].parent=oya;
    if(migi!=NIL) tree[migi].parent=oya;
   
  }

  for(i=0;i<n;i++){

    if(tree[i].parent==NIL) root=i;
  }

  horu(root, 0);
  takasa(root);

  for(i=0;i<n;i++){

    degree=0;

    printf("node %d: parent = %d, sibling = %d, ",i, tree[i].parent,kyoudai(i));

    if(tree[i].left!=NIL) degree++;
    if(tree[i].right!=NIL)degree++;

    printf("degree = %d, ", degree);
    printf("depth = %d, ", depth[i]);
    printf("height = %d, ", height[i]);
  

    if(tree[i].parent==NIL) printf("root\n");
    else if(tree[i].left!=NIL||tree[i].right!=NIL) printf("internal node\n");
    else printf("leaf\n");

  }


  return 0;
  
}

  



Measured memory_bytes: 2108
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};

fn main() {
  let r = read::<i32>();

  println!("{}", r * r * 3);
}



Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

vector<pair<int,int>>dp(1 << 19);
vector<int>A;

void chmax(pair<int,int>&a,pair<int,int>b) {
	if (a.first < b.first) {
		a.second = max(a.first,b.second);
		a.first = b.first;
	}
	else a.second = max(a.second,b.first);
}

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

	int N;
	cin >> N;
	A.resize(1 << N);
	for (int i = 0; i < 1 << N; i++)cin >> A[i];
	for (int i = 0; i < 1 << N; i++) {
		dp[i].first = A[i];
		dp[i].second = -1;
	}

	for (int j = 0; j < N; j++) {
		for (int i = 0; i < (1<<N); i++) {
			if (i & (1 << j))chmax(dp[i],dp[i & ~(1 << j)]);
		}
	}

	int ans = 0;
	for (int i = 1; i < (1 << N); i++) {
		ans = max(ans, dp[i].first + dp[i].second);
		puts(ans);
	}

	return 0;
}

Measured memory_bytes: 8192
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

int main(void) {
	int num, i, j, h, w;
	cin >> h >> w;
	vector<string> s(h);
	vector<vector<int>> d(h, vector<int>(w, INF));
	rep(i, h)
		cin >> s[i];
	if (s[0][0] == '#')
		d[0][0] = 1;
	else
		d[0][0] = 0;
	rep(i, h) {
		rep(j, w) {
			if (i + 1 < h) {
				if (s[i][j] == '.' && s[i + 1][j] == '#')
					chmin(d[i + 1][j], d[i][j] + 1);
				else
					chmin(d[i + 1][j], d[i][j]);
			}
			if (j + 1 < w) {
				if (s[i][j] == '.' && s[i][j + 1] == '#')
					chmin(d[i][j + 1], d[i][j] + 1);
				else
					chmin(d[i][j + 1], d[i][j]);
			}
		}
	}
	cout << d[h - 1][w - 1] << "\n";
	return 0;
}

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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  cout<<(abs(a-c)<=d||(abs(a-b)<=d&&abs(b-c)<=d)?"Yes":"No")<<endl;
}

Measured memory_bytes: 256