akhauriyash/Code-Regression huggingface dataset:
using System;

namespace AtCoder.ABC095
{
    public class A
    {
        public static void Solve()
        {
            string[] input = Console.ReadLine().Split(' ');
            string s1 = input[0];

            int cnt = 0;
            for (int i = 0; i < s1.Length; i++)
            {
                if (s1[i].ToString() == "o")
                {
                    cnt++;
                }
            }

            Console.WriteLine(700 + cnt * 100);
        }     
    }
}

namespace AtCoder {
    class Program
    {
        static void Main(string[] args)
        {
            ABC095.A.Solve();
        }
    }
}


Measured memory_bytes: 11092
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <bitset>
#include <stack>
#include <deque>
using namespace std;
typedef pair<int, int> pii;
typedef long long LL;
const int MAXN = 123456;
int A[MAXN], B[MAXN];

int main() {
    int N;
    scanf("%d", &N);
    LL sumA = 0, sumB = 0;
    for (int i = 0; i < N; i++) {
        scanf("%d", &A[i]);
        sumA += A[i];
    }
    for (int i = 0; i < N; i++) {
        scanf("%d", &B[i]);
        sumB += B[i];
    }
    if (sumA < sumB) return !printf("-1\n");
    vector<int> V;
    LL need = 0;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        LL cur = A[i] - B[i];
        if (A[i] <= B[i]) {
          need += (cur * -1);
          if (A[i] != B[i]) ans++;
        } else V.push_back(cur);
    }
    sort(V.rbegin(), V.rend());
    for (int i : V) {
        if (need <= 0) break;
        ans++;
        need -= i;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;


int main() {
    ll n, m, k; cin >> n >> m >> k;
    vector<ll> a(n+1), b(m+1);
    rep(i, n) {
        int x; cin >> x;
        a[i+1] = a[i] + x;
    }
    rep(i, m) {
        int x; cin >> x;
        b[i+1] = b[i] + x;
    }
    ll ans = 0, j = m;
    rep(i, n+1) {
        if(a[i] > k) continue;
        while(a[i] + b[j] > k) j--;
        chmax(ans, i + j);
    }
    cout << ans << endl;
}


Measured memory_bytes: 6432
#include<stdio.h>
int main(void){
  int N;
  scanf("%d",&N);
  if(N==25){
    printf("Christmas");
  }
  else if(N==24){
    printf("Christmas Eve");
  }
  else if(N==23){
    printf("Christmas Eve Eve");
  }
  else if(N==22){
    printf("Christmas Eve Eve Eve");
  }
  return 0;
}

Measured memory_bytes: 128
// Created by ahmed_drawy on 10/09/19.
///dp educational contest atcoder - vjudge
#include <bits/stdc++.h>
#include <string.h>
#pragma clang diagnostic push
#pragma ide diagnostic ignored "OCUnusedMacroInspection"
using namespace std;
#define lp(i,start , end)       for(int i = start ; i<end ; ++i)
#define lllp(i,start , end)       for(ll i = start ; i<end ; ++i)
#define inN(arr ,  n) for(int i = 0 ; i< n ; ++i)  cin>>arr[i];
#define Rlp(i,start , end)      for(int i = start ; i>end ; --i)
#define all(v)                   ((v).begin(),(v).end())
#define sz(v)                  (int)((v).size())
#define clr(v,d)                memset(v , d , sizeof(v))
#define inf 0x3f3f3f3f
//#define dbg (v)    for(auto it : v)cout<<it<<' ';
typedef long long               ll;
typedef vector<int>             vi;
typedef vector  <ll>            vll;
typedef vector<vector<int> >    adj;
typedef pair<int ,int>          pii;
const double EPS =1e-7;
const int OO = 1e6;
#define endl '\n'
#define cint(c) (int)c -'0';
#define itc(c) (char)c +'A';
bool sortpair( const pair<int , int> & x, const pair<int , int> & y){
    return  x.first != y.first ? x.first < y.first : x.second > y.second ;
}
int dcomp(double x , double y){
    return fabs(x-y) <= EPS? 0: x>y?1:-1;
}

void smile() {
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#ifndef ONLINE_JUDGE
 //   freopen("/home/tw3/Desktop/Desktop/training/in.txt", "r", stdin);
//    freopen("/home/tw3/Desktop/Desktop/training/out.txt" , "w" , stdout);
#endif
}
#define fastin smile()

int n , w;
const int N = 1e5 +3;
ll dp[101][N];
ll w8[101];
ll cost[101];
ll knapsack(int indx , int rem){
    if(indx == n )
        return 0 ;
    ll &ret = dp[indx][rem];
    if(~ret)
        return ret;
    ret = knapsack(indx+1 , rem);
    if(w8[indx] <= rem)
        ret = max(ret , cost[indx] + knapsack(indx+1 , rem - w8[indx]) );
    return ret;



}
int main() {
    fastin;
    cin >>  n  >> w;
    for (int i = 0; i <n ; ++i) {
        cin >>w8[i]>>cost[i];
    }
    clr(dp, 0);
    for (int k = 0; k <=w ; ++k) {
        dp[n][k]  = 0;
    }
    for (int indx = n-1; indx >= 0; --indx) {
        for (int rem = 0; rem <=w ; ++rem) {
            ll &ret = dp[indx][rem];
            ret = dp[indx+1][rem];
            if(w8[indx] <= rem)
                ret = max(ret , cost[indx] + dp[indx+1][rem - w8[indx]]) ;


        }
    }
    cout << dp[0][w]<<endl;

}

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

int main()
{
   int n;
   cin>>n;
   ll arr[n],temp=0;
   for(int i=0;i<n;i++)
   {
       cin>>arr[i];
       temp^=arr[i];
   }
   for(int i=0;i<n;i++)
   {
        ll res= temp^arr[i];
        cout<<res<<" ";
   }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 5096
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define siz(v) (ll)(v).size()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repn(i, n) for (ll i = 0; i <= (ll)(n); i++)
typedef pair<ll, ll> P;
typedef pair<ll, ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
vector<ll> dx = {-1, 1, 0, 0}, dy = {0, 0, -1, 1};
//cin.tie(0);
//ios::sync_with_stdio(false);

class UnionFind
{
public:
    //以下公開

    //親の番号を格納する。親である場合は-(その集合のサイズ)
    vector<ll> Parent;

    //作るときはParentの値を全て-1にする
    //こうすると全てバラバラになる
    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }

    //Aがどのグループに属しているか調べる
    ll root(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = root(Parent[A]);
    } //代入しておくことで参照を速くする

    //自分のいるグループの頂点数を調べる
    ll size(ll A)
    {
        return -Parent[root(A)];
    } //親である場合は-(その集合のサイズ)なので、Ａの親の

    //AとBをくっ付ける
    bool connect(ll A, ll B)
    {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B)
        {
            //すでにくっついてるからくっ付けない
            return false;
        }

        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらひっくり返しちゃう。
        if (size(A) < size(B))
            swap(A, B);

        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;

        return true;
    }

    bool same(ll A, ll B)
    {
        return root(A) == root(B);
    }
};

