akhauriyash/Code-Regression huggingface dataset:
package main

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

func main() {
	sc := NewScanner()

	n := sc.ReadInt()
	m := sc.ReadInt()
	q := sc.ReadInt()
	abcds := make([]ABCD, q)
	for i := 0; i < q; i++ {
		a := sc.ReadInt()
		b := sc.ReadInt()
		c := sc.ReadInt()
		d := sc.ReadInt()
		abcds[i] = ABCD{a, b, c, d}
	}

	cur := make(SeqA, n)
	for i := 0; i < n-1; i++ {
		// the last is 0
		cur[i] = 1
	}

	maxScore := 0
	for {
		var ok bool
		ok, cur = nextSeqA(n, m, cur)
		if !ok {
			break
		}

		score := computeScore(abcds, cur)
		if score > maxScore {
			maxScore = score
		}
	}

	fmt.Println(maxScore)
}

func nextSeqA(n int, m int, cur SeqA) (bool, SeqA) {
	carryDigitCount := 0
	for i := n - 1; i >= 0; i-- {
		if cur[i] == m {
			carryDigitCount++
		} else {
			break
		}
	}

	if carryDigitCount == 0 {
		cur[n-1]++
		return true, cur
	} else if carryDigitCount == n {
		return false, nil
	} else {
		min := cur[n-1-carryDigitCount] + 1
		for i := 0; i <= carryDigitCount; i++ {
			cur[n-1-i] = min
		}
		return true, cur
	}
}

func computeScore(abcds []ABCD, seqA SeqA) int {
	totalD := 0
	for _, abcd := range abcds {
		if seqA[abcd.B-1]-seqA[abcd.A-1] == abcd.C {
			totalD += abcd.D
		}
	}
	return totalD
}

type SeqA []int

type ABCD struct {
	A int
	B int
	C int
	D int
}

// util
// *   math/simple

func Abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func Min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow(base int, exponent uint) int {
	answer := 1
	for i := uint(0); i < exponent; i++ {
		answer *= base
	}
	return answer
}

// *   io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}


Measured memory_bytes: 1764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF (INT_MAX / 4)
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
/* clang-format off */
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */

int main() {
  string s, t;
  cin >> s >> t;
  bool f = true;
  REP(i,s.size()){
    if (s.at(i) != t.at(i)) f = false;
  }
  if(f)cout << "Yes" << "\n";
  else cout << "No" << "\n";
  return 0;
}


Measured memory_bytes: 3628
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

#ifndef _DEBUG
#define main_ main
#endif
#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
	return left.second > right.second;
}

void init_global() {}

int main_() {
	int H, W;
	cin >> H >> W;

	vector<string> c(H);
	FOR(i, 0, H) {
		cin >> c[i];
	}

	FOR(i, 0, H) {
		cout << c[i] << endl;
		cout << c[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val a = mutableListOf<Int>()
    repeat(n) {
        a.add(sc.nextInt())
    }

    println(problem134_c(n, a))
}

fun problem134_c(n: Int, a: MutableList<Int>): String {
    val result = mutableListOf<Int>()

    val tmpSet = TreeSet<Int> { o1, o2 -> o2 - o1 }

    for (el in a) {
        tmpSet.add(el)
    }

    val tmpList = tmpSet.toList()

    val first = tmpList[0]
    val second = if (a.count { it == first } > 1 || tmpList.size == 1) {
        tmpList[0]
    } else {
        tmpList[1]
    }

    for (e in a) {

        if (e == first) {
            result.add(second)
        } else {
            result.add(first)
        }

    }

    return result.joinToString("\n")
}

Measured memory_bytes: 78384
#include <iostream>
#include <cmath>
#include <string>
#include <iomanip>
using namespace std;

void selection_sort(int nums[100], int n){
    int min, count, min_index;
    count = 0;
    for(int i=0; i<n; i++){
        min = nums[i];
        min_index = i;
        for(int j=i; j<n; j++){
            if(min > nums[j]){
                min = nums[j];
                min_index = j;
            }
        }
        if(min_index != i){
            nums[min_index] = nums[i];
            nums[i] = min;
            count++;
        }
    }
    for(int i=0; i<n; i++){
        cout << nums[i];
        if(i<n-1){
            cout << " ";
        }
    }
    cout << endl;
    cout << count << endl;
}

int main()
{
    int N;
    int num[100];
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> num[i];
    }
    selection_sort(num, N);
    return 0;
}


Measured memory_bytes: 3116
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i,0,n)
#define BFOR(bit,a,b) for(int bit = (a); bit < (1<<(b)); ++bit)
#define BREP(bit,n) BFOR(bit,0,n)
using namespace std;
using ll = long long;

int main() {
  ll x;
  cin >> x;
  ll ans = 0;
  
  ll n = x / 11;
  ans += n*2;
  x -= n*11;
  
  if(x == 0){}
  else if(x <= 6){ans += 1;}
  else{ans += 2;}
  
  
  cout << ans << endl;
    

}


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

