akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using pint = pair<int, int>;
using tint = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

int conv[26] = {
  '2','2','2',
  '3','3','3',
  '4','4','4',
  '5','5','5',
  '6','6','6',
  '7','7','7','7',
  '8','8','8',
  '9','9','9','9'
};

int n;
vector<string> word;
vector<string> num;
string seq;
vector<string> ans;

string tonum(string s) {
  string res = "";
  rep(i, s.size()) res += conv[s[i]-'a'];
  return res;
}

bool input() {
  cin >> n;
  if(n == 0) return false;

  word.clear();
  word.resize(n);
  num.clear();
  num.resize(n);
  rep(i, n) {
    cin >> word[i];
    num[i] = tonum(word[i]);
  }

  cin >> seq;
}

void solve(int idx, string t) {
  if(idx == seq.size()) {
    ans.push_back(t+".");
    return;
  }
  rep(i, n) {
    if(seq.substr(idx, num[i].size()) != num[i]) continue;
    solve(idx+num[i].size(), (t.empty() ? word[i] : t+" "+word[i]));
  }
}

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  while(input()) {
    ans.clear();
    solve(0, "");
    for(string s : ans) cout << s << endl;
    cout << "--" << endl;
  }

  return 0;
}

Measured memory_bytes: 3152
n,m =(int(i) for i in input().split())
query = [1]*m
for i in range(n):
 a = list(int(i) for i in input().split())
 a = a[1::]
 for j in range(m):
  if not (j+1) in a:
    query[j] = 0
    
print(sum(query))

Measured memory_bytes: 3060
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define vi vector<int>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())

