akhauriyash/Code-Regression huggingface dataset:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    s = S()
    d = defaultdict(int)
    for i in s:
        d[i] += 1
    for i in d.keys():
        if d[i] != 2:
            print("No")
            quit()
    print("Yes")
    return

#B
def B():
    n = I()
    p = LI()
    ans = 0
    for i in range(1,n-1):
        k = p[i-1:i+2]
        k.sort()
        if k[1] == p[i]:
            ans += 1
    print(ans)
    return

#C
def C():
    n = I()

    return

#D
def D():
    n = I()

    return

#E
def E():
    n = I()

    return

#F
def F():
    n = I()

    return


#Solve
if __name__ == "__main__":
    B()


Measured memory_bytes: 39152
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
	//a < b < c
	int a,b,c;cin >> a >> b >> c;
	int k;cin >> k;

	while(k&& a >= b){
		if(a >=b) b *= 2;
		k--;
	}
	if(k == 0){
		cout << "No" << endl;
		return 0;
	}
	while(k&& b >= c){
		if(b >= c)c *= 2;
		k--;

	}
	if(a < b && b < c){
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3580
#include <stdio.h>

#define START 0
#define END 600

int f(int x);

int main(void)
{
	int d, s;
	int i;

	while(scanf("%d", &d) != EOF) {
		s = 0;
		for(i = START; i < END; i += d) {
			s += d*f(i);
		}
		printf("%d\n", s);
	}

	return 0;
}

int f(int x) {
	return x*x;
}

Measured memory_bytes: 0
//============================================================================
// Name        : AOL.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cctype>
#include <string>
#include<algorithm>

using namespace std;



int main(){

	int x;
	int a;
	int b;
	int e;
	int f;

	cin>>x>>a>>b;

	if( x < a){
		e=a-x;
	}else if( x > a){
		e=x-a;
	}

	if( x < b){
		f=b-x;
	}else if( x > b){
		f=x-b;
	}

	if( e > f){
		cout<<"B"<<endl;
	}else if( e < f){
		cout<<"A"<<endl;
	}





}


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>
#include <iomanip>
#define M_PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
int now = 0;

const int MAX = 200000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
struct edge {
	int t;
	ll cost;
	edge(int _t, ll _cost) : t(_t)
		, cost(_cost) {
	}
};
bool isPrime(int n) {

	if (n == 1) return false;
	for (ll i = 2; i * i <= n; i++)
	{
		if (n % i == 0) return false;
	}
	return true;
}
int anyDigitSum(int n) {
	int res = 0;
	while (n > 0)
	{
		res += n % 10;
		n /= 10;
	}
	return res;
}
ll f(double n) {

	n *= n;
	n += 4.0;
	return n / 8.0;
}
void Solve() {

	ll a, b;
	cin >> a >> b;
	if (a <= 0 && 0 <= b) {
		cout << "Zero" << endl;
	}
	else if (a <= 0) {
		cout << (((b - a) + 1 ) % 2 == 0 ? "Positive" : "Negative") << endl;
	}
	else {
		cout << "Positive" << endl;
	}

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



Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
using namespace std;
const int N=200010,mod=(int)1e9+7;
int a[N],f[N],s[N];
vector<int> pos[N];
int main(){
	int n,i,x,m=0,j;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&x);
		if(x!=a[m]) a[++m]=x;
	}
	s[a[1]]=1;
	for(i=1;i<=m;i++){
		f[i]=s[a[i]];
		s[a[i+1]]=(s[a[i+1]]+f[i])%mod;
	}
	printf("%d\n",f[m]);
	return 0;
}