using namespace std;
using ll = long long;

const int MOD = 1000000007;

template<typename T>
T powi(T b, ll e) {
    if(e == 0) return 1;
    T p = powi(b, e / 2);
    if(e % 2 == 0) return p * p;
    return p * p * b;
}

template<const int mod>
struct Intmod {
    ll a;
    Intmod(ll a = 0): a(((a % mod) + mod) % mod) {}

    Intmod operator-() const {return Intmod(-a);}

    Intmod& operator+=(const Intmod b) {
        if((a += b.a) >= mod) a -= mod;
        return *this;
    }
    Intmod& operator+=(const ll b) {
        if((a += b) >= mod) a -= mod;
        return *this;
    }
    Intmod& operator-=(const Intmod b) {
        if((a -= b.a) < 0) a += mod;
        return *this;
    }
    Intmod& operator-=(const ll b) {
        if((a -= b) < 0) a += mod;
        return *this;
    }
    Intmod& operator*=(const Intmod b) {
        (a *= b.a) %= mod;
        return *this;
    }
    Intmod& operator*=(const ll b) {
        (a *= b) %= mod;
        return *this;
    }
    
    template<typename T> Intmod operator+(const T b) const {return Intmod(*this) += b;}
    template<typename T> Intmod operator-(const T b) const {return Intmod(*this) -= b;}
    template<typename T> Intmod operator*(const T b) const {return Intmod(*this) *= b;}

    // Valid for prime mod.
    int i = 0;
    Intmod inv() {
        if(a == 0) throw "Inverse of zero does not exist.";
        if(!i) i = powi(*this, mod - 2).a;
        return Intmod(i);
    }
    Intmod& operator/=(const Intmod b) {return *this *= b.inv();}
    Intmod& operator/=(const ll b) {return *this *= Intmod(b).inv();}
    template<typename T> Intmod operator/(const T b) const {return Intmod(*this) /= b;}
};
template<const int mod, typename T> Intmod<mod> operator+(const T b, Intmod<mod> a) {return a += b;}
template<const int mod, typename T> Intmod<mod> operator-(const T b, Intmod<mod> a) {return a -= b;}
template<const int mod, typename T> Intmod<mod> operator*(const T b, Intmod<mod> a) {return a *= b;}
template<const int mod, typename T> Intmod<mod> operator/(const T b, Intmod<mod> a) {return a /= b;} //Valid for prime mod.

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

    int n, a, b;

    cin >> n >> a >> b;

    Intmod<MOD> ans;

    ans = powi(Intmod<MOD>(2), n) - 1;

    if(a > n / 2) a = n - a;
    if(b > n / 2) b = n - b;

    Intmod<MOD> ca = 1, cb = 1;

    for(int i = 0; i < a; ++i) {
        ca *= n - i;
        ca /= i + 1;
    }
    for(int i = 0; i < b; ++i) {
        cb *= n - i;
        cb /= i + 1;
    }

    ans -= ca;
    ans -= cb;

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

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
int a, b;

int gcd(int a, int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

void solve() {
    cin >> a >> b;
    int out_num = (a > b) ? a - 1: a;
    cout << out_num << endl;
    return;
}
//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long 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;
}
int main(int args, char* argv[]) {
    solve();
}



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

int a[100000];

int main(){
    int N;
    cin>>N;

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

    int ans=0;

    for(auto p: mp)
    {
        int x=p.first;
        int n=p.second;
        
        if(n<x)ans+=n;
        else ans+=n-x;
    }

    cout<<ans<<"\n";

    return 0;
}


Measured memory_bytes: 5120
#include<stdio.h>
int main(void)
{
  char s[6];
  scanf("%s",s);
  for(int i=0;i<3;i++){
    if(s[i]=='1'){
      s[i]='9';
    }else if(s[i]=='9'){
      s[i]='1';
    }
  }

  printf("%s\n",s);
  return 0;
}


Measured memory_bytes: 1608
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;

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

struct edge {
    int dst;
    int dist;
    int limit;
};

struct entry {
    double cost;
    int city;
    int prev;
    int vel;

    bool operator<(const entry& rhs) const { return cost > rhs.cost; }
};

double costs[30][30][31];
bool visit[30][30][31];