void print(bool a)
{
    if (a == true)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

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

int main()
{
    int n;
    cin >> n;
    string s[100];
    rep(i, 0, n) cin >> s[i];

    bool ok = true;
    rep(i, 0, n)
    {
        rep(j, i + 1, n)
        {
            if (s[i] == s[j])
            {
                ok = false;
                break;
            }
        }
    }
    rep(i, 0, n - 1)
    {
        if (s[i][s[i].size() - 1] != s[i + 1][0])
        {
            ok = false;
        }
    }
    print(ok);
}


Measured memory_bytes: 256
/*input
6 6
#####.
#.#.##
####.#
.#..#.
#.##..
#.#...

*/
#include <bits/stdc++.h>
using namespace std;

int mines[53][52];
char c[53][52];

int dr[] = {-1,-1,0,1,1,1,0,-1};
int dc[] = {0,1,1,1,0,-1,-1,-1};

int main(int argc, char const *argv[])
{
  int n,m;
  scanf("%d%d\n",&n,&m);
  for (int i = 1; i <= n; ++i) {
    scanf("%s",c[i]+1);
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      for (int k = 0; k < 8; ++k) {
        if (c[i][j]=='#') mines[i+dr[k]][j+dc[k]]++;
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      if (c[i][j]=='#') putchar('#');
      else printf("%d", mines[i][j]);
    }
    puts("");
  }
  return 0;
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;
typedef vector<int> vint;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;
  int anssum = 0, anssug = 0;
  for(int i = 0; i <= F; i++) {
    for(int j = 0; j <= i; j++) {
      int sug = j, wat = i-j;
      if(wat%100 != 0) continue;
      if(100*sug > wat*E) continue;
      bool flag = false;
      for(int a = 0; a <= wat/100/A; a++) {
	if((wat/100-A*a)%B == 0) flag = true;
      }
      if(!flag) continue;
      flag = false;
      for(int c = 0; c <= sug/C; c++) {
	if((sug-C*c)%D == 0) flag = true;
      }
      if(!flag) continue;
      if(sug*anssum >= anssug*(sug+wat)) anssum = sug+wat, anssug = sug;
    }
  }
  cout << anssum << " " << anssug << endl;

  return 0;
}


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

int main() {
	int n, m;
	vector<int> v[100000];
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	deque<int> d;
	bool visited[100000] = {};
	for (int i = 0; i < n; i++) {
		if (!v[i].empty()) {
			d.push_back(i);
			visited[i] = true;
			break;
		}
	}
	while (true) {
		bool updated = false;
		int a = d.back();
		for (int i = 0; i < v[a].size(); i++) {
			int b = v[a][i];
			if (!visited[b]) {
				d.push_back(b);
				visited[b] = true;
				updated = true;
				break;
			}
		}
		if (!updated) {
			break;
		}
	}
	while (true) {
		bool updated = false;
		int a = d.front();
		for (int i = 0; i < v[a].size(); i++) {
			int b = v[a][i];
			if (!visited[b]) {
				d.push_front(b);
				visited[b] = true;
				updated = true;
				break;
			}
		}
		if (!updated) {
			break;
		}
	}
	cout << d.size() << endl;
	for (auto i = begin(d); i != end(d); i++) {
		if (i != begin(d)) cout << ' ';
		cout << *i + 1;
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 6784
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    int c[256];
    c['I'] = 1;
    c['V'] = 5;
    c['X'] = 10;
    c['L'] = 50;
    c['C'] = 100;
    c['D'] = 500;
    c['M'] = 1000;

    for(;;){
        string s;
        if(!(cin >> s))
            return 0;

        int n = s.size();
        int ret = 0;
        for(int i=0; i<n; ++i){
            if(i+1 < n && c[s[i]] < c[s[i+1]])
                ret -= c[s[i]];
            else
                ret += c[s[i]];
        }
        cout << ret << endl;
    }
}

Measured memory_bytes: 0
n=int(input())
a=list(map(int,input().split()))
c1=c2=0
for i in range(n):
    if a[i]%2==0:c1+=1
    if a[i]%4==0:c2+=1
c1-=c2
if c2*2>=n-1:print('Yes')
else: print('YNeos'[2*c2+c1<n::2])

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

using ll = long long;
using namespace std;

int main() {
    int n, k;
    string s;
    cin >> n >> k >> s;
    int border_count = 0;
    char cur = s[0];
    for (auto c: s) {
        if (c != cur) {
            border_count++;
            cur = c;
        }
    }
    cout << n - 1 - max(0, border_count - 2 * k) << endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#include <fstream>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LL long long
#define LI long int
#define LLI long long int
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POS(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//

int main(){
    int n; cin>>n;
    string s[301][301];
    string now;
    FOR(i,0,n){
        cin>>now;
        FOR(j,0,n){
            s[i][j]=now[j];
        }
    }
    int ans=0;
    FOR(a,0,n){
        int fl=1;
        FOR(i,0,n){
            FOR(j,0,n){
                if(s[(i-a+n)%n][(j+n)%n]!=s[(j-a+n)%n][(i+n)%n]){
                    fl=0;
                    break;
                }
            }
            if(fl==0) break;
        }
        ans+=fl;
    }
    cout<<ans*n<<endl;
}


Measured memory_bytes: 5120
#include <iostream>
#include <cmath>

using namespace std;

const int N = 1000001;

int main() {

  int primes[N] = {0}; // 素数ならば0, 素数でなければ1
  primes[0] = 1;
  primes[1] = 1;

  for(int i=3; i<N; i++) {
    bool flag = true;
    for(int j=2; j<sqrt(i)+1 && flag==true; j++) {
      if(i%j == 0) { // 割りきれたならば素数でない
	primes[i] = 1;
	flag = false;
      }
    }
  }

  /*
  for(int i=0; i<100; i++) {
    cout<<i<<":"<<primes[i]<<" ";
  }
  */

  int a, d, n;

  while(cin>>a>>d>>n && !(a==0 && d==0 && n==0)) {
    int nTh = 0;
    int ans;
    for(int i=0; nTh<n; i++) {
      //cout<<a+i*d<<":"<<primes[a+i*d]<<endl;
      if(primes[a+i*d] == 0) {
	//cout<<"added"<<endl;
	nTh++;
	ans = i;
      }
    }
    cout<<a+ans*d<<endl;
  }

}

Measured memory_bytes: 5072
#include <bits/stdc++.h>
using namespace std;
const long long mod = (long long)(1e9+7);
int ct[300002][60];
long long a[300002];
int p[61];

int main() 
{
    int n;
    cin >> n;
    
    for(int i=0;i<n;i++) cin >> a[i];
    
    p[0]=1;
    
    for(int i=1;i<60;i++){
        p[i] = p[i-1]*2;
        p[i] %= mod;
    }
    
    for(int i=0;i<n;i++){
        long long x = a[i];
        int k = 0;
        while(x){
            if(x%2==1) ct[i][k]++;
            x/=2;
            k++;
        }
    }
    
    for(int i=0;i<60;i++){
        for(int j=1;j<n;j++){
            ct[j][i]+=ct[j-1][i];
        }
    }
    
    // for(int i=0;i<2;i++){
    //     for(int j=0;j<n;j++){
    //         cout<<ct[j][i]<<" ";
    //     }
    //     cout<<endl;
    // }
    
    long long ans = 0;
    
    for(int i=0;i<n;i++){
        long long x = a[i];
        
        for(int j=0;j<60;j++){
            if( (x>>j) & 1 ){           // ith bit is set
                int zeros = n - 1 -i - (ct[n-1][j] - ct[i][j]);
                ans += (1LL*zeros*p[j]);
                ans %= mod;
            }
            else{
                int ones = ct[n-1][j] - ct[i][j];
                ans += (1LL*ones*p[j]);
                ans %= mod;
            }
            //cout<<"ans is "<<i<<" "<<j<<" "<<ans<<endl;
        }
        //cout<<"ans is "<<i<<" "<<ans<<endl;
    }
    
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 72960
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	inputList, _ := toIntArray(splitInput(scanner, " "))
	x := inputList[0]
	y := inputList[1]

	xVal := 0
	yVal := 0

	if x == 1 {
		xVal = 300000
	} else if x == 2 {
		xVal = 200000
	} else if x == 3 {
		xVal = 100000
	}
	if y == 1 {
		yVal = 300000
	} else if y == 2 {
		yVal = 200000
	} else if y == 3 {
		yVal = 100000
	}
	bonus := 0
	if x == 1 && y == 1 {
		bonus = 400000
	}

	fmt.Println(xVal + yVal + bonus)
}

func splitInput(scanner *bufio.Scanner, sep string) []string {
	scanner.Scan()
	return strings.Split(scanner.Text(), sep)
}

func toIntArray(str []string) ([]int, error) {
	length := len(str)
	resVal := make([]int, length)
	var err error
	for i := 0; i < length; i++ {
		resVal[i], err = strconv.Atoi(str[i])
		if err != nil {
			return nil, err
		}
	}
	return resVal, nil
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

bool V[10];

bool judge(int m, int keta){
    bool ret = true;
    for(int i = 0; i < keta; i++){
        int n = m / pow(10, i);
        n %= 10;
        if(!V[n]) ret = false;
    }
    return ret;
}


int main(){
    int N, K;
    cin >> N >> K;
    fill(V, V+10, true);
    REP(i,K){
        int d;
        cin >> d;
        V[d] = false;
    }

    int keta;
    int n = N;
    while(n > 0){
        keta++;
        n /= 10;
    }

    int m = N;
    while(1){
        if(judge(m, keta)) break;
        if(pow(10, keta)-1 == m) keta++;
        m++;
    }

    cout << m << endl;
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub


import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N):
    ans = 0
    for i in range(1, N+1):
        for j in range(i, N+1, i):
            ans += j
    return ans


def main():
    N = read_int()
    print(slv(N))


if __name__ == '__main__':
    main()


Measured memory_bytes: 78752
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define FOR(a,b,c) for(a = b;a<c;a++)
#define IFOR(a,b,c) for(a = b;a>c;a--)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a)  ((a)<(0)?-(a):(a))
#define INF 1000000000



int a,b,c,d;

int main(){
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	
	if(a+b==c+d) printf("Balanced");
	else if(a+b>c+d) printf("Left");
	else printf("Right");
	return 0;
	
}



Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(void){
  int n;
  string A[100010];
  int ac,wa,tle,re = 0;
  
  cin >> n;
  for(int i = 0;i<n;i++){
      cin >> A[i];
  }
  
  for(int i = 0;i<n;i++){
      if(A[i] == "AC"){
          ac++;
      }
      if(A[i] == "WA"){
          wa++;
      }
      if(A[i] == "TLE"){
          tle++;
      }
      if(A[i] == "RE"){
          re++;
      }
  }
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
}


Measured memory_bytes: 6676
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    cout << n*n*n << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.OutputStream;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.math.BigDecimal;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int N = in.nextInt();
            int a[] = new int[N];
            for(int i=0; i<N; i++){
                a[i] = in.nextInt();
            }
            int two = 0;
            int four = 0;
            int x = 0;
            for(int i=0; i<N; i++){
                if(a[i]%4==0){
                    four++;
                }
                else if(a[i]%4==2){
                    two++;
                }
                else{
                    x++;
                }
            }
            if(two==0){
                if(2*x<=(N+1)){
                    out.println("Yes");
                }
                else out.println("No");
            }
            else{
                if(2*x>(N-two)){
                    out.println("No");
                }
                else out.println("Yes");
            }
            
        }
    }


    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

    }
}

Measured memory_bytes: 35836
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 300005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
    	if(c == '-') f = -1;
    	c = getchar();
    }
    while(c >= '0' && c <= '9') {
    	res = res * 10 +c - '0';
    	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
    	out(x / 10);
    }
    putchar('0' + x % 10);
}
int N,T;
int ans;
void Solve() {
    read(N);read(T);
    int t,r;
    r = 0;
    for(int i = 1 ; i <= N ; ++i) {
        read(t);
        ans += t + T - max(t,r);
        r = t + T;
    }
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>

using namespace std;

int main(void)
{
	int n, a, b;

	while(scanf("%d%d%d", &n, &a, &b)==3)
	{
		printf("%d %d\n", min(a, b), max(a+b-n, 0));
	}

	return 0;
}


Measured memory_bytes: 128
process.stdin.resume();
process.stdin.setEncoding('utf8');

class Dice {
    constructor(top, front, right, left, back, bottom) {
        this.top = top;
        this.front = front;
        this.right = right;
        this.left = left;
        this.back = back;
        this.bottom = bottom;
    }
    rollVertical() {
        return new Dice(this.front, this.bottom, this.right, this.left, this.top, this.back);
    }
    rollHorizontal() {
        return new Dice(this.top, this.right, this.back, this.front, this.left, this.bottom);
    }
    existVertial(number) {
        return [this.top, this.front, this.bottom, this.back].includes(number);
    }
    existHorizontal(number) {
        return [this.front, this.left, this.back, this.right].includes(number);
    }
    /**
     * 別のDice１つを引数に取り、同じであればtrue, 違えばfalseを返す
     * @param {Dice}} otherDice 
     */
    isSameDice(otherDice) {
        return JSON.stringify(this) === JSON.stringify(otherDice);
    }

    /**
     * 他のダイス１つ引数に取り、回転しているだけで同じダイスであればtrue,別のダイスであればfalseを返す
     * @param {Dice} otherDice 
     */
    detectSameDice(otherDice) {

        // 
        const verticalDiceList = otherDice.vertialRollDiceList();
        const verticalHorizontaldiceList = verticalDiceList.map(x => x.horizontalRollDiceList());
        const rolledDice = otherDice.rollHorizontal();

        const verticalDiceList2 = rolledDice.vertialRollDiceList();
        const verticalHorizontaldiceList2 = verticalDiceList2.map(x => x.horizontalRollDiceList());

        const diceListFlat = Array.prototype.concat.apply([],verticalHorizontaldiceList.concat(verticalHorizontaldiceList2));

        return diceListFlat.find(x => x.isSameDice(this)) ? true : false;
    }

    /**
     * 自分を横に四回回して得られる全てのサイコロを配列で返す
     */
    horizontalRollDiceList() {
        const diceList = [];
        let diceState = this;
        [...Array(4).keys()].forEach(x => {
            diceList.push(diceState);
            diceState = diceState.rollHorizontal();
        });
        return diceList;
    }
    /**
     * 自分を縦に四回回して得られる全てのサイコロを返す
     */
    vertialRollDiceList() {
        const diceList = [];
        let diceState = this;
        [...Array(4).keys()].forEach(x => {
            diceList.push(diceState);
            diceState = diceState.rollVertical();
        });
        return diceList;
    }

}


process.stdin.on('data', function (chunk) {
    const n = chunk.toString() // 文字列化する
        .split("\n") // \nで分割
        .filter(x => x !== "");

    const [one, two] = n;
    const [top, front, right, left, back, bottom] = one.split(" ");
    const [top2, front2, right2, left2, back2, bottom2] = two.split(" ");


    const dice1 = new Dice(top, front, right, left, back, bottom);
    const dice2 = new Dice(top2, front2, right2, left2, back2, bottom2);
    const ans = dice1.detectSameDice(dice2) ? "Yes" : "No";
    console.log(ans); 

});



Measured memory_bytes: 16320
#include<bits/stdc++.h>
using namespace std;
#define all(a) a.begin(),a.end()
int f(string n,long maxn){
  int res=0;
  if(count(all(n),'3')&&count(all(n),'5')&&count(all(n),'7'))res++;
  if(stol(n+"3")<=maxn)res+=f(n+"3",maxn);
  if(stol(n+"5")<=maxn)res+=f(n+"5",maxn);
  if(stol(n+"7")<=maxn)res+=f(n+"7",maxn);
  return res;
}
main(){
  int n;
  cin>>n;
  cout<<f("3",n)+f("5",n)+f("7",n);
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        a: i64,
        b: i64
    }
    println!("{}", max(0, a - 2 * b));
}


