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

using namespace std;

#define llong long long int
#define ldouble long double
#define ternary(condition, x, y) ((condition) ? x : y) 
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) x.begin(), x.end()
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)

const static llong MOD = 1000000000 + 7;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

int H, W, K;
llong dp[101][8] = {};

bool check_amidakuji_bar(int bit) {
    for (int check_bit = 0; check_bit < (1 << (W - 1 - 1)); ++ check_bit) {
        if ((bit & (1 << check_bit)) && (bit & (1 << (check_bit + 1)))) return false;
    }

    return true;
}

int main (int argc, char *argv[]) {
    cin.tie(0); 
    ios::sync_with_stdio(false);

    cin >> H >> W >> K;
    if (W == 1) {
        cout << 1 << endl;
        return 0;
    }
    dp[0][0] = 1;
    for (int h = 0; h < H; ++h) {
        for (int w = 0; w < W; ++w) {
            for (int bit = 0; bit < (1 << (W - 1)); ++bit) {
                if (check_amidakuji_bar(bit)) {
                    if (w < W - 1 && (bit & (1 << w))) dp[h + 1][w + 1] += dp[h][w] % MOD;
                    else if (w - 1 >= 0 && (bit & (1 << (w - 1)))) dp[h + 1][w - 1] += dp[h][w] % MOD;
                    else dp[h + 1][w] += dp[h][w] % MOD;
                }
            }
        }
    }

    cout << dp[H][K - 1] % MOD << endl;

    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
    int A, B; cin >> A >> B;
    if(A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
    return 0;
}

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

using namespace std;

int main(){

    long long s,cnt=1;

    cin>>s;


    if(s == 1 || s == 2)cnt = 3;
    else{
    while(s!=1){
        if(s&1)
            s = 3*s+1;
        else 
            s>>=1;
        cnt++;
    }
    }

    cout<<cnt+1;
    return 0;
}

Measured memory_bytes: 256
from itertools import accumulate

L = int(input())
A = [int(input()) for _ in range(L)]
two_way_A = [a%2 if a>0 else 2 for a in A]
one_way_A = [(a+1)%2 for a in A]

dp = [[0]*L for _ in range(5)]
transition = [A, two_way_A, one_way_A, two_way_A, A] 

dp[0] = list(accumulate(A))
for i in range(1,5):
  dp[i][0] = min(transition[i][0], dp[i-1][0])
  for j in range(1,L):
    dp[i][j] = min(min(dp[i-1][j-1],dp[i][j-1])+transition[i][j], dp[i-1][j])

print(dp[-1][-1])
    

Measured memory_bytes: 48928
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

int main(){
    int A, B;
    cin >> A >> B;
    if(A>9 || B>9){
        cout << -1 << endl;
    }else{
        cout << A*B << endl;
    }
}

Measured memory_bytes: 256
def check(s, summ):
	for i in s:
		if i % 10 != 0:
			return summ - i
	return 0

t = int(input())
s = []
summ = 0
for _ in range(t):
	n = int(input())
	summ += n
	s.append(n)
s.sort()
if summ % 10 != 0:
	print(summ)
else:
	print(check(s, summ))

Measured memory_bytes: 9124
#include <iostream>
#include <cmath>
const double pi = 3.14159265358979;
using namespace std;

double deg2rad(double degree)
{
	return degree/180*pi;
}

int main(void)
{
	double a, b, c;
	double r, s, length, h;
	
	cin >> a >> b >> r;

	r *= pi/180;
	h = b * sin(r);
	s = a * h / 2;
	c = sqrt(a*a + b*b - 2*a*b*cos(r));
	length = a + b + c;

	cout << fixed << s << " " << length << " " << h << endl;
	return 0;
}

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

using namespace std;

#define mod 1000000007LL
#define pi 3.141592653589793238462643383279;
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define f first
#define s second
#define pic pair<char,long long >


void scan(vector<ll> & v)
{
    for(int i=0;i<v.size();i++)
        scanf("%lld",&v[i]);
}

void print(vector<char> & v)
{
    for(int i=0;i<v.size();i++)
        printf("%c",v[i]);
}
bool valid(char ch,char sp,char a,char b)
{
    if((ch=='o'&&sp=='S')||(ch=='x'&&sp=='W'))
        return a==b;
    else
        return a!=b;
}
int n;
string s;
bool fun(vector<char> &v1)
{
     for(int i=0;i<n-2;i++)
    {
        //if(i!=)
        if(s[i+1]=='o'&&v1[i+1]=='S'||(s[i+1]=='x'&&v1[i+1]=='W'))
            v1[i+2]=v1[i];
        else
        {
            if(v1[i]=='S')
                v1[i+2]='W';
            else
                v1[i+2]='S';
        }
    }
    //for(int i=0;i<n;i++)
           // cout<<v1[i];
    if(valid(s[0],v1[0],v1[1],v1[n-1])&&valid(s[n-1],v1[n-1],v1[n-2],v1[0]))
    {

        //ll acc;cin>>acc;
        return true;
    }
    return false;
}
int main()
{
    //int n;
    cin>>n;
    //string s;
    cin>>s;
    vector<char> v1(n),v2(n),v3(n),v4(n);
    v1[0]='S';
    v1[1]='S';
    if(fun(v1))
    {
        print(v1);
        return 0;
    }
    v2[0]='S';
    v2[1]='W';
    if(fun(v2))
    {
        print(v2);
        return 0;
    }
    v3[0]='W';
    v3[1]='S';
    if(fun(v3))
    {
        print(v3);
        return 0;
    }
    v4[0]='W';
    v4[1]='W';
    if(fun(v4))
    {
        print(v4);
        return 0;
    }
    cout<<-1<<endl;
    ll acc;cin>>acc;
    return 0;
}


Measured memory_bytes: 896
n = int(input())
a = sorted(list(map(int,input().split())))
d = {}

for i in range(min(a)-1,max(a)+2):
    d[i] = 0

for v in a:
    d[v] += 1

ans = 0
for i in range(min(a),max(a)+1):
    tmp = d[i-1]+d[i]+d[i+1]
    if ans < tmp:
        ans = tmp
print (ans)


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

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		while(in.hasNextInt()){
			int n=in.nextInt(),sum=0;
			for(int i=n;i<600;i+=n)sum+=i*i*n;
			System.out.println(sum);
		}
	}
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
namespace
{
	double Square(double x)
	{
		return x * x;
	}
}
void ABC145C()
{
	int N;
	cin >> N;
	vector<double> x(N), y(N);
	for (int i = 0; i < N; ++i)
	{
		int xx, yy;
		cin >> xx >> yy;
		x[i] = (double)xx;
		y[i] = (double)yy;
	}
	vector<int> idx(N);
	iota(idx.begin(), idx.end(), 0);

	double avg = 0.0;
	int l = 0;
	do
	{
		double d = 0;
		for (int i = 1; i < N; ++i)
		{
			d += sqrt(Square(x[idx[i]] - x[idx[i - 1]]) + Square(y[idx[i]] - y[idx[i - 1]]));
		}
		avg += d;
		++l;
	} while (next_permutation(idx.begin(), idx.end()));
	avg /= l;
	cout << std::fixed << std::setprecision(30) << avg << endl;
}


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