int main()
{
    int n, m;
    while (cin >> n >> m, n) {
        int s, g; cin >> s >> g; --s; --g;

        vector<vector<edge>> edges(n);
        rep(i, m) {
            int x, y, d, c; cin >> x >> y >> d >> c; --x; --y;
            edges[x].push_back({ y, d, c });
            edges[y].push_back({ x, d, c });
        }

        rep(i, n) rep(j, n) rep(k, 31) {
            costs[i][j][k] = 1e10;
            visit[i][j][k] = false;
        }

        priority_queue<entry> Q;
        Q.push({ 0.0, s, s, 0 });
        costs[s][s][0] = 0.0;
        double ans = 1e10;

        while (!Q.empty()) {
            entry t = Q.top(); Q.pop();
            if (visit[t.city][t.prev][t.vel])
                continue;
            visit[t.city][t.prev][t.vel] = true;
            if (t.city == g && t.vel == 1) {
                ans = costs[g][t.prev][1];
                break;
            }

            for (const edge& e : edges[t.city]) {
                if (e.dst == t.prev) continue;
                for (int v = max(1, t.vel - 1); v <= min(30, t.vel + 1); ++v) {
                    if (v > e.limit) continue;
                    double new_cost = costs[t.city][t.prev][t.vel] + e.dist / double(v);
                    if (new_cost < costs[e.dst][t.city][v]) {
                        costs[e.dst][t.city][v] = new_cost;
                        Q.push({ new_cost, e.dst, t.city, v });
                    }
                }
            }
        }

        cout.precision(15);
        if (ans == 1e10)
            cout << "unreachable" << endl;
        else
            cout << ans << endl;
    }
}

Measured memory_bytes: 2032
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N,K;
  cin >> N >> K;
  ll h[N];
  rep(i,N) cin >> h[i];
  sort(h,h+N);
  ll ans=1LL * INT_MAX;
  rep(i,N-K+1){
    ans = min(ans, h[i+K-1]-h[i]);
  }
  cout << ans << endl;

  return 0;
    

}


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

int main() {
	// your code goes here
	int n; 
	cin>>n;
	int count=0;
	int x,y;
	int flag=0;
	for(int i=1;i<=n;i++)
	{
	    cin>>x>>y;
	    if(x==y)
	    {
	        count++;
	        if(count>=3)
	        {
	           //cout<<"Yes"<<"\n";
	            flag=1;
	            break;
	        }
	    }
	    else
	    {
	        count=0;
	    }
	}
	if(flag==1)
	cout<<"Yes"<<"\n";
	else
	cout<<"No"<<"\n";
	return 0;
}


Measured memory_bytes: 3632
def bitcount(x):
  x = x - ((x >> 1) & 0x5555555555555555)
  x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
  x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
  x = x + (x >> 8)
  x = x + (x >> 16)
  x = x + (x >> 32)
  return x & 0x0000007f
N, K = map(int, input().split())
A = list(map(int, input().split()))
r = float('INF')
for i in range(1<<N):
  if bitcount(i) != K:
    continue
  cost, hights, idx = 0, [], 0
  for j in range(N):
    if j > 0 and i>>j & 1:
      c = max(0, max(hights[idx:j]) - A[j] + 1)
      cost += c
      hights.append(A[j] + c)
      idx = j
    else:
      hights.append(A[j])
  # print(bin(i), cost, hights)
  r = min(r, cost)
print(r)