signed main()
{
    ll n, k, l, cnt = 1;
    cin >> n >> k >> l;
    UnionFind UnionFind(n + 1), UF(n + 1);

    rep(i, k)
    {
        ll p, q;
        cin >> p >> q;
        UnionFind.connect(p, q);
    }

    rep(i, l)
    {
        ll r, s;
        cin >> r >> s;
        UF.connect(r, s);
    }

    vector<P> v;
    map<P, int> ap;

    for (ll i = 1; i <= n; i++)
    {
        v.pb({UnionFind.root(i), UF.root(i)});
    }
    sort(all(v));

    for (int i = 0; i < siz(v) - 1; i++)
    {
        P next = v[i + 1];
        if (next == v[i])
            cnt++;
        else
        {
            ap[v[i]] = cnt;
            cnt = 1;
        }
    }
    ap[v[siz(v) - 1]] = cnt;

    for (int i = 1; i <= n; i++)
    {
        cout << ap[{UnionFind.root(i), UF.root(i)}] << (i == n ? '\n' : ' ');
    }
}


Measured memory_bytes: 18028
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e9 + 7;

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

  ll n;
  cin >> n;
  vector<ll> a(n);
  ll ans = 0;
  REP(i, n){
    cin >> a[i];
    ans += a[i] - 1;
  }
  cout << ans << endl;
  

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
#include <numeric>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<Pll> vp;
typedef vector<bool> vb;
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define rrep(i, a, n) for (ll i = (a); i > (n); --i)
#define erep(i, a, n) for (ll i = (a); i <= (n); ++i)
#define rerep(i, a, n) for (ll i = (a); i >= (n); --i)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define SORT(x) sort(all(x))
#define RSORT(x) sort(all(x),greater<ll>())
#define vec_max(V) *max_element(all(V))
#define vec_min(V) *min_element(all(V))
#define vec_sum(V) accumulate(all(V), 0LL)
#define print(X) cout << (X) << "\n"
#define sprint(X) printf("%f\n", (X)) // 小数点の出力
#define _ << " " <<
#define Yes print("Yes")
#define No print("No")
#define case(X) cout << "Case #" << (X) + 1 << ":" << "\n"
static const int INF = 1e+9+7;