Measured memory_bytes: 256
#include<stdio.h>
#include <stdlib.h>
int main(void){
	int a,b,big;
	scanf("%d %d",&a,&b);
	big=a+b;
	if(big<a-b){
	big=a-b;
	}
	if(big<a*b){
	big=a*b;
	}
	printf("%d",big);
	return 0;
}

Measured memory_bytes: 128
/*
─────────────────────
───────────████████──
──────────███▄███████
──────────███████████
──────────███████████
──────────██████─────
──────────█████████──
█───────███████──────
██────████████████───
███──██████████──█───
███████████████──────
███████████████──────
─█████████████───────
──███████████────────
────████████─────────
─────███──██─────────
─────██────█─────────
─────█─────█─────────
─────██────██────────
─────────────────────
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
 
#define int long long
#define read(a) int a; cin >> a;
#define readarr(a, n) int a[(n) + 1] = {}; fori(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; fori(i, 1, n) {fori(j, 1, m) cin >> a[i][j];}
#define pb push_back
#define fi first
#define se second
#define rz resize
#define fori(i, a, b) for (int i = (a); i <= (b); i++)
#define ford(i, a, b) for (int i = (a); i >= (b); i--)
#define sort1(v) sort(v.begin(), v.end()) 
#define endl '\n'
 
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair <int, int>> vpi;
typedef vector < vector <int> > vvi;
 
const long long inf2 = (long long)1e18;
const long long mod = (long long)(1e9+7);
const long long inf1 =(long long)(1e6+1);

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

    int n, m, p, cor = 0, pen = 0; string s;
    cin >> n >> m;
	int flag[n+1] = {}; vpi vec;
	if(m == 0) {cout << 0 << " " << 0; return 0;}
    fori(i, 1, m)
    {
        cin >> p; cin >> s;
        if(s == "AC") {flag[p] = 1; vec.pb({p, 1});}
        else vec.pb({p, 0});
    }
    fori(i, 1, n) if(flag[i] == 1) cor++;

    fori(i, 0, vec.size()-1)
    {
        p = vec[i].fi; int val = vec[i].se;

        if(flag[p] == 1 && val == 0) pen++;
        if(flag[p] == 1 && val == 1) flag[p] = 0;
    }
    cout << cor << " " << pen;
    
    return 0;
}

Measured memory_bytes: 3188
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> d = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            d.add(sc.nextInt());
        }
        sc.close();

        Collections.sort(d);

        if (d.size() % 2 != 0) {
            System.out.println(0);
            System.exit(0);
        }

        int a = d.get(n / 2 - 1);
        int b = d.get(n / 2);
        int ans = b - a;
        System.out.println(ans);
    }

}


Measured memory_bytes: 58496
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <bitset>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
using namespace std;
#define Int int64_t
using ll = long long;

int main() {
	Int x, y;
	cin >> x >> y;

	Int a = x;
	int i = 0;
	while (a <= y) {
		i++;
		a = a * 2;
	}

	cout << i << endl;


}

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

int main(){
  vector<int> a(3);
  
  for(int i = 0; i < 3; i++){
    cin >> a[i];
  }
  
  sort(a.begin(), a.end());
  cout << a[0] + a[1] << endl;
  
  return 0;
}

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

#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()

using namespace std;

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

    int N, M;
    cin >> N >> M;
    vector<int> H(N);
    REP(i, N) cin >> H[i];
    vector<int> is_good(N, true);
    REP(_, M) {
        int A, B;
        cin >> A >> B;
        --A;
        --B;
        if (H[A] <= H[B]) {
            is_good[A] = false;
        }
        if (H[A] >= H[B]) {
            is_good[B] = false;
        }
    }

    int n_goods = accumulate(all(is_good), 0);
    cout << n_goods << endl;

    return 0;
}


Measured memory_bytes: 3996
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <string>
#include <unordered_map>
#include <bitset>

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

const ll mod=1000000007ll;

unordered_map<ll,ll> factorization(ll n){
    unordered_map<ll,ll> mp;
    ll t=n;
    for(ll i=2;i<=t;i++){
        while(n%i==0){
            mp[i]++;
            n/=i;
        }
        if(n==1) break;
    }
    if(n!=1) mp[n]++;
    return mp;
}

// x^n (mod を法として)
ll mod_pow(ll x,ll n,ll mod){
    ll r=1;
    while(n>0){
        if(n&1){
            r=r*x%mod;
        }
        x=x*x%mod;
        n>>=1;
    }
    return r;
}

ll mod_inv_prime(ll n,ll mod){
    return mod_pow(n,mod-2,mod)%mod;
}


ll mod_comb(ll n,ll k,ll mod){
    ll r=1;
    for(ll i=1;i<=k;i++){
        r=r*(n-k+i)%mod;
        r=r*mod_inv_prime(i,mod)%mod;
    }
    return r;
}



int main(){
    ll N,M;
    cin>>N>>M;
    unordered_map<ll,ll> mp;
    mp=factorization(M);

    ll ans=1ll;
    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        //cout<<itr->first<<","<<itr->second<<endl;
        ans*=mod_comb((itr->second)+N-1,(itr->second),mod);
        ans%=mod;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using ll = long long;
const int INF = 0x3f3f3f3f;
using namespace std;

const double EPS = 0.00000001;
int n;
double arr[3001], dp[3001];

int main()
{
    IOS
    //bfreopen("balalance.in", "r", stdin);
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
    }
    dp[0] = 1;
    for (int i = 0; i < n; ++i) {
        for (int heads = i+1; heads >= 0; --heads) {
            dp[heads] = dp[heads] * (1-arr[i]);
            if (heads) {
                dp[heads] += dp[heads-1] * arr[i];
            }
        }
    }
    double ans = 0;
    for (int heads = (n>>1)+1; heads <= n; ++heads) {
        ans += dp[heads];
    }
    cout.precision(10);
    cout << fixed << ans << endl;
    return 0;
}


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

 
signed main() {
int n,m;
cin >> n >> m;
int s = 0;
int res = 0;
map<int, int> M;
M[0] = 1;
for (int i = 0; i < n; ++i) {
  int x;
  cin >> x;
  s = (s + x) % m;
  res += M[s];
  M[s]++;
}

cout << res << endl;
}

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

using namespace std;

#define ll long long int

ll n,ara[100005],dp[100005],k;

ll Abs(ll x)
{
    if(x<0) return -x;

    return x;
}

ll func(ll indx)
{
    if(indx>n)
    {
        return 1e12;
    }

    if(indx==n) return 0;

    if(dp[indx]!=-1) return dp[indx];

    ll ans=1e13;

    for(ll i=1; i<=k; i++)
    {
        if(indx+i<=n)
        {
            ans=min(ans,Abs(ara[indx+i]-ara[indx])+func(indx+i));
        }
    }

    return dp[indx]=ans;
}

int main()
{
    ll i,j;

    scanf("%lld %lld",&n,&k);

    for(i=1; i<=n; i++)
    {
        scanf("%lld",&ara[i]);
    }

    memset(dp, -1, sizeof dp);

    ll ans=func(1);

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

    return 0;
}


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

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

  int ue = s / 100;
  int st = s % 100;
  bool isMonthUe;
  bool isMonthSt;
  if (1 <= ue && ue <= 12)
  {
    isMonthUe = true;
  }
  else
  {
    isMonthUe = false;
  }
  if (1 <= st && st <= 12)
  {
    isMonthSt = true;
  }
  else
  {
    isMonthSt = false;
  }

  if (!isMonthSt && !isMonthUe)
    printf("NA\n");
  if (isMonthSt && isMonthUe)
    printf("AMBIGUOUS\n");
  if (isMonthSt && !isMonthUe)
    printf("YYMM\n");
  if (!isMonthSt && isMonthUe)
    printf("MMYY\n");

  return 0;
}

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

using namespace std;

int main()
{
    int n;
    cin>>n;
    if(n%10==2||n%10==4||n%10==5||n%10==7||n%10==9)
    {
        cout<<"hon"<<endl;
    }
    else if(n%10==0||n%10==1||n%10==6||n%10==8)
    {
        cout<<"pon"<<endl;
    }
    else
    {
        cout<<"bon"<<endl;
    }
    return 0;
}



Measured memory_bytes: 3568
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int a = input.nextInt();
        int b = input.nextInt();
        System.out.println(Math.min(a,b)+" "+Math.max(0,a + b - n));
    }
}

Measured memory_bytes: 21716
/* Mere paradesiyaan ki yahi hai nishaani
   Ankhiyaan bilor ki, shishe ki jawaani
*/
#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define LOG1(a)			  cerr<< #a << " = " << (a) << "\n"
#define LOG2(a, b)		  cerr<< #a << " = " << (a) << ", " << #b << " = " << (b) << "\n"
#define endl "\n"

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