Measured memory_bytes: 42972
//Mahir Ratanpara (DA-IICT)
#include<bits/stdc++.h>
using namespace std;
#define Ff(i,a,n) for(i=a;i<n;i++)
#define Fr(i,a,n) for(i=a;i>n;i--)
#define ll long long
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef pair<ll, ll>	pa;
typedef vector<ll>		vc;
typedef vector<pa>		vp;
typedef vector<vc>		vvc;
int mpow(int base, int exp); 
void ipgraph(ll n,ll m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vc g[N];

int main() {
    FAST;
    ll t, i, j, k, p, q, r, x, y, u, v, n, m;
	cin>>n;
	ll a[n];
	x=0;
	Ff(i,0,n)
	{
		cin>>a[i];
		x^=a[i];
	}

	Ff(i,0,n)
	{
		cout<<(x^a[i])<<" ";
	}
    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(ll n, ll m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

Measured memory_bytes: 12188
N,M = map(int,input().split())
mod = 10**9 + 7
leng = 500010
fac = [1,1]
for i in range(2,500010):
    fac.append(fac[-1]*i%mod)

invfac = [0]*500010
invfac[500009] = pow(fac[500009],-1,mod)
for i in range(500009):
    invfac[500008-i] = invfac[500009-i]*(500009-i)%mod

def combi(n,m):
    return(fac[n]*invfac[m]*invfac[n-m]%mod)

def permu(n,m):
    return(fac[n]*invfac[n-m]%mod)

Ans = 0

for i in range(N+1):
    if i%2 == 0:
        Ans += combi(N,i)*permu(M,i)*(permu(M-i,N-i)**2)
    else:
        Ans -= combi(N,i)*permu(M,i)*(permu(M-i,N-i)**2)

print(Ans%mod)

Measured memory_bytes: 48448
import math
n, d = map(int, input().split())
count = 0
x = []

for i in range(n):
    x.append(list(map(int, input().split())))

for i in range(n):
    for j in range(i, n):
        distance = 0
        if i == j:
            continue
        for k in range(d):
            distance += (x[i][k] - x[j][k])**2
        distance = math.sqrt(distance)
        if distance % 1 == 0:
            count += 1
print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> X(N);
  vector<int> P(100, 0);
  for (int i = 0; i < N; i++) {
    cin >> X.at(i);
  }
  for (int i = 0; i < 100; i++) {
    for (int j = 0; j < N; j++) {
      P.at(i) += (X.at(j) - i - 1) * (X.at(j) - i - 1);
    }
  }
  sort(P.begin(), P.end());
  cout << P.at(0) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
template <bool P = 0> struct SegmentTree {
  #define lson L, R, N[u].l
  #define rson L, R, N[u].r
  #define OUT R <= N[u].L || N[u].R <= L
  #define IN  L <= N[u].L && N[u].R <= R
  struct Node { int L, R, l, r; 
    LL maxV;
  };
  vector<Node> N; int p, n; vector<int> rt;
  inline void init(int _n) { N.resize(_n * (P ? 40:4));
    n = _n; p = 1; rt.assign(1, build(0, n));
  }
  inline int copy(Node u) { return N[p] = u, p++; }
  int build(int L, int R) {
    int u = copy({L, R}), M = (L + R) >> 1;;
    if (R - L == 1) return u;
    return pull(u, build(L, M), build(M, R));
  }
  inline int push(int u) {
    return u;
  }
  inline int pull(int u, int l, int r) {
    if (!l || !r) return l ? l : r;
    N[u].L = N[l].L; N[u].R = N[r].R;
    push(N[u].l = l); push(N[u].r = r);
    N[u].maxV = max(N[l].maxV, N[r].maxV);
    return u;
  }
  int m(int L, int R, int u, LL v) {
    if (OUT) return u; push(u);
    if (P) u = copy(N[u]);
    if (IN) return N[u].maxV = max(N[u].maxV, v), u;
    return pull(u, m(lson, v), m(rson, v));
  }
  int q(int L, int R, int u) {
    if (OUT) return 0; push(u); if (IN) return u;
    return pull(copy(N[u]), q(lson), q(rson));
  }
  inline void modify(int L, int R, int ver, LL v) {
    rt[ver] = m(L, R, rt[ver], v);
  }
  inline Node& query(int L, int R, int ver) {
    if (!P) p = 2 * n; return N[q(L, R, rt[ver])];
  }
};
int maxn = 300005;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, k; cin >> n >> k;
    vector<int> arr(n);
    for (auto &v : arr)
        cin >> v;
    SegmentTree solver; solver.init(maxn);
    int ans = 0;
    for (int i = 0 ; i < n ; i++) {
        int l = max(0, arr[i] - k);
        int r = min(arr[i] + k + 1, maxn);
        int cur = solver.query(l, r, 0).maxV;
        ans = max(ans, cur + 1);
        solver.modify(arr[i], arr[i] + 1, 0, cur + 1);
    }
    cout << ans << '\n';
    

}


Measured memory_bytes: 32516
a,b,m = gets.split.map(&:to_i)
refs = gets.split.map(&:to_i)
mics = gets.split.map(&:to_i)

min = refs.min + mics.min

m.times do
  x,y,c = gets.split.map(&:to_i)
  min = [refs[x-1] + mics[y-1] - c, min].min
end

puts min

Measured memory_bytes: 18588
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;

int main() {
	ll n, m;
	ll ans = 0;

	cin >> n >> m;

	if (n > 1 && m > 1) {
		ans = (n - 2) * (m - 2);
	}
	else if (n == 1 && m != 1) {
		ans = m - 2;
	}
	else if (n != 1 && m == 1) {
		ans = n - 2;
	}
	else {
		ans = 1;
	}

	cout << ans << endl;
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> X(N);
  vector<int> sortX(N);
  
  int x;
  for (int i = 0; i < N; i++) {
    cin >> x;
    X.at(i) = x;
    sortX.at(i) = X.at(i);
  }
  
  sort(sortX.begin(),sortX.end());
  
  for (int i = 0; i < N; i++) {
    if (sortX.at(N / 2 - 1) >= X.at(i))
      cout << sortX.at(N / 2) << endl;
    else
      cout << sortX.at(N / 2 - 1) << endl;
  }
}

Measured memory_bytes: 3712
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    def inp():
        s = LS()
        a = []
        for i in range(len(s)-1):
            if i % 2 == 0:
                a.append(s[i])
            else:
                a.append(int(s[i]))
        return a

    def com(a):
        r = a[:2]
        for i in range(2,len(a), 2):
            if a[i] == r[-2]:
                r[-1] += a[i+1]
            else:
                r += a[i:i+2]
        return r

    a = com(inp())
    b = com(inp())
    c = com(inp())

    r = []
    ff = True
    if len(b) == 2:
        b0 = b[0]
        b1 = b[1]
        for i in range(0,len(a),2):
            if a[i] == b0:
                while a[i+1] >= b1 and ff:
                    r += c
                    a[i+1] -= b1
                    ff = False
                if a[i+1] > 0:
                    r += a[i:i+2]
            else:
                r += a[i:i+2]
    else:
        i = 0
        al = len(a)
        bl = len(b)
        be = bl - 2
        while i < al:
            f = True
            for j in range(0,bl,2):
                ii = i + j
                if al <= ii or a[ii] != b[j] or (a[ii+1] < b[j+1] if j in [0, be] else a[ii+1] != b[j+1]) or not ff:
                    f = False
                    break
            if f:
                for j in range(0,bl,2):
                    ii = i + j
                    a[ii+1] -= b[j+1]
            if a[i+1] > 0:
                r += a[i:i+2]
            if f:
                r += c
                ff = False
            i += 2

    r += '$'


    return ' '.join(map(str,com(r)))




print(main())



Measured memory_bytes: 9312
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pi pair<int,int>
#define ff first
#define ss second
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#define endl "\n"


int32_t main() {
	boost;
	int n;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++)
		cin >> a[i];
	sort(a, a + n);
	int ans = 0;
	for(int i = 0; i < n; i++) {
		for(int j = i + 1; j < n; j++) {
			int l = a[j] - a[i];
			int r = a[j] + a[i];
			l = lower_bound(a, a + n, l + 1) - a;
			r = lower_bound(a, a + n , r) - a;
			ans += r - l - 1;
			if(a[j] - a[i] < a[i])
				ans--;
			//cout << a[i] << ' ' << a[j] <<' '<< l << ' ' << r << endl;
		}
	}
	ans /= 3;
	cout << ans << endl;	
}


Measured memory_bytes: 3660
#include<stdio.h>
#define MAX 100
#define INF 10000000
#define WHITE 0
#define GRAY 1
#define BLACK 2

int prim();

int n,M[MAX][MAX];
int i,j;

int main()
{
  int e;
  
  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&e);
      if(e==-1) M[i][j] = INF;
      else M[i][j] = e;
    }
  }

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

  return 0;
}