Measured memory_bytes: 7296
/*input
8
-406 10
512 859
494 362
-955 -475
128 553
-986 -885
763 77
449 310
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long 
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back

#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)

#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int raise(int a,int n,int m = MOD){
  if(n == 0)return 1;
  if(n == 1)return a;
  int x = 1;
    x *= raise(a,n/2,m);
    x %= m;
    x *= x;
    x %= m;
    if(n%2)x*= a;
    x %= m;
    return x;
}

int floor1(int n,int k){
    if(n%k == 0 || n >= 0)return n/k;
    return (n/k)-1;
}

int ceil1(int n,int k){
    return floor1(n+k-1,k);
}

vector< pair<int,int> > all;
int n;

void solve(){
  	cin >> n;
  	double naft  = 1;
  	REP(i,n){
  		int x,y;cin >> x >> y;
  		all.pb({x,y});
  		naft*=(double)(i+1);
  	}
  	double sum = 0;
  	vector<int> hehe;
  	REP(i,n)hehe.pb(i);
  	do{
  		for (auto it:all){
  		//	cout << it.f << " " << it.s << endl;
  		}
  		double cur = 0;
  		REP(j,n-1){
  			int i = hehe[j];
  			int i1 = hehe[j+1];
  			double one = abs(all[i].f-all[i1].f);
  			double two = abs(all[i].s-all[i1].s);
  			one *= one;
  			two *= two;
  			sum += sqrt(one+two);
  			cur += sqrt(one+two);
  		}
  	//	cout << cur << endl;
  	}while(next_permutation(all(hehe)));
  	sum = sum/(double)naft;
  	cout << fixed << setprecision(10) << sum;
}

signed main(){
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  //freopen(".in","r",stdin);freopen(".out","w",stdout);
  int t = 1;
  //cin >> t;
  while(t--){
    solve();
  }
  return 0;
}

Measured memory_bytes: 256
def main():
    s = list(input())
    t = list(input())
    lt = len(t)
    ls = len(s)
    ans = 1000
    
    
    def dis(a, b):
        d = 0
        for ai, bi in zip(a, b):
            if ai == bi:
                continue
            d += 1
        return d
    
    for i in range(ls-lt+1):
        ans = min(ans, dis(s[i:i+lt], t))
    
    print(ans)
        
    

if __name__ == "__main__":
    main()

Measured memory_bytes: 9088
#include <stdio.h>
#define N 500000
#define INFTY 1000000000
void mergesort(int,int);
void merge(int,int,int);

int count=0,S[N];

int main(){
  int i,n;
 
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  mergesort(0,n);
  for(i=0;i<n;i++){
    printf("%d",S[i]);
    if(i<n-1)  printf(" ");
  }
  printf("\n");
  printf("%d\n",count);
  return 0;

}
 

void merge(int left,int mid,int right){

  int x,y,L[N],R[N],i,j,k;

  x = mid - left;
  y = right - mid;

  for(i=0;i<x;i++){
    L[i]=S[left+i];
  }
  for(i=0;i<y;i++){
    R[i]=S[mid+i];
  }
  L[x]=INFTY;
  R[y]=INFTY;
  i=0;
  j=0;


  for(k=left;k<right;k++){
    if(L[i]<=R[j]){
      S[k]=L[i];
      i++;
    }
    else{
      S[k]=R[j];
      j++;
    }
    count++;
  }
}


void mergesort(int left,int right){
  int mid;
  if(left+1<right){
    mid = (left+right)/2;
    mergesort(left,mid);
    mergesort(mid,right);
    merge(left,mid,right);
  }
}

Measured memory_bytes: 5584
#include <stdio.h>
int main(void)
{
 int i,j;
 int X;
 scanf("%d",&X);
 for(i=X;i<200000;i++)
  {
   
   for(j=2;j<i;j++)
    {
    if(i%j==0) goto L_Break;
    }
     printf("%d\n",i);
     return 0;
   L_Break:
   i=i;
  }
 return 0;
}


Measured memory_bytes: 128
n=int(input())
a=list(map(int,input().split()))
h=[0]*n
h[1]=abs(a[0]-a[1])
for i in range(2,n):
    h[i]=min(h[i-2]+abs(a[i-2]-a[i]),h[i-1]+abs(a[i-1]-a[i]))
print(h[n-1])

Measured memory_bytes: 13980
#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rf(i,a,b) for(ll i=a;i>=b;i--)
#define rep(i,n) f(i,0,n)
#define rrep(i,n) rf(i,n-1,0)
#define w(t) ll t; cin>>t; while(t--)
#define vi vector<ll>
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mii map<ll,ll>
#define mci map<char,ll>
using namespace std;

void fast_IO_file()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int main()
{
	fast_IO_file();

	char a;
	cin >> a;

	if (isupper(a))
		cout << "A" << endl;
	else
		cout << "a" << endl;




	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
typedef long long int lint;
using namespace std;

struct edge {
    //(fromの位置)+dist=(personの位置)
    int person;
    int dist;
    edge(int p, int d) : person(p), dist(d){};
};

void yes() {
    cout << "Yes" << endl;
}
void no() {
    cout << "No" << endl;
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<edge>> graph(n);
    for (int i = 0; i < m; i++) {
        int l, r, d;
        cin >> l >> r >> d;
        l--;
        r--;
        graph[l].push_back(edge(r, d));
        graph[r].push_back(edge(l, -d));
    }
    //一回でもwhileで登場したらtrue
    vector<bool> check(n, false);
    //人の"位置"
    // x[i]==-1e+9-1の時は位置未定義
    vector<int> x(n, -1e+9 - 1);
    for (int i = 0; i < n; i++) {
        if (check[i] == true) continue;
        x[i] = 0;
        queue<int> bfs;
        bfs.push(i);
        while (bfs.size() > 0) {
            int now = bfs.front();
            for (int j = 0; j < graph[now].size(); j++) {
                int dest = graph[now][j].person;
                if (x[dest] < -1e+9) {
                    x[dest] = x[now] + graph[now][j].dist;
                    bfs.push(dest);
                } else {
                    if (x[dest] != x[now] + graph[now][j].dist) {
                        no();
                        return 0;
                    }
                }
            }
            check[now] = true;
            bfs.pop();
        }
    }
    yes();
}

Measured memory_bytes: 9344
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
 
int main() {
	int a,b,c,d;
    cin>>a>>b>>c>>d;
    
    if(a!=c) cout<<1<<endl;
    else cout<<0<<endl;
 
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

def monsat(num):
    L = [False for i in range(num+1)]
    for i in range(0,num,7):
        if i == 1 or i == 0:
            continue
        for d in [-1,1]:
            if L[i+d] == False:
                L[i+d] = True
                for j in range((i+d)*2,num,i+d):
                    if L[j] is False:
                        L[j] = [i+d]
                    else:
                        L[j].append(i+d)
    return L

L = monsat(3*10**5+1)
while True:
    n = int(input())
    if n == 1:
        break
    print(str(n) + ':',n if L[n] is True else ' '.join(map(str,L[n])))

Measured memory_bytes: 43292
use std::io::prelude::*;
use std::str::FromStr;

fn main() {
    let stdin_ = std::io::stdin();
    let stdout_ = std::io::stdout();
    let mut stdin = stdin_.lock();
    let mut stdout = stdout_.lock();

    let mut buffer = String::new();
    stdin.read_line(&mut buffer).unwrap();
    let mut v = buffer.split_whitespace().map(|s| u64::from_str(s).unwrap());
    let a = v.next().unwrap();
    let b = v.next().unwrap();

    let mut ans = std::cmp::max(a + a - 1, a + b);
    ans = std::cmp::max(ans, b + b - 1);

    write!(stdout, "{}\n", ans).unwrap();
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1000000007;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX*/                      ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
/*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
int main(){
    int n;
    cin >> n;
    vector<map<char,int>>a(n);
    for(int i=0;i<n;i++){
        string s;
        cin >> s;
        for(int j=0;j<s.size();j++){
            if(!a.at(i).count(s.at(j))){
                a[i][s.at(j)]=1;
            }
            else {
               a[i][s.at(j)]+=1;
            }
        }
    }
    string ans = "";
    for(int i='a';i<='z';i++){
        int che = 10e6;
        char z = i;
        for(int j=0;j<n;j++){
            if(a.at(j).count(z)){
                che = min(che,a.at(j).at(z));
            }
            else che = 0;
        }
        for(int j=0;j<che;j++){
            ans+=z;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

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

#define MOD 1000000007

void solve(int test_case) {//233
	int n,cnt=0;
	cin>>n;
	vi arr(n);
	for(int &i:arr)cin>>i;
	REP(i,1,n-2) {
		if((arr[i]>arr[i+1]&&arr[i]<arr[i-1])||(arr[i]>arr[i-1]&&arr[i]<arr[i+1]))cnt++;
	}
	cout<<cnt;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String l1 = scan.nextLine();
        scan.close();

        int L = Integer.valueOf(l1);
        double side = L / 3.0;
        System.out.println(String.format("%.12f", side * side * side));
	}
}

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

int min(int a, int b){
	return a < b ? a : b;
}

int main(void){
	int n, *h, *cost;
	scanf("%d", &n);
	h = malloc(sizeof(int) * n);
	cost = malloc(sizeof(int) * n);
	for(int i = 0; i < n; i++)
		scanf("%d", h + i);
	cost[0] = 0;
	cost[1] = abs(h[1] - h[0]);
	for(int i = 2; i < n; i++)
		cost[i] = min(cost[i - 1] + abs(h[i] - h[i - 1]),
				cost[i - 2] + abs(h[i] - h[i - 2]));
	printf("%d\n", cost[n - 1]);
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int f(int a, int b) {
	if (a % b == 0) return a / b;
	return a / b + 1;
}

int main() {
	int l, a, b, c, d; cin >> l >> a >> b >> c >> d;
	int day = max( f(a, c), f(b, d) );
	cout << (l - day) << endl;
}

Measured memory_bytes: 1160
n, m = gets.split.map(&:to_i)
students = Array.new(n) { gets.split.map(&:to_i) }
checkpoints = Array.new(m) { gets.split.map(&:to_i) }

def manhattan_dist(x1, x2, y1, y2)
  (x1 - x2).abs + (y1 - y2).abs
end

students.each do |student|
  closest_cp = 0
  closest_dist = Float::INFINITY
  
  checkpoints.each_with_index do |cp, idx|
    cand_dist = manhattan_dist(student[0], cp[0], student[1], cp[1])
    if cand_dist < closest_dist
      closest_cp = idx + 1
      closest_dist = cand_dist
    end
  end
  
  puts closest_cp
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pint = pair<int, int>;
ll N;
vector<string> v;
const ll INF = 1e12;

int main()
{
    cin >> N;
    v.resize(N);
    for (int i = 0; i < N; ++i)
    {
        cin >> v[i];
    }

    map<string, int> ord;
    for (string st : v)
    {
        ord[st]++;
    }

    vector<pair<int, string>> ans;
    for (auto p : ord)
    {
        pair<int, string> elm(-p.second, p.first);
        ans.push_back(elm);
    }

    sort(ans.begin(), ans.end());
    int max = -ans[0].first;
    for (auto a : ans)
    {
        if (-a.first < max)
        {
            return 0;
        }

        cout << a.second << endl;
    }
}

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

int main(){
    int N;
    int a;
    int max = 0;
    int min = 1000;
    cin >> N;
    for(int i = 0; i < N ; i++){
        cin >> a ;
        if(a > max){
            max = a;
        }
        if(a < min){
            min = a;
        }
    }
    cout << max - min << endl;
    return 0;
}

Measured memory_bytes: 256
<?php
$N = (int)trim(fgets(STDIN));
//$S = trim(fgets(STDIN));
//list($a,$b,$c,$d) = array_map('intval',explode(" ",trim(fgets(STDIN))));
//$A = array_map('intval',explode(" ",trim(fgets(STDIN))));

for($i=0;$i<$N;$i++) {
  list($a,$b) = array_map('intval',explode(" ",trim(fgets(STDIN))));
  if ($a==$b) {
    $zolo[]=1;
  }
  else {
    $zolo[]=0;
  }
}
for($i=2;$i<count($zolo);$i++) {
  if ($zolo[$i-1]==$zolo[$i] && $zolo[$i-2]==$zolo[$i] && $zolo[$i]==1) {
    echo "Yes";
    exit;
  }
}
echo "No";


Measured memory_bytes: 16220
fn main() {
    let n: usize = read();
    let mut v: Vec<usize> =  Vec::new();
    for _i in 0..n {
        let p: usize = read();
        v.push(p);
    }
    let mut max = 0;
    for i in &v[..] {
        if i > &max {
            max = *i;
        }
    }
    let mut ans = 0;
    for i in v {
        ans += i;
    }
    ans -= max / 2;

    println!("{}", ans);

}


// ########################################################################################### //

// 標準入力から一行を読み取り、指定の型に変換する関数
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

// 標準入力から一行を読み取り、空白文字で分割し、各要素を指定の型に変換する関数
pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

// 標準入力からn行を読み取り、各行を空白文字で分割し、各要素を指定の型に変換する関数
pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

// 10進数での各桁の和
pub fn sum_dights(x: isize) -> isize {
    if x % 10 == 0 {
        return 0
    }
    let m = x % 10;
    m + sum_dights((x - m) / 10)
}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;
  
int main(){
 int R[MAX], n;
  
cin >> n;
  
for (int i = 0; i < n; i++)cin >> R[i];
  
int maxv = -2000000000;
int minv = R[0];
  
for(int i = 1; i < n; i++){
maxv = max(maxv, R[i]-minv);
minv = min(minv, R[i]);
}
  
cout << maxv << endl;
  
return 0;
}


Measured memory_bytes: 3900
N = int(input())
abc = [list(map(int, input().split())) for _ in range(N)]

dp = [[0, 0, 0]] * (N+1)

for i in range(1, N+1):
    tmp1 = max([dp[i-1][1]+abc[i-1][0], dp[i-1][2]+abc[i-1][0]])
    tmp2 = max([dp[i-1][0]+abc[i-1][1], dp[i-1][2]+abc[i-1][1]])
    tmp3 = max([dp[i-1][0]+abc[i-1][2], dp[i-1][1]+abc[i-1][2]])
    dp[i] = [tmp1, tmp2, tmp3]
    
print(max(dp[N]))

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

int main(){
  int N;
  cin >> N;
  vector<tuple<int, int, int>> T(N);
  int X, Y, H;
  for(int i=0; i<N; i++){
    cin >> X >> Y >> H;
    T.at(i)=make_tuple(H, X, Y);
  }
  sort(T.begin(), T.end());
  int Ansx, Ansy, Ansh;
  for(int x=0; x<=100; x++){
    for(int y=0; y<=100; y++){
      int h=abs(x-get<1>(T.at(N-1)))+abs(y-get<2>(T.at(N-1)))+get<0>(T.at(N-1));
      int k=1;
      for(int i=0; i<N; i++){
        if(max(h-abs(x-get<1>(T.at(i)))-abs(y-get<2>(T.at(i))), 0)!=get<0>(T.at(i))){
          k=0;
          break;
        }
      }
      if(k==1){
        Ansx=x;
        Ansy=y;
        Ansh=h;
      }
    }
  }
  cout << Ansx << " " << Ansy << " " << Ansh << endl;      
}

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

int main() {
    double r;
    cin >> r;

    cout << setprecision(20) << M_PI * r * r <<  " " << setprecision(20) << 2 * M_PI * r << endl;
    return 0;
}


Measured memory_bytes: 3292
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
int prime_number[55565] = {};
int main() {
	prime_number[1] = 1;
	int sum = 0;
	vector<int>primes;
	for (int i = 2; i <= 55555; i++) {
		if (prime_number[i] == 0) {
			if (i % 5 == 1 && i >= 5) {
				primes.push_back(i);
			}
			for (int j = i+i; j <= 55555; j = j + i) {
				prime_number[j] = 1;
			}
		}
	}
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cout << primes[i] << " ";
	}
}

Measured memory_bytes: 512
import java.util.ArrayList;
import java.util.Scanner;

class SortingThreeNumbers extends ArrayList<Integer> {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public SortingThreeNumbers(int n1, int n2, int n3) {
		add(n1);
		add(n2);
		add(n3);
	}
	
	public SortingThreeNumbers sort() {
		sort(null);
		return this;
	}
	
	public String toString() {
		return get(0) + " " + get(1) + " " + get(2);
	}
}

public class Main {

	public static void main(String[] args) {
		
		Scanner scan = new Scanner(System.in);
		SortingThreeNumbers sortingThreeNumbers
			= new SortingThreeNumbers(scan.nextInt(), scan.nextInt(), scan.nextInt());
		System.out.println(sortingThreeNumbers.sort().toString());
	}

}



Measured memory_bytes: 26256
# -*- coding: utf-8 -*-
from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect
import copy
import math
sys.setrecursionlimit(10**6)

# lis_of_lis = [[] for _ in range(N)]


def zz(): return list(map(int, sys.stdin.readline().split()))


def z(): return int(sys.stdin.readline())


def S(): return sys.stdin.readline()[:-1]


def C(line): return [sys.stdin.readline() for _ in range(line)]


H, W = zz()
C = []
for i in range(10):
    C.append(zz())
A = []
num_lis = [0]*10
for i in range(H):
    a = zz()
    for a_ in a:
        if (a_ == -1):
            continue
        num_lis[a_] += 1
    A.append(a)
# 1->1, 2->1, 3->1 にするためのコストを計算する
# cost = [0]*10
# for num in range(2, 10):
#     min_cost = C[num][1]
a = floyd_warshall(C)
ans = 0
for i, num in enumerate(num_lis):
    ans += a[i, 1]*num
print(int(ans))


Measured memory_bytes: 38164
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

ll n, a, b;
int main(){
  cin.tie(0); ios_base::sync_with_stdio(0);
  cin >> n >> a >> b;
  ll rep = n/(a+b);
  ll rem = n-rep*(a+b);
  ll blue = rep*a + min(rem, a);
  cout << blue <<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    int a, b, c, i, x = 0;
    
    scanf("%d %d %d", &a, &b, &c);
    
    for(i = a; i <= b; i++){
        if(c % i == 0){
            x++;
        }else{
            
        }
    }
    
    printf("%d\n", x);
	return 0;
}




Measured memory_bytes: 2108
void solve();

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

//////////////////////////////////////////////////
//////////////////////////////////////////////////
#include <iostream>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;
typedef pair<int, int> pii;

vector<pair<long long,int>> tasks;

void solve() {
	int N;
	cin >> N;
	tasks.resize(N);
	for (int n = 0; n < N; n++) {
		int a, b;
		cin >> a >> b;
		tasks[n] = pair<long long,int>(a, b);
	}
	bool flag = true;
	long long sum = 0;
	sort(tasks.begin(), tasks.end(), [](pair<long long, int> a, pair<long long, int> b) {return a.second < b.second; });
	for (int n = 0; n < N; n++) {
		sum += tasks[n].first;
		if (sum > tasks[n].second) {
			flag = false;
			break;
		}
	}
	if (flag)cout << "Yes" << endl;
	else cout << "No" << endl;
	return;
}

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

int main(int argc, char const *argv[])
{
	int cnt[26] = {};
	string W;
	cin >> W;

	for (int i = 0; i < W.size(); i++)
	{
		cnt[W[i] - 'a']++;
	}

	for(int i = 0; i < 26; i++)
	{
		if(cnt[i]%2!=0)
		{
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>

using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define rrep(i, x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i, x) for(int i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007
#define put2darr(arr, row, col) rep(i, row) { rep(j, col) { printf("%18d", arr[i][j]); } cout << endl; }

using namespace std;

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

/* 1..10
 * rep:   0 1 2 3 4 5 6 7 8 9
 * reps:  1 2 3 4 5 6 7 8 9 10
 * rrep:  9 8 7 6 5 4 3 2 1 0
 * rreps: 10 9 8 7 6 5 4 3 2 1
 */

