akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
const int N = 5 * 1000 + 100;
const int MOD = 1000000007;
const int oo = 1e9;

int n, x, y, sz[N], dp[N][N];
ll fact[N], inv[N];
vector<int> g[N], cen, v;

ll fast(ll a , ll b) {
	if (!b)return 1ll;
	ll res = fast(a, b / 2);
	res = (res * res) % MOD;
	if (b & 1)
		return (res * a) % MOD;
	return res;
}
ll nCk(ll n , ll k) {
	return ((fact[n] * inv[n - k]) % MOD * inv[k]) % MOD;
}

void dfs(int u , int p) {
	sz[u] = 1;
	int mx = 1;
	vector<int> ar;
	for (int i = 0; i < g[u].size(); ++i) {
		int v = g[u][i];
		if (v == p)continue;
		dfs(v, u);
		ar.pb(sz[v]);
		sz[u] += sz[v];
		mx = max(mx, sz[v]);
	}
	if (n - sz[u] > 0)
		ar.pb(n - sz[u]);
	mx = max(mx, n - sz[u]);
	if (2 * mx <= n) {
		v = ar;
		cen.pb(u);
	}
}
int calc(int idx , int rem) {
	if (idx == v.size())return !rem;
	int &ret = dp[idx][rem];
	if (ret != -1)return ret;
	ret = 0;
	for (int take = 0; take <= min(rem, v[idx]); ++take) {
		ret = (ret + 1ll * (((nCk(v[idx], take) * nCk(v[idx], take)) % MOD) * fact[take])%MOD* calc(idx + 1, rem - take)) % MOD;
	}
	return ret;
}
int main() {
	
	memset(dp, -1, sizeof dp);
	scanf("%d", &n);
	for (int i = 0; i < n - 1; ++i) {
		scanf("%d%d", &x, &y);
		g[x].pb(y);
		g[y].pb(x);
	}
	fact[0] = 1;
	inv[0] = fast(fact[0], MOD - 2);
	for (int i = 1 ; i <=  n ; ++i) {
		fact[i] = (fact[i - 1] * i) % MOD;
		inv[i] = fast(fact[i], MOD - 2);
	}
	dfs(1, -1);
	if (cen.size() == 2) {
		printf("%lld\n", (fact[n / 2]*fact[n / 2]) % MOD );
		return 0;
	}

	ll res = 0;
	for (int i = 1; i <= n ; ++i) {
		res = (res + (i % 2 == 1 ? 1 : -1) * (calc(0, i) * fact[n - i])%MOD + MOD) % MOD;
                
	}
	res = (fact[n]-res+MOD)%MOD;
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 102656
def c_exception_handling(N, A):
    max_from_left = [0] * N
    max_from_right = [0] * N

    for i in range(1, N):
        max_from_left[i] = max(A[i - 1], max_from_left[i - 1])
        max_from_right[N - i - 1] = max(A[N - i], max_from_right[N - i])

    ans = [max(a, b) for a, b in zip(max_from_left, max_from_right)]
    return '\n'.join(map(str, ans))

N = int(input())
A = [int(input()) for _ in range(N)]
print(c_exception_handling(N, A))

Measured memory_bytes: 29740
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl; cout << "       ";
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}

////////////////////////////////////////////////////////////////

int main(void) {
	int L, R, d;
	cin >> L >> R >> d;
	int ans = 0;
	for(int i=L; i<=R; i++){
		if(i % d == 0) ans++;
	}
	
	cout << ans << endl;
}


Measured memory_bytes: 3676
import sys
input = sys.stdin.readline


class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n  # 各要素の親要素の番号を格納するリスト

    def find(self, x):  # 要素xが属するグループの根を返す
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):  # 要素xが属するグループと要素yが属するグループとを併合する
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):  # 要素xが属するグループのサイズ（要素数）を返す
        return -self.parents[self.find(x)]

    def same(self, x, y):  # 要素x, yが同じグループに属するかどうかを返す
        return self.find(x) == self.find(y)

    def members(self, x):  # 要素xが属するグループに属する要素をリストで返す
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):  # すべての根の要素をリストで返す
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):  # グループの数を返す
        return len(self.roots())

    def all_group_members(self):  # {ルート要素: [そのグループに含まれる要素のリスト], ...}の辞書を返す
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def main():
    """
    <考察>
    (x, y)の組が与えられるが，親が一緒のところには自由に移動できる．
    UnionFind木で管理する．
    """
    n, m = map(int, input().split())
    p = list(map(int, input().split()))
    g = []
    for i in range(n):
        g.append((p[i] - 1, i))
    g.sort()  # p[i]でsort

    uf = UnionFind(n)
    for i in range(m):
        x, y = [int(i) - 1 for i in input().split()]
        uf.union(x, y)

    ans = 0
    for i in range(n):
        if uf.same(i, g[i][1]):
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 23448
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <ctime>
#include <functional>
#include <sstream>
#include <fstream>
#include <valarray>
#include <complex>
#include <queue>
#include <cassert>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define debug_flag 1
#else
	#define debug_flag 0
#endif

template <class T1, class T2 >
std::ostream& operator << (std::ostream& os, const pair<T1, T2> &p) 
{
	os << "[" << p.first << ", " << p.second << "]";
	return os;
}