int prim()
{
  int u,minv,v;
  int d[MAX],p[MAX],color[MAX];
  int sum=0;

  for(i=0;i<n;i++){
    d[i] = INF;
    p[i] = -1;
    color[i] = WHITE;
  }

  d[0]=0;

  while(1){
    minv = INF;
    u = -1;
    for(i=0;i<n;i++){
      if(minv > d[i] && color[i] != BLACK){
	u = i;
	minv = d[i];
      }
    }
    if(u == -1) break;
    color[u] = BLACK;
    for(v=0;v<n;v++){
      if(color[v]!=BLACK && M[u][v]!=INF){
	if(d[v] > M[u][v]){
	  d[v] = M[u][v];
	  p[v] = u;
	  color[v] = GRAY;
	}
      }
    }
  }
  for(i=0;i<n;i++){
    if(p[i]!=-1) sum += M[i][p[i]];
  }

  return sum;
}



Measured memory_bytes: 2108
def gcd(x,y)
	while y >0
		r =x%y
		x=y
		y=r
	end
	return x
end

def lcm(x,y)
	return x * y / gcd(x,y)
end

a=Array.new
n=gets.chomp.to_i
a=gets.chomp.split(" ").map{|i| i.to_i}

a.sort!{|a, b| b <=> a }


while a.length>=2
	a[1]=lcm(a[0],a[1])
	a.shift
end
puts a[0]

Measured memory_bytes: 8640
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPD(i,n) for(int i=(n)-1;i>=0;--i)
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define FORD(i,a,b) for(int i=(a);i>=(b);--i)
#define TLE() cerr<<"\nTime elapsed: "<<1000*clock()/CLOCKS_PER_SEC<<"ms.\n";
const ll MOD = 1E9+7;
const ll IINF = 1E18;
const int INF = 1e9;
const double EPS = 1E-9;
const double PI = atan(1.0) * 4.0;
template<class T> T getbit(T s, int i) {return s>>i&1;}
template<class T> void flipbit(T& s, int i) {s^=(1LL<<i);}
constexpr int cntbit(ll x) {return __builtin_popcountll(x);}
constexpr int lg2(ll x) {return __lg(x);} // return int(log2(x))
// mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); 
ll fpow(ll a,ll p){ll res=1LL;while(p){if(p&1LL) res=res*a%MOD;a=a*a%MOD;p>>=1LL;} return res;}

const int N=1005;
int n;
bool used[N];
queue<int> q[N];

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>n;
	FOR(i,1,n)
		FOR(j,1,n-1){
			int x;
			cin>>x;
			q[i].push(x);
		}
	int days=0;
	while(true){
		bool isEmpty=true;
		FOR(i,1,n) isEmpty&=q[i].empty();
		if(isEmpty) break;
		bool found=false;
		vector<int> chosen;
		FOR(i,1,n){
			if(used[i]) continue;
			int op=q[i].front();
			if(!q[op].empty()&&q[op].front()==i){
				found=true;
				chosen.pb(i);
				chosen.pb(op);
				used[i]=true;
				used[op]=true;
			}
		}
		if(!found) exit(puts("-1\n")*0);
		for(int x:chosen){
			q[x].pop();
			used[x]=false;
		}
		++days;
	}
	cout<<days<<'\n';
}