ll n, m;
ll l;
ll r;
ll imo[100010];

int main() {
    cin >> n >> m;
    rep(i, m) {
        cin >> l >> r;
        imo[l] += 1;
        imo[r + 1] -= 1;
    }
    ll mx = 0;
    reps(i, n) {
        imo[i] += imo[i - 1];
    }
    ll ans = 0;
    reps(i, n) {
        if(imo[i] == m)ans++;
    }
    cout << ans << endl;
}



Measured memory_bytes: 1024
//#include "debug.h"
#include <string.h>
#include <limits.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

#define MAXN 200
typedef long long i64;

int n;
unsigned char g[MAXN][MAXN+1];
int vis[MAXN];

int input() {
	if (scanf("%d", &n) < 0) return 0;
	for (int i=0; i<n; i++) {
		scanf("%s", g[i]);
		for (int j=0; j<n; j++)
			g[i][j] -= '0';
	}
	return 1;
}

void init() {
}

int dfs(int v, int c) {
	vis[v] = c;
	for (int i=0; i<n; i++)
		if (g[v][i]) {
			if (vis[i]) {
				if (vis[i]==c) return 0;
			}
			else {
				if (!dfs(i, 3-c)) return 0;
			}
		}
	return 1;
}

int solve() {
	memset(vis, 0, sizeof(vis));
	if (!dfs(0, 1)) return -1;
	for (int k=0; k<n; k++)
		for (int i=0; i<n; i++)
			for (int j=0; j<n; j++)
				if (g[i][k] && g[k][j]) {
					int d = g[i][k] + g[k][j];
					if (!g[i][j] || g[i][j]>d)
						g[i][j] = d;
				}
	int d = 0;
	for (int i=0; i<n; i++)
		for (int j=i+1; j<n; j++)
			if (g[i][j]>d)
				d = g[i][j];
	return d+1;
}