Measured memory_bytes: 4352
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

const int N = 1e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

#define int ll

typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

string s;
int k;
main() {
    file("censor");
    ios;
    cin >> s >> k;
    int cnt1 = 1, cnt2 = 1;
    for (int i = 1; i < s.size(); ++i) if (s[i] == s[i - 1]) ++cnt1; else break;
    for (int i = s.size() - 2; i >= 0; --i) if (s[i] == s[i + 1]) ++cnt2; else break;
    if (cnt1 == s.size()) return !(cout << cnt1 * k / 2);
    int cnt = 1, ans = 0;
    for (int i = 1; i < s.size(); ++i) {
        if (s[i] == s[i - 1]) ++cnt;
        else {
            ans += cnt / 2;
            cnt = 1;
        }
    }
    ans += cnt / 2;
    if (s[0] != s.back()) return !(cout << k * ans);
    cout << k * ans - (k - 1) * (cnt1 / 2 + cnt2 / 2 - (cnt1 + cnt2) / 2);
    return 0;
}
/**

*/


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
    int A, B, C;
    cin >> A >> B >> C;
    int count = 0;

    while(B-A >= 0){
        if(count == C)
            break;
        count++;
        B -= A;
    }

    cout << count << endl;
    return 0;
}

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

// 比較演算子を自動生成
#define CAT(a, b) a ## b
#define COMP_1(v1) return lhs.v1 < rhs.v1
#define COMP_2(v1, ...) if (lhs.v1 != rhs.v1) COMP_1(v1); COMP_1(__VA_ARGS__)
#define COMP_3(v1, ...) if (lhs.v1 != rhs.v1) COMP_1(v1); COMP_2(__VA_ARGS__)
#define COMP_4(v1, ...) if (lhs.v1 != rhs.v1) COMP_1(v1); COMP_3(__VA_ARGS__)
#define COMP_5(v1, ...) if (lhs.v1 != rhs.v1) COMP_1(v1); COMP_4(__VA_ARGS__)
#define LESS_THAN(n, ...) bool operator<(const A & rhs) const { auto& lhs = *this; CAT(COMP_, n)(__VA_ARGS__); }