template <class T >
std::ostream& operator << (std::ostream& os, const std::vector<T>& v) 
{
	os << "[";
	bool first = true;
	for (typename std::vector<T>::const_iterator it = v.begin(); it != v.end(); ++it)
	{
		if (!first)
			os << ", ";
		first = false;
		os << *it;
	}
	os << "]";
	return os;
}

#define dbg(args...) { if (debug_flag) { _print(_split(#args, ',').begin(), args); cerr << endl; } else { void(0);} }

vector<string> _split(const string& s, char c) {
	vector<string> v;
	stringstream ss(s);
	string x;
	while (getline(ss, x, c))
		v.emplace_back(x);
	return v;
}

void _print(vector<string>::iterator) {}
template<typename T, typename... Args>
void _print(vector<string>::iterator it, T a, Args... args) {
    string name = it -> substr((*it)[0] == ' ', it -> length());
    if (isalpha(name[0]))
	    cerr << name  << " = " << a << " ";
	else
	    cerr << name << " ";
	_print(++it, args...);
}

typedef long long int int64;

const int N = 505;

int n, m, d;
int mx[N][N];

void do_coloring() {
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      int ii = i + j + N * d;
      int jj = i - j + N * d;
      int x = ii / d;
      int y = jj / d;
      int xx = x % 2;
      int yy = y % 2;
      int color = (xx << 1) ^ yy;
      mx[i][j] = color;
    }
  }
}

char to_char(int x) {
  return "RYGB"[x];
}

void print() {
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      printf("%c", to_char(mx[i][j]));
    }
    printf("\n");
  }
}

int main()
{
#ifdef LOCAL
	freopen ("input.txt", "r", stdin);
#endif

  scanf("%d%d%d", &n, &m, &d);
  
  do_coloring();

  print();

	return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define Decimal fixed << setpresicion(20)


typedef long long ll;
typedef pair<ll, ll> P;

void prime_factor(ll n, map<ll, ll>& res) {
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n] = 1;
}

ll mypow(ll m, ll n) {
  ll ans = 1;
  while(n > 0) {
    if(n & 1) ans = (ans * m);
    m = (m * m);
    n >>= 1;
  }
  return ans;
}

int main()
{
  ll N, P; cin >> N >> P;
  map<ll, ll> mp;
  prime_factor(P, mp);
  ll ans = 1;
  for (auto e : mp) {
    if (e.SE >= N) ans *= mypow(e.FI,(e.SE/N));
  }
  cout << ans << endl;
  return 0;
}



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

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

  for (int i = 0; i < N; i++) {
    string X;
    cin >> X;
     
    if (X=="Y") {
      cout << "Four" << endl;
      break;}
    
    else if (i== N-1) {
      cout << "Three" << endl;}
    
   }
      
}

Measured memory_bytes: 3564
n = int(input())
import math
import numpy as np
t = []
b = n
# print(int(math.sqrt(n)))
for i in range(int(math.sqrt(n))):
    if b >= i+2:
        flag = True
        if b % (i + 2) == 0 and flag == True:
            flag = False
            t.append(0)
            while b % (i + 2) == 0:
                t[-1] += 1
                b /= (i+2)
                # print(i+2)
                # print(b)
    # print('a')
ans = 0
# print(b)
# print(t)
# exit()

tt = t

for i in range(len(t)):
    count = 1
    while t[i] >= count:
        ans += 1
        t[i] = t[i] - count
        count += 1

# for i in range(len(t)):
#     count = 1
#     while t[i]

if n != 1 and ans == 0:
    print('1')
    exit()

if n!= 1 and b != 1:
    ans += 1
# print(t)
print(ans)


Measured memory_bytes: 27156
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)*}
    };
}
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, 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")
    };
}

fn main() {
    input!{
        s: String
    };
    let mut former = "".to_string();
    let mut latter = "".to_string();
    for (i, c) in s.chars().enumerate() {
        if i < 2 {
            former += &*c.to_string();
        } else {
            latter += &*c.to_string();
        }
    }
    let former = former.parse::<i32>().unwrap();
    let latter = latter.parse::<i32>().unwrap();
    let canmmyy = if 0 < former && former < 13 { true } else {false};
    let canyymm = if 0 < latter && latter < 13 { true } else {false};
    if canyymm && canmmyy {
        println!("AMBIGUOUS");
    } else if !canyymm && !canmmyy {
        println!("NA");
    } else if canmmyy {
        println!("MMYY");
    } else {
        println!("YYMM");
    }


}



Measured memory_bytes: 4352
<?php 
$N = intval(trim(fgets(STDIN)));
$tmp = trim(fgets(STDIN));
$a = array_map("intval", explode(" ", $tmp));

$l = 0;
$left = [];
$left[0] = 0;
foreach($a as $value){
    $l += $value;
    array_push($left, $l);
}

$r = 0;
$right = [];
$right[0] = 0;
$r_a = array_reverse($a);
foreach($r_a as $value){
    $r += $value;
    array_push($right, $r);
}
$right = array_reverse($right);

$ans = abs($right[1] - $left[1]);
for($i = 2;$i<count($right)-1;$i++){
    if($ans > abs($right[$i] - $left[$i])){
        $ans = abs($right[$i] - $left[$i]);
    }
}

echo $ans . PHP_EOL;

