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

using namespace std;

char a[3003], b[3003], ans[3003];

int dp[3003][3003];

int main() {
        scanf("%[^\n]\n%[^\n]", a, b);
        int n = strlen(a), m = strlen(b);
        for(int i = 1; i <= n; i++)
            for(int j = 1; j <= m; j++)
                dp[i][j] = (a[i - 1] == b[j - 1]) ? dp[i - 1][j - 1] + 1 : max(dp[i - 1][j], dp[i][j - 1]);

        int len = dp[n][m], i = n, j = m;
        ans[len] = '\0';
        while(i && j) {
            if(a[i - 1] == b[j - 1]) {
                ans[--len] = a[--i]; --j;
            } else {
                if(dp[i - 1][j] > dp[i][j - 1]) --i;
                else  --j;
            }
        }
        printf("%s", ans);


}



Measured memory_bytes: 35456
#include <bits/stdc++.h>
#define N 500005
using namespace std;
char str[N];
int n;
int l[N];
int dp[N];
void Init()
{
	scanf("%d",&n);
	scanf("%s",str+1);
	l[0]=0;
	for(int i=1;i<=n;i++)
	{
		if(str[i]=='1')l[i]=l[i-1];
		else l[i]=i;
	}
}
void Solve()
{
	dp[0]=0;
	for(int i=1;i<=n;i++)
	{
		dp[i]=dp[i-1];
		if(str[i]=='1')
		{
			if(str[i-1]=='0' and str[i-2]=='1')
			{
				dp[i]=max(dp[i],dp[l[i-2]]+(i-2)-l[i-2]);
				dp[i]=max(dp[i],dp[l[i-2]+1]+(i-2)-(l[i-2]+1));
			}
			else if(l[i]>1 and str[l[i]-1]=='1')
			{
				dp[i]=max(dp[i],dp[l[i]-2]+i-l[i]);
			}
		}
	}
}
void Print()
{
	printf("%d\n",dp[n]);
}
int main()
{
    Init();
    Solve();
	Print();
	//printf("%d\n",dp[-1]);
	return 0;
}

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

int N, K;
int A[5001];
int Asum[5002];

void insertionSort(int g) {
	for (int i = g; i < N; i++) {
		int v = A[i];
		int j = i - g;

		while (j >= 0 && A[j] > v) {
			A[j + g] = A[j];
			j -= g;
		}
		A[j + g] = v;
	}
}

void shellSort() {
	vector<int>G; G.reserve(10);
	for (int h = 1;;) {
		if (h > N)break;
		G.push_back(h);
		h = 3 * h + 1;
	}

	for (int i = G.size() - 1; i >= 0; i--) {
		insertionSort(G[i]);
	}
}

int BinarySearch(int max, int right) {
	int l = 0, r = right;

	while(A[r - 1] < max) {
		--r;
		max -= A[r];
		if (r == 0)return right;
	}

	int m;
	while (l < r) {
		m = (l + r) / 2;

		if (A[m] < max)l = m+1;
		else r = m;
	}

	if (r == 0)return 0;

	return BinarySearch(max, r);
}

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

	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	shellSort();

	cout << BinarySearch(K, N) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <sstream>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <vector>

using namespace std;

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

#define PB push_back
#define MP make_pair

#define FOR(prom, a, b) for(int prom = (a); prom < (b); prom++)
#define FORD(prom, a, b) for(int prom = (a); prom > (b); prom--)
#define FORDE(prom, a, b) for(int prom = (a); prom >= (b); prom--)
#define R1(a) do{scanf("%d", &(a));}while(0)
#define R2(a, b) do{scanf("%d%d", &(a), &(b));}while(0)
#define R3(a, b, c) do{scanf("%d%d%d", &(a), &(b), &(c));}while(0)
#define SV(vec) do{int s_v_;scanf("%d", &(s_v_));vec.PB(s_v_);}while(0)
#define ALL(vec) (vec).begin(), (vec).end()
#define MM(co, cim) memset((co), (cim), sizeof((co)))
#define DEB(x) cerr << ">>> " << #x << " : " << x << endl;
#define INF   1000000007
#define INFLL 1000000000000000007LL

int s, w;

int main ()
{
  R2(s, w);
  printf("%ssafe\n", w >= s ? "un" : "");
  return 0;
}


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

using namespace std;

typedef long long int ll;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

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

    ll x;
    cin >> x;

    ll ans = 0;
    ans+=2*(x/11);
    x%=11;

    if(x<=6 && x)
    {
        cout << ans+1 << endl;
    }    

    else if(x>6)
    {
        cout << ans+2 << endl;
    }

    else
    {
        cout << ans << endl;
    }
    

    return 0;
}