#define MAXC(c, x) (c = max(c, x))
#define MINC(c, x) (c = min(c, x))

#define FOR(i, s, n) for(ll i = (s); i < (ll)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(c) (c).begin(), (c).end()

// 10^x (by math)
#define TEN(x) ((ll)1e##x)

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

void solution(istream& cin, ostream& cout) {
	ll a, b, h, m;
	cin >> a >> b >> h >> m;
	auto diff = abs((h * 60 + m * 1) - m * 12) / 2.0;
	auto deg = min(diff, 360 - diff) / 180.0 * M_PI;
	auto ans = sqrt(a * a + b * b - 2 * a * b * std::cos(deg));
	cout << ans << endl;
}

int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);

	solution(cin, cout);
}


Measured memory_bytes: 4144
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
#define ALL(x) (x).begin(), (x).end()
LL POW(LL a,LL p,LL M){ if(!p) return 1LL;LL T = POW(a,p/2,M);T = T*T%M; if(p&1) T=T*(a%M)%M; return T; }
LL SQRT(LL a) { LL b = (LL)sqrtl(((double)a)+0.5); while(b*b<a) ++b; while(b*b>a) --b; return (b*b==a)?b:-1; }
//endl
//<------------------------edits---------------------------------------------->
const LL MOD = 1e9+7;//998244353
// #define LOCAL LDD
// #define int LL