int main(){

  str yobi[] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};

  str S;
  cin >> S;

  rep(i,0,7){
    if(S == yobi[i]){
      print(7 - i);
    }
  }

 return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func newInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func main() {

	var n, cnt, d int
	sc.Split(bufio.ScanWords)
	n = newInt()
	d = newInt()
	d = d * d
	for i := 0; i < n; i++ {
		x := newInt()
		y := newInt()
		if x*x+y*y <= d {
			cnt++
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 4892
N, T = map(int, input().split())
lst_t = list(map(int, input().split()))
ans = 0


for i in range(N - 1):
    s, t = lst_t[i], lst_t[i+1]
    interval = t - s
    ans += min(T, interval)
else:
    ans += T


print(ans)

Measured memory_bytes: 25196
#include <bits/stdc++.h>
#define vec vector<int>
using namespace std;
int Del(int x,int k)
{
    return (x>>(k+1)<<k)|(x&((1<<k)-1));
}
int Add(int x,int k,int ty)
{
    return (x&((1<<k)-1))|(x>>k<<(k+1))|(ty<<k);
}
vec DC(int n,int s,int t)
{
    if(__builtin_popcount(s^t)%2==0){
        puts("NO");
        exit(0);
    }
    vec res(1<<n);
    if(n==1){
        res[0]=s,res[1]=t;
        return res;
    }
    int p=__builtin_ctz(s^t);
    int s1=Del(s,p),t1=Del(t,p);
    for(int u=0;;u++)
        if(__builtin_popcount(s1^u)&1){
            vec r1=DC(n-1,s1,u),r2=DC(n-1,u,t1);
            for(int i=0;i<(1<<(n-1));i++)
                res[i]=Add(r1[i],p,s>>p&1),res[i+(1<<(n-1))]=Add(r2[i],p,t>>p&1);
            return res;
        }
}
int main()
{
    int n,a,b;
    scanf("%d%d%d",&n,&a,&b);
    vec ans=DC(n,a,b);
    puts("YES");
    for(int v:ans)printf("%d ",v);
    return 0;
}

Measured memory_bytes: 1792
#include <atcoder/lazysegtree>
#include <atcoder/modint>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
struct S { mint a, b; };
using F = int;
S op(S l, S r) { return S{l.a * r.b + r.a, l.b * r.b}; }
S e() { return S{0, 1}; }
F id() { return -1; }
S mapping(F f, S x) { return f == id() ? x : S{(x.b - 1) / 9 * f, x.b}; }
F composition(F f, F g) { return f == id() ? g : f; }
main() {
    int n, q;
    scanf("%d%d", &n, &q);
    vector<S> a(n, S{1, 10});
    lazy_segtree<S, op, e, F, mapping, composition, id> seg(a);
    for (int i = 0; i < q; i++) {
        int l, r, d;
        scanf("%d%d%d", &l, &r, &d);
        seg.apply(l - 1, r, d);
        printf("%d\n", seg.all_prod().a.val());
    }
}

Measured memory_bytes: 9788
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Trim();
        var b = Console.ReadLine().Trim();
        var c = Console.ReadLine().Trim();

        var k = 0;
        for (int i = 0; i < n; i++)
        {
            if (a[i] == b[i] && b[i] == c[i])
            {
                continue;
            }

            if (a[i] != b[i] && b[i] != c[i] && c[i] != a[i])
            {
                k += 2;
            }
            else
            {
                k++;
            }
        }
        Console.WriteLine(k);
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int X, Y, A, B, C;
	cin >> X >> Y >> A >> B >> C;
	vector<pair<int, int>> apples(A + B + C);

	for (int i = 0; i < A; i++) {
		int p;
		cin >> p;
		apples[i] = make_pair(p, 0);
	}

	for (int i = A; i < A + B; i++) {
		int q;
		cin >> q;
		apples[i] = make_pair(q, 1);
	}

	for (int i = A + B; i < A + B + C; i++) {
		int r;
		cin >> r;
		apples[i] = make_pair(r, 2);
	}

	sort(apples.begin(), apples.end(), greater<pair<int, int>>());

	long long ans = 0;
	int i = 0, r = 0, g = 0, w = 0;
	while (X + Y > r + g + w) {
		switch (apples[i].second) {
		case 0:
			if (r < X) {
				r++;
				ans += apples[i].first;
			}
			break;
		case 1:
			if (g < Y) {
				g++;
				ans += apples[i].first;
			}
			break;
		case 2:
			w++;
			ans += apples[i].first;
		}
		i++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

#include <set>
#include <map>
#include <iomanip>

using namespace std;

#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define all(x) (x).begin(),(x).end()

using ll = long long;

bool is_sorted(vector<int> vec)
{
	rep(i, vec.size() - 1)
	{
		if (vec[i] <= vec[i + 1])
		{
			// ok
		}
		else
		{
			return false;
		}
	}

	return true;
}

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

	vector<int> p(N);
	rep(i, N)
	{
		cin >> p[i];
	}

	int index = -1;
	rep(i, N - 1)
	{
		if (p[i] > p[i + 1])
		{

			if (index == -1)
			{
				index = i;
			}
			else
			{
				swap(p[i + 1], p[index]);
				break;
			}
		}
	}


	if (is_sorted(p))
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}


	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include <bits/stdc++.h>
using namespace std;
int main()
{


   long long int i,j,k,n,m,t;
   cin>>n>>k>>t;
   j=n/k;
   if(n%k!=0)
   {
       j++;
   }
   j=j*t;
   cout<<j<<endl;





return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
struct data{int to,next,wi;}e[maxn*2];
int head[maxn];
int cnt=0;
int du[maxn];
queue<int> q;
bool vis[maxn];
void ins(int u,int v,int ww)
{
	e[++cnt].to=v;
	e[cnt].next=head[u];
	e[cnt].wi=ww;
	head[u]=cnt;
}
int n,m;
int dis[maxn];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);
		ins(x,y,z);
		du[y]++;
	}
	for(int i=1;i<=n;i++)dis[i]=1e9+10;
	for(int s=1;s<=n;s++)
	{
		if(du[s]==0)
		{
			dis[s]=0;
			vis[s]=1;
			q.push(s);
			while(!q.empty())
			{
				int x=q.front();
				q.pop();
				for(int i=head[x];i;i=e[i].next)
				{
					int u=e[i].to;
					if(vis[u]==1&&dis[u]!=dis[x]+e[i].wi)
					{
						puts("No");
						return 0;
					}
					if(vis[u]==0)
					{
						vis[u]=1;
						dis[u]=min(dis[u],dis[x]+e[i].wi);
						q.push(u);
					}
				}
			}
		}
	}
	for(int i=1;i<=n;i++)if(vis[i]==0){puts("No");return 0;}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 4224
#include <iostream>
#include <string>
#include <sstream>
using namespace std;

class Stack{
private:
  int sp;
  int S[100];

public:
  Stack(){sp=0;}
  bool isFull() const {return (sp==100);}
  bool isEmpty() const {return (sp==0);}
  void push(int d);
  int top();
  void pop();
};

void Stack::push(int d){
  if(isFull()){
    return;
  }
  S[sp++]=d;
}

int Stack::top(){
  if(isEmpty()){
    return -1;
  }
  return S[sp-1];
}

void Stack::pop(){
  if(isEmpty()){
    return;
  }
  sp--;
}


int main(){
  Stack s;
  string expr;
  getline(cin,expr);
  istringstream is(expr);

  while(!is.eof()){
    string op;
    is>>op;

    int tmp1,tmp2;

    switch(op[0]){
      case'+':
        tmp1=s.top();s.pop();
        tmp2=s.top();s.pop();
        s.push(tmp2+tmp1);
        break;
      case'-':
        tmp1=s.top();s.pop();
        tmp2=s.top();s.pop();
        s.push(tmp2-tmp1);
        break;
      case'*':
        tmp1=s.top();s.pop();
        tmp2=s.top();s.pop();
        s.push(tmp2*tmp1);
        break;
      default:
        istringstream is2(op);
        is2>>tmp1;
        s.push(tmp1);
        break;
    }
  }
  cout<<s.top()<<endl;
  return 0;
}



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

string s, t;

int main(void){
    cin >> s >> t;
    if(s.size() < t.size()){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    vector<string> r;
    for(int i = 0; i < s.size()-t.size()+1; i++){
        string p = s.substr(i, t.size());
        for(int j = 0; j < p.size(); j++){
            if(p[j] == '?') p[j] = t[j];
        }
        if(p == t) r.push_back(s.substr(0, i)+p+s.substr(i+p.size()));
    }
    if(r.size() == 0) cout << "UNRESTORABLE" << endl;
    else{
        sort(r.begin(), r.end());
        string res = r[0];
        for(int i = 0; i < res.size(); i++){
            if(res[i] == '?') cout << 'a';
            else cout << res[i];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>

int main(int argc, char **argv)
{
    int n;
    scanf("%d", &n);

    long long int p = 1;
    int div = 1000000007;
    for (int i = 1; i <= n; ++i) {
        p *= i;
        p %= div;
    }
    p %= div;
    printf("%ld\n", p);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

//find_by_order gives kth-largest element
//order_of_key gives the number of items in the set that are strictly smaller!!

// OT.find_by_order(k-1)
// 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define db4(x, y, z, w) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << "," << #w << "=" << w << endl
#define ll long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define X first
#define Y second
#define sz(x) (int)((x).size())
#define pii pair<int,int>
#define MOD (ll)(1e9 + 7)
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
typedef vector<int> vi;
#define inf (ll)(1e18)
#define double long double
#define int long long

//////////////////////
const int N = 1005;
vector<int> primes;
void pre() {
	vector<bool> pri(N,1);

	for(int i = 4; i < N; i += 2) pri[i] = 0;

	for(int i = 3; i * i < N; i += 2) {
		if(!pri[i])
			continue;
		for(int j = i * i; j < N; j += i)
			pri[j] = 0;
	}
	repA(i,2,N-1)
		if(pri[i])
			primes.pb(i);
}

int32_t main() {

    ios::sync_with_stdio(false);
    cin.tie(0); 
    cout.tie(0);
	
	int a,b,c,d;
	cin >> a >> b >>  c >> d;
	cout << max(a*b, c*d) << '\n';	
}

Measured memory_bytes: 256
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>


typedef long double ld;
typedef long long ll;

using namespace std;

ll MOD = ((ll)1e9 + 7);

struct mod {
	ll x;

	mod(ll tx = 0) {
		x = tx;
	}
	
	mod& operator=(const ll & tx) {
		x = tx;
		return *this;
	}
	
	mod& operator=(const mod & m2) {
		x = m2.x;
		return *this;
	}

	mod operator+(const mod& m2) const {
		return (x + m2.x) % MOD;
	}

	mod& operator+=(const mod& m2) {
		x += m2.x;
		x %= MOD;
		return *this;
	}

	mod operator-(const mod & m2) const {
		return (x - m2.x + MOD) % MOD;
	}

	mod& operator-=(const mod & m2) {
		x -= m2.x;
		x = (x + MOD) % MOD;
		return *this;
	}

	mod operator*(const mod & m2) const {
		return (x * m2.x) % MOD;
	}

	mod& operator*=(const mod & m2) {
		x *= m2.x;
		x %= MOD;
		return *this;
	}

	mod mypow(ll k) const {
		mod ret = 1;
		mod cur = x;
		while (k) {
			if (k & 1) {
				ret *= cur;
			}
			cur *= cur;
			k >>= 1;
		}
		return ret;
	}

	mod inv() const {
		return mypow(MOD - 2);
	}

	mod operator/(const mod & m2) const {
		return mod(((*this).x * (*this).inv().x) % MOD);
	}

	mod& operator/=(const mod & m2) {
		x *= m2.inv().x;
		x %= MOD;
		return *this;
	}

	bool operator<(const mod & m2) const {
		return x < m2.x;
	}
};

ostream &operator<<(ostream & os, const mod & m) {
	return os << m.x;
}

/* TEMPLATE ENDS HERE */

int main() {
	int n;
	cin >> n;
	if (n & 1) {
		printf("%Lf\n", (ld)((n + 1) / 2) / (ld) n);
	} else {
		cout << "0.5" << endl;
	}
	return 0;
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
ll minn(ll x, ll y){
    if(x<y)
        return x;
    return y;
}
ll maxx(ll x, ll y){
    if(x>y)
        return x;
    return y;
}
vector <int> v[100009];
ll dp[100009][2];

void cal(int cur, int par){
    dp[cur][0] = 1;
    dp[cur][1] = 1;
    for(int i=0;i<v[cur].size();i++){
        if(v[cur][i] != par){
            cal(v[cur][i], cur);
            dp[cur][0] = (dp[cur][0] * dp[v[cur][i]][1])%mod;
            dp[cur][1] = (dp[cur][1] * (dp[v[cur][i]][1] + dp[v[cur][i]][0]))%mod;
        }
    }
    // cout<<cur<<" "<<dp[cur][0]<<" "<<dp[cur][1]<<endl;
    return;
}
int main() {
    int n, x, y;
    ll ans = 0;
    cin>>n;
    for(int i=1;i<n;i++){
        cin>>x>>y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    cal(1,0);
    cout<<(dp[1][0] + dp[1][1])%mod;
}

Measured memory_bytes: 14208
using System;
using System.Linq;


	public class StableSort
	{
		public static void Main(string[] args)
		{
			int count=int.Parse(Console.ReadLine());			
			string data=Console.ReadLine();
			string[] bubble=data.Split();//?????????????????°??????
			string[] selection=data.Split();
			string stable="Stable";
			string temp;
		
			//int[] target=new int[count];
			
			/*
			for(int d=0;d<count;d++)
			{
				target[d]=int.Parse(bubble[d][1].ToString);//????????????????????£??????
			}
			*/
		//bubble sort

			for(int i=0;i<count-1;i++)
			{
				for(int j=count-1;j>i;j--)
				{
					int target=int.Parse(bubble[j][1].ToString());
					int preTarget=int.Parse(bubble[j-1][1].ToString());
					if(target<preTarget)
					{
						temp=bubble[j-1];
						bubble[j-1]=bubble[j];
						bubble[j]=temp;
						
					}
				}				
			}
			
			Console.Write(bubble[0]);
			for(int k=1;k<bubble.Length;k++)
			{
				Console.Write(" "+bubble[k]);
			}
			Console.Write("\r\n");
			
			Console.WriteLine("Stable");
			
			
			//selectionSort
			for(int i=0;i<count-1;i++)
			{  
				int mini=i;
		
				for(int j=i+1;j<count;j++)
				{
					int targetMini=int.Parse(selection[mini][1].ToString());
					int target=int.Parse(selection[j][1].ToString());
					if(target<targetMini)
					{
						mini=j;						
					}					
				}
				if(i!=mini)
				{
					temp=selection[i];
					selection[i]=selection[mini];
					selection[mini]=temp;
				}
			}
			//stable??????
			bool isEqual=bubble.SequenceEqual(selection);
			
			if(isEqual)
			{
				stable="Stable";
			}
			else
			{
				stable="Not stable";
			}
			
			Console.Write(selection[0]);
			for(int k=1;k<selection.Length;k++)
			{
				Console.Write(" "+selection[k]);
			}
			Console.Write("\r\n");
			Console.WriteLine(stable);
		}
	}

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

int main() {
	int a=0;
	string s;
	
	cin>>s;
	
	for(int i=0;i<s.size();i++){
		
		if(a==0&&s[i]=='C'){
			a=1;
		}
		if(a==1&&s[i]=='F'){
			a=2;
		}
		
	}
	
	if(a==2){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

//=============big_com============================
ll big_com(ll n, ll r) {
  vector<ll> prime(n + 1, 0);
  for (ll i = n; i > n - r; --i) {
    ll now = i;
    for (ll j = 2; j * j <= i; ++j) {
      while (now % j == 0) {
        prime.at(j) += 1;
        now /= j;
      }
      if (now == 1) {
        break;
      }
    }
    if (now != 1) {
      prime.at(now) += 1;
    }
  }
  for (ll i = r; i >= 2; --i) {
    ll now = i;
    for (ll j = 2; j * j <= i; ++j) {
      while (now % j == 0) {
        prime.at(j) -= 1;
        now /= j;
      }
      if (now == 1) {
        break;
      }
    }
    if (now != 1) {
      prime.at(now) -= 1;
    }
  }
  ll res = 1;
  for (ll i = 1; i <= n; ++i) {
    res *= pow(i, prime.at(i));
  }
  return res;
}
//=================================================

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N, P;
  cin >> N >> P;
  ll odd = 0;
  ll even = 0;
  for (ll i = 0; i < N; ++i) {
    ll a;
    cin >> a;
    if (a % 2 == 1) {
      odd += 1;
    }
    else {
      even += 1;
    }
  }
  ll ans = 0;
  if (P % 2 == 0) {
    for (ll i = 0; i <= odd / 2; ++i) {
      ans += big_com(odd, i * 2);
    }
  }
  else {
    for (ll i = 0; i < odd / 2; ++i) {
      ans += big_com(odd, i * 2 + 1);
    }
  }
  ans *= pow(2, even);
  cout << ans << "\n";
}


Measured memory_bytes: 3956
#include <algorithm>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
class edge {
   public:
    int t;
    int id;
    edge(int to, int i) : t(to), id(i) {}
    edge() {}
};
int n = 0, m = 0;
vector<vector<edge>> g;
vector<int> pre;
vector<int> ll;
vector<pair<int, int>> res;
int tt = 0;
void input() {
    cin >> n >> m;
    int id = 1, M = m;
    g = vector<vector<edge>>(n, vector<edge>());
    pre = vector<int>(n, -1);
    ll = vector<int>(n, -1);
    while (M--) {
        int a = 0, b = 0;
        cin >> a >> b;
        g[a].push_back({b, ++id});
        g[b].push_back({a, id});
    }
}
int dfs(int i, int p, int id) {
    if (pre[i] != -1) {
        ll[p] = min(ll[p], pre[i]);
        return ll[p];
    }
    pre[i] = ++tt;
    ll[i] = pre[i];
    for (auto v : g[i]) {
        if (v.id == id) {
            continue;
        }
        if (dfs(v.t, i, v.id) < 0) {
            ll[i] = min(ll[i], ll[v.t]);
            if (ll[v.t] == pre[v.t]) res.push_back({i, v.t});
        }
    }
    return -1;
}
void compute() {
    for (int i = 0; i < n; i++) {
        if (pre[i] == -1) {
            dfs(i, i, m + 2);
        }
    }
    for (auto &r : res) {
        if (r.first > r.second) {
            swap(r.first, r.second);
        }
    }
    sort(res.begin(), res.end());

    for (auto b : res) {
        cout << b.first << " " << b.second << endl;
    }
}

int main() {
    input();
    compute();
    return 0;
}


Measured memory_bytes: 5324
#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0); cin.tie(0)
typedef pair<int,int> ii;
typedef long long int ll;
typedef vector<int> vi;

struct Item{
	int val,weight;
	Item(){
		this->val = 0;
		this->weight = 0;
	}
	Item(int v, int w){
		this->val = v;
		this->weight = w;
	}
};

vector<Item> vec;

int main(){
	fast;
	int n,cap;
	cin >> n >> cap;
	vec.resize(n,Item());
	for(int i = 0 ; i < n ; i++){
		int w,v;
		cin >> w >> v;
		vec[i] = Item(v,w);
	}
	vector<vector<ll>> dp(n+1);
	for(int i = 0 ; i <= n ; i++){
		dp[i].resize(cap+1,0);
	}
	for(int item = 1 ; item <= n ; item++){
		for(int freecap = 0 ; freecap <= cap ; freecap++){
			ll pick_item = -1;
			ll not_pick_item = dp[item-1][freecap];
			if(freecap >= vec[item-1].weight){
				pick_item = dp[item-1][freecap-vec[item-1].weight] + (ll)vec[item-1].val;
			}
			dp[item][freecap] = max(pick_item,not_pick_item);
		}
	}
	cout << dp[n][cap] << endl;
	return 0;
}

Measured memory_bytes: 79488
n, a, b = map(int, input().split())
x = list(map(int, input().split()))
uf = [1]*n
ans = 0
for i in range(n-1):
    if a*(x[i+1]-x[i]) <= b:
        ans += a*(x[i+1]-x[i])
        uf[i+1] = 0
ans += b*(sum(uf)-1)
print(ans)

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

//nの約数を返す(1を含まない)
vector<ll> divisor(ll n){
    vector<ll> res;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            res.push_back(i);
            if(i*i!=n) res.push_back(n/i);
        }
    }
    sort(res.begin(),res.end());
    return res;
}

int main(){
    ll N; cin >> N;
    ll ans = 0;
    ans += divisor(N-1).size() - 1;
    vector<ll> divN = divisor(N);
    for(auto &K : divN){
        if(K == 1) continue;
        ll n = N;
        while(n % K == 0){
            n /= K;
        }
        if(n % K == 1) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3644
import java.util.*;
import java.util.stream.*;

class Main {
	Scanner sc;
	int N, M;
	int[][] B;
	Edge[] E;
	List<Edge>[] to;
	boolean[] seen;
	Set<Integer> ans;
	
	static class Edge {
		int pos, idx;
		Edge to;
	}
	
	@SuppressWarnings("unchecked")
	private void calc() {
		sc = new Scanner(System.in);
		N = sc.nextInt();
		M = sc.nextInt();
		B = new int[N+1][2];
		for (int i = 0; i < N; i++) {
			B[i][0] = sc.nextInt();
			B[i][1] = sc.nextInt();
		}
		B[N][0] = Integer.MAX_VALUE;
		B[N][1] = 0;
		Arrays.sort(B, Comparator.comparingInt(b -> b[0]));
		int v = 0;
		for (int i = 0; i <= N; i++) {
			int t = B[i][1];
			B[i][1] = v ^ B[i][1];
			v = t;
		}
		E = new Edge[M*2];
		for (int i = 0; i < M; i++) {
			E[i*2] = new Edge();
			E[i*2].pos = sc.nextInt();
			E[i*2+1] = new Edge();
			E[i*2+1].pos = sc.nextInt()+1;
			E[i*2].to = E[i*2+1];
			E[i*2+1].to = E[i*2];
			E[i*2].idx = i;
			E[i*2+1].idx = i;
		}
		Arrays.sort(E, Comparator.comparingInt(e -> e.pos));
		
		int j = 0;
		for (int i = 0; i <= N; i++) {
			while (j < E.length && E[j].pos <= B[i][0]) E[j++].pos = i;
		}
		
		to = new List[N+1];
		for (int i = 0; i <= N; i++) to[i] = new ArrayList<>();
		for (int i = 0; i < M*2; i++)
			if (E[i].pos != E[i].to.pos)
				to[E[i].pos].add(E[i]);
		
		seen = new boolean[N+1];
		ans = new TreeSet<>();
		int i = 0;
		for (; i <= N; i++)
			if (!seen[i]) if (!dfs(null, i)) break;
		if (i > N) {
			System.out.println(ans.size());
			System.out.println(ans.stream().map(String::valueOf).collect(Collectors.joining(" ")));
		} else {
			System.out.println(-1);
		}
	}
	
	boolean dfs(Edge es, int s) {
		seen[s] = true;
		for (Edge e : to[s]) {
			if (seen[e.to.pos]) continue;
			dfs(e, e.to.pos);
		}
		if (B[s][1] == 1) {
			if (es == null) return false;
			ans.add(es.idx+1);
			B[es.pos][1] ^= 1;
		}
		return true;
	}
	
	public static void main(String[] args) {
		new Main().calc();
	}
}


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

int main()
{
	int t, n, s, f, sum;
	while(cin >> t && t != 0){

		sum = 0;

		cin >> n;
		for(int i=0; i<n; i++){
			cin >> s >> f;
			sum += f-s;
		}

		if(sum >= t){
			cout << "OK" << endl;
		}
		else if(sum < t){
			cout << t - sum << endl;
		}
		
	}

	return 0;
}

Measured memory_bytes: 1160
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

int ret_idx(string s, char x)
{
	rep(i, s.size())
	{
		if (s[i] == x)
		{
			return i;
		}
	}

	return -1;
}
int main()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);

	string s;
	
	cin >> s;

	int start = -1, end = -1;

	start = ret_idx(s, 'A');
	//cout << "start = " << start << endl;
	reverse(s.begin(), s.end());

	end = s.size() - (ret_idx(s, 'Z') + 1);
	//cout << "end = " << end << endl;

	cout << end-start+1 << endl;

	
	return 0;
}


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

const int MAX = 3;
int main() {
	int cost[MAX];
	for (int i = 0;i < MAX;i ++) cin >> cost[i];
	sort(cost, cost+MAX);
	cout << cost[0] + cost[1];
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

3C2=3なので3通りのパターンをそれぞれ比較すればおｋ
安い順に買うので、上のコードのようにソートして求めても良い
*/

Measured memory_bytes: 256
#include <stdio.h>

long long gcd(long long a,long long b){
    long long r;
    while(b>0)
    {
         r=a%b;
         a=b;
         b=r;
    }
    return a;
}

int main()
{
    long long a,b,c,d;
    long long ans;
    scanf("%lld%lld%lld%lld",&a,&b,&c,&d);

    long long e,f=gcd(c,d);

    if ( b/f < c/f*d/f )
        e=b+1;
    else e=c/f*d;
    ans = b-a+1LL;
    ans -= b/c;
    ans += (a-1)/c;
    ans -= b/d;
    ans += (a-1)/d;
    ans += b/e;
    ans -=(a-1)/e;
    printf("%lld\n",ans);
    //printf("%I64d", b-a+1-( b/c- (a-1)/c ) - ( b/d-(a-1)/d ) + ( b/e-(a-1)/e  )   );



}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=[-1]*N
for i in range(N):
    C[i]=A[i]-B[i]
C.sort()
 
count=0
num=0
#print(C)
 
if (sum(C))<0:
    print(-1)
else:
    while C[0]<0:
        count+=1
        num+=C.pop(0)    
        if num<0:
            num+=C.pop(-1)
            count+=1
        if len(C)==0:
            break
    print(count)


Measured memory_bytes: 18356
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

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

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

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

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) 
{
    os << "{ ";
    for(auto& y : x) 
    {
        os << y << " ";
    }
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) 
{
    return os << "[" << p.ff << ", " << p.ss << "]";
}

ll gcd(ll a, ll b)
{
    if(b==0)
    {
        return a;
    }

    return gcd(b, a%b);
}

ll modexp(ll a, ll b, ll c)
{   
    a%=c;

    ll ans = 1;

    while(b)
    {
        if(b&1)
        {
            ans = (ans*a)%c;
        }

        a = (a*a)%c;
        b >>= 1;
    }

    return ans;
}

const ll L = 1e5+5;

ll solve(ll x)
{
    if(x == 1)
    {
        return 1;
    }

    return 1 + 2 * solve(x/2);
}

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

    ll H;
    cin >> H;

    cout << solve(H) << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	const double eps=1e-11;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.La;
		s[0]^=s[1];
		s[1]^=s[0];
		s[0]^=s[1];
		s[0]^=s[2];
		s[2]^=s[0];
		s[0]^=s[2];
		Console.WriteLine("{0}",String.Join(" ",s));
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),double.Parse);}
	public double[] Da3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;



int main() {
  ll n, m; cin >> n >> m;
  if(n == 1 && m == 1){
    cout << 1 << endl;
    return 0;
  }else if(n == 1 || m == 1){
    cout << n*m - 2 << endl;
    return 0;
  }
  cout << (n-2)*(m-2) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int n,i,j,max;
	max=0;
	scanf("%d",&n);
	int h[n],t[n-1];
	for(i=0;i<n;i++){
		scanf("%d",&h[i]);
		t[i]=0;
	}
	for(i=0;i<n-1;i++){
		j=i+1;
		if(h[i]>=h[j]){
			t[i]+=1;
			t[j]+=t[i];
		}
		if(t[i]>max){
			max=t[i];
		}
	}
	printf("%d",max);
	
	// your code goes here
	return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string s; cin>>s;
  int n=s.size();

  bool x=true, y=true;// z=true;

  for(int i=0; i<(n-1)/2; ++i)if(s[i]!=s[n-1-i])x=false;
  for(int i=0; i<(n-1)/2/2; ++i)if(s[i]!=s[(n-1)/2-1-i])y=false;
  //for(int i=(n+3)/2-1; i<n; ++i)if(s[i]!=s[n-1-i])

  if(x && y)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
# from pprint import pprint
# import math
# import collections

# n = int(input())
N, T = map(int, input().split(' '))
t = list(map(int, input().split(' ')))

total = 0
for i in range(N):
    if i > 0:
        total += min(T, t[i]-t[i-1])

    # print(i, total)
total += T

print(total)


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

#define ll long long
#define pb push_back
#define mp make_pair
#define all(s) s.begin(),s.end()
#define ld long double

using namespace std;

const int maxn = 1e5 + 7;
const ld eps = 1e-6;
const ll inf = 1e9 + 7;

int n;
ll aa[maxn], bb[maxn], cc[maxn];
vector<ll> a, b, c;
ll suff[maxn];

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> aa[i];
	}
	for (int i = 1; i <= n; i++) {
		cin >> bb[i];
	}
	for (int i = 1; i <= n; i++) {
		cin >> cc[i];
	}
	sort (aa + 1, aa + n + 1);
	sort (bb + 1, bb + n + 1);
	sort (cc + 1, cc + n + 1);
	for (int i = 1; i <= n; i++) {
		a.pb(aa[i]), b.pb(bb[i]), c.pb(cc[i]);	
	}
	vector<ll>fir;
	vector<ll>sec;
	for (int i = 1; i <= n; i++) {
		vector<ll>::iterator it;
		it = upper_bound (b.begin(), b.end(), aa[i]);
		fir.pb (n - (it - b.begin()));	
	}            
	for (int i = 1; i <= n; i++) {
		vector<ll>::iterator it;
		it = upper_bound (c.begin(), c.end(), bb[i]);
		sec.pb (n - (it - c.begin()));
	}
	/*
	for (int i = 0; i < fir.size(); i++) {
		cout << fir[i] << ' ';
	}
	cout << endl;
	for (int i = 0; i < sec.size(); i++) {
		cout << sec[i] << ' ';
	}
	*/
	suff[sec.size() - 1] = sec[sec.size() - 1];
	for (int i = sec.size() - 2; i >= 0; i--) {
		suff[i] = suff[i + 1] + sec[i];
	}
	ll ans = 0;
	for (int i = 0; i < fir.size(); i++) {
		ans += suff[n - fir[i]];
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 7392
#include <stdio.h>
#include <string.h>
int main(){
    char c[11],ans[11]={'\0'};
    scanf("%s",c);
    for(int i=0;c[i]!='\0';i++){
        if(c[i]!='B')
            ans[strlen(ans)] = c[i];
        else
            ans[strlen(ans)-1]='\0';
    }
    printf("%s\n",ans);
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <fstream>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

int main()
{
	int n,k;
	cin >> n >> k;
	cout << n - k + 1 << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static long LINF = 1L << 55;

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			long x = in.nextLong();

			long ans = 1;
			for (int i = 2; i <= (long)Math.sqrt(x)+1; i++) {
				for (int j = 2; (long)Math.pow(i, j) <= x; j++) {
					ans = Math.max(ans, (long)Math.pow(i, j));
				}
			}
			out.println(ans);
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


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

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i, n) cin >> p[i];

  sort(p.begin(), p.end());
  p[n - 1] = p[n - 1] / 2;
  int ans = 0;
  rep(i, n) ans += p[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>
using namespace std;
typedef long long LL;

LL n,a[1000005] = {0};
LL tot[1000005] = {0},tcn = 0;
priority_queue <LL> q,p;

int main(){
	ios::sync_with_stdio(false);
	cin >> n;
	for(LL i = 1;i <= (1LL << n);i ++) cin >> a[i];
	sort(a + 1,a + 1 + (1LL << n));
	LL tmp = 1;
	for(LL i = (1LL << n) - 1;i >= 0;i --){
		if(a[i] == a[i + 1]) tmp ++;
		else{
			tot[++ tcn] = tmp;
			tmp = 1;
		}
	}
	
//	for(LL i = 1;i <= tcn;i ++) cout << tot[i] << endl;
	q.push(n + 1);
	for(LL i = 1;i <= tcn;i ++){
//		cout << i << ' ' << q.size() << endl;
		if(q.size() < tot[i]){
			cout << "No" << endl;
			return 0;
		}
		for(LL j = 1;j <= tot[i];j ++){
			tmp = q.top(); q.pop();
			for(LL k = 1;k < tmp;k ++) p.push(k);
		}
		while(!p.empty()){
			q.push(p.top());
//			cout << p.top() << endl;
			p.pop();
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 9592
#include<iostream>
#include<string>
using namespace std;
int main() {
	string s; cin >> s;
	int y = stoi(s.substr(0, 4));
	int m = stoi(s.substr(5, 2));
	int d = stoi(s.substr(8, 2));
	if (y < 2019) {
		cout << "Heisei" << endl;
	}
	else if (y == 2019 && m < 4) {
		cout << "Heisei" << endl;
	}
	else if (y == 2019 && m == 4 && d <= 30) {
		cout << "Heisei" << endl;
	}
	else {
		cout << "TBD" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
/* ****TCIITB**** */

#include<bits/stdc++.h>
#define io          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;

#define N  100005

int main()
{
	
	io
	
	ll d,t,s;
	cin>>d>>t>>s;
	if(s*t>=d)
		cout<<"Yes";
	else
		cout<<"No";
}

Measured memory_bytes: 3644
// Day of Takahashi

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ios>
#include <iomanip>
#include <string>
#include <numeric>

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;

    int res = 0;
    for (int i = 1; i <= 12; i++) {
        for (int j = 1; j <= 31; j++) {
            if (i == j) {
                res++;
            }
            if (i == a && j == b) {
                break;
            }
        }
        if (i == a) {
            break;
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256