Measured memory_bytes: 7992
use proconio::input;

fn main() {
    input! {
        n: usize,
        mut a: [u128; n],
    }

    a.sort();
    if a[0] == 0 {
        println!("0");
        return;
    }

    let mut ans = 1;
    for i in 0..n {
        ans *= a[i];

        if ans > 1_000_000_000_000_000_000 {
            println!("-1");
            return;
        }
    }

    println!("{}", ans);
}


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

int main(){
    int N; cin >> N;
    bool flg = false;
    for(int i = 1; i <= 9; i++){
        if(N % i == 0 && 1 <= N / i && N / i <= 9) flg = true;
    }
    cout << (flg ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
W, a, b = map(int, input().split())

A2W = (a, a+W)
B2W = (b, b+W)

if (A2W[0] <= B2W[0] and B2W[0] <= A2W[1]) or (A2W[0] <= B2W[1] and B2W[1] <= A2W[1]):
    print(0)
elif B2W[0] > A2W[1]:
    print(B2W[0]-A2W[1])
else:
    print(A2W[0]-B2W[1])


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
int main() {
    int n, m;
    scanf("%d%d", &n, &m);

    vector<int> h(n);
    rep(i, n) scanf("%d", &h[i]);

    vector<vector<int>> g(n);
    rep(i, m) {
        int a, b;
        scanf("%d%d", &a, &b);
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    int ans = 0;
    rep(i, n) {
        bool ok = true;
        for (auto j: g[i]) if (h[i] <= h[j]) ok = false;
        if (ok) ans++;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 8812
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <memory.h>
#include <cmath>
#include <array>

using namespace std;

void re(int& x);

template<class T> void re(std::vector<T>& a);

void pr(int x);

void pr(const char *x);

void ps();
template<class T, class... Ts> void ps(const T& t, const Ts&... ts);

#ifdef FFDBG

#else
#define dbg(x...) dsfdsfsdfasd
#endif

typedef vector<int> vi;

#define all(v) (v).begin(), (v).end()

#define rep(i, a, b) for(int i = a; i < (b); ++i)

int n;

void solve()
{
    re(n);
    vi a(n); re(a);

    sort(all(a));
    int bst = 0;
    rep(i,0,n-1) {
        if ( abs(a[i]*2 - a[n-1]) < abs(a[bst]*2 - a[n-1])) bst = i;
    }

    ps(a[n-1], a[bst]);
}

int main() {

    solve();
}

void re(int& x) { scanf("%d", &x); }

template<class T> void re(std::vector<T>& a) { for (int i = 0; i < a.size(); i++) re(a[i]); }

void pr(int x) { printf("%d", x); }

void pr(const char *x) { printf("%s", x); }

void ps() { pr("\n"); }
template<class T, class... Ts> void ps(const T& t, const Ts&... ts) { 
    pr(t); if (sizeof...(ts)) pr(" "); ps(ts...); 
}



Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void bubbleSort(int[] array, int n) {
		boolean flag = true;
		int tmp, count = 0;
		while (flag) {
			flag = false;
			for (int j = n - 1; j > 0; j--) {
				if (array[j] < array[j-1]) {
					tmp = array[j]; array[j] = array[j-1]; array[j-1] = tmp;
					count++;
					flag = true;
				}
			}
		}
		for (int i = 0; i < n; i++) {
			System.out.print(array[i]);
			if (i < n - 1) System.out.print(" ");;
		}
		System.out.println();
		System.out.println(count);
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] array = new int[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextInt();
		}
		bubbleSort(array, n);
	}
}



Measured memory_bytes: 26392
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */


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

    int n, m; cin >> n >> m;
    vector<vector<int>> to(n);
    rep(i, m){
        int s, t; cin >> s >> t;
        --s; --t;
        to[s].push_back(t);
    }
    vector<double> dp(n, 0);
    for(int v=n-2; v>=0; --v){
        double now = 0;
        for(int u : to[v]) {
            now += dp[u];
        }
        now /= to[v].size();
        now += 1;
        dp[v] = now;
    }
    double ans = dp[0];
    for(int nv = 0; nv < n-1; ++nv){
        if(to[nv].size() == 1) continue;
        int nu = to[nv][0];
        for(int u : to[nv]){
            if(dp[nu] < dp[u]) nu = u;
        }
        
        double now = [&]{
            vector<double> dp2(n);
            for(int v = n-2; v>=0; --v){
                double now = 0;
                for(int u : to[v]){
                    if(v == nv && u == nu) continue;
                    now += dp[u];
                }
                int deg = to[v].size();
                if(v == nv) --deg;
                now /= deg;
                now += 1;
                dp[v] = now;
            }
            return dp[0];
        }();
        chmin(ans, now);
    }

    cout << setprecision(15) << ans << endl;

    return 0;
}

Measured memory_bytes: 1536
import scala.io.StdIn._
object Main extends App {
  val n = readInt
  val abc = (1 to n)
    .map { _ =>
      readLine.split(" ").map(_.toInt)
    }
  val dp = Array.fill(n + 1)(Array.fill(3)(0))
  for (i <- 0 until n; j <- 0 until 3; k <- 0 until 3 if j != k) {
    dp(i + 1)(j) = math.max(dp(i + 1)(j), dp(i)(k) + abc(i)(j))
  }

  println(dp(n).max)
}


Measured memory_bytes: 74436
import sys
import collections


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    s = str(readline().rstrip().decode('utf-8'))
    dict1 = collections.defaultdict(int)
    dict2 = collections.defaultdict(int)
    dict3 = collections.defaultdict(int)
    for i in range(n):
        t = [s[i]]
        if "".join(t) not in dict1:
            dict1["".join(t)]
            for j in range(i + 1, n):
                t = [s[i], s[j]]
                if "".join(t) not in dict2:
                    dict2["".join(t)]
                    for k in range(j + 1, n):
                        t = [s[i], s[j], s[k]]
                        dict3["".join(t)]
    print(len(dict3))


if __name__ == '__main__':
    solve()


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

char S[100001];
int  E[100001];

int main() {
  int N;
  int i;
  int A, B;
  scanf ("%s", S);
  
  
  i=0;
  while ((S[i]=='R')||(S[i]=='L')) {
      i++;
  }
  N=i;
  

  for (i=0;i<N;i++) {
    E[i]=0;
  }
  
  for (i=0;i<N;i++) {
      if (S[i]=='R') {
          A=0; B=0;
          while(1) {
             A++;
             i++;
             if (S[i]=='L') {
                 E[i-1]+=A;
                 E[i]+=B;
                 break;
             }
             B++;
             i++;
             if (S[i]=='L') {
                 E[i]+=B;
                 E[i-1]+=A;
                 break;
             }
          }
      }
  }

  for (i=N-1;i>=0;i--) {
      if (S[i]=='L') {
          A=0; B=0;
          while(1) {
             A++;
             i--;
             if (S[i]=='R') {
                 E[i+1]+=A;
                 E[i]+=B;
                 break;
             }
             B++;
             i--;
             if (S[i]=='R') {
                 E[i]+=B;
                 E[i+1]+=A;
                 break;
             }
          }
      }
  }

      
  printf ("%d", E[0]);
  for (i=1;i<N;i++) {
    printf (" %d", E[i]);
  }
  return 0;
}




Measured memory_bytes: 896
#include<stdio.h>
int main(){
  int n,m,s,i,j,t,d[101];
  while(scanf("%d",&n)!=EOF){
    for(i=0;i<n;i++){
      scanf("%d",&d[i]);
      for(j=i;j;j--){
	if(d[j-1]>d[j]){
	  t=d[j-1];
	  d[j-1]=d[j];
	  d[j]=t;
	}
      }
    }
    s=0;
    for(i=0;i<n;i++){
      s+=d[i]*(n-i);
    }
    printf("%d\n",s);
  }
  return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>

typedef long long ll;
using namespace std;

int main(){
  ll N,K,i;
  cin >> N >> K;
  vector<pair<int,int>> pairs(N);
  for(i=0;i<=N-1;i++)
    cin >> pairs[i].first >> pairs[i].second;
  sort(pairs.begin(),pairs.end());
  ll count = 0;
  i = 0;
  while(count<K){
    count += pairs[i].second;
    i++;
  }
  cout << pairs[i-1].first << endl;
}

Measured memory_bytes: 1024
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!{
        n: usize,
        v: [usize; n]
    }
    println!("{}", if v.iter().filter(|&&x| x % 2 == 1).count() % 2 == 0 {"YES"} else {"NO"});
}


Measured memory_bytes: 4476
n=int(input())
a=list(map(int,input().split()))
dic={}
for n in a:
    if n in dic:
        dic[n]+=1
    else:
        dic[n]=1
ans=0
for k in dic.keys():
    if dic[k]-k>0:
        ans+=dic[k]-k
    elif dic[k]-k==0:
        pass
    else:
        ans+=dic[k]
print(ans)
        
        

Measured memory_bytes: 18160
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iterator>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>

using namespace std;

#define dump(n) cerr<<"# "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

bool solve(string s)
{
	stack<char> st;
	rep(i,s.size()){
		if(s[i]=='(' || s[i]=='[')
			st.push(s[i]);
		if(s[i]==')' || s[i]==']'){
			if(st.empty())
				return false;
			else if(s[i]==')' && st.top()!='(')
				return false;
			else if(s[i]==']' && st.top()!='[')
				return false;
			else
				st.pop();
		}
	}
	return st.empty();
}

int main()
{
	for(string s;getline(cin,s),s!=".";)
		puts(solve(s)?"yes":"no");
	
	return 0;
}

Measured memory_bytes: 0
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

void dfs(int now,vector<vector<bool>>pass, vector<bool>isVidited,int &ans) {
    int N = pass.size() - 1;
    if (count(isVidited.begin(), isVidited.end(), true) == N) {
        ans++;
        return;
    }
    for (int i = 1; i <= N; i++) {
        if (pass[now][i] == true && isVidited[i] == false) {
            isVidited[i] = true;
            dfs(i, pass, isVidited, ans);
            isVidited[i] = false;
        }
    }
    return;
}


int main() {

    int N, M;
    cin >> N >> M;
    vector<vector<bool>>pass(N + 1, vector<bool>(N + 1, false));
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        pass[a][b] = pass[b][a] = true;
    }

    vector<bool>isVidited(N + 1, false);
    isVidited[1] = true;
    int ans = 0;
    dfs(1, pass, isVidited, ans);

    cout << ans << endl;

    return 0;
}

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

int main() {
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int dx = x2 - x1;
  int dy = y2 - y1;
  int x = x2;
  int y = y2;
  rep(i, 2) {
    swap(dx, dy);
    dx = -dx;
    x += dx;
    y += dy;
    cout << x << " " << y << endl;
  }
  return 0;
}

Measured memory_bytes: 3576
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int dp[100001];
int main(void){
	int i,j,n;
	cin>>n;
	vector<int> a={
		1,6,6*6,6*6*6,6*6*6*6,6*6*6*6*6,6*6*6*6*6*6,
		9,9*9,9*9*9,9*9*9*9,9*9*9*9*9};
	sort(a.begin(),a.end());
	vector<int> b;
	dp[0]=0;
	for(i=1;i<100001;i++){
		b.clear();
		for(j=0;j<12;j++){
			if((i-a[j])>=0){
				b.push_back(dp[i-a[j]]+1);
			}
			else{
				break;
			}
		}
		sort(b.begin(),b.end());
		dp[i]=b[0];
	}
	cout<<dp[n]<<endl;
	return 0;
}


Measured memory_bytes: 640
# 入力
N,M=map(int,input().split())

la=[]
for i in range(N):
  la.append(input())

lb=[]
for i in range(M):
  lb.append(input())

for i in range(N-M+1):
  for j in range(N-M+1):

    f=True
    for k in range(M):
      for l in range(M):
        if la[i+k][j+l]!=lb[k][l]:
          f=False
    if f:
      print('Yes')
      exit()

print('No')

Measured memory_bytes: 3064
n,x0=map(int,input().split())
x=list(map(int,input().split()))

def gcd(x,y):
    if y==0:
        return x
    else:
        return gcd(y,x%y)
if n==1:
    ans=abs(x[0]-x0)
else:
    ans=gcd(abs(x[0]-x0),abs(x[1]-x0))
    for i in range(n):
        ans=gcd(ans,abs(x[i]-x0))
print(ans)

Measured memory_bytes: 14224
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define len(n) (int)n.length()
#define pb push_back
#define ll long long
#define make_pair mkp
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n-1;i >= 0;i--)
#define ALL(v) (v).begin(), (v).end()
#ifdef DBGPRT
#define dbg(n) cerr << "//" << #n << ":" << n <<endl
#else
#define dbg(n) ;
#endif
typedef pair<ll, ll> LLARR;
#define INF 999999999
const double PI = 3.1415926535897932384626433832795;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

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

	string n;
	cin >> n;
	if ((n[0] == '9') || (n[1] == '9'))
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
        var c = sc.ReadStr()[0];
        if (c == 'a' || c == 'i' || c == 'e' || c == 'u' || c == 'o')
        {
            Console.WriteLine("vowel");
        }
        else
        {
            Console.WriteLine("consonant");
        }
    }

    static Scanner sc = new Scanner();
}