int r,c;
const int N = 102;
string grid[N];
int dp[N][N];

int solve(int i,int j){
  if(i==r-1 && j==c-1){
    if(grid[i][j]=='#') return 1;
    else return 0;
  }
  if(dp[i][j]!=-1) return dp[i][j];
  dp[i][j] = INT_MAX;
  if(i+1<r){
    dp[i][j] = solve(i+1,j);
    if(grid[i][j]=='#' && grid[i+1][j]=='.') 
      dp[i][j]++;
  }
  if(j+1<c){
    dp[i][j] = min(dp[i][j],solve(i,j+1)+(grid[i][j]=='#' && grid[i][j+1]=='.'));
  }
  return dp[i][j];
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);cout << fixed;
#ifdef LOCAL
  freopen("input.txt", "rt", stdin);
#endif
  memset(dp,-1,sizeof(dp));
  cin >> r >> c;
  for(int i=0;i<r;i++) cin >> grid[i];
  cout << solve(0,0) << endl;
  // cout << dp[0][1] << endl;
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s\n";
  return 0;
}

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

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

ll lcm(ll a, ll b){
  return a/gcd(a,b) * b;
}
ll func2(ll n){
  ll res = 0;
  while(n%2 == 0){
    n /= 2;
    res++;
  }
  return res;
}