const ll INF = 1e18;
const int inf = 1e9;
const int MOD = 1e9 + 7;
const int nax = 1000000 + 10;

int n, arr[nax];
int main()
{
    ios::sync_with_stdio(0);
    cin >> n;
    int x = 0, y = 0;
    bool ok = false;
    int t = 0;
    for(int i = 1; i <= n; i++)
    {
        int xi, yi, ti;
        cin >> ti >> xi >> yi;
        int dist = abs(xi - x) + abs(yi - y);
        if(dist > ti - t)
        {
            ok = true;
        }
        int num = (ti - t) - dist;
        if(num % 2 == 1) ok = true;
        x = xi;
        y = yi;
        t = ti;
    }
    if(ok) cout << "No";
    else cout << "Yes";
    return 0;
}


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

int main() {
    int X;
    cin >> X;
    
    if ( 400 <= X and X <= 599 ){
        cout << 8 << endl;
    } else if ( 600 <= X and X <= 799){
        cout << 7 << endl;
    } else if ( 800 <= X and X <= 999){
        cout << 6 << endl;
    } else if ( 1000 <= X and X <= 1199){
        cout << 5 << endl;
    } else if ( 1200 <= X and X <= 1399){
        cout << 4 << endl;
    } else if ( 1400 <= X and X <= 1599){
        cout << 3 << endl;
    } else if ( 1600 <= X and X <= 1799){
        cout << 2 << endl;
    } else {
        cout << 1 << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(i=0;i<n;i++)
#define foreach(c,itr) for(__typeof(c)::iterator itr=c.begin();itr!=c.end();itr++)
typedef long long ll;
int i,j,k;

int main(){
	ios::sync_with_stdio(false);
    cin.tie();
    
    int n;
    cin>>n;
    ll l[n];
    for(i=0;i<n;i++) cin>>l[i];
    if(n==1||n==2){
    	cout<<0<<endl;
    	return 0;
	}
	ll ans=0;
	for(i=0;i<n;i++){
		for(j=0;j<n&&j!=i;j++){
			for(k=0;k<n&&k!=j;k++){
				if(l[i]==l[j]||l[i]==l[k]||l[j]==l[k]) continue;
				else{
					if(l[i]+l[j]>l[k]&&l[i]+l[k]>l[j]&&l[j]+l[k]>l[i]) ans++;
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3688
C = [list(map(int, input().split())) for _ in range(3)]
x = [0, 0, 0]
y = [0, 0, 0]

for i in range(3):
    y[i] = C[0][i]
for i in range(3):
    x[i] = C[i][0] - y[0]
for i in range(3):
    for j in range(3):
        if C[i][j] != x[i] + y[j]:
            print('No')
            exit()
print('Yes')

Measured memory_bytes: 9208
#include <iostream>

int main() {
  int n;
  std::cin >> n;
  long long a[100010], b[100010], c[100010];
  for (int i = 0; i < n; i++) {
    std::cin >> a[i] >> b[i] >> c[i];
  }

  long long dp[100010][3];
  for (int i = 0; i < 10010; i++) {
    dp[i][0] = 0;
    dp[i][1] = 0;
    dp[i][2] = 0;
  }

  for (int i = 0; i < n; i++) {
    dp[i + 1][1] = dp[i][0] + b[i] > dp[i + 1][1]? dp[i][0] + b[i]:dp[i + 1][1];
    dp[i + 1][2] = dp[i][0] + c[i] > dp[i + 1][2]? dp[i][0] + c[i]:dp[i + 1][2];
    dp[i + 1][0] = dp[i][1] + a[i] > dp[i + 1][0]? dp[i][1] + a[i]:dp[i + 1][0];
    dp[i + 1][2] = dp[i][1] + c[i] > dp[i + 1][2]? dp[i][1] + c[i]:dp[i + 1][2];
    dp[i + 1][0] = dp[i][2] + a[i] > dp[i + 1][0]? dp[i][2] + a[i]:dp[i + 1][0];
    dp[i + 1][1] = dp[i][2] + b[i] > dp[i + 1][1]? dp[i][2] + b[i]:dp[i + 1][1];
  }
  long long res = 0;
  for (int i = 0; i < 3; i++) {
    if (res < dp[n][i]) {
      res = dp[n][i];
    }
  }
  std::cout << res << "\n";
  return 0;
}

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

int main(){
	int W,H,x,y,r;
	cin >> W >> H >> x >> y >> r;
	if(x+r<=W && x-r>=0 && y+r<=H && y-r>=0){
        cout << "Yes" << endl;
	}else{
        cout << "No" << endl;
	}
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define MOD 1000000007
#define len(x) x.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define alla(a,n) a, a + n
#define endstring std::string::npos
#define prtarr(n,len) {for(int i=0;i<len;i++) cout<<n[i]<<" "; cout<<"\n";}
#define prtpair(n) {cout<<n.fr<<" "<<n.sc<<"\n";}
using namespace std;

typedef long long int ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<string> vs;
using namespace std;
int judge(int x,int y){
    cout<<"? "<<x+1<<" "<<y+1<<endl;
    int a; cin>>a;
    return a;
}

ll a,b,c,d;
int main() {
    //freopen("input.txt", "r", stdin) ;
    //freopen("output.txt", "w", stdout) ;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL) ; cout.tie(NULL) ;
    cin>>a>>b>>c>>d;
    cout<<max({min(a,b)*max(c,d),min(a,b)*min(c,d),max(a,b)*max(c,d),max(a,b)*min(c,d)});



    return 0;
}




Measured memory_bytes: 3652
#include <stdio.h>

int main(void)
{
	int lake, homes;
	int dist[1000000];
	int diff, maxdist;
	int i;

	//Input
	scanf("%d%d", &lake, &homes);

	i = 0;
	while (i < homes)
	{
		scanf("%d", &dist[i]);
		i++;
	}

	//Find most long distance.
	i = 0;
	maxdist = 0;
	while (i < homes)
	{
		if(i == homes - 1)
		{
			diff = lake - dist[i] + dist[0];
		}
		else diff = dist[i + 1] - dist[i];
		if(maxdist < diff)
			maxdist = diff;
		i++;
	}

	printf("%d\n", lake - maxdist);

	return (0);
}


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

int main(){	
  ll K,A,B,n=1;
  cin>>K>>A>>B;
  while(K){
    if(n>=A&&K>1&&B-A>1){K-=2;n+=B-A;}
    else{K--;n++;}
  }
  cout<<n<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
  int K,len;
  char S[101];
  scanf("%d",&K);
  scanf("%s",S);
  len=strlen(S);
  if(len<=K){
   printf("%s",S);
  }
  else {for(int i=0;i<K;i++)
    printf("%c",S[i]);
    printf("...");
  };
};

Measured memory_bytes: 1728
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <functional>
#include <array>

using namespace std;

int main(){
    int A, B;
    cin >> A >> B;
    cout << ((A <= 8 && B <= 8) ? "Yay!" : ":(") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

int main()
{
	int P, Q, R;
	cin >> P >> Q >> R;

	cout << min(P + Q, min(Q + R, P + R)) << endl;

	return 0;
}

Measured memory_bytes: 256
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
using namespace std;
typedef long long ll;

int read() {
	int X=0,w=1; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
	while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
	return X*w;
}

const int N=100000+10;

int n,m,a[N],b[N],c[N],p[N],rk[N];
vector<int> G[N],E[N];
bool cmp(int x,int y) { return c[x]<c[y]; }

int f[N];
int find(int x) { return x==f[x]?x:f[x]=find(f[x]); }

ll dp[N],sum[N];
void dfs(int u) {
	sum[u]=b[u],dp[u]=1e18;
	if (E[u].empty()) { dp[u]=max(a[u],b[u]); return; }
	for (int v:E[u]) dfs(v),sum[u]+=sum[v];
	for (int v:E[u])	
		dp[u]=min(dp[u],sum[u]-sum[v]+max(1ll*c[u],dp[v]));
}

int main() {
	n=read(),m=read();
	for (int i=1;i<=n;++i) a[i]=read(),b[i]=read();
	for (int i=1;i<=m;++i) {
		int u=read(),v=read();
		G[u].emplace_back(v),G[v].emplace_back(u);
	}
	for (int i=1;i<=n;++i) c[i]=max(0,a[i]-b[i]),p[i]=i;
	sort(p+1,p+n+1,cmp);
	for (int i=1;i<=n;++i) rk[p[i]]=f[i]=i;
	for (int i=1;i<=n;++i)
		for (int v:G[p[i]])
			if (find(v)!=p[i]&&rk[v]<i)
				E[p[i]].emplace_back(find(v)),f[find(v)]=p[i];
	dfs(p[n]); printf("%lld\n",dp[p[n]]);
	return 0;
}

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

using namespace std;

void Solve(){
    int k, n;
    cin>>k>>n;
    vector<int> v(n);
    for(int i = 0; i < n; i++)
        cin>>v[i];
    int max_d = 0;
    for(int i = 1; i < n; i++){
        if(v[i] - v[i - 1] > max_d){
            max_d = v[i] - v[i - 1];
        }
    }
    int x = (k - v[n - 1]) + v[0];
    if(max_d < x) max_d = x;
    cout<<k - max_d<<'\n';
}
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int q = 1;
    //cin>>q;
    while(q--){
        Solve();
    }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define fore(x, a) for(auto &x : a)
#define pb push_back
#define mp make_pair
#define INF 100100100100
#define inf 2001001001
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vii = vector<int>;
using vll = vector<ll>;
template<class T>using vv = vector<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<class T>void show(const vector<T> &a) { for (int i = 0; i < (int)a.size(); ++i) cout << a[i] << (i != (int)a.size()-1 ? " " : "\n"); }
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
int dy[]={0, 1, -1, 0};
int dx[]={1, 0, 0, -1};

ll n, x, a[100005];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n >> x;
    rep(i, 0, n) cin >> a[i];
    ll ans = 0;
    rep(i, 0, n-1) {
      if (a[i] + a[i+1] > x) {
        ans += (a[i] + a[i+1] - x);
        a[i+1] = max(0LL, a[i+1] - (a[i] + a[i+1] - x));
      }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1024
/*
 * Contents   : DPL 2 A
 * Author     : Kitaura Hiromi
 * LastUpdate : 20180626
 * Since      : 20180626
 */
#include <bits/stdc++.h>
using namespace std;
#define MAX_N 15
#define INF 1<<20
int n, E;
int d[MAX_N][MAX_N];
int dp[1<<MAX_N][MAX_N];

int main(void){
    cin >> n >> E;
    fill((int*)dp, (int*)(dp+(1<<MAX_N)), INF);
    fill((int*)d, (int*)(d+MAX_N), INF);
    for(int e=0; e<E; e++){
        int i, j;
        cin >> i >> j;
        cin >> d[i][j];
    }
    dp[(1<<n) - 1][0] = 0;

    for(int S=(1<<n)-2; S>=0; S--){
        for(int v=0; v<n; v++){
            for(int u=0; u<n; u++){
                if(!(S>>u & 1)){
                    dp[S][v] = min(dp[S][v], dp[S|1<<u][u] + d[v][u]);
                }
            }
        }
    }
    if(dp[0][0] >= INF) cout << -1 << endl;
    else cout << dp[0][0] << endl;
}


Measured memory_bytes: 5020
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())
#define PRINT(V) for (auto v:(V)) {cerr << v << " ";} cerr << endl
#define dump(x) cerr << #x << " : " << (x) << endl
#define dump2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
/* END OF TEMPLATE */

ll dp[110][100010] = {0};
int n, W;

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> n >> W;
    vll w(n), v(n);
    rep(i, n){
        cin >> w[i] >> v[i];
    }
    rep(i, 100010){
        dp[0][i] = 0;
    }
    rep(i, n){
        rep(j, W+1){
            if(j >= w[i]){
                dp[i+1][j] = max(dp[i][j-w[i]]+v[i], dp[i][j]);
            }else{
                dp[i+1][j] = dp[i][j];
            }
        }
    }
    cout << dp[n][W] << endl;
    return 0;
}

Measured memory_bytes: 80128
N,M,X = gets.chomp.split.map(&:to_i)
C = N.times.map{gets.chomp.split.map(&:to_i)}

bits = [0, 1].repeated_permutation(N).to_a
ans = (10 ** 5) * 13

bits.each do |bit|
  rikaido = [0] * (M + 1) 
  (0..N-1).each do |j|
    if bit[j] == 1
      (0..M).each do |k|
        rikaido[k] += C[j][k]
        if rikaido[1..M].all? { |n| n >= X }
          ans = rikaido[0] if ans >= rikaido[0]
        end
      end
    end
  end
end

puts ans == (10 ** 5) * 13 ? -1 : ans

Measured memory_bytes: 15652
N = int(input())
A = list(map(int, input().split()))
cnt = [0]*3

for x in A:
  x %= 4
  if x == 0:
    cnt[2] += 1
  elif x == 2:
    cnt[1] += 1
  else:
    cnt[0] += 1

if cnt[0] <= cnt[2] or ( cnt[1] == 0 and cnt[0] == cnt[2] + 1):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 20000
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
using namespace std;

int main(){
    int N;cin>>N;
    string s=to_string(N);
    int n=s.size();
    int S=0;
    for(int i=0;i<n;i++){
        int c=s[i]-'0';
        S+=c;
    }
    if(N%S==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
random_device rnd;
mt19937 mt(rnd());

const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;
const ll e18 = 1000000000000000000ll;
int main()
{
    ll n;
    lld m;
    cin >> n >> m;
    cout << (ll)(n * m) << endl;
    return 0;
}

Measured memory_bytes: 3708
n = int(input())
s = input()

r = 0
g = 0
b = 0

for x in s:
    if x == 'R':
        r += 1
    elif x == 'G':
        g += 1
    else:
        b += 1

ans = r*g*b

for i in range(n):
    for j in range(i+1, n):
        if 2*j-i < n and len(set([s[i], s[j], s[2*j-i]])) == 3:
            ans -= 1

print(ans)


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

int n, A[50];

int solve(int i, int m) {
    if (m == 0) return 1;
    if (i >= n) return 0;
    int res = solve(i+1, m) || solve(i+1, m-A[i]);
    return res;
}

int main() {
    int q, M, i;

    cin >> n;
    for (i = 0; i < n; i++) cin >> A[i];
    cin >> q;
    for (i = 0; i < q; i++) {
        cin >> M;
        if (solve(0, M)) cout << "yes" << endl;
        else cout << "no" << endl;
    }

    return 0;
}


Measured memory_bytes: 3108
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int myfind(int a, vector<int>& relation) {
    if (relation[a] == a) return a;
    int res = myfind(relation[a], relation);
    relation[a] = res;
    return res;
}

void myunion(int a, int b, vector<int>& relation) {
    int ta = myfind(a, relation);
    int tb = myfind(b, relation);
    if (ta == tb) return;
    relation[ta] = tb;
}

int main() {
    int n, k, l;
    cin >> n >> k >> l;
    vector<int> r1(n + 1, 0), r2(n + 1, 0), r3(n + 1, 0);
    for (int i = 1; i <= n; i++) {
        r1[i] = r2[i] = r3[i] = i;
    }
    int a, b;
    for (int i = 0; i < k; i++) {
        cin >> a >> b;
        myunion(a, b, r1);
    }
    for (int i = 0; i < l; i++) {
        cin >> a >> b;
        myunion(a, b, r2);
    }
    unordered_map<int, vector<int>> um1, um2;
    for (int i = 1; i <= n; i++) {
        um1[myfind(i, r1)].push_back(i);
    }
    for (auto p : um1) {
        um2.clear();
        for (auto index : p.second) {
            um2[myfind(index, r2)].push_back(index);
        }
        for (auto pp : um2) {
            int l = pp.second.size();
            for (int i = 1; i < l; i++) {
                myunion(pp.second[i], pp.second[i - 1], r3);
            }
        }
    }
    vector<int> res(n + 1, 0);
    um1.clear();
    for (int i = 1; i <= n; i++) {
        um1[myfind(i, r3)].push_back(i);
    }
    for (auto p : um1) {
        for (auto index : p.second) {
            res[index] = p.second.size();
        }
    }
    for (int i = 1; i <= n; i++) {
        cout << res[i] << " ";
    }
    cout << endl;
}









Measured memory_bytes: 22696
<?php
while ($line = fgets(STDIN)) {
   $tmp[] = trim($line);
}
$N = $tmp[0];
$A = explode(' ',$tmp[1]);
$A_count = count($A,COUNT_RECURSIVE);
$count = $A[0];
$sum_A = 0;
foreach($A as $value){
  if ($count > $value) {
    $sum_A += $count - $value;
  } else if ($count <= $value) {
    $count = $value;
  }
}
echo $sum_A;

Measured memory_bytes: 31992
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

#読書時間を机A,Bそれぞれについて上から順に加算
A_min = [0]
for i in range(N):
  A_min.append(A_min[i]+A[i])
B_min = [0]
for i in range(M):
  B_min.append(B_min[i]+B[i])

#A_min,B_minを順に加算して、Kを超えていなければ冊数を更新
ans = 0
B_len = M
for i in range(len(A_min)):
  if A_min[i] > K:
    break
  while B_min[B_len] > K - A_min[i]:
    B_len -= 1
  ans = max(ans,i+B_len)
print(ans)

Measured memory_bytes: 47500
#include<stdio.h>
#include<string.h>
void judge(char bubble[][3],char selection[][3],int n);

int main(){
  int n;
  int i,k,minj;
  char a[36][3],b[36][3],temp[3];
 

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",a[i]);
    strcpy(b[i],a[i]);
  }

  
  for(i=0;i<n;i++){
    for(k=n-1;k>i;k--){
      if(a[k][1]<a[k-1][1]){
	strcpy(temp,a[k]);
	strcpy(a[k],a[k-1]);
	strcpy(a[k-1],temp);
      }
    }
  }
  
  for(i=0;i<n;i++){
    printf("%s",a[i]);
    if(i!=n-1) printf(" ");
    else printf("\n");
  }
  
  printf("Stable\n");

  
  for(i=0;i<n;i++){
    minj = i;
    for(k=i;k<n;k++){
      if(b[k][1]<b[minj][1]) minj = k;
    }
    if(minj != i){
	strcpy(temp,b[i]);
	strcpy(b[i],b[minj]);
	strcpy(b[minj],temp);
    }
  }
  
    for(i=0;i<n;i++){
    printf("%s",b[i]);
    if(i!=n-1) printf(" ");
    else printf("\n");
  }
    judge(a,b,n);
  
  return 0;
  
}

void judge(char bubble[][3],char selection[][3],int n){
  int i,count=0;
  for(i=0;i<n;i++)
    if(strcmp(bubble[i],selection[i])!=0) count++;
    if(count==0) printf("Stable\n");
    else printf("Not stable\n");
    
    
}





Measured memory_bytes: 2104
#include<stdio.h>
int main ()
{
    long long a,b,k;
    scanf("%lld %lld %lld",&a, &b, &k);
    a=a-k;
    if(a<0){b=b+a;
            a=0;}
    if(b<0){b=0;}
    printf("%lld %lld", a,b);

}


Measured memory_bytes: 1712
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = long long;
using PAIR = pair<int, int>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 1e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<"\n";
#define debug(x) cerr << #x << ":" << (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

signed main() {
  INIT;

	VAR(int, n);
	VEC(int, a, n);

	map< int, int > mp;
	REP(i, n) {
		mp[min(a[i] / 400, 8LL)]++;
	}

	int mn = 0, mx = 0;
	EACH(mi, mp) {
		if (mi.first < 8) {
			mn++;
			mx++;
		} else {
			mn = max(1LL, mn);
			mx = mx + mi.second;
		}
	}

	OUT(mn)SP;OUT(mx)BR;
  
  return 0;
}


Measured memory_bytes: 256
// Rustで競技プログラミングの入力をスッキリ記述するマクロ
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8

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

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

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

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

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

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

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

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

use std::cmp::Ordering;

fn solve(n: usize) {
    fn _solve(current: usize, n: usize) -> bool {
        match current.cmp(&n) {
            Ordering::Equal => true,
            Ordering::Greater => false,
            _ => _solve(current + 4, n) || _solve(current + 7, n),
        }
    }
    println!("{}", if _solve(0, n) { "Yes" } else { "No" });
}

fn main() {
    input! {
        n: usize
    }
    solve(n)
}


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

int main () 
{
    int a, b;
    
    std::cin >> a >> b;
    
    int d, r;
    double f;
    
    d = a/b;
    r = a%b;
    f = (double)a / (double)b;
    
    cout << fixed;
    std::cout << d << " " << r << " " << setprecision(10) << f << std::endl;
    
    return 0;
}


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

#define mod 1000000007

using namespace std;
typedef long long ll; 
 
int main(void){
	
	ll N, M;
	
	cin >> N >> M;

	if(N == 1 && M == 1)
		cout << 1;
	else if(N == 1)
		cout << M-2;
	else if(M == 1)
		cout << N-2;
	else
		cout << (N-2) * (M-2);
	
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {

    public static void main(String[] args) throws IOException, InterruptedException {
        Scanner sc = new Scanner();
        PrintWriter out = new PrintWriter(System.out);
        PriorityQueue<Apple> apples = new PriorityQueue<>();
        int x = sc.nextInt(), y = sc.nextInt(), a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();
        long ans = 0;
        while (a-- > 0)
            apples.add(new Apple(0, sc.nextInt()));
        while (b-- > 0)
            apples.add(new Apple(1, sc.nextInt()));
        while (c-- > 0) apples.add(new Apple(2, sc.nextInt()));
        int[] ate = new int[]{x, y, 0};
        while (ate[0] + ate[1] > ate[2]) {
            Apple cur = apples.remove();
            if (cur.c == 2) {
                ans += cur.d;
                ate[cur.c]++;
            } else if (ate[cur.c] > 0) {
                ans += cur.d;
                ate[cur.c]--;
            }
        }
        out.println(ans);
        out.flush();
        out.close();
    }

    static class Apple implements Comparable<Apple> {
        int c, d;

        Apple(int c, int d) {
            this.c = c;
            this.d = d;
        }

        @Override
        public int compareTo(Apple apple) {
            return apple.d - d;
        }
    }


    static class Scanner {
        BufferedReader br;
        StringTokenizer st;

        boolean ready() throws IOException {
            return br.ready();
        }

        double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        Scanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

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

        int nextChar() throws IOException {
            return next().charAt(0);
        }

        int[] nextIntArray(int n) throws IOException {
            int[] ans = new int[n];
            for (int i = 0; i < n; i++)
                ans[i] = nextInt();
            return ans;
        }

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

    }
}


Measured memory_bytes: 64816
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<int,ii>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)>>1)
#define all(x) x.begin(),x.end()
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define pw(x) (1<<(x))
#define inf 2005000000
#define MOD 1000000007
#define N 100005
#define M 100000000
#define LOG 20
#define KOK 4000000
using namespace std;

int n,x,y;
int ata[N];
multiset<int> s[N];
map<int,int> cnt[N];
queue<ii> q;

int bul(int node) {

	if(node==ata[node]) return node;

	return ata[node]=bul(ata[node]);

}

void merge(int x,int y) {

	if(x==y) return ;

	if(sz(s[x])<sz(s[y])) swap(x,y);

	ata[y]=x;

	for(auto go:s[y]) {

		s[go].erase(s[go].find(y));
		
		if(x!=go) {
		
			s[x].insert(go);
			s[go].insert(x);

		}

		int val=--cnt[min(y,go)][max(y,go)];

		if(!val) cnt[min(y,go)].erase(cnt[min(y,go)].find(max(y,go)));

		if(x!=go) {
		
			val=++cnt[min(x,go)][max(x,go)];

			if(val==2) q.push({x,go});

		}

	}

	s[y].clear();

}

int main() {

	//freopen("input.txt","r",stdin);

	scanf("%d",&n);

	for(int i=1;i<2*n-1;i++) {

		scanf("%d %d",&x,&y);

		if(x>y) swap(x,y);

		s[x].insert(y);
		s[y].insert(x);

		cnt[x][y]++;

	}

	for(int i=1;i<=n;i++) {

		for(auto x:cnt[i]) {

			if(x.nd==2) {

				q.push({i,x.st});

			}

		}

		ata[i]=i;

	}

	while(!q.empty()) {

		ii p=q.front();

		q.pop();

		merge(bul(p.st),bul(p.nd));

	}

	int tot=0;

	for(int i=1;i<=n;i++) {

		tot+=(bul(i)==i);

	}

	printf(tot==1?"YES":"NO");

}

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

int solve(int n,int k,int s){
	if(k==0) return s==0?1:0;
	if(n==0 or s<0) return 0;
	return solve(n-1,k,s)+solve(n-1,k-1,s-n);
}

int main(){
	int n,k,s;
	while(cin>>n>>k>>s,n){
		cout<<solve(n,k,s)<<endl;
	}
	return 0;
}



Measured memory_bytes: 3016
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

char solve(char c)
{
  int x = c - 'a';
  return 0 <= x && x <= 26 ? 'a' : 'A';
}

int main()
{
  char c;
  std::cin >> c;

  std::cout << std::setprecision(20);
  std::cout << solve(c) << std::endl;
}


Measured memory_bytes: 3552
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n;cin>>n;
  int i,j,k;
  vector<int> v;
  for(i=0;i<n;i++){
    cin >> k;
    v.push_back(k);
  }
  for(j=0;j<n;j++) cout << v[j] << (j==n-1?'\n':' ');
  for(i=1;i<n;i++){
    for(j=0;j<i;j++){
      if(v[j]>v[i]){
    k=v[i];
    v.erase(v.begin()+i);
    v.insert(v.begin()+j,k);
    break;
      }
    }
    for(j=0;j<n;j++) cout << v[j] << (j==n-1?'\n':' ');
  }
  return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;
#define INF 1000000000000000000
#define MOD 1000000007

pair<int,int> dfs(Graph &G,int v,int color,vector<bool> &seen){
  seen.at(v)=true;
  int zero=0;
  int one=0;
  if(color==0){
    zero++;
  }else{
    one++;
  }
  for(auto nv:G.at(v)){
    if(seen.at(nv)){
      continue;
    }
    pair<int,int> p=dfs(G,nv,1-color,seen);
    zero+=p.first;
    one+=p.second;
  }
  return make_pair(zero,one);
}

int main(){
  int N;
  cin>>N;
  vector<int> x(N),y(N);
  for(int i=0;i<N;i++){
    cin>>x.at(i)>>y.at(i);
  }
  map<int,int> mx,my;

  int ix=1;
  for(int i=0;i<N;i++){
    if(mx[x.at(i)]==0){
      mx[x.at(i)]=ix;
      ix++;
    }
  }
  int iy=1;
  for(int i=0;i<N;i++){
    if(my[y.at(i)]==0){
      my[y.at(i)]=iy;
      iy++;
    }
  }

  Graph G(ix+iy);
  for(int i=0;i<N;i++){
    G.at(mx[x.at(i)]).push_back(ix+my[y.at(i)]);
    G.at(ix+my[y.at(i)]).push_back(mx[x.at(i)]);
  }

  ll ans=0;
  vector<bool> seen(ix+iy,0);
  for(int i=0;i<ix+iy;i++){
    if(seen.at(i)){
      continue;
    }
    pair<int,int> p=dfs(G,i,0,seen);
    ans+=(ll)p.first*(ll)p.second;
  }

  cout<<ans-N<<endl;

}


Measured memory_bytes: 18944
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

int n, m; 
vector<vector<int>> g;

void solve() {
	cin >> n >> m;
    g.assign(n, vector<int>());
    rep(i, m) {
        int a, b; cin >> a >> b;
        --a, --b;
        g[a].pb(b);
        g[b].pb(a);
    }
    queue<int> que;
    que.push(0);
    vector<int> dist(n, inf), ans(n, -1);
    dist[0] = 0;
    while(!que.empty()) {
        int v = que.front(); que.pop();
        for(int nv: g[v]) {
            if(chmin(dist[nv], dist[v] + 1)) {
                que.push(nv);
                ans[nv] = v;
            }
        }
    }
    cout << "Yes" << endl;
    rep(i, n - 1) {
        cout << ans[i + 1] + 1 << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 10672