class Scanner
{
    string[] S = new string[0];
    int Index = 0;
    char[] Separators = new char[] { ' ' };

    public string Next()
    {
        if (this.Index < this.S.Length) return this.S[this.Index++];
        var line = "";
        while (line == "") line = Console.ReadLine();
        this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
        if (this.S.Length == 0) return this.Next();
        this.Index = 0;
        return this.S[this.Index++];
    }
    public string ReadStr()
    {
        return this.Next();
    }
    public char ReadChar()
    {
        return this.Next()[0];
    }
    public int ReadInt()
    {
        return int.Parse(this.Next());
    }
    public uint ReadUInt()
    {
        return uint.Parse(this.Next());
    }
    public long ReadLong()
    {
        return long.Parse(this.Next());
    }
    public double ReadDouble()
    {
        return double.Parse(this.Next());
    }
    public int[] ReadIntArray(int n)
    {
        var array = new int[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadInt();
        }
        return array;
    }
    public long[] ReadLongArray(int n)
    {
        var array = new long[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadLong();
        }
        return array;
    }
    public double[] ReadDoubleArray(int n)
    {
        var array = new double[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadDouble();
        }
        return array;
    }
    public char[] ReadCharArray(int n)
    {
        var array = new char[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadChar();
        }
        return array;
    }
    public string[] ReadStrArray(int n)
    {
        var array = new string[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadStr();
        }
        return array;
    }
}


Measured memory_bytes: 11092