ll zyou(ll a,ll b){//a＾b
  ll res = 1;
  for(int i = 1;i<=b;i++){
    res *= a;
  }
  return res;
}
using Graph = vector<vector<char>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}

typedef pair<int,int> P;

bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}
int factorial(int a){
  int res = 1;
  while(a){
    res *= a;
    a--;
  }
  return res;
}


int main(){
  int N,K;
  cin >> N >> K;
  string S;
  cin >> S;
  S.push_back('#');
  vector<int> v;
  if(S[0] == '0') v.push_back(0);

  int c = 1;
  rep(i,N){
    if(S[i] == S[i+1]){
      c++;
    }
    else{
      v.push_back(c);
      c =1;
    }
  }
  if(S[N-1] == '0') v.push_back(0);
  /*rep(i,v.size()){
    cout <<v[i];
  }
  cout << endl;*/

  vector<int> sum(N+10);//累積和
  sum[0] = v[0];
  for(int i = 1;i<v.size();i++){
    sum[i] = sum[i-1] + v[i];
   }
   /*rep(i,v.size()){
     cout << sum[i];
   }
   cout << endl;*/
   int ans = 0;
   for(int i = 0;i<=v.size()-1;i += 2){
     int res = 0;
     if(i+2*K >= v.size()){
       res = sum[v.size()-1] - sum[i] + v[i];
     }
     else res = sum[i+2*K] - sum[i] + v[i];
     ans = max(ans,res);
   }
   cout << ans << endl;

}

Measured memory_bytes: 1272
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

const ll max_n=670000;
vi fac(max_n),finv(max_n),inv(max_n);
// テーブルを作る前処理 O(max_n)
void init(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  REP(i,2,max_n){
    fac[i]=fac[i-1]*i%mod;
    inv[i]=mod-inv[mod%i]*(mod/i)%mod;
    finv[i]=finv[i-1]*inv[i]%mod;
  }
}
// 二項係数計算 O(1)
ll COM(int n,int k){
  if(n<k) return 0;
  if(n<0||k<0) return 0;
  return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}
//init(); を忘れない！
void solve() {
  init();
  ll x,y;
  cin>>x>>y;
  if((x+y)%3){
    out(0); return;
  }
  ll p=(x+y)/3;
  x-=p; y-=p;
  if(x<0||y<0){
    out(0); return;
  }
  if(x>y) swap(x,y);
  out(COM(x+y,x));
  //cout<<x<<" "<<y<<'\n';
}

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