Measured memory_bytes: 256
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 100000001;
ll t[100010][50];
const ll mod = 1000000007;
void Reconciled() {
	
	int x, y;
	cin >> x >> y;
	int t[13] ={-1,1,3,1,2,1,2,1,1,2,1,2,1};
	if (t[x] == t[y])
	{
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

}

int main() {
	Reconciled();

	return 0;
}



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

#define __STDC_FORMAT_MACROS
#define p64 PRId64

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define ALL(f, x, ...)                                                         \
    ([&] (decltype ((x)) ALL) {                                                \
        return (f) (begin (ALL), end (ALL), ##__VA_ARGS__);                    \
    }) (x)

using namespace std;
using ll = int64_t;

int main() {
    int N = 3;
    vector<int> A (N, 0);
    REP (i, N) cin >> A[i];
    cout << (22 <= ALL (accumulate, A, 0) ? "bust" : "win") << endl;
    return 0;
}


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

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

	int h,w,n;

	cin >> h;
	cin >> w;
	cin >> n;

	cout << min(ceil(n*1.0/h),ceil(n*1.0/w)) << '\n';

	return 0;
}

Measured memory_bytes: 256
def sq(a, b, mod):  # aのb乗を剰余,kは初期値#20191116-D-Knight
    if b == 0:
        return 1
    elif b % 2 == 0:
        return sq(a, b // 2, mod)**2 % mod
    else:
        return sq(a, b - 1, mod) * a % mod


def nCk(n, k, mod=10 ** 9 + 7):
    x = max(k, n - k)
    y = min(k, n - k)
    kkai = 1
    for i in range(2, y + 1):
        kkai = (kkai * i) % mod
    nkkai = 1
    for i in range(x + 1, n + 1):
        nkkai = (nkkai * i) % mod
    answer = sq(kkai, mod - 2, mod) * nkkai % mod
    return answer

mod = 10**9+7
n, a, b = map(int, input().split())

def modpow(x, y):
    res = 1
    while y > 0:
        if y & 1:
            res = res*x % (10**9+7)
        x = x*x%(10**9+7)
        y >>= 1
        y = int(y)
    return res
ans = 0
ans -= nCk(n, b)
ans -= nCk(n, a)
ans -= 1
ans += modpow(2, n)
print((ans+10**9+7)%(10**9+7))

Measured memory_bytes: 38768
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] h = new int[n][3];
        int[][] dp = new int[n][3];

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 3; j++) {
                h[i][j] = sc.nextInt();
                dp[i][j] = Integer.MIN_VALUE;
            }
        }

        dp[0][0] = h[0][0];
        dp[0][1] = h[0][1];
        dp[0][2] = h[0][2];

        for (int i = 1; i < n; i++) {
            for (int j = 0; j < 3; j++) {
                for (int k = 0; k < 3; k++) {
                    if (k != j) {
                        dp[i][j] = Math.max(dp[i][j], dp[i - 1][k] + h[i][j]);
                    }
                }
            }
        }

        int max = Math.max(dp[n - 1][0], dp[n - 1][1]);
        System.out.println(Math.max(max, dp[n - 1][2]));

    }
}


Measured memory_bytes: 104512
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