Measured memory_bytes: 53732
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;
int main() {
	string A, B;	cin >> A >> B;
	if (A == B) {
		cout << "EQUAL" << endl;
		cin >> A;
		return 0;
	}
	if (A.size() > B.size()) {
		cout << "GREATER" << endl;
		cin >> A;
		return 0;
	}
	if (A.size() < B.size()) {
		cout << "LESS" << endl;
		cin >> A;
		return 0;
	}
	for (int i = 0; i < A.size(); ++i) {
		if (A[i] > B[i]) {
			cout << "GREATER" << endl;
			cin >> A;
			return 0;
		}
		if (A[i] < B[i]) {
			cout << "LESS" << endl;
			cin >> A;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_que<int> pque;//これは大きい順
//typedef priority_que<int, vector<int>, greater<int>> pque;//これは小さい順


int main(){
	int n;
	cin >> n;
	n++;
	printf("%d", n/2);

  return 0;
}


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

using namespace std;

template <typename T>
T gcd(T a, T b) {
  while (a) {
    b %= a;
    std::swap(a, b);
  }
  return b;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  int g = 0;
  for (int a : A) {
    g = gcd(g, a);
  }
  for (int a : A) {
    if (a < K) continue;
    if ((a - K) % g == 0) {
      cout << "POSSIBLE" << '\n';
      return 0;
    }
  }
  cout << "IMPOSSIBLE" << '\n';
  return 0;
}


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

int main(){
  ll n;
  cin>>n;
  ll gr[n+1];
  rep1(i, n){
    cin>>gr[n+1-i];}
  
  ll minp=2;
  ll maxp=2;
  rep1(i, n){
    if(maxp/gr[i]==minp/gr[i] && maxp%gr[i]!=0 && minp%gr[i]!=0){
      cout<<-1<<endl;
      return 0;}
    
    if(minp%gr[i]!=0){
      minp=((minp+gr[i])/gr[i])*gr[i];}
    if(maxp%gr[i]==0){
      maxp=maxp+gr[i]-1;}
    if(maxp%gr[i]!=0){
      maxp=(maxp/gr[i])*gr[i]+gr[i]-1;}
    
  }
  cout<<minp<<" "<<maxp<<endl;
    
return 0;
  
}

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


int main() {

    string a, b;
    cin >> a >> b;
    int num = stoi(a + b);
    for (ll i = 1; i < 1000; ++i) {
        if (i * i == num) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
def sum_digits(n):
  sum_ = 0
  while(n > 0):
    sum_ += (n % 10)
    n = (n // 10)
  return sum_
   
 
  
def main():
  n, a, b = map(int, input().strip().split())
  total = 0
  for i in range(1, n+1):
    tmp = sum_digits(i)
    
    if (tmp >= a) & (tmp <= b):
      total += i
  print(total)
 
    
if __name__=="__main__":
  main()

Measured memory_bytes: 3060
unittest
{
	assert( [
		"2 2",
		"*.",
		".*",
	].parse.expand.solve == "*.\n*.\n.*\n.*" );
	assert( [
		"1 4",
		"***.",
	].parse.expand.solve == "***.\n***." );
	assert( [
		"9 20",
		".....***....***.....",
		"....*...*..*...*....",
		"...*.....**.....*...",
		"...*.....*......*...",
		"....*.....*....*....",
		".....**..*...**.....",
		".......*..*.*.......",
		"........**.*........",
		".........**.........",
	].parse.expand.solve == ".....***....***.....\n.....***....***.....\n....*...*..*...*....\n....*...*..*...*....\n...*.....**.....*...\n...*.....**.....*...\n...*.....*......*...\n...*.....*......*...\n....*.....*....*....\n....*.....*....*....\n.....**..*...**.....\n.....**..*...**.....\n.......*..*.*.......\n.......*..*.*.......\n........**.*........\n........**.*........\n.........**.........\n.........**........." );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto hw = input.front.split.to!( long[] );
	auto css = new string[]( hw[ 0 ] );
	foreach( ref cs; css )
	{
		input.popFront;
		cs = input.front;
	}
	return tuple( css );
}

auto solve( string[] css )
{
	auto anss = new string[]( css.length * 2 );
	
	for( auto i = 0L; i < css.length; i++ )
	{
		anss[ i * 2     ] = css[ i ];
		anss[ i * 2 + 1 ] = css[ i ];
	}
	
	return anss.join( "\n" );
}


Measured memory_bytes: 380
from collections import deque

n = int(input())
p = list(map(str,input().split()))
q = list(map(str,input().split()))

p = int(''.join(p))
q = int(''.join(q))

n_list = []
que = deque([[0,[i+1 for i in range(n)]]])
num = 0
temp_list = []

while len(que) != 0:
    temp = que.popleft()
    if len(temp[1]) == 0:
        n_list.append(temp[0])
        continue
    for i in range(len(temp[1])):
        num = 0
        temp_list = []
        for j in range(len(temp[1])):
            temp_list.append(temp[1][j])
        num += temp_list[i] + temp[0]*10
        temp_list.pop(i)
        que.append([num,temp_list])

for i in range(len(n_list)):
    if n_list[i] == p:
        a = i
    if n_list[i] == q:
        b = i

print(abs(b-a))


Measured memory_bytes: 13220
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep2(i, m, n) for(int i=(int)m; i<(int)n; i++)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
const ll INF = 100100100100;
const int MOD = 1000000007;
const ld EPS = 1e-10;

int main(){
  string S, T; cin >> S >> T;
  cout << T + S << endl;
  return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;


#define pb push_back
#define ff first
#define ss second
#define INF int(3e9)
#define BIG_INF ll(9e18)
#define SIZE 100001
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define len(v) int((v).size())
#define sqr(x) (x) * (x)
#define cube(x) (x) * (x) * (x)
#define filein freopen("input.txt", "r", stdin)
#define fileout freopen("output.txt", "w", stdout);


ll binpow(ll a, ll b, ll MOD = BIG_INF)
{
    ll res = 1;

    while(b)
    {
        if(b & 1)
            res *= a;
        a *= a;
        b >>= 1;
        a %= MOD;
        res %= MOD;
    }

    return res % MOD;
}

const ll mod = 1e9 + 7;

int T = 1;
ll n, m;
string s;


void solve()
{
    cin >> n >> m;

    vector<ll> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    ll sum = 0;
    sort(rall(a));
    for(ll i: a) sum += i;


    sum = ceil((ld)sum / (m * 4));

//    cout << sum << '\n';

    for(ll i: a)
    {
        if(i < sum || m == 0) break;
        m--;
    }

    if(m == 0) cout << "Yes";
    else cout << "No";


    return;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
//    filein;fileout;

//    cin >> T;

    while(T--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3628
N, M, Q = map(int, input().split())
abcd = []
for _ in range(Q):
    abcd.append(list(map(int, input().split())))
import itertools
ans = 0
for v in itertools.combinations_with_replacement(list(range(1, M+1)), N):
    point = 0
    for i in range(Q):
        a, b, c, d = abcd[i]
        if v[b-1] - v[a-1] == c:
            point += d
    ans = max(ans, point)
print(ans)












Measured memory_bytes: 68068
N,M = list(map(int,input().split(" ")))

xyz =[]
for i in range(N):
    xyz.append(list(map(int,input().split(" "))))
a=[[] for x in range(8)]

for i,abc in enumerate(xyz):
    a[0].append(abc[0]+abc[1]+abc[2])
    a[1].append(abc[0]+abc[1]-abc[2])
    a[2].append(abc[0]-abc[1]+abc[2])
    a[3].append(abc[0]-abc[1]-abc[2])
    a[4].append(-abc[0]+abc[1]+abc[2])
    a[5].append(-abc[0]+abc[1]-abc[2])
    a[6].append(-abc[0]-abc[1]+abc[2])
    a[7].append(-abc[0]-abc[1]-abc[2])
ansSet=[]
for i in range(8):
    ansSet.append(sum(sorted(a[i],reverse=True)[:M]))
print(max(ansSet))


Measured memory_bytes: 3700
import java.util.*;
public class Main {
    public static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
    	int i, j, k;
    	int tp = 0;
    	int hp = 0;
    	int n = sc.nextInt();
    	
    	for(i = 0; i < n; i++) {
    		String taro = sc.next();
    		String hana = sc.next();
    		
    		if(taro.compareTo(hana) > 0) tp += 3;
    		else if(taro.compareTo(hana) < 0) hp += 3;
    		else {
    			tp++;
    			hp++;
    		}
    	}
    	System.out.println(tp + " " + hp);
    }
}


Measured memory_bytes: 30040
import java.util.Scanner;


public class Main {
	public static void main(String []args){
		//????????£?????????????????????
		Scanner sc = new Scanner(System.in);
		//?????°?????£?¨?
		int i = 1;

		//??°?????????
		while(true){

		//????????£??????????????§????????????
		int num = sc.nextInt();
		//?????¶???0?????????????????´??? ??????
		if(num == 0){
			break;
		}
		//??¨???
		System.out.println("Case " + i + ": " + num);
		i++;
		}
	}
}

Measured memory_bytes: 41812
#include <iostream>
#define UNVISITED -1
#define _ ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0), cout.precision(15);
using namespace std;

typedef long long int64;
typedef pair<int, int> ii;

int main(){ _
  int x1, y1, x2, y2;   cin >> x1 >> y1 >> x2 >> y2;
  int deltax = x1 - x2, deltay = y1 - y2;
  int x3 = x2 + deltay, y3 = y2 - deltax;
  int x4 = x1 + deltay, y4 = y1 - deltax;
  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
  return 0;
}


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

int main() {
  int n, sum;
  cin >> n;
  sum = 0;
  
  rep(i,n) {
    int l, r;
    cin >> l >> r;
    
  	sum += r-l+1;
  }
  cout << sum << endl;
}

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

int main(){
  char S[200001];
  char T[200001];
  cin >> S >> T;
  
  int64_t l = strlen(S);
  int count = 0;
  for(int i=0; i<l; i++){
    if(S[i] != T[i]){
      count++;
    }
    else{}
  }
    
  cout << count << endl;
  return 0;
}
  

Measured memory_bytes: 4020
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
class Simple {
    string N;
    void Solve() {
        N = io.String;
        Console.WriteLine(N.Contains("9")?"Yes":"No");
    }
    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) { new Simple().Stream(); }
    void Stream() {
        Solve();
        io.writeFlush();
    }
}
class SimpleIO {
    string[] nextBuffer;
    int BufferCnt;
    char[] cs = new char[] { ' ' };
    StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
    public SimpleIO() {
        nextBuffer = new string[0];
        BufferCnt = 0;
        Console.SetOut(sw);
    }
    public string Next() {
        if (BufferCnt < nextBuffer.Length)
            return nextBuffer[BufferCnt++];
        string st = Console.ReadLine();
        while (st == "")
            st = Console.ReadLine();
        nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        BufferCnt = 0;
        return nextBuffer[BufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void writeFlush() { Console.Out.Flush(); }
}


Measured memory_bytes: 11092
#include <assert.h>
#include <limits.h>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cout << i << "\n"

//const ll MOD = 998244353;
const ll MOD = 1e9+7;
 
int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll n,m;
  std::cin>>n>>m;
  std::vector<P> s;

  rep(i,0,m){
    ll a,b;
    std::cin>>a>>b;
    s.push_back(P(b,a));
  }  

  std::sort(all(s));

  ll ans=0,last=-1;

  rep(i,0,m){
    if(s[i].second>last){
      ans++;
      last=s[i].first-1;
    }
  }

  std::cout<<ans;

  return 0;
}

Measured memory_bytes: 2420
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
int n,K;
int f[100][100][100];
struct area{ll x1,x2,y1,y2,d1,d2;};
vector<area> all;
set<ll> x,y,d;
map<int,ll> tx,ty,td;
int main()
{
	cin >> n >> K;
	for(int i=0;i<n;i++)
	{
		area in;
		cin >> in.x1 >> in.y1 >> in.d1 >> in.x2 >> in.y2 >> in.d2;
		all.pb(in);
		x.insert(in.x1);
		x.insert(in.x2);
		y.insert(in.y1);
		y.insert(in.y2);
		d.insert(in.d1);
		d.insert(in.d2);
	}
	int nx=x.size(),ny=y.size(),nd=d.size();
	set<ll>::iterator it;
	int p=0;
	for(it=x.begin();it!=x.end();it++){tx[p++]=*it;}
	p=0;
	for(it=y.begin();it!=y.end();it++){ty[p++]=*it;}
	p=0;
	for(it=d.begin();it!=d.end();it++){td[p++]=*it;}
	for(int i=0;i<all.size();i++)
	{
		for(int j=0;j<nx-1;j++)
		{
			for(int k=0;k<ny-1;k++)
			{
				for(int l=0;l<nd-1;l++)
				{
					if(all[i].x1<=tx[j]&&all[i].x2>tx[j]&&all[i].y1<=ty[k]&&all[i].y2>ty[k]&&all[i].d1<=td[l]&&all[i].d2>td[l]){f[j][k][l]++;/*cout << "・∴'、-=≡ ≡ (っ'ヮ'c)ウッヒョ アアアアアアｗｗｗｗｗ" << endl;*/}
				}
			}
		}
	}
	ll ans=0ll;
	for(int i=0;i<nx-1;i++)
	{
		for(int j=0;j<ny-1;j++)
		{
			for(int k=0;k<nd-1;k++)
			{
				if(f[i][j][k]>=K)
				{
					ans+=(tx[i+1]-tx[i])*(ty[j+1]-ty[j])*(td[k+1]-td[k]);
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4920
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int n;
  cin >> n;
  int h[n];
  REP(i, n) cin >> h[i];
  int ans = 0;
  REP(i,n-1){
    int p=0;
    while(h[i]>=h[i+1]){
      i++;
      p++;
      if(i>n-2) break;
    }
    ans = max(ans,p);
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
function main()
  n,m=parse.(split(readline()))
  if n==1
    print(1*Int(m==0))
    return 0
  end
  check=ones(n)
  mod=1000000007
  for i=1:m
    check[parse(Int,readline())]=0
  end
  dp=zeros(n+3)
  f(i::Int)=dp[i]*check[i]
  dp[1]=check[1]*1
  dp[2]=(dp[1]+1)*check[2]
  if n<3
    print(Int(dp[n]))
    return 0
  end
  for i=3:n
    dp[i]=check[i]*(dp[i-1]+dp[i-2])%mod
  end
  print(Int(dp[n]))
end
main()

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

int main(){
    long long dp[110][25];
    int sum[110];
    int n;
    cin >> n;
    for(int i=1; i <= n; i++) cin >> sum[i];
    memset(dp, 0, sizeof(dp));

    dp[1][sum[1]] = 1;
    for(int i=2; i < n; i++){
        for(int j=0; j <= 20; j++){
            if(j+sum[i] <= 20)dp[i][j+sum[i]] += dp[i-1][j];
            if(0 <= j-sum[i]) dp[i][j-sum[i]] += dp[i-1][j];
        }
    }
    cout << dp[n-1][sum[n]] << endl;
}

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

int main() {
  int n;
  cin>>n;
  vector<int> a(n);
  rep(i,n) cin>>a[i];
  ll ans=0;
  rep(i,n){
    while(a[i]%2==0){
      a[i]/=2;
      ans++;
    }
  }
  cout<<ans<<endl;
}//素因数2の数

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

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

	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for(int &ai : a)
		cin >> ai;

	vector<bool> win(k + 1);
	for(int i = 1; i <= k; ++i)
		for(int ai : a)
			if(ai <= i && win[i - ai] == false)
				win[i] = true;

	cout << (win[k] ? "First" : "Second") << '\n';
}


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

int main() {
    
	int i,j,n,k,m;
	cin>>n>>m;
	int w[n];
	long int p[n];
	for(i=0;i<n;i++)
	{
	    cin>>w[i]>>p[i];
	}
	long int dp[n+1][m+1];
	for(i=0;i<=n;i++)
	{
	    for(j=0;j<=m;j++)
	    {
	        if(i==0||j==0)
	            dp[i][j]=0;
	       
	       else if(w[i-1]<=j)
	       dp[i][j]=max(p[i-1]+dp[i-1][j-w[i-1]],dp[i-1][j]);
	        else
	        dp[i][j]=dp[i-1][j];
	        
	    }
	}
	cout<<dp[n][m];
	
	return 0;
}

Measured memory_bytes: 79104
import java.io.*;
import java.util.*;

class Main {

    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        
        int n = sc.nextInt();

        double s=0;

        int[] A = new int[100];
        for(int i=0;i<n;i++){
            s += 1.0/sc.nextInt();
        }

        System.out.println(1/s);

    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;
    
        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }
    
        int nextInt() {
            return Integer.parseInt(next());
        }
    
        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 21076
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

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

#define HOGE 5000
#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define sz size()


int main(){
    int n;
    cin>>n;
    rep(i,n){
        double x[2],y[2],r[2];
        rep(j,2){
            cin>>x[j]>>y[j]>>r[j];

        }
        double len=sqrt( pow(abs(x[0]-x[1]),2) + pow(abs(y[0]-y[1]),2) );

        if( r[0]+r[1]<len ){
            cout<<"0"<<endl;
        }
        else{
            if(len+r[0]<r[1])cout<<"-2"<<endl;
            else if(len+r[1]<r[0])cout<<"2"<<endl;
            else cout<<"1"<<endl;
            }
        }
    return 0;
}

Measured memory_bytes: 1224
import fractions
from functools import reduce

MOD = 10**9 + 7


def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)


def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a, x0, y0


def modinv(a, m):
    g, x, y = xgcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m


def pathes(x, y):
    xf = None
    yf = None
    xyf = None
    temp = 1
    for i in range(1, x + y + 1):
        temp = (temp*i) % MOD
        if i == x:
            xf = temp
        if i == y:
            yf = temp
        if i == x + y:
            xyf = temp

    return xyf * modinv(xf * yf % MOD, MOD)


def main():
    r1, c1, r2, c2 = map(int, input().split())

    a = (pathes(r1, c1) - 1) % MOD
    b = (pathes(r1, c2 + 1) - 1) % MOD
    c = (pathes(r2 + 1, c1) - 1) % MOD
    d = (pathes(r2 + 1, c2 + 1) - 1) % MOD

    print((d - c - b + a) % MOD)


main()


Measured memory_bytes: 5044
import numpy as np
from numpy.fft import fft
from numpy.fft import ifft
class FFT:
  def exe(s, A, B):
    N, M = 1, len(A) + len(B) - 1
    while N < M: N <<= 1
    A, B = s.arrN(N, A), s.arrN(N, B)
    A = fft(A) * fft(B)
    A = ifft(A).real[:M] + 0.5
    return list(map(int, A))
  def arrN(s, N, L):
    return np.zeros(N) + (L + [0] * (N - len(L)))

N, M = list(map(int, input().split()))
A = list(map(int, input().split()))

MAX = max(A)
L = [0] * (MAX + 1)
for i in A:
  L[i] += 1

f = FFT()
L = f.exe(L, L)

ans = 0
for i in range(len(L) - 1, -1, -1):
  if L[i] < M:
    ans += i * L[i]
    M -= L[i]
  else:
    ans += i * M
    break

print(ans)

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

using ll  = long long;
using pii = pair<int,int>;
#define dbg(n) cout<<'\n'<<#n<<" is "<<n<<'\n';
#define pb push_back
#define all(v) v.begin(), v.end()
#define cs(i) cout<<"Case "<<i+1<<": \n"; 
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);

const int N   = 1e5+5;
const int INF = 0x7fffffff;

int h[N];
int dp[N];

int main(){
    int n,t,hold=0;

    cin>>n;
    for(int i=0;i<n;i++)
        cin>>h[i];
    
    memset(dp,-1,sizeof dp);
    dp[0]=0;
    dp[1]=abs(h[0]-h[1]); //dbg(dp[0]) dbg(dp[1]) 
    hold=dp[1];
    for(int i=2;i<n;i++){
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2])); //dbg(dp[i])
    }
    cout<<dp[n-1]<<endl;;
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main {
    public static void main(String args[]){
        Scanner s=new Scanner(System.in);
        int T=s.nextInt();
        for(int i=0;i<T;i++){
            int a=s.nextInt();
            int b=s.nextInt();
            int c=s.nextInt();
            if(a*a==b*b+c*c||a*a+b*b==c*c||a*a+c*c==b*b)System.out.println("YES");
            else System.out.println("NO");
        }
    }
}
//by TTTMongolia 11/05/2012

Measured memory_bytes: 13000
#include <bits/stdc++.h>
#define INF 100000000
using namespace std;

int n,a[200010];

bool C(int x){
	int d[2] = {INF,INF};
	for(int i = n - 1;i < n * 2 - 2;i++){
		if(i == n * 2 - 2 || (a[i] >= x) == (a[i + 1] >= x)){
			d[a[i] >= x] = i - n + 1;
			break;
		}
	}
	for(int i = n - 1;i >= 0;i--){
		if(!i || (a[i] >= x) == (a[i - 1] >= x)){
			d[a[i] >= x] = n - 1 - i;
			break;
		}
	}
	return d[0] > d[1];
}

signed main(){
	cin >> n;
	for(int i = 0;i < 2 * n - 1;i++) cin >> a[i];
	int low = 0,up = 2 * n;
	while(up - low > 1){
		int mid = (low + up) / 2;
		if(C(mid)) low = mid;
		else up = mid;
	}
	cout << low << endl;
	return 0;
}

Measured memory_bytes: 1024
#!/usr/bin/env python3

import sys
import numpy as np


def input():
    return sys.stdin.readline().rstrip()


def main():
    # n, k = map(int, sys.stdin.buffer.readline().split())
    n, k = map(int, input().split())

    # warps = list(map(int, sys.stdin.buffer.readline().split()))
    warps = list(map(int, input().split()))
    warps = [0] + warps
    warps = np.array(warps, dtype=int)

    dp = np.zeros((k.bit_length() + 1, n + 1), dtype=int)

    dp[0, :] = warps

    for h in range(1, len(dp)):
        dp[h] = dp[h - 1][dp[h - 1]]

    node = 1
    # for i in reversed(range(k.bit_length())):
    for i in range(k.bit_length(), -1, -1):
        if k >> i & 1:
            node = dp[i][node]

    print(node)


main()


Measured memory_bytes: 126476
#include<bits/stdc++.h>
#define pb push_back
#define fr first
#define sc second
#define all(x) x.begin(), x.end()
#define skip continue
#define NAME "code"

using namespace std;
 
typedef long long ll;
typedef long double ld;

const int maxn = 2e5 + 10;
const int inf = 1e6;
const ll mod = 2e3 + 7;
const ld pi = acos(-1);

ll n, a[maxn], ans = 1, cnt = 1, K, C;

int main(){

cin >> n >> C >> K;

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

sort(a, a + n);
int last = a[0];
for(int i = 1; i < n; ++i){
	if(last + K < a[i] || cnt == C){
		ans++;
		last = a[i];
		cnt = 1;
	}
	else cnt++;
}

cout << ans;

return 0;
}

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

int main() {
    int n;
    string s;
    cin >> n >> s;
    int ans = INF;
    int c = 0;
    for(int i = 1; i < n; i++){
        if(s.at(i) == 'E') c++;
    }
    ans = min(ans, c);
    for(int i = 1; i < n; i++){
        if(s.at(i) == 'E') c--;
        if(s.at(i-1) == 'W') c++;
        ans = min(ans, c);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 900
nk = [int(i) for i in input().split()]
if nk[0] % 2 == 0:
    if nk[0]/2 >= nk[1]:
        print("YES")
    else:
        print("NO")
else:
    if (nk[0]+1)/2 >= nk[1]:
        print("YES")
    else:
        print("NO")

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);

/* -----  2019/04/04  Problem: ABC 045 D / Link: http://abc045.contest.atcoder.jp/tasks/abc045_d  ----- */


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

	LL H, W, N; cin >> H >> W >> N;
	map<PLL, LL>m;
	int DY[] = { 1, -1, 0, 0, 1, -1, 1, -1,0 };
	int DX[] = { 0, 0, 1, -1, 1, 1, -1, -1,0 };
	FOR(i, 0, N) {
		int y, x; cin >> y >> x;
		y--, x--;
		auto in = [](int a, int b) {
			return 0 < a && a < b-1;
		};
		FOR(k, 0, 9) {
			int ny = y + DY[k], nx = x + DX[k];
			if (in(ny, H) && in(nx, W)) {
				m[PLL(ny, nx)]++;
			}
		}
	}
	VL ans(10, 0);
	ans.front() = (W-2) *(H-2);
	for (auto it : m) {
		++ans[it.second];
		--ans.front();
	}
	for (auto it : ans) {
		cout << it << endl;
	}

	return 0;
}


Measured memory_bytes: 56576
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int A, B;
    cin >> A >> B;
    cout << ((A - 1) * (B - 1)) << endl;
    return 0;
}

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

void solve(std::istream &in, std::ostream &out);

int main() {
#ifdef LOCAL
  freopen("../IO/f.in", "r", stdin);
//  freopen("../IO/f.out", "w", stdout);
#else
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
#endif
  solve(std::cin, std::cout);
  return 0;
}


void solve(std::istream &in, std::ostream &out) {
  int64_t n;
  in >> n;
  vector<int64_t> ans;
  ans.push_back(n);
  if (n > 2) ans.push_back(n - 1);
  for (int64_t i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      int64_t a=n;
      while (a % i == 0) a /= i;
      if (a % i == 1) {
        ans.push_back(i);
      }
    } else if (n % i == 1) {
      ans.push_back(i);
      ans.push_back((n - 1) / i);
    }
  }
  sort(ans.begin(), ans.end());
  ans.resize(unique(ans.begin(), ans.end()) - ans.begin());
  out << ans.size() << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define debugg(x) cout<<#x <<":"<< x << endl;
typedef  long long ull;
using namespace std;
#define  INF 1e10
int main()
{
     int N;
     cin >> N;
     int T[N+5];
     for(int i=1 ; i<=N ; i++)
     {
         cin >> T[i];
     }
     int dp[N+5];
     int j;
     dp[1]=0;
     for(int i=2  ; i<=N ; i++)
     {
         if(i==2)
         {
             dp[i]= abs(T[i] -T[i-1]);
         }
         else
         {
             int res1 = abs(T[i] -T[i-1]) + dp[i-1];
             int res2 = abs(T[i] -T[i-2]) + dp[i-2];
             dp[i] = min(res1 , res2);
         }

     }

     cout << dp[N] << endl;



    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n, y;
        n = input.nextInt();
        if (n % 2 == 0) {
            System.out.println(n);
        } else {
            System.out.println(n * 2);
        }
    }
}

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

const int D = 60;

vector<int> search(int n, const vector<int> &v)
{
    vector<int> res(n);
    for(int i=0; i<n; i++)
    {
        res.at(i) = v.at(v.at(i));
    }
    return res;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    ll k;
    cin >> n >> k;
    vector<int> as(n);
    for(int i=0; i<n; i++)
    {
        int a;
        cin >> a;
        as.at(i) = a - 1;
    }

    vector<vector<int>> mp(D);
    mp.at(0) = as;
    for(int i=1; i<D; i++)
    {
        mp.at(i) = search(n, mp.at(i-1));
    }

    int cp = 0;
    for(int i=D-1; i>=0; i--)
    {
        ll l = 1ll << i;
        if(l <= k)
        {
            cp = mp.at(i).at(cp);
            k -= l;
        }
    }
    cout << cp + 1 << '\n';

    return 0;
}

Measured memory_bytes: 50988
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

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

using namespace std;
typedef long long ll;

int main()
{
    // Input
    string s, t;
    cin >> s;
    cin >> t;

    int ans = t.length();

    rep(i, s.length() - t.length() + 1) {
        int diff = 0;
        rep(j, t.length()) {
            if (s[i + j] != t[j]) {
                diff++;
            }
        }
        ans = min(diff, ans);
    }
    cout << ans;

    return 0;
}


Measured memory_bytes: 3168
fun main(args: Array<String>) {
    val (n,k) = readLine()!!.split(" ").map { it.toInt() }
    val points = MutableList(n) { 0 }
    for (i in 0 until k) {
        val d = readLine()!!.toInt()
        readLine()!!.split(" ").map { it.toInt() - 1 }.forEach{ points[it]++ }
    }
    println(points.count { it == 0 })
}



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

int main(){
	string a,b,c;
	cin>>a>>b>>c;
	if(a[a.size()-1]==b[0]&&b[b.size()-1]==c[0]){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
	return 0;
}

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

using namespace std;

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

    int n;
    cin >> n;

    int a[n], number = 1, k = 0;
    for(int i=0; i<n; i++){
        cin >> a[i];
        if(a[i] == number){
            k++;
            number++;
        }
    }

    cout << (n-k < n ? (n-k) : -1)  << "\n";


    return 0; 
} 

Measured memory_bytes: 1024
// luogu-judger-enable-o2
#include<bits/stdc++.h>
using namespace std;
long long n,a[100002],z,zs;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
      cin>>a[i];
    sort(a+1,a+n+1);
    z=1;
    for(int i=2;i<=n;i++)
    {
        if(a[i]==a[i-1])z=(z+1)%2;
        else zs+=z,z=1;
    }
    if(z%2)
        zs++;
    cout<<zs<<endl;
    return 0;
}

Measured memory_bytes: 1024
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    static long fib_recur(int n){
        //TLE
            if (n==0){
                return 1;
            }else if(n==1){
                return 1;
            }else{
                return fib(n-1)+fib(n-2);
            }
        }
    static long fib(int n){
        if (n==0) return 1;
        else if (n==1) return 1;
        
        long val = 2;
        long val_pre = 1;
        long val_prepre = 1; 
        for (int i = 2; i < n; i++){
            long temp = val_pre;
            val_pre = val;
            val_prepre = temp;
            val = val_pre + val_prepre;
        }
        return val;
    }
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        System.out.println(fib(n));
    }
}

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

using namespace std;
using ll = long long int;
using P = pair<int, int>;

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

int main(void){

    string str;
    cin >> str;

    if(str.back()-'0' == 2 || str.back()-'0' == 4 || str.back()-'0' == 5 || str.back()-'0' == 7 || str.back()-'0' ==  9) cout << "hon" << endl;
    else if(str.back()-'0' == 0 || str.back()-'0' == 1 || str.back()-'0' == 6 || str.back()-'0' == 8) cout << "pon" << endl;
    else cout << "bon" << endl;

    return 0;
}


Measured memory_bytes: 3596
//package atcoder.beginner_178;

import java.io.*;
import java.util.StringTokenizer;

public class Main {

    public static void main (String[] args) throws Exception {

        String s = "0";

//        br = new BufferedReader(new StringReader(s));
        br = new BufferedReader(new InputStreamReader(System.in));
        bw = new BufferedWriter(new OutputStreamWriter(System.out));

        rl(); int N = nin();
        bw.write((N^1) + "\n");
        bw.flush();
    }

    static BufferedReader br; static BufferedWriter bw; static StringTokenizer st;
    static void rl() throws Exception{ st = new StringTokenizer(br.readLine()); }
    static long nlo(){ return Long.parseLong(st.nextToken()); }
    static int nin(){ return Integer.parseInt(st.nextToken()); }
    /*private static void te(){}*/
    static double ndo(){ return Double.parseDouble(st.nextToken()); }
    static char[] nca(){ return st.nextToken().toCharArray(); }
}


Measured memory_bytes: 36488