Measured memory_bytes: 16000
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 1<<30
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef long long int LL;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n;cin>>n;
    int ans=0;
    while(n){
        ans+=n%10;
        n/=10;
    }
    if(ans==1)ans=10;
    cout<<ans<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)

typedef long long ll;

int main(){
	int w;
	
	while (scanf("%d", &w), w != -1){
		int ans = 1150;
		
		if (w > 10 && w <= 20){
			ans += (w-10) * 125;
		}
		else if (w > 20 && w <= 30){
			ans += (w-20) * 140 + 1250;
		}
		else if (w > 30) {
			ans += (w-30) * 160 + 1250 + 1400;
		}
		
		cout << 4280 - ans << endl;
	}	
	return 0;
}

Measured memory_bytes: 3120
#![allow(non_snake_case)]
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let N:usize = sc.read();
    if N%2 == 1{
        println!("0");
        return
    }
    let mut ans:usize = N/10;
//    let ten:usize = 10;
    let five:usize = 5;
//    let five_hun:usize = 500;
//    let mut fives:Vec<usize> = vec![];
    for i in 1..27{
        ans += N/(five.pow(i) * 10);
    }
    println!("{}", ans);
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
        .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}




Measured memory_bytes: 4352
#include<stdio.h>
int main(void){
  int counter=0,a;
  double b,c,d;
  scanf("%d",&a);
  scanf("%lf",&b);
  for(int i=0;i<a;i++){
    scanf("%lf%lf",&c,&d);
  	if(c*c+d*d<=b*b)counter++;
  }
  printf("%d",counter);
}

Measured memory_bytes: 1748
#include <bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
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;
}
const long long INF = 1LL << 60;
using pll = pair<long long, long long>;

int main() {
  // 標準入力が早くなる。Cスタイルの入出力とC++スタイルの入出力を混合させてはならない。
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int N, M;
  cin >> N >> M;

  cout << (N + M) * (N + M - 1) / 2 - M * N << endl;
  return 0;
}


Measured memory_bytes: 256
A1=list(map(int,input().split()))
A2=list(map(int,input().split()))
A3=list(map(int,input().split()))
N=int(input())
for i in range(N):
    b=int(input())
    if b in A1:
        x=A1.index(b)
        A1[x]=0
    elif b in A2:
        x=A2.index(b)
        A2[x]=0
    elif b in A3:
        x=A3.index(b)
        A3[x]=0
D=[sum(A1),sum(A2),sum(A3)]
D.append(A1[0]+A2[0]+A3[0])
D.append(A1[1]+A2[1]+A3[1])
D.append(A1[2]+A2[2]+A3[2])
D.append(A1[0]+A2[1]+A3[2])
D.append(A1[2]+A2[1]+A3[0])
if 0 in D:
    print("Yes")
else:print("No")


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

using namespace std;
using ll=long long;

const int N = 15;

int x[N], y[N], z[N];
ll a[N][1<<N];
ll b[N][1<<N];

void solve() {
    int n; cin >> n;
    const int MSK = 1<<n; 
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i] >> z[i];
    }
    auto prep = [&](auto& x, auto& a){
        for (int msk = 0; msk < MSK; msk++) {
            for (int i = 0; i < n; i++) {
                if (msk>>i&1) a[i][msk] = 0;
                else {
                    int res = abs(x[i]);
                    for (int j = 0; j < n; j++) {
                        if (msk>>j&1) res = min(res, abs(x[i] - x[j]));
                    }
                    a[i][msk] = res *1ll* z[i]; // ll
                }
            }
        }
    };
    prep(x,a); prep(y,b);
    vector<ll> res(n + 1, 1ll<<60);
    for (int tot = 0; tot < MSK; tot++) {
        int cnt = __builtin_popcount(tot);
        for (int u = tot; u >= 0; (u-=1)&=tot) {
            int v = tot^u;
            ll sum = 0;
            for (int i = 0; i < n; i++) {
                if (tot>>i&1) continue;
                sum += min(a[i][u], b[i][v]);
            }
            res[cnt] = min(res[cnt], sum);
            if (u==0) break;
        }
    }
    for (auto& x: res) {
        cout << x << '\n';
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


Measured memory_bytes: 11252
# http://at274.hatenablog.com/entry/2018/02/02/173000#%E5%AE%8C%E6%88%90%E5%BD%A2 より引用


class UnionFind:
    def __init__(self, n):
        # 0indexは使用しない. 親要素のノード番号を格納．par[x]==xの時，xは根
        self.par = [i for i in range(n+1)]
        # 木の高さを表す
        self.rank = [0] * (n+1)
        # それぞれの要素数を持つ
        self.size = [0] + [1] * n

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)