int32_t main()
{
  uint32_t num, val;
  cin >> num;

  uint32_t total = 0;
  uint32_t min_not_10_times = UINT32_MAX;
  for (uint32_t i = 0; i < num; i++) {
    cin >> val;
    total += val;
    if ((val % 10) != 0) {
      min_not_10_times = min(min_not_10_times, val);
    }
  }

  if ((total % 10) == 0) {
    if (min_not_10_times == UINT32_MAX) {
      cout << "0" << endl;
    } else {
      cout << total - min_not_10_times << endl;
    }
  } else {
    cout << total << endl;
  }

  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Mon Sep  7 00:38:11 2020

@author: liang
"""

"""
＜D - Multiple of 2019>
【方針】
a = b(mod2019) => a - b は　2019の倍数
余りが等しいグループの組み合わせの総数が解になる。
既に2019の倍数であるものは単体で成立するため、[0]のカウントを一つあげておく


＜累積和＞
【計算量削減】
大きな数を使わない　⇒　mod を使う
tmp += 7 * 100000000  => 7 * ( 2019*N + α) => 7 * α　と同じ
　　⇒　累乗(10**N) に  mod をかけると良い

100000000 + γ => (2019*N + β) + γ => β + γ と同じ
　⇒　累積和　に　mod をかけると良い
 
 for文で１文字ずつ足し算していくことで実装可能
 
 reversed() : 逆順に並べ替え
 reversed(input()) : 入力を逆順に取り出す
 
"""
S = input()

MOD = 2019 

counter = [0] * 2019
counter[0] = 1
t = 1
tmp = 0
for i in reversed(S):
    tmp += int(i)*t
    tmp %= MOD #累積和を効率化
    t *= 10
    t %= MOD   #累乗を効率化 
    #print(tmp)
    counter[tmp] += 1

ans = sum( i*(i-1)//2 for i in counter)
print(ans)

Measured memory_bytes: 9352
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <numeric>
#include <functional>
#include <cmath>
#include <cassert>
#include <string>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
ll MOD = 1000000007;
const int mod = 1000000007;
ll INF = 1LL << 60;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
   for (auto &v : vec)
      is >> v;
   return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec)
{
   os << "[";
   for (auto v : vec)
      os << v << ",";
   os << "]";
   return os;
}
template <typename T>
ostream &operator<<(ostream &os, const deque<T> &vec)
{
   os << "deq[";
   for (auto v : vec)
      os << v << ",";
   os << "]";
   return os;
}
template <typename T>
ostream &operator<<(ostream &os, const set<T> &vec)
{
   os << "{";
   for (auto v : vec)
      os << v << ",";
   os << "}";
   return os;
}
template <typename T>
ostream &operator<<(ostream &os, const unordered_set<T> &vec)
{
   os << "{";
   for (auto v : vec)
      os << v << ",";
   os << "}";
   return os;
}
template <typename T>
ostream &operator<<(ostream &os, const multiset<T> &vec)
{
   os << "{";
   for (auto v : vec)
      os << v << ",";
   os << "}";
   return os;
}
template <typename T>
ostream &operator<<(ostream &os, const unordered_multiset<T> &vec)
{
   os << "{";
   for (auto v : vec)
      os << v << ",";
   os << "}";
   return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &pa)
{
   os << "(" << pa.first << "," << pa.second << ")";
   return os;
}
template <typename TK, typename TV>
ostream &operator<<(ostream &os, const map<TK, TV> &mp)
{
   os << "{";
   for (auto v : mp)
      os << v.first << "=>" << v.second << ",";
   os << "}";
   return os;
}
template <typename TK, typename TV>
ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp)
{
   os << "{";
   for (auto v : mp)
      os << v.first << "=>" << v.second << ",";
   os << "}";
   return os;
}
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val)
{
   fill((T *)array, (T *)(array + N), val);
}


int solve()
{
   int n;
   cin >> n;
   double a[n];
   for (int i = 0; i < n;i++){
      cin >> a[i];
      a[i] = (double)a[i];
   }
   sort(a, a + n);
   double ansa = a[n-1];
   double ansb=0.0;
   double sa = 10000000000000.0;
   for(int i=0; i < n-1; i++){
      if(abs(ansa/2.0 - a[i]) < sa){
         ansb = a[i];
         sa = (double)abs(ansa/2.0 - a[i]);
      }
   }

   cout << (int)ansa << " " << (int)ansb << endl;

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

   solve();
}

Measured memory_bytes: 1024
//** aman**/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define dl          double
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b) for(int i=a;i<b;i++)
#define lb lower_bound
#define ub upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
int main(){
	int a,b,c,n;cin>>a>>b>>c>>n;
	int ans=0;
	for(int i=0;i<=3000;i++){
		for(int j=0;j<=3000;j++){
			if(n-a*i-b*j>=0&&(n-a*i-b*j)%c==0)ans++;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.io.*;

class Main{

static final PrintWriter out=new PrintWriter(System.out);

public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
int a=Integer.parseInt(line);
int b=Integer.parseInt(br.readLine());
int c=Integer.parseInt(br.readLine());
int d=Integer.parseInt(br.readLine());
int p=Integer.parseInt(br.readLine());
int x=a*p;
int y=(p>=c)?b+(p-c)*d:b;
out.println(Math.min(x,y));
out.flush();
}
}
}

Measured memory_bytes: 16896
#include<iostream>
#include<vector>
#include<queue>
#include<functional>

const int INF = 1 << 24;

struct P{
	int x, y;
};

typedef std::pair<P, int> State;

std::vector<P> getPointYouCanGo(int x, int y){
	if(y % 2 == 0){//even
			return {{x-1, y-1}, {x-1, y}, {x-1, y+1}, {x, y-1}, {x, y+1}, {x+1, y}};
	}else{//odd
		return {{x-1, y}, {x, y-1}, {x, y+1}, {x+1, y-1}, {x+1, y}, {x+1, y+1}};
	}
}

template<class T>
std::vector<T> filter(const std::vector<T> v, std::function<bool(T)> cond){
	std::vector<T> result;
	for(auto e : v){
		if(cond(e)){
			result.push_back(e);
		}
	}
	return result;
}

int map[3][100][100], m, n;

void initializeMap(int index, int default_value){
	for(int i=0;i<m;i++){
		for(int j=0;j<n;j++){
			map[index][i][j] = default_value;
		}
	}
}

void createMap(int x, int y){
	std::queue<State> sv;
	map[0][x][y] = 0;
	sv.push(std::make_pair(P{x, y}, 0));
	
	while(!sv.empty()){
		State s = sv.front(); sv.pop();
		P begin_p = s.first;
		int count = s.second;

		std::vector<P> pv = filter<P>(getPointYouCanGo(begin_p.x, begin_p.y), [](P p) -> bool{
				return 0 <= p.x && p.x < m && 0 <= p.y && p.y < n;
			});

		for(const P p : pv){
			if(map[0][p.x][p.y] == -1){
				map[0][p.x][p.y] = count + 1;
				sv.push(std::make_pair(p, count+1));
			}
		}
	}
}

void update(){
	for(int i=0;i<m;i++){
		for(int j=0;j<n;j++){
			map[1][i][j] = std::min(map[1][i][j], map[0][i][j]);
		}
	}
}

int main(){
	int s, t;

	while(std::cin >> m >> n, m){
		initializeMap(1, INF);

		std::cin >> s;
		for(int i=0;i<s;i++){
			int x, y;
			std::cin >> x >> y;
			initializeMap(0, -1);
			createMap(x-1, y-1);
			update();
		}

		int maximumBlocks = 0;
		std::cin >> t;
		for(int k=0;k<t;k++){
			int x, y, blocks = 0;
			std::cin >> x >> y;
			initializeMap(0, -1);
			createMap(x-1, y-1);
			for(int i=0;i<m;i++){
				for(int j=0;j<n;j++){
					if(map[0][i][j] < map[1][i][j]){//win
						blocks++;
					}
				}
			}
			maximumBlocks = std::max(maximumBlocks, blocks);
		}

		std::cout << maximumBlocks << std::endl;
	}
}

Measured memory_bytes: 1256
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <sstream>
#include <string>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define EPS 1e-14
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) FOR(i, 0, n)
#define PI 2*acos(0.0)
#define ALL(a) (a).begin(),(a).end()
#define DEBUG(x) cout<<#x <<": "<< x << "\n"
#define DEBUG_ARR(a) REP(i, size(a)){ cout << #a << "[" << i << "]: " << a[i] << "\n"; }
const int VX[] = { 0, 1, 0, -1 };
const int VY[] = { 1, 0, -1, 0 };
const long MOD = 1000000007;

int main()
{
	string S;
	cin >> S;

	int N = S.length(), ans = N;

	REP(i, N - 1)
	{
		if (S[i] == S[i + 1])
		{
			continue;
		}

		ans = min(ans, max(i + 1, N - i - 1));
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 512
# -*- coding: utf-8 -*-
"""
https://abc059.contest.atcoder.jp/tasks/abc059_b

"""
import sys
from sys import stdin
input = stdin.readline


def solve(A, B):
    if len(A) > len(B):
        return 'GREATER'
    elif len(A) < len(B):
        return 'LESS'
    elif A == B:
        return 'EQUAL'
    else:
        return 'GREATER' if A > B else 'LESS'


def main(args):
    A = input().strip()
    B = input().strip()
    ans = solve(A, B)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <iostream>
#include <numeric>
#include <string>
#include <list>
#include <limits>
#include <type_traits>
#include <vector>

using namespace std;

int main(void) {

    int n, m ,temp = 0, sum =0 ;

    cin >> n;
    cin >> m;

    for (int i = 0; i < m; i ++ ) {
        cin >> temp;
        sum += temp;

    }


    if( n - sum  >= 0 ){
        cout << n - sum;
    }
    else {
        cout << -1;
    }

    
}

Measured memory_bytes: 3652
<?php
define("MOD", 10**9+7);
list($n,$a,$b)=explode(" ",trim(fgets(STDIN)));
$i=1;
$ans=powerm(2,$n)-1;
$ans-=nCm($n,$a);
$ans-=nCm($n,$b);
while($ans<0){
  $ans+=MOD;
}
echo $ans;

//yoichiro's func
//掛け算
function mulm($a, $b){
    return ($a * $b) % MOD;
}

//割り算
function divm($a, $b){
    return mulm($a, powerm($b, MOD - 2));
}

//累乗
function powerm($a, $b){
    if($b == 0)return 1;
    if($b & 1)return (powerm($a, $b>>1)**2 % MOD) * $a % MOD;
    return powerm($a, $b>>1)**2 % MOD;
}

//階乗
function factorialm($a){
    if($a == 0)return 1;
    return factorialm($a - 1) * $a % MOD;
}

//順列
function nPm($n, $m){
    if($m == 0)return 1;
    return nPm($n, $m - 1) * ($n - $m + 1) % MOD;
}

//組み合わせ
function nCm($n, $m){
    $m = min($m, $n-$m);
    return divm(nPm($n, $m), factorialm($m));
}

Measured memory_bytes: 61944
def solve():
    import sys
    file_input = sys.stdin
    
    while True:
        w, h = map(int, file_input.readline().split())
        if w == 0 and h == 0:
            break
        
        width = 2 * w + 1
        
        maze = '1' * width
        line = file_input.readline()
        maze += '1' + line.rstrip() + ' 1'
        for _ in range(h - 1):
            line = file_input.readline()
            maze += '1' + line.rstrip() + '1'
            line = file_input.readline()
            maze += '1' + line.rstrip() + ' 1'
        maze += '1' * width
        
        start = width + 1
        goal = len(maze) - width - 2
        
        from collections import deque
        forward_q = deque()
        forward_q.append(start)
        reverse_q = deque()
        reverse_q.append(goal)
        
        forward_rec = [None] * (goal + 1)
        forward_rec[start] = 1
        reverse_rec = [None] * (goal + 1)
        reverse_rec[goal] = 1
        
        adj_move = (1, -1, width, -width)
        
        def shortest_path_len():
            while forward_q and reverse_q:
                fp = forward_q.popleft()
                fp_len = forward_rec[fp]
                rp = reverse_q.popleft()
                rp_len = reverse_rec[rp]
                
                for move in adj_move:
                    wall = maze[fp + move]
                    if wall == '0':
                        next_place = fp + move * 2
                        if forward_rec[next_place] == None:
                            if reverse_rec[next_place]:
                                return fp_len + reverse_rec[next_place]
                            forward_q.append(next_place)
                            forward_rec[next_place] = fp_len + 1
                    wall = maze[rp + move]
                    if wall == '0':
                        next_place = rp + move * 2
                        if reverse_rec[next_place] == None:
                            if forward_rec[next_place]:
                                return rp_len + forward_rec[next_place]
                            reverse_q.append(next_place)
                            reverse_rec[next_place] = rp_len + 1
            return 0
        
        print(shortest_path_len())

solve()


Measured memory_bytes: 6144
n = int(input())
s = [list(map(int, input().split())) for i in range(n)]

ans = 0
for i in range(n):
    for j in range(n):
        if i != j:
            ans += ((s[i][0] - s[j][0])**2 + (s[i][1] - s[j][1])**2)**0.5
print(ans/n)


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

struct Edge {
  ll to;
  Edge(ll to) : to(to) {}
};

using Graph = vector<vector<Edge>>;
/* LCA(G, root): 木 G に対する根を root として Lowest Common Ancestor
   を求める構造体 query(u,v): u と v の LCA を求める。計算量 O(logn) 前処理:
   O(nlogn)時間, O(nlogn)空間
*/
struct LCA {
  vector<vector<int>> parent;  // parent[k][u]:= u の 2^k 先の親
  vector<int> dist;            // root からの距離

  LCA(const Graph &G, int root = 0) { init(G, root); }
  // 初期化
  void init(const Graph &G, int root = 0) {
    int V = G.size();
    int K = 1;
    while ((1 << K) < V) K++;
    parent.assign(K, vector<int>(V, -1));
    dist.assign(V, -1);
    dfs(G, root, -1, 0);
    for (int k = 0; k + 1 < K; k++) {
      for (int v = 0; v < V; v++) {
        if (parent[k][v] < 0) {
          parent[k + 1][v] = -1;
        } else {
          parent[k + 1][v] = parent[k][parent[k][v]];
        }
      }
    }
  }

  // 根からの距離と1つ先の頂点を求める
  void dfs(const Graph &G, int v, int p, int d) {
    parent[0][v] = p;
    dist[v] = d;
    for (auto e : G[v]) {
      if (e.to != p) dfs(G, e.to, v, d + 1);
    }
  }

  int query(int u, int v) {
    if (dist[u] < dist[v]) swap(u, v);  // u の方が深いとする
    int K = parent.size();
    // LCA までの距離を同じにする
    for (int k = 0; k < K; k++) {
      if ((dist[u] - dist[v]) >> k & 1) {
        u = parent[k][u];
      }
    }
    // 二分探索で LCA を求める
    if (u == v) return u;
    for (int k = K - 1; k >= 0; k--) {
      if (parent[k][u] != parent[k][v]) {
        u = parent[k][u];
        v = parent[k][v];
      }
    }
    return parent[0][u];
  }
};

int main() {
  int n, q;
  cin >> n;
  Graph g(n);
  rep(i, n) {
    int k;
    cin >> k;
    rep(j, k) {
      ll c;
      cin >> c;
      Edge edge(c);
      g[i].push_back(edge);
    }
  }

  cin >> q;
  LCA lca(g);
  vector<int> ans(q);
  rep(i, q) {
    int u, v;
    cin >> u >> v;
    ans[i] = lca.query(u, v);
  }

  rep(i, q) cout << ans[i] << endl;
}


Measured memory_bytes: 19256
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> b(N);
    vector<int> ans(N);
    ans[0] = 1;
    for(int i = 0; i < N; i++)
    {
        cin >> b[i];
    }
    int j = N - 1;
    for(int i = 0; i < N; i++)
    {
        if(b[i] > i + 1)
        {
            cout << -1;
            return 0;
        }
    }
    while(b.size() != 1)
    {
        for(int i = b.size() - 1; i > -1; i--)
        {
            if(b[i] == i + 1)
            {
                ans[j] = b[i];
                j--;
                b.erase(b.begin() + i);
                break;
            }
        }
    }
    for(int i = 0; i < N; i++)
    {
        cout << ans[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int P,Q,R,a,b,c;
  
  cin>>P>>Q>>R;
  
  a=P+Q;
  b=P+R;
  c=R+Q;
  
  int ans;
  
  if(a>=b){
    if(c>=b)
     ans=b;
    else
      ans=c;
  }
  else if(a>=c){
    if(b>=c)
     ans=c;
    else
      ans=b;
  }
  else
    ans=a;
  
  cout<<ans<<endl;
}

Measured memory_bytes: 256
n, k = map(int, input().split())

all_snucks = set(i for i in range(1, n + 1))

for snack in range(1, k + 1):
    d = int(input())
    snucks = map(int, input().split())

    for snuck in snucks:
        if snuck in all_snucks:
            all_snucks.remove(snuck)

print(len(all_snucks))

Measured memory_bytes: 67376
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define all(x)  (x).begin(), (x).end()
#define N 100000
using namespace std;

int main(){
  int n;  cin >> n;
  string s = "";
  if(n==0)  s.push_back('0');
  while(n!=0){
    if(n%2 != 0){
      s.push_back('1');
      n--;
    }else{
      s.push_back('0');
    }
    n/=(-2);
  }
  reverse(all(s));
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ri(x) scanf("%d",&(x))
#define ri2(x,y) scanf("%d %d",&(x),&(y))
#define ri3(x,y,z) scanf("%d %d %d",&(x),&(y),&(z))
#define rll(x) scanf("%lld",&(x))
#define rll2(x,y) scanf("%lld %lld",&(x),&(y))
#define rll3(x,y,z) scanf("%lld %lld %lld",&(x),&(y),&(z))
#define gc(x) ((x) = getchar())
using namespace::std;

const long double PI = acos(-1);
const long long MOD = 1000000000 +7;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> tll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<tll> vtll;
typedef vector<string> vs;
typedef set<int> si;
typedef set<ii> sii;
typedef set<iii> siii;

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

ll add(ll a, ll b, ll m = MOD){
	if(a >= m) a %= m;
	if(b >= m) b %= m;
	if(a < 0) a += m;
	if(b < 0) b += m;
	ll res = a+b;
	if(res >= m or res <= -m) res %= m;
	if(res < 0) res += m;
	return res;
}

ll mul(ll a, ll b, ll m = MOD){
	if(a >= m) a %= m;
	if(b >= m) b %= m;
	if(a < 0) a += m;
	if(b < 0) b += m;
	ll res = a*b;
	if(res >= m or res <= -m) res %= m;
	if(res < 0) res += m;
	return res;
}

ll pow_mod(ll a, ll b, ll m = MOD){
	ll res = 1LL;
	a = a%m;
	while(b){
		if(b&1) res = mul(res,a,m);
		b >>= 1;
		a = mul(a,a,m);
	}
	return res;
}

ll fastexp(ll a, ll b){
	ll res = 1LL;
	while(b){
		if(b&1) res = res*a;
		b >>= 1;
		a *= a;
	}
	return res;
}

int gcdExtendido(int a, int b, int *x, int *y){
	if(a == 0){
		*x = 0;
		*y = 1;
		return b;
	}
	int x1, y1;
	int gcd = gcdExtendido(b%a,a,&x1,&y1);
	
	*x = y1-(b/a)*x1;
	*y = x1;
	return gcd;
}

int modInverso(int a, int m){
	int x, y;
	int g = gcdExtendido(a,m,&x,&y);
	if(g!=1) return -1;
	else return (x%m + m)%m;
}

/****************************************
*************P*L*A*N*T*I*L*L*A************
*****************************************/

const int N = 100+5;

int n;
int a[N];

int main(){
	ri(n);
	for(int i = 1; i <= n; i++) ri(a[i]);
	int ans = 0;
	sort(a + 1, a + n + 1);
	for(int i = 1; i <= n; i++){
		for(int j = i + 1; j <= n; j++){
			if(a[i] == a[j]) continue;
			for(int k = j + 1; k <= n; k++){
				if(a[j] == a[k]) continue;
				if(a[k] < a[i] + a[j]) ans += 1;
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}


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

int main(){
  int a, b, c, k;
  cin >> a >> b >> c;
  cin >> k;
  if(a>=b){
    if(a>=c) cout << (a<<k)+b+c << endl;
    else cout << a+b+(c<<k) << endl;
  }else{
    if(b>=c) cout << a+(b<<k)+c << endl;
    else cout << a+b+(c<<k) << endl;
  }
  return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<pair<int, int>> P(N);
  int X, L;
  for(int i=0; i<N; i++){
    cin >> X >> L;
    P.at(i)=make_pair(X+L, X-L);
  }
  sort(P.begin(), P.end());
  int Ans=0;
  int Now=-1000000009;
  for(int i=0; i<N; i++){
    if(P.at(i).second>=Now){
      Ans++;
      Now=P.at(i).first;
    }
  }
  cout << Ans << endl;
}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-

N, L, T = map(int, input().split())

ants = []
for i in range(N):
    x, w = map(int, input().split())
    ants.append((x, w))

# After T
ants2 = []
for ant in ants:
    ants2.append((ant[0] + T * (3 - 2 * ant[1])) % L)

st = 0
for i in range(N):
    if ants2.count(ants2[i]) == 1:
        st = i
        break

# Number of collision for Ants[st]
cl = 0
for i in range(N):
    if ants[i][1] == ants[st][1]:
        continue  # same direction
    else:
        if ants[st][1] == 1:
            if ants[i][0] > ants[st][0]:
                fc = (ants[i][0] - ants[st][0]) / 2
            else:
                fc = ((L - ants[st][0]) + ants[i][0]) / 2
            cl += (2 * (T - fc)) // L + 1
        else:
            if ants[i][0] > ants[st][0]:
                fc = ((L - ants[i][0]) + ants[st][0]) / 2
            else:
                fc = (ants[st][0] - ants[i][0]) / 2
            cl -= (2 * (T - fc)) // L + 1

stant = ants2[st]
ants2.sort()
idx = ants2.index(stant) - int(cl) - st

for i in range(N):
    print(ants2[(i + idx) % N])


Measured memory_bytes: 18464
N = int(input())
A = map(int, input().split())

alpha, beta = 1, 1

for i in A:
    if i % 2 == 0:
        alpha += 1
        if i % 3 == 0 or i % 5 == 0:
            beta += 1
if alpha == beta:
    print("APPROVED")
else:
    print("DENIED")


Measured memory_bytes: 2940
package main

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

func main() {
	ABK := sc.nextInts()
	A := int64(ABK[0])
	B := int64(ABK[1])
	K := int64(ABK[2])

	A = A - K
	if A < 0 {
		B = B + A
		A = 0
	}
	if B < 1 {
		B = 0
	}
	fmt.Println(A, B)
}

var (
	sc scanner
)

func init() {
	sc = scanner{
		buf: make([]string, 0, 0),
		cur: 0,
		r:   bufio.NewReader(os.Stdin),
	}
}

type scanner struct {
	buf []string
	cur int
	r   *bufio.Reader
}

func (s *scanner) readln() {
	rbuf := make([]byte, 0, 0)
	for {
		line, prefix, err := s.r.ReadLine()
		if err != nil {
			panic(err)
		}
		rbuf = append(rbuf, line...)
		if prefix == false {
			break
		}
	}
	s.cur = 0
	s.buf = strings.Split(*(*string)(unsafe.Pointer(&rbuf)), " ")
}
func (s *scanner) isFull() bool {
	if s.cur == len(s.buf) {
		return true
	}
	return false
}
func (s *scanner) resetCur() {
	s.cur = 0
}
func (s *scanner) next() string {
	if s.cur == 0 {
		s.readln()
	}
	res := s.buf[s.cur]
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nexts() []string {
	s.readln()
	s.resetCur()
	return s.buf
}
func (s *scanner) nextInt() int {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.Atoi(s.buf[s.cur])
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextInts() []int {
	s.readln()
	res := make([]int, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.Atoi(s.buf[i])
	}
	s.resetCur()
	return res
}
func (s *scanner) nextFloat() float64 {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.ParseFloat(s.buf[s.cur],
		64)
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextFloats() []float64 {
	s.readln()
	res := make([]float64, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.ParseFloat(s.buf[i],
			64)
	}
	s.resetCur()
	return res
}
func digits(x int) int {
	return len(strconv.Itoa(x))
}
func powInt(x, p int) (result int) {
	result = 1
	for i := 0; i < p; i++ {
		result *= x
	}
	return
}
func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}
func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}
func abs(x int) int {
	return int(math.Abs(float64(x)))
}
func varDump(value ...interface{}) {
	for _, v := range value {
		fmt.Fprintf(os.Stderr, "%#v\n", v)
	}
}
func yes() {
	fmt.Println("Yes")
}
func no() {
	fmt.Println("No")
}

// Pair a
type Pair struct {
	first  int
	second int
}

// Queue a
type Queue struct {
	v []Pair
}

// Push for queue
func (q *Queue) Push(v Pair) {
	q.v = append(q.v, v)
}

// Pop for queue
func (q *Queue) Pop() Pair {
	r := q.v[0]
	q.v = q.v[1:]
	return r
}

// Front for queue
func (q Queue) Front() Pair {
	return q.v[0]
}

// Empty return true if empty
func (q Queue) Empty() bool {
	return len(q.v) == 0
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = int_fast64_t;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
#define fast() ios::sync_with_stdio(false), cin.tie(nullptr)

int main()
{
    fast();

    using P = pair<int, int>;

    // d[0] : ひだり, d[1] : うえ, d[2] : みぎ, d[3] : した
    int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};
    int H, W, K;
    cin >> H >> W >> K;
    vector<string> grid(H);
    vector<vector<vector<P>>> d(H);

    int sx, sy, gx, gy;

    cin >> sx >> sy >> gx >> gy;
    sx--, sy--, gx--, gy--;

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

    for (int i = 0; i < H; i++) // init
    {
        d[i] = vector<vector<P>>(W, vector<P>(4, P(inf, inf)));
    }

    // (最短距離, その方向に進んだ回数), (x, y), dir
    priority_queue<pair<P, pair<P, int>>, vector<pair<P, pair<P, int>>>, greater<pair<P, pair<P, int>>>> pq;

    for (int i = 0; i < 4; i++)
    {
        d[sx][sy][i] = P(1, 0);
        pq.push({d[sx][sy][i], {{sx, sy}, i}});
    }

    while (!pq.empty())
    {
        auto v = pq.top();
        pq.pop();
        int vx = v.second.first.first, vy = v.second.first.second, dir = v.second.second;

        if (d[vx][vy][dir] < v.first)
            continue;

        for (int i = 0; i < 4; i++) // 向きを変える
        {
            P ncost = make_pair(d[vx][vy][dir].first + 1, 0);
            if (d[vx][vy][i] <= ncost)
                continue;
            d[vx][vy][i] = ncost;
            pq.push({ncost, {{vx, vy}, i}});
        }

        // 直進する
        int nx = vx + dx[dir], ny = vy + dy[dir];
        if (nx < 0 || nx >= H || ny < 0 || ny >= W) // grid の外
            continue;
        if (grid[nx][ny] == '@') // 行き止まり
            continue;
        int df = d[vx][vy][dir].first, ds = d[vx][vy][dir].second;
        P ncost = make_pair(df + (ds + 1) / (K + 1), ds % K + 1);
        if (d[nx][ny][dir] <= ncost)
            continue;
        d[nx][ny][dir] = ncost;
        pq.push({ncost, {{nx, ny}, dir}});
    }

    int min_cost = (*min_element(d[gx][gy].begin(), d[gx][gy].end())).first;

    cout << (min_cost == inf ? -1 : min_cost) << "\n";
}


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

public class Main {

	void submit() {
		int n = nextInt();
		int a = nextInt();
		int b = nextInt();
		out.println((b - a) % 2 == 0 ? "Alice" : "Borys");
	}

	void preCalc() {

	}

	void stress() {

	}

	void test() {

	}

	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		preCalc();
		submit();
		//stress();
		//test();
		out.close();
	}

	static final Random rng = new Random();

	static int rand(int l, int r) {
		return l + rng.nextInt(r - l + 1);
	}

	public static void main(String[] args) throws IOException {
		new Main();
	}

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;

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

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	int nextInt() {
		return Integer.parseInt(nextToken());
	}

	long nextLong() {
		return Long.parseLong(nextToken());
	}

	double nextDouble() {
		return Double.parseDouble(nextToken());
	}
}


Measured memory_bytes: 23252
#include<iostream>
using namespace std;
int main(){
  
  int N, i;
  char S;
  bool Y = false;
  
  cin >> N;
  
  for(i = 0; i < N; i++){
    
    cin >> S;
    if(S == 'Y'){
      Y = true;
    }
  }
  
  if(Y){
    cout << "Four" << endl;
  }else{
    cout << "Three" << endl;
  }
  
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>

using namespace std;

typedef pair<int, int> P;

int main()
{
	int N, M;
	vector<P> r;
	int count = 1;
	int end;

	cin >> N >> M;

	for (int i = 0; i < M; i++)
	{
		P tmp;
		cin >> tmp.second >> tmp.first;
		r.push_back(tmp);
	}

	sort(r.begin(), r.end());
	end = r.front().first;

	for (int i = 1; i < M; i++)
	{
		if (end <= r[i].second)
		{
			end = r[i].first;
			count++;
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
vector<vector<pair<int,int>>> gr;
vector<long long> val;
void dfs(int u,int parent)
{
	for(auto e:gr[u])
	{
		int v=e.first;
		int cap=e.second;
		if(v!=parent)
		{
			val[v]=val[u]+cap;
			dfs(v,u);
		}
	}
}
int main()
{
	int n;
	cin>>n;
	gr.resize(n);
	val.resize(n);
	for(int i=0;i<n-1;i++)
	{
		int u,v,c;
		cin>>u>>v>>c;
		u--;v--;
		gr[u].push_back({v,c});
		gr[v].push_back({u,c});
	}
	int q,k;
	cin>>q>>k;
	dfs(k-1,-1);
	while(q--)
	{
		int u,v;
		cin>>u>>v;
		cout<<val[u-1]+val[v-1]<<endl;	
	}
}

Measured memory_bytes: 12800
#include <iostream>
#include <algorithm>
#include <cmath>
#define EPS 0.000000001
using namespace std;

double X[2][60],Y[2][60],R[2][60];
int res[60];
int main(){
	int N;
	cin>>N;
	for(int i=1;i<=N;i++){
		for(int j=0;j<2;j++){
			cin>>X[j][i]>>Y[j][i]>>R[j][i];
		}
	}

	double re;
	for(int i=1;i<=N;i++){
		re=pow(X[0][i]-X[1][i],2)+pow(Y[0][i]-Y[1][i],2);
		if(re>pow(R[0][i]+R[1][i],2)){
			res[i]=0;
		}
		else if(re>=pow(R[0][i]-R[1][i],2)){
			res[i]=1;
		}
		else if(R[0][i]>R[1][i]){
			res[i]=2;
		}
		else res[i]=-2;
	}
	for(int i=1;i<=N;i++){
		cout<<res[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

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


void solve(long long N, long long D, std::vector<long long> X, std::vector<long long> Y){
    ll ans = 0;
    ll d = 0;
    string key = "";

    rep(i,N){

        d = (X[i]*X[i]) + (Y[i]*Y[i]);
        if(d <= D*D) ans++;
    }

    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long D;
    scanf("%lld",&D);
    std::vector<long long> X(N);
    std::vector<long long> Y(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&X[i]);
        scanf("%lld",&Y[i]);
    }
    solve(N, D, std::move(X), std::move(Y));
    return 0;
}


Measured memory_bytes: 6372
n = int(input())
adjc_list = [[] for _ in range(n)]
INF = 99999999999999999999
V = [ele for ele in range(n)]
S = []
d = [INF] * n
p = [ele for ele in range(n)]

for i in range(n):
    tmp = [int(ele) for ele in input().split()]
    for j in range(1, tmp[1]*2, 2):
        v = tmp[j+1]
        w = tmp[j+2]
        adjc_list[i].append([w, v])
    adjc_list[i].sort()


def my_dijkstra_solver():
    root = 0  # given
    # 1. 初期化
    d = [INF] * n
    d[root] = 0
    VS = V

    # 2. 以下の処理を、S = Vになるまで繰り返す
    while VS:
        # 2.1. V-S の中から、 d[u] が最小である頂点 u を選択する。
        u = VS[0]
        for i in VS:
            if d[i] < d[u]:
                u = i

        S.append(u)  # 2.2. u を S に追加する.
        # 2.3. u に隣接し, かつ V-S に属するすべての頂点 v に対する以下の値を更新する
        VS.remove(u)
        for w, v in adjc_list[u]:
            if v in VS:
                if d[v] > d[u] + w:
                    d[v] = d[u] + w
                    p[v] = u  # 親をどこかで使うのはわかるが一旦忘れよう

    for i, cost in enumerate(d):
        print(i, cost)


if __name__ == "__main__":
    my_dijkstra_solver()



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

int main() {
  int mi=1e9, mx=0;
  int n;
  cin >> n;
  for (int i=0; i<n; i++) {
    int x;
    cin >> x;
    mi=min(x,mi);
    mx=max(x,mx);
  }
  cout << mx-mi << endl; 
  return 0;
}

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

int main() {
  ll n, m; cin >> n >> m;
  cout << abs((n-2) * (m-2)) << endl;
  return 0;
}

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



int main(){
	string s;
	int w;
	cin >> s >> w;
	for (int i = 0; i < s.size(); i += w) {
		cout << s[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define vll vector<ll>
#define pii pair<ll,ll>
#define sz(v) (v).size()
#define srt(v) sort(v.begin(),v.end())
#define ull unsigned long long
#define tell(a) cout<<a<<" "
#define el cout<<endl;
#define rev(v) reverse(v.begin(),v.end())
#define rep(i,a,n) for(int i=a;i<n;i++)
#define M 1000000007
ll power(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){   if (y & 1)res = (res*x) % p;y = y>>1;
x = (x*x) % p;}return res;}



int main()
{
	IOS;
	string s;
	cin>>s;
	int l=s.size();
	ll dp[l+1][13];
	memset(dp,0,sizeof(dp));
	if(s[0]=='?')
	rep(i,0,10)dp[0][i]=1;
	else
	dp[0][s[0]-'0']=1;
	for(int i=1;i<l;i++)
	{
		for(int j=0;j<13;j++)
		{
			if(s[i]!='?')
			{
				dp[i][(j*10+s[i]-'0')%13]+=dp[i-1][j];
				dp[i][(j*10+s[i]-'0')%13]%=M;
			}
			else
			{
				rep(k,0,10)
				{
					dp[i][(j*10+k)%13]+=dp[i-1][j];
					dp[i][(j*10+k)%13]%=M;
				}
			}
		}
	}
	cout<<dp[l-1][5];
}



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

int main(){
    ll a;
  cin >> a;
  if(a >= 30) cout << "Yes" << endl;
  else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>
#include <stack>
#include <tuple>
#include <array>
using namespace std;
#define rep(i,n) for (int i=0; i < (n); i++)


typedef long long int ll;
typedef double D; // ???§??¨?????????????double???long double?????????
typedef complex<D> P; // Point
typedef pair<P, P> L; // Line
typedef vector<P> VP;


const int INF = (1<<30) - 1;
const D EPS = 1e-9;

#define X real()
#define Y imag()
#define LE(n,m) ((n) < (m) + EPS)
#define GE(n,m) ((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)

string S;

string dfs(int s, int t){
    string ret = "";
    
    while(s<t){
        char c = S[s];
        if(c == '['){
            int count = 0;
            for(int i=s; i<t; i++){
                if(S[i] == '[') count++;
                if(S[i] == ']') count--;
                if(count == 0){
                    string tret = dfs(s+1, i);
                    reverse(tret.begin(), tret.end());
                    ret += tret;
                    s = i;
                    break;
                    }
                }
            }else{
                int count = 0;
                while(S[s] == '+' || S[s] == '-'){
                    if(S[s] == '+')
                        count++;
                    else if(S[s] == '-')
                        count--;
                    s++;
                }
                if(S[s] == '?')
                    ret += 'A';
                else
                    ret += ((S[s]-'A'+count)%26+26)%26 + 'A';
            }
        s++;
    }
    return ret;
}

//g++ -std=c++0x -msse4.2 -O3
//#include <bits/stdc++.h>
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cout.precision(16);
    
    while(cin>>S, S!=".")
        cout << dfs(0, S.length()) << endl;
    
    return 0;
}

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

#define int long long
typedef vector<int> vint;
typedef pair<int, int> pint;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<typename T, typename U> inline bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> inline bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
struct Init {
    Init() {
        cout << fixed << setprecision(20);
    };
} init;

int N, M;
bool like[33][33];
signed main() {
    cin >> N >> M;
    for (int i = 0; i < N; i++) {
        int K;
        cin >> K;
        for (int j = 0; j < K; j++) {
            int A;
            cin >> A;
            like[i][A] = true;
        }
    }
    int ans = 0;
    for (int i = 1; i <= M; i++) {
        bool c = true;
        for (int j = 0; j < N; j++) { c &= like[j][i]; }
        ans += c;
    }
    cout << ans << endl;
}

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

int main() {
  int k, s, z, c = 0;
  cin >> k >> s;
  for(int x = 0; x <= k; ++x) for (int y = 0; y <= k; ++y) {
    z = s - x - y;
    if (z >= 0 && z <= k) ++c;
  }
  cout << c << endl;
  return 0;
}

Measured memory_bytes: 256
# Aizu Problem 0176: What Color?
#
import sys, math, os, bisect

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")

colors = {"black": "#000000", "blue": "#0000ff", "lime": "#00ff00",
          "aqua": "#00ffff", "red": "#ff0000", "fuchsia": "#ff00ff",
          "yellow": "#ffff00", "white": "#ffffff"}

def distance(cc1, cc2):
    r1 = int(cc1[1:3], 16)
    r2 = int(cc2[1:3], 16)
    g1 = int(cc1[3:5], 16)
    g2 = int(cc2[3:5], 16)
    b1 = int(cc1[5:], 16)
    b2 = int(cc2[5:], 16)
    return math.sqrt((r1 - r2)**2 + (g1 - g2)**2 + (b1 - b2)**2)

    
def get_color(cc):
    min_dist = float('Inf')
    for color in colors:
        dist = distance(cc, colors[color])
        if dist < min_dist:
            min_dist = dist
            best = color
    return best


while True:
    cc = input().strip()
    if cc[0] == '0':
        break
    print(get_color(cc))

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


public class Main {

	public static void main(String[] a){

		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));

		String tmpString = null;

		try {
			while(null != (tmpString = bf.readLine())){
				int[] numbersA = convert(tmpString);
				tmpString = bf.readLine();
				int[] numbersB = convert(tmpString);
				int count = numbersA.length;

				int hit = 0, blow = 0;
				for(int i = 0; i < count; i++){
					for(int j = 0; j < count; j++){
						if(numbersB[i] == numbersA[j]){
							if(i == j){
								hit++;
							} else {
								blow++;
							}
							break;
						}
					}
				}
				System.out.println(hit + " " + blow);
			}
		} catch (IOException e) {
		}
	}

	private static int[] convert(String text){
		String[] tmp = text.split(" ");
		int count = tmp.length;
		int[] retval = new int[count];
		for(int i = 0; i < count; i++){
			retval[i] = Integer.parseInt(tmp[i]);
		}
		return retval;
	}
}

Measured memory_bytes: 9060
//“Make it work, make it right, make it fast.” – Kent Beck
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double dd;
const int siz = 1e6 + 5;
const int MOD = 1e9 + 7;
#define endl '\n'
#define deb(x) cout << #x << " = " << x << endl;

void solve() {
  string s;
  cin >> s;
  int n = (int)s.size();
  ll ans = 0;
  for(int i = 0; i < (1 << (n-1)); i++) {
    string res = "";
    res += s[0];
    for(int j = 0; j < n-1; j++) {
      if((i & (1 << j))) {
        ans += stoll(res);
        res.clear();
      }
      res += s[j+1];
    }
    ans += stoll(res);
  }
  cout << ans << endl;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout << fixed << setprecision(10);
  int t = 1;
  // cin >> t;
  for(int tt = 1; tt <= t; tt++) {
    //cout << "Case #" << tt << ": ";
    solve();
  }
  return 0;
}  

Measured memory_bytes: 3580