void output(int ans) {
	printf("%d\n", ans);
}

void cleanup() {
}

int main() {
	//precalc();
	//int ca; scanf("%d", &ca);
	while (input()) {
		init();
		output(solve());
		cleanup();
		break;
	}
}




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

int main(){
  int n;
  cin >> n;
  long long sm = 0;
  
  for (int i = 1; i<=n; i++){
    if (i%3==0 && i%5==0) {
    }else if (i%3==0){
    }else if (i%5==0){
    }else{
      sm = sm + i;
    }
  }
  cout << sm << endl;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int n,a[1000005];
int t1[4]={1,1,0,0},t2[4]={1,0,0,1};
char s[1000005];
bool check(int x,int y,int n)
{
	a[0]=x;
	a[1]=y;
	for(int i=1;i<n-1;i++)
	{
		if(s[i]=='o')
		{
			if(a[i])
				a[i+1]=a[i-1];
			else
				a[i+1]=!a[i-1];
		}
		else
		{
			if(a[i])
				a[i+1]=!a[i-1];
			else
				a[i+1]=a[i-1];
		}
	}
	if(s[0]=='o')
	{
		if(a[0])
		{
			if(a[1]!=a[n-1])
				return 0;
		}
		else if(a[1]==a[n-1])
			return 0;
	}
	else
	{
		if(a[0])
		{
			if(a[1]==a[n-1])
				return 0;
		}
		else if(a[1]!=a[n-1])
			return 0;
	}
	if(s[n-1]=='o')
	{
		if(a[n-1])
		{
			if(a[0]!=a[n-2])
				return 0;
		}
		else if(a[0]==a[n-2])
			return 0;
	}
	else
	{
		if(a[n-1])
		{
			if(a[0]==a[n-2])
				return 0;
		}
		else if(a[0]!=a[n-2])
			return 0;
	}
	return 1;
}
int main()
{
	cin>>n>>s;
	for(int i=0;i<4;i++)
	{
		if(check(t1[i],t2[i],n))
		{
			for(int j=0;j<n;j++)
			{
				if(a[j])
					cout<<"S";
				else
					cout<<"W";
			}
			return 0;
		}
	}
	cout<<"-1";

	return 0;
}

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

int main(){
	ios::sync_with_stdio(0);
	cout << setprecision(10) << fixed;
	int n, m;
	cin >> n >> m;
	int sum = 0;
	for(int i = 0; i < m; ++i){
		int x;
		cin >> x;
		sum += x;
	}
	if (sum > n){
		cout << -1;
	}
	else{
		cout << n - sum;
	}
	return 0;
}



Measured memory_bytes: 3644
#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>;

int main() {
    int N;
    cin >> N;
    string S, T;
    cin >> S >> T;

    string U = "";
    for (int i = 0; i < N; i++)
    {
        U += S[i];
        U += T[i];
    }
    cout << U << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
const long long mod=1e9+7;
long long fac[20000010],inv[20000010],facinv[20000010];
int r1,c1,r2,c2;
long long C(int x,int y){
	++x;++y;
	return (fac[x+y]*facinv[x]%mod*facinv[y]%mod-1+mod)%mod;
}
int main(){
	inv[1]=fac[1]=facinv[1]=1ll;
	for (register int i=2;i<=2000005;++i){
		fac[i]=fac[i-1]*i%mod;
		inv[i]=(long long)(mod-mod/i)*inv[mod%i]%mod;
		facinv[i]=facinv[i-1]*inv[i]%mod;
	}
	scanf ("%d%d%d%d",&r1,&c1,&r2,&c2);
	printf ("%lld\n",(C(r2,c2)-C(r1-1,c2)+mod-C(r2,c1-1)+mod+C(r1-1,c1-1)+mod)%mod);
	return 0;
}

Measured memory_bytes: 51328
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#define nummax 110000
using namespace std;

int main() {
	bool canA = false;
	bool canB = false;
	string s;
	cin >> s;
	if (s[0] == '0')
	{
		if (s[1] != '0')
			canA = true;
	}
	else if (s[0] == '1')
	{
		if (s[1] == '0' || s[1] == '1' || s[1] == '2')
			canA = true;
	}

	if (s[2] == '0')
	{
		if (s[3] != '0')
			canB = true;
	}
	else if (s[2] == '1')
	{
		if (s[3] == '0' || s[3] == '1' || s[3] == '2')
			canB = true;
	}
	if (canA)
	{
		if(canB)
			cout << "AMBIGUOUS" << endl;
		else
			cout << "MMYY" << endl;
	}
	else
	{
		if (canB)
			cout << "YYMM" << endl;
		else
			cout << "NA" << endl;
	}
}

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

int h, w;
map <int, int> available;
multiset <int> minDist;

int main() {
	scanf("%d%d", &h, &w);
	for (int i = 1; i <= w; i++) available[i] = i, minDist.insert(0);
	for (int i = 0; i < h; i++) {
		int a, b; scanf("%d%d", &a, &b);
		auto cur = available.lower_bound(a);
		int l = -1;
		while (cur != available.end() && cur -> first <= b + 1) {
			minDist.erase(minDist.find(cur -> first - cur -> second));
			l = max(l, cur -> second);
			available.erase(cur++);
		}
		if (l != -1 && b < w) {
			available[b + 1] = l;
			minDist.insert(b + 1 - l);
		}
		printf("%d\n", minDist.empty() ? -1 : (*minDist.begin() + i + 1));
	}
	return 0;
}


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

template<class graph_type> auto spfa(const graph_type &graph,const int start){
    using T=decltype(graph.front().front().second);
    std::vector<T> dist(graph.size(),std::numeric_limits<T>::max());
    std::deque<int> dq;
    std::vector<bool> in_dq(graph.size(),false);
    dist[start]=0;
    dq.push_back(start);
    in_dq[start]=true;

    int64_t denom=1,numer=0;
    auto small_label_first=[&](){
        const int u=dq.front(),v=dq.back();
        if(dist[u]>dist[v]){
            dq.pop_back();
            dq.push_front(v);
        }
    };
    auto large_label_last=[&](){
        while(dist[dq.front()]*denom>numer){
            dq.push_back(dq.front());
            dq.pop_front();
        }
    };
    while(!dq.empty()){
        const int u=dq.front();
        dq.pop_front();
        in_dq[u]=false;
        --denom;
        numer-=dist[u];
        for(const auto &edge:graph[u]){
            const int v=edge.first;
            if(dist[v]>dist[u]+edge.second){
                dist[v]=dist[u]+edge.second;
                if(!in_dq[v]){
                    dq.push_back(v);
                    in_dq[v]=true;
                    ++denom;
                    numer+=dist[v];
                    small_label_first();
                    large_label_last();
                }
            }
        }
    }
    return dist;
}

void solve(){
    int v,e,r;
    cin >> v >> e >> r;
    vector<vector<pair<int,int>>> graph(v);
    rep(i,0,e){
        int s,t,d;
        cin >> s >> t >> d;
        graph[s].push_back(make_pair(t,d));
    }
    vector<int> dist=spfa<vector<vector<pair<int,int>>>>(graph,r);
    rep(i,0,v){
        if(dist[i]==std::numeric_limits<int>::max()) cout << "INF" << endl;
        else cout << dist[i] << endl;
    }
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}

Measured memory_bytes: 12316
#include <iostream>
using namespace std;
int main(void) {
  int n, p;
  while(cin >> n >> p, n+p) {
    int st[64] = {};
    int b = p;
    for(int i = 0; ; i = (i + 1) % n) {
      if(b == 1) {
        bool f = true;
        for(int j = 0;j < n; j++) {
          if(st[j] != 0 && j != i) {
            st[i] += b--;
            f = false;
            break;
          }
        }
        if(f) {
          cout << i << endl;
          break;
        }
      }
      else if(b) st[i]++, b--;
      else b += st[i], st[i] = 0;
    }
  }
}


Measured memory_bytes: 1160
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



long long N, M;

long long solve() {
    if (N > M) swap(N, M);
    if (N == 1 && M == 1) return 1;
    if (N == 1) return M-2;
    
    
    return (N-2) * (M-2);
}

int main() {
    while (cin >> N >> M) {
        cout << solve() << endl;
    }
}

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

int main(void){
	int N,A;
	map<int,int> mp;
	cin>>N;
	rep(i,N){
		cin>>A;
		mp[A]++;
		if(mp[A]>2 || A>=N || mp[0]>1){
			cout<<0<<endl;
			return 0;
		}
	}
	N/=2;
	ll res=1;
	rep(i,N){
		res*=2;
		res%=1000000007;
	}
	cout<<res<<endl;



	return 0;
}


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

long long n;

long long inp(){
    cin >> n;
    return n;
}

int res(long long n){
    int cnt = 0;
    while(true){
        if(n==1) break;
        cnt++;
        if(n%3==0) n /= 3;
        else n = n/3+1;
    }
    return cnt;
}

int main(){
    cout << res(inp()) << endl;
    return 0;
}

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

long long n, m, q, c, p1, p2;
long long a[500001], b[500001];
const long long M = 1e9 + 7;

long long pow(long long p, long long t) {
	long long w = 1, u = p;

	while (t) {
		if (t & 1)
			w = w * u % M;

		u = u * u % M;
		t >>= 1;
	}

	return w;
}

int main()
{
	cin >> n >> m;

	a[0] = 1, b[0] = 1;

	for (int i = 1; i <= m; i++) {
		a[i] = a[i - 1] * i % M;
		b[i] = pow(a[i], M - 2);
	}
	
	int r = 1;

	for (int k = 0; k <= n; k++) {
		c = (a[n] * b[k] % M) * b[n - k] % M;
		p1 = a[m] * b[m - k] % M;
		p2 = a[m - k] * b[m - n] % M;

		q = (q + M + r * ((c * p1 % M) * (p2 * p2 % M)) % M) % M;
		r *= -1;
	}

	cout << q << endl;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define sz(x) ((long long)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define oo 1e15;
const ld eps = 1e-9;
const ld pi = acosl(-1);
const int mod = 998244353;
const int mod1 = 1e9 + 7;


mt19937_64 rnd(time(0));

void faster()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios::sync_with_stdio(false);
}

signed main() {
    faster();
    // freopen("in", "r", stdin);
    // freopen("out", "w", stdout);
    //______________________________________
    /*__*/double start = clock();/*__*/
    //_____________________________________
    string s, s1;
    cin >> s >> s1;
    s = '#' + s;
    s1 = '@' + s1;
    vector <vector <int> > dp(sz(s) + 1, vector <int> (sz(s1) + 1, 0));
    vector <vector <pair <int, int> > > p(sz(s) + 1, vector <pair <int, int> > (sz(s1) + 1, {0, 0}));
    for (int i = 1; i < sz(s); i++)
    {
        for (int j = 1; j < sz(s1); j++)
        {
            if (s[i] == s1[j])
            {
                dp[i][j] = dp[i - 1][j - 1] + 1;
                p[i][j] = {-1, -1};
            }
            else
            {
                if (dp[i - 1][j] > dp[i][j - 1])
                    p[i][j] = {-1, 0};
                else
                    p[i][j] = {0, -1};
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            }
        }
    }
    string ans;
    int ni = sz(s) - 1, nj = sz(s1) - 1;
    while (true)
    {
        if (s[ni] == s1[nj])
            ans.push_back(s[ni]);
        auto mn = p[ni][nj];
        ni += mn.first;
        nj += mn.second;
        if (mn.first == 0 && mn.second == 0)
            break;
    }
    reverse(all(ans));
    cout << ans;
    //______________________________________
    //  cerr << "Time " << (clock() - start)  * 1.0 / CLOCKS_PER_SEC << "s\n";
    return 0;
}

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

int f(int n) {
	int cnt = 0;
	for (int x = 1; x <= 100; x++) {
		for (int y = 1; y <= 100; y++) {
			int a = (x + y);
			int b = 4 * (x * x + y * y + x * y - n);
			double c = sqrt(a * a - b);
			if ((c - a) >= 2 && int(c) == c && (int(c) - a) % 2 == 0) cnt++;
		}
	}
	return cnt;
}

int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cout << f(i) << "\n";
	}
	return 0;
}


Measured memory_bytes: 3508
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<=n; i++)
#define ALL(a) begin(a), end(a)
using namespace std;
vector<int> vec;
int main() {
    int N;
    ll Y, remain, a = 0, b = 0, c = 0;
    cin >> N >> Y;
    rep(i, 0, N) {
        remain = Y;
        if (i == 0) {
            a = 0;
        } else {
            remain = Y - (10000 * i);
            a = i;
        }
        ll temp = remain;
        rep(j, 0, N-a) {
            remain = temp;
            if (j == 0) {
                b = 0;
            } else {
                remain = remain - (5000 * j);
                b = j;
            }
            int c = N - a - b;
            if (remain == 0 && c == 0) {
                    cout << a;
                    cout << " ";
                    cout << b;
                    cout << " ";
                    cout << c;
                    cout << endl;
                    return 0;
            } else {
                if (remain / 1000 == c && c > 0) {
                    cout << a;
                    cout << " ";
                    cout << b;
                    cout << " ";
                    cout << c;
                    cout << endl;
                    return 0;
                }
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <queue>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

int gcd(int a, int b) {
    int r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

priority_queue<int, vector<int>, greater<int>> divisor(int m){
    priority_queue<int, vector<int>, greater<int>> l;
    int m_div = (int)(sqrt(m) + 1);
    for(int i=1; i<m_div; ++i){
        if(m % i == 0){
            l.push(i);
            if(i < m / i){
                l.push(m / i);
            }
        }
    }
    return l;
}

int main()
{
    int n, max;
    priority_queue<int, vector<int>, greater<int>> l;
    cin >> n;
    vector<int> v(n);
    if(n == 2){
        cin >> v[0] >> v[1];
        max = gcd(v[0], v[1]);
        l = divisor(max);
    }
    else {
        cin >> v[0] >> v[1] >> v[2];
        sort(v.begin(), v.end());
        max = gcd(gcd(v[0], v[1]), v[2]);
        l = divisor(max);
    }
    while(!l.empty()){
        cout << l.top() << endl;
        l.pop();
    }
    return 0;
}


Measured memory_bytes: 3156
//#include "debug.h"
#include <string.h>
#include <limits.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

#define MAXN 100000

int n;
int a[MAXN+2];

int input() {
	if (scanf("%d", &n) < 0) return 0;
	for (int i=0; i<n; i++) scanf("%d", &a[i+1]);
	return 1;
}

void init() {
}

long solve() {
	a[0] = 0;
	a[n+1] = 0;
	n += 2;
	long s = 0;
	for (int i=1; i<n; i++)
		s += abs(a[i]-a[i-1]);
	for (int i=1; i<n-1; i++) {
		long x = s + abs(a[i+1]-a[i-1]) - abs(a[i]-a[i-1]) - abs(a[i+1]-a[i]);
		printf("%ld\n", x);
	}
	return 1;
}

void output(long ans) {
}

void cleanup() {
}

int main() {
	//int ca; scanf("%d", &ca);
	while (input()) {
		init();
		output(solve());
		cleanup();
		//break;
	}
}





Measured memory_bytes: 1536