N,M,*t=map(int,open(0).read().split())
# 壊していく橋の始点
A = [0] + t[0::2]

# 壊していく橋の終点
B = [0] + t[1::2]

# 出力用の解答を格納する変数
out_ans = [0] * (M + 1)

# 1 ~ Mについて到達不可能な2点の組み合わせの数(不便さ)を計算する
# 解答より，M, M-1,...,1の順で計算する
UF = UnionFind(N)

# 全ての辺を削除した時の答えを格納
sum=N*(N-1)//2

# 出力用のリスト
out_ans[M] = sum

for i in range(M, 0, -1):
    # out_ans[i] = (ans(i, UF))
    if not UF.same_check(A[i], B[i]):
        root_a = UF.find(A[i])
        root_b = UF.find(B[i])
        UF.union(A[i], B[i])
        sum -= UF.size[root_a] * UF.size[root_b]
        tmp = UF.size[root_a] + UF.size[root_b]
        UF.size[root_a] = tmp
        UF.size[root_b] = tmp
    out_ans[i-1] = sum

[print(tmp) for tmp in out_ans[1:]]

Measured memory_bytes: 25416
#include <stdio.h>
#include <string.h>

int main(void)
{
	char str[128];
	char stack[128];
	char t[512];
	int stack_n;
	int i;
	int ok;

	t['['] = ']';
	t['('] = ')';

	while (1){
		fgets(str, sizeof(str), stdin);
		if (str[0] == '.') break;

		memset(stack, 0, sizeof(stack));
		stack_n = 0;
		ok = 1;

		for (i = 0; str[i] != '\0'; i++){
			if (str[i] == '(' || str[i] == '['){
				stack_n++;
				stack[stack_n] = str[i];
			}
			else if (str[i] == ')' || str[i] == ']'){
				if (t[stack[stack_n]] != str[i]){
					ok = 0;
				}
				stack_n--;
			}
			if (stack_n < 0){
				break;
			}
		}

		puts(ok && stack_n == 0 ? "yes" : "no");
	}

	return (0);
}

Measured memory_bytes: 524
#include<cstdio>
using namespace std;

int dp[330];
int s,d,m;
int k[110],w[110][55],p[110][55],f;

int main(){
  while(scanf("%d%d%d",&s,&d,&m)!=EOF){
    for(int i=0;i<s;i++){
      scanf("%d",&k[i]);
      for(int j=0;j<k[i];j++)scanf("%d%d",&w[i][j],&p[i][j]);
    }

    for(int i=0;i<=m;i++)dp[i] = -1;
    dp[0] = 0;

    for(int i=0;i<d;i++){
      scanf("%d",&f);
      for(int x=0;x<k[f];x++){
	int v = p[f][x], c = w[f][x];
	for(int j=m-v;j>=0;j--){
	  if(dp[j]>=0 && dp[j+v]<dp[j]+c)dp[j+v] = dp[j]+c;
	}
      }
    }
	
    int ans = 0;
    for(int i=1;i<=m;i++)
      if(dp[i] > dp[ans])ans = i;
    printf("%d %d\n",dp[ans],ans);
  }
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

int main(){
    ld A,B; cin>>A>>B;
    ld ans = A*B;
    cout << (ll)(ans) << "\n";
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
#define int long long
#define double long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define pii pair<int,int>
#define ff first
#define ss second
#define frr(i,n) for(int i=0;i<n;i++)
#define td(v) v.begin(),v.end()
#define inf 1000000000 // 1e9
#define M   1000000007 // 1e9 + 7
using namespace std;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int exp(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}
int32_t main(){
    fastio;
    int a,b;
    cin >> a >> b;
    if(a >= 13){
        cout << b << endl;
    }
    else if( a<13 && a >=6){
        cout << b/2 << endl;
    }
    else cout << 0 << endl;
}

Measured memory_bytes: 256