akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    static int n, a[200010], b[200010], power[31]={1}, bit[31], c, moda, modb[200010], ans=0;
    cin>>n;
    for (int i=0; i<n; i++) cin>>a[i];
    for (int i=0; i<n; i++) cin>>b[i];
    for (int i=1; i<31; i++) power[i]=power[i-1]*2;
    for (int i=0; i<29; i++)
    {
        for (int j=0; j<n; j++) modb[j]=b[j]%power[i+1];
        sort(modb, modb+n);
        c=0;
        for (int j=0; j<n; j++)
        {
            moda=a[j]%power[i+1];
            auto itr1=lower_bound(modb, modb+n, power[i]-moda), itr2=lower_bound(modb, modb+n, power[i]*2-moda);
            c+=itr2-itr1;
            itr1=lower_bound(modb, modb+n, 3*power[i]-moda); itr2=lower_bound(modb, modb+n, 4*power[i]-moda);
            c+=itr2-itr1;
            c%=2;
        }
        if (c%2==0) bit[i]=0;
        else bit[i]=1;
    }
    for (int i=0; i<29; i++) ans+=bit[i]*power[i];
    cout<<ans<<'\n';
    return 0;
}


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


int main() {
  int n;
  cin>>n;
  int a[n];
  int i,sum[n]={},usum[n]={},ans[n]={};
  for(i=0;i<n;i++){
    cin>>a[i];
    if(i==0) sum[i]=a[i];
    else sum[i]=sum[i-1]+a[i];
  }
  for(i=0;i<n;i++){
    cin>>a[i];
  }
  for(i=0;i<n;i++){
    if(i==0) usum[i]=a[n-1-i];
    else usum[i]=usum[i-1]+a[n-i-1];
  }
  for(i=0;i<n;i++){
    ans[i]=sum[i]+usum[n-1-i];
  }
  sort(ans,ans+n);
  cout<<ans[n-1];
  
    
}

Measured memory_bytes: 256
import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
# import statistics
import decimal
import heapq
import collections
import itertools
from operator import mul

sys.setrecursionlimit(100001)


# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

n = int(input())
s = input()

ans = 0
for i in range(n - 2):
    if s[i:i + 3] == "ABC":
        ans += 1

print(ans)

Measured memory_bytes: 5108
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
    int H, W;
    cin >> H >> W;
    vector<string> m;
    for (int i = 0; i < H; i++) {
        string s;
        cin >> s;
        m.push_back(s);
    }
    vector<string> ans = m;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (m[i][j] == '#') continue;
            int cnt = 0;
            for (int k = 0; k < 8; k++) {
                int tx = j + dx[k];
                int ty = i + dy[k];
                if (tx >= 0 && tx < W && ty >= 0 && ty < H) {
                    if (m[ty][tx] == '#') cnt++;
                }
            }
            ans[i][j] = '0' + cnt;
        }
    }
    for (int i = 0; i < H; i++) {
        cout << ans[i] << endl;
    }
    return 0;
}

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

int main()
{
  int N;
  std::cin >> N;
  
  struct Shop { int n; std::string city; int score; };
  std::vector<Shop> shops;
  for(int i=0; i<N; i++)
  {
    Shop s;
    s.n = i;
    std::cin >> s.city >> s.score;
    shops.push_back(s);
  }

  std::sort(shops.begin(), shops.end(), [](const Shop& l, const Shop& r)
    {
      return l.city==r.city ? l.score>r.score : l.city<r.city; 
    });

  for(const auto& s : shops)
  {
    std::cout << (s.n+1) << std::endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

#define m 1000000007

int main() {
     char L[100100];
     fgets(L, sizeof(L), stdin);

     long long result = 1;
     long long t = 1;
     for(int i = strlen(L) - 2; i >= 0; i--) {
         if (L[i] == '1') {
             result = result * 2 + t;
             result %= m;
         }
         t *= 3;
         t %= m;
     }
     printf("%lld\n", result);
}


Measured memory_bytes: 1692
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define mp make_pair
#define fir first 
#define sec second
#define int long long
#define endl "\n"
using namespace std;
const int nax=2e5+5;
vector<int>adj[nax];
const int mod=1e9+7;
const int inf=1e18+7;
int cnt[nax];
signed main(){
	int n;
	cin>>n;
	for(int i=2;i<=n; i++){
		int a;
		cin>>a;
		cnt[a]++;
	}
	for(int i=1; i<=n; i++){
		cout<<cnt[i]<<endl;
	}
	return 0;
}



Measured memory_bytes: 9840
import sys

def comb(n, r, fact, revfact, mod):
    return (fact[n] * revfact[n-r] * revfact[r]) % mod

def solve():
    H, W, A, B = map(int, input().split())
    mod = 7 + 10 ** 9
    fact = [1] * (H + W + 4)
    revfact = [1] * (H + W + 4)
    for i in range(1, H + W + 4): fact[i] = (i * fact[i-1]) % mod
    revfact[H + W + 3] = pow(fact[H + W + 3], mod - 2, mod)
    for i in reversed(range(1, H + W + 3)): revfact[i] = ((i + 1) * revfact[i + 1]) % mod

    ans = 0
    for j in range(B + 1, W + 1):
        up = comb(H - A + j - 2, j - 1, fact, revfact, mod)
        down = comb(A + W - j - 1, A - 1, fact, revfact, mod)
        ans += (up * down) % mod
        ans %= mod
    print(ans)

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 18804
#include <stdio.h>
#define mod 1000000007
#define ll long long

int main(){

  int n, i;
  int cnt[100001] = {0};
  ll ans = 1;

  scanf("%d", &n);

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

  int flag = 1;

  if(n % 2 == 1){
    if(cnt[0] != 1) flag = 0;
    for(i = 2; i <= n; i++) if(i % 2 == 0 && cnt[i] != 2) flag = 0;
  }else{
    for(i = 1; i < n; i++) if(i % 2 == 1 && cnt[i] != 2) flag = 0;
  }

  if(flag){
    for(i = 0; i < n/2; i++) ans = (ans * 2) % mod;
    printf("%lld\n", ans);
    return 0;
  }else{
    printf("0\n");
    return 0;
  }
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include<iostream>
#include<vector>
#include<map>
#include<math.h>

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)

#define fi first
#define se second

using namespace std;

using ll = long long;
using v_int = vector<int>;
using v2_int = vector<v_int>;
using v_ll = vector<ll>;
using v2_ll = vector<v_ll>;
using v_string = vector<string>;
using v_bool = vector<bool>;
using v2_bool = vector<v_bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p) {
    return o << "{" << p.first << "," << p.second << "}";
}
template<typename T> inline
istream& operator>>(istream &is, vector<T> &vec) {
    for(auto &v : vec) { is >> v; }
    return is;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &vec) {
    for(auto &v : vec) { os << v << ",";}
    return os;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<vector<T> > &mat) {
    for(auto &row : mat) { os << row << endl; }
    return os;
}

template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }
template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

int main(void)
{
    int n;
    cin >> n;
    v_int a(n+1);
    irep2(i,1,n) {
        cin >> a[i];
    }
    
    v_ll x(n+1);

    irep2(i, 1, n) {
        if(i%2) {
            x[1] += a[i];
        } else {
            x[1] -= a[i];
        }
    }

    irep2(i, 2, n) {
        x[i] = 2 * a[i-1] - x[i-1];
    }
    irep(i,n) {
        printf("%d ", x[i+1]);
    }
    return 0;
} /*atcoder*/



Measured memory_bytes: 4560
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <utility>
#include <map>
#include <unordered_map>
using namespace std;
typedef long long int ll;

int main() {
  string S;
  cin>>S;
  
  vector<bool> b(26);
  for(int i=0;i<S.size();++i){
    b[S[i]-'a']=true;
  }
  
  for(int i=0;i<26;++i){
    if(!b[i]){
      cout<<char(i+'a')<<endl;
      return 0;
    }
  }
  
  cout<<"None"<<endl;
  return 0;
}


Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
#include <iterator>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
int tx[] = {0,1,0,-1};//URDL
int ty[] = {-1,0,1,0};
 
static const double EPS = 1e-8;

class Edge{
public:
  int to;
  int distance;
  int cost;
  int road_idx;
  Edge(int _t,int _d,int _c,int _r) : to(_t),distance(_d),cost(_c),road_idx(_r) {}
  Edge() {}
  bool operator<(const Edge& e) const{
    return distance < e.distance;
  }

  bool operator>(const Edge& e) const{
    return distance > e.distance;
  }
};

class State {
public:
  int city;
  int total_distance;
  int total_cost;
  int prev_road;
  State(int _c,int _td,int _tc,int _pr) : city(_c), total_distance(_td), total_cost(_tc),prev_road(_pr) {}
  bool operator<(const State& s) const{
    return total_distance < s.total_distance;
  }
  bool operator>(const State& s) const{
    return total_distance > s.total_distance;
  }
};

int main(){
  int total_cities;
  int total_roads;
  while(~scanf("%d %d",&total_cities,&total_roads)){
    if(total_cities == 0 &&  total_roads == 0) break;

    vector<Edge> edges[10001];

    for(int road_idx = 0; road_idx < total_roads; road_idx++){
      int from,to,distance,cost;
      scanf("%d %d %d %d",&from,&to,&distance,&cost);
      edges[from-1].push_back(Edge(to-1,distance,cost,road_idx));
      edges[to-1].push_back(Edge(from-1,distance,cost,road_idx));
    }
    
    int dp[10001];
    memset(dp,0x3f,sizeof(dp));

    priority_queue<State,vector<State>,greater<State> > que;
    que.push(State(0,0,0,-1));
    
    while(!que.empty()){
      State s = que.top();
      que.pop();

      if(dp[s.city] <= s.total_distance) continue;
      dp[s.city] = s.total_distance;

      for(int i=0;i<edges[s.city].size();i++){
	int to = edges[s.city][i].to;
	int next_distance = edges[s.city][i].distance;
	int next_cost = edges[s.city][i].cost;

	que.push(State(to,s.total_distance + next_distance,s.total_cost + next_cost,i));
      }
    }

    int res = 0;
    for(int to=1; to<total_cities; to++){
      int min_v = INF;
      for(int from_idx=0; from_idx<edges[to].size(); from_idx++){
	int from = edges[to][from_idx].to;
	int distance = edges[to][from_idx].distance;
	int cost = edges[to][from_idx].cost;
	
	//check whether the path is corresponding to the dijkstra's shortest path or not
	if(dp[from] + distance == dp[to] && cost < min_v){
	  min_v = cost;
	}
      }
      res += min_v;
    }

    printf("%d\n",res);
  }
}

Measured memory_bytes: 3156
#include<cstdio>
#include<bitset>
using namespace std;
bitset<4000020> s;
int n,sum,a;
int main()
{
	s[0]=1;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	scanf("%d",&a),sum+=a,s|=(s<<a);
	for(int tmp=(sum+1)/2;;tmp++)
	if(s[tmp]){printf("%d\n",tmp);return 0;}
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
        using namespace std;
        #define int long long int
        #define pb push_back
        #define mk make_pair
        #define ft first
        #define sc second
        #define ppb pop_back
        #define sz size
        #define forn(i,a,n) for(i=a;i<n;i++)
        #define M 998244353 
        #define inf 2e18
 
        signed main() {
 

        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        
        int n,d;
        cin>>n>>d;
        int ans=0;
        while(n--){
            int a,b;
            cin>>a>>b;
            if(sqrt(a*a+b*b)<=d)
                ans++;
        }
        cout<<ans;

        return 0;
    }
    

Measured memory_bytes: 3696
#include <stdio.h>

int main()
{   
    int n,k,ans=0;
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++){
        int tmp;
        scanf("%d",&tmp);
        if(tmp>=k)ans++;
    }
    printf("%d",ans);
    
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define x first
#define y second

using namespace std;

typedef long long ll;

vector <int> opa;
int a[100005], used[100005];
vector <int> g[100005];

void dfs(int v, int cnt)
{
    used[v] = cnt;
    opa.pb(a[v]);
    for (int i = 0; i < (int) g[v].size(); i++)
    {
        int u = g[v][i];
        if (used[u] == 0) dfs(u, cnt);
    }
    return;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    for (int i = 1; i <= m; i++)
    {
        int u, v;
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }

    int cnt = 0, ans = 0;
    for (int i = 1; i <= n; i++)
    {
        opa.clear();
        if (used[i] == 0)
        {
            cnt++;
            dfs(i, cnt);
            for (int j = 0; j < (int) opa.size(); j++)
                if (used[opa[j]] == cnt) ans++;
        }
    }
    cout << ans;
    return 0;
}



Measured memory_bytes: 10236
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;


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

  cin >> N;
  cin >> S;
  cin >> T;

  // cout << S << ", " << T << endl;

  REP(i, 0, N) {
    cout << S.substr(i, 1);
    cout << T.substr(i, 1);
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  char s[10];
  while(scanf("%s",s)!=EOF){
    if(s[0]!='s'&&s[0]==s[1]&&s[1]==s[2]){
      printf("%c\n",s[0]);
    }
    else if(s[3]!='s'&&s[3]==s[4]&&s[4]==s[5]){
      printf("%c\n",s[3]);
    }
    else if(s[6]!='s'&&s[6]==s[7]&&s[7]==s[8]){
      printf("%c\n",s[6]);
    }
    else if(s[0]!='s'&&s[0]==s[3]&&s[3]==s[6]){
      printf("%c\n",s[0]);
    }
    else if(s[1]!='s'&&s[1]==s[4]&&s[4]==s[7]){
      printf("%c\n",s[1]);
    }
    else if(s[2]!='s'&&s[2]==s[5]&&s[5]==s[8]){
      printf("%c\n",s[2]);
    }
    else if(s[0]!='s'&&s[0]==s[4]&&s[4]==s[8]){
      printf("%c\n",s[0]);
    }
    else if(s[2]!='s'&&s[2]==s[4]&&s[4]==s[6]){
      printf("%c\n",s[4]);
    }
    else puts("d");
  }
    return 0;
}

Measured memory_bytes: 552
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] n = sc.next().split("");
        if (n[1].equals(n[2]) &&
                (n[0].equals(n[1]) || n[2].equals(n[3]))) {
            System.out.println("Yes");
            return;
        }
        System.out.println("No");
    }

}


Measured memory_bytes: 23764
#define _USE_MATH_DEFINES //円周率を使用
#include <math.h>
#include <iomanip> //小数点以下を表示
#include <iostream>
using namespace std;

int main(void)
{
	int a, b, c;

	cin >> a >> b >> c;

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

	return 0;
}


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

typedef long long ll;

int main() {
	ios::sync_with_stdio(0);
	
	int a, b, c;
	cin >> a >> b >> c;
	if (a+b >= c) {cout << "Yes";}
	else {cout << "No";}
	
	return 0;
}

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

minus_count = 0

for a in A:
    if a < 0:
        minus_count += 1

total = 0
min_num = 10 ** 9

for a in A:
    total += abs(a)
    min_num = min(min_num, abs(a))

if minus_count % 2 == 1:
    total -= 2 * min_num

print(total)


Measured memory_bytes: 64880
def main():
    sx, sy, tx, ty = map(int, input().split())
    print(
        ''.join(
            [
                'U' * (ty - sy),
                'R' * (tx - sx),
                'D' * (ty - sy),
                'L' * (tx - sx + 1),
                'U' * (ty - sy + 1),
                'R' * (tx - sx + 1),
                'D',
                'R',
                'D' * (ty - sy + 1),
                'L' * (tx - sx + 1),
                'U'
            ]
        )
    )


if __name__ == "__main__":
    main()


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

#define int long long
#define pii pair<int,int>
#define ff first
#define ss second
bool cmp(pii a, pii b)
{
	return (a.ss-a.ff>b.ss-b.ff);
}
void solve(int tt)
{
    
    int n;
    cin>>n;
    vector<pii> v;
    vector<int> pos,neg;
    for(int i=1;i<=n;i++)
    {
        string str;
        cin>>str;
        stack<int> st;
        int a=0,b=0;
        for(int j=0;j<str.size();j++)
        {
            if(str[j]=='(')
                st.push(j);
            else
            {
                if(st.empty())
                    b++; 
                else
                    st.pop();
            }
        }
        a=st.size();
        if(a!=0 && b!=0)
            v.push_back({b,a});
        else
        {
            pos.push_back(a);
            neg.push_back(b);
        }
    }
    int up=0,down=0;
    sort(pos.begin(),pos.end());
    sort(neg.begin(),neg.end());
    if(pos.size())
    {
        up=pos[pos.size()-1];
        for(int i=0;i+1<pos.size();i++)
            v.push_back({0,pos[i]});
    }
    
    if(neg.size())
    {
        down=neg[neg.size()-1];
        for(int i=0;i+1<neg.size();i++)
            v.push_back({neg[i],0});
    }
    int temp=0;
    sort(v.begin(),v.end(),cmp);
    for(int i=0;i<v.size();i++)
    {
        temp+=v[i].ff;
        if(up<temp)
        {
            cout<<"No";
            return;
        }
        up+=v[i].ss;
    }
    temp+=down;
    if(up!=temp)
        cout<<"No";
    else
        cout<<"Yes";
}

int32_t main()
{
    int t=1;
    //cin>>t;
    for(int i=1;i<=t;i++)
        solve(i);
}


Measured memory_bytes: 51924
#include<stdio.h>

#define NIL -1

int depth(int);

struct Node{
  int parent;
  int left;
  int right;
};

struct Node T[100000];

int main(){

  int n,id,k,c[100000],i,j,m,de,count=0;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    T[i].parent=NIL;
    T[i].right=NIL;
    T[i].left=NIL;
  }

  while(1){

    scanf("%d%d",&id,&k);
    count++;

    
    // printf("wa-i1\n");

    for(j=0;j<k;j++){
      
      scanf("%d",&c[j]);
    }

    
    /* if(count==1){
      
      T[id].parent=NIL;
      T[id].left=c[0];
      T[id].right=NIL;
      //printf("T:%d c[0]:%d\n",T[id].left,c[0]);
      } */
    
    if(k!=0){
      
      T[id].left=c[0];
      
      for(j=0;j<k;j++){
	T[c[j]].parent=id;
	
	if(j==k-1){T[c[j]].right=NIL;} 
	else {T[c[j]].right=c[j+1];}
	
      }
    }
    
    /* else if(k==0){
      
      T[id].left=NIL;
      
      
      // T[id].right=NIL;
	 }*/

    if(count==n)break;
  }

  //fprintf(stderr,"wa-i2\n");
  
  for(i=0;i<n;i++){

    //printf("wa-i4\n");
    
    de = depth(i);

    //printf("wa-i3\n");
    
    printf("node %d: parent = %d, depth = %d,",i,T[i].parent,de);
    
    if(T[i].parent==NIL){printf(" root, ");}
    else if(T[i].left==NIL){printf(" leaf, ");}
    else {printf(" internal node, ");}
    
    printf("[");

    j=T[i].left;

    //printf("\nj:%d\n",j);
    
    while(j!=NIL){

      if(T[i].left==j){
	printf("%d",j);
       
      }
      else{
	printf(", %d",j);
      }
      j=T[j].right;
    }
    
    printf("]\n");
  }

  //printf("node1:right:%d\n",T[].right);


  
  return 0;
}

int depth(int num){

  if(T[num].parent==NIL)return 0;

  return depth(T[num].parent)+1;
  
}
  

Measured memory_bytes: 2176
x, y = map(int, input().split())


def calc(xx, yy):
    if yy >= xx:
        return yy - xx
    else:
        return float('inf')


x1, y1 = x, y
x2, y2 = -x, y
x3, y3 = x, -y
x4, y4 = -x, -y

ans1 = calc(x1, y1)
ans2 = calc(x2, y2) + 1
ans3 = calc(x3, y3) + 1
ans4 = calc(x4, y4) + 2

print(min(ans1, ans2, ans3, ans4))

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

int main() {
    double current, target;
    cin >> target;

    current = 100;
    for (int year = 1; ; year++) {
        current *= 1.01;
        current = floor(current);
        if (current >= target) {
            cout << year << endl;
            break;
        }
    }
}


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

int main() {
	string s;
  	cin >> s;
  
  	bool can = true;
  
  	if(s.at(0) != 'A') can = false;
  
  	if(isupper(s.at(1)) || isupper(s.at(s.size() - 1)))  can = false;
  	
  	int C = 0;
  
  	for(int i = 2; i < s.size() - 1; i++) {
    	if(s.at(i) == 'C') C++;
      	if(isupper(s.at(i)) && s.at(i) != 'C') can = false;
    } 
  
  	if(C != 1) can = false;
  
  	if(can) {
    	cout << "AC" << endl;
    }else {
    	cout << "WA" << endl;
    }
}

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

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


Measured memory_bytes: 3092
N=int(input())
T=list(map(int,input().split()))
A=list(map(int,input().split()))
mod=10**9+7
Tres=[0]*N
Ares=[0]*N
Tres[0]=(0,T[0])
Ares[N-1]=(0,A[N-1])
for i in range(1,N):
    if T[i]>Tres[i-1][1]:
        Tres[i]=(0,T[i])
    else:
        Tres[i]=(1,T[i])
    if A[N-i-1]>Ares[N-i][1]:
        Ares[N-i-1]=(0,A[N-i-1])
    else:
        Ares[N-i-1]=(1,A[N-i-1])
if Tres[0]<=Ares[0]:
    ans=1
else:
    ans=0
for i in range(1,N):
    x,t=Tres[i]
    y,a=Ares[i]
    if x==y==1:
        ans=ans*min(t,a)%mod
    elif x==1 and y==0 and t<a:
        ans=0
    elif x==0 and y==1 and t>a:
        ans=0
    elif x==0 and y==0 and t!=a:
        ans=0
print(ans)

Measured memory_bytes: 25412
#pragma GCC optimize ("O2")
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-label"
#pragma GCC diagnostic ignored "-Wsign-compare"

#include <bits/stdc++.h>
using namespace std;

#define trav(a, A) for (auto & a : A)
#define f first
#define s second

typedef long long ll;

const ll MOD = 1e+9+7;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const ll MAXN = 1e+5+7;

int main ()
{
	ios_base::sync_with_stdio (0);
	cin.tie (0);
	int tc = 1; //cin >> tc;
	while (tc--)
	{
		int i, j, n, q, t, f;
		char c;
		string s;
		cin >> s >> q;
		deque <char> dq;
		bool inv = false;
		trav (a, s) dq.push_back (a);
		for (int qq = 0; qq < q; ++qq)
		{
			cin >> t;
			if (t == 1) inv = !inv;
			else
			{
				cin >> f >> c;
				while (c < 'a' || 'z' < c) cin >> c;
				if ((f == 1 && !inv) || (f == 2 && inv)) dq.push_front (c);
				else dq.push_back (c);
			}
		}
		if (inv)
			for (auto itt = dq.rbegin (); itt != dq.rend (); ++itt)
				cout << *itt;
		else
			trav (a, dq)
				cout << a;
		cout << '\n';
	}

	return 0;
}



Measured memory_bytes: 976
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin>>n;
    int s[n];
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        s[i]=a;
    }
    int l=0,ans=0;
    while(l<n-1){
        if(s[l]==s[l+1]){
            ans++;
            l+=2;
        }
        else l++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
using namespace std;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    // cout << fixed << setprecision(20);
    int n,r;cin >> n >> r;
    if(n < 10)cout << r + 100*(10-n) << '\n';
    else cout << r << '\n';

    return 0;
}


Measured memory_bytes: 256
<?php
while(1){
  $n=trim(fgets(STDIN));
  if(!$n) break;

  $Np=explode(' ',trim(fgets(STDIN)),$n);

  $x=0;
  $n=count($Np);

  foreach($Np as $np) $x+=$np;

  $m=$x/$n;
  $y=0;
  foreach($Np as $np) $y+=pow($np-$m,2);

  echo sqrt($y/$n),PHP_EOL;
}

Measured memory_bytes: 15788
#include <bits/stdc++.h>
using namespace std;
                     
#define int             long long
#define ld              long double
#define mp              make_pair
#define ff              first
#define ss              second
#define pb              push_back
#define fo(i,n)         for(i=0;i<n;i++)
#define fo1(i,n)        for(i=1;i<=n;i++)
#define FO(i,a,b)       for(i=a;i<=b;i++)
#define FOR(i,a,b)       for(i=a;i>=b;i--)
#define all(c)          c.begin(),c.end()
#define rall(c)         c.rbegin(),c.rend()
#define si              set<int>
#define vi              vector<int>
#define mii             map<int,int>
#define pii             pair<int,int>
#define vpii            vector<pii>
#define vvi             vector<vi>
#define usi             unordered_set<int>
#define umii            unordered_map<int,int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int,vi,greater<int> >
#define sp(x)           cout<<setprecision(x)<<fixed;
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)     __builtin_ctzll(x)
#define in(a,n)         vi a(n);fo(i,n)cin>>a[i];
#define in1(a,n)        vi a(n+1);fo1(i,n)cin>>a[i];
#define w(t)            int t;cin>>t;while(t--)
#define sz(v)           (int)v.size()
#define gcd             __gcd
#define lcm(x,y)        x*(y/gcd(x,y))
#define endl            '\n'
#define PI              3.14159265358979323846
const int inf =         1e18;
const int mod =         1e9+7;
void __p(int x) {cout<<x;}
void __p(int32_t x){cout<<x;}
void __p(float x){cout<<x;}
void __p(double x){cout<<x;}
void __p(ld x) {cout<<x;}
void __p(char x){cout <<'\''<<x<<'\'';}
void __p(const char *x){cout <<'\"' <<x<<'\"';}
void __p(const string &x) {cout<<'\"'<<x<<'\"';}
void __p(bool x) {cout<<(x?"true":"false");}
void _p() {cout << "]\n";}
template<typename T,typename V>     void __p(const pair<T,V> &x) {cout<<'{';__p(x.first);cout<<',';__p(x.second);cout<<'}';}
template<typename T>                void __p(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __p(i); cout << "}";}
template <typename T,typename... V> void _p(T t, V... v) {__p(t);if(sizeof...(v))cout<<", ";_p(v...);}
int po(int x,int p) {int ans=1;x%=mod;while(p>0){if(p&1)ans=(ans*x)%mod;p=p>>1;x=(x*x)%mod;}return ans;}
int inv(int x){return po(x,mod-2)%mod;}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout<<"["<<#x<<"]=[";_p(x)
#else 
#define dbg(x...)
#endif
//=================================================================================




const int N=1e6+6;
int n,m,k,x,y,z,a,b,c,d,i,j,l,r,f,q;








void sol()
{ 
  cin>>l>>r>>d;
  
  
  
  
  cout<< r/d-(l-1)/d <<endl;
}





int32_t main()
{ 
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  //pre();
  //sp(10);
//   w(t)
  sol();
  return 0;
}  

Measured memory_bytes: 3612
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;
 
void main() {
    auto N = readln.chomp.to!int;
    auto edges = new int[][](N);
    foreach (_; 0..N-1) {
        auto s = readln.split.map!(to!int);
        edges[s[0] - 1] ~= s[1] - 1;
        edges[s[1] - 1] ~= s[0] - 1;
    }

    int dfs(int n, int p) {
        int ret = 0;
        foreach (m; edges[n]) if (m != p) ret ^= (dfs(m, n) + 1);
        return ret;
    }

    writeln( dfs(0, -1) ? "Alice" : "Bob" );
}


Measured memory_bytes: 17788
use std::io::stdin;
use std::vec::Vec;

mod utils {
    use std::io::BufRead;
    use std::str::{self, FromStr};

    pub struct StdinReader<R: BufRead> {
        reader: R,
        buf: Vec<u8>,
    }

    impl<R: BufRead> StdinReader<R> {
        pub fn new(reader: R) -> StdinReader<R> {
            StdinReader {
                reader: reader,
                buf: Vec::new(),
            }
        }

        #[allow(unused)]
        #[inline]
        pub fn reads<T: FromStr>(&mut self) -> T {
            self.read_until(b' ')
        }

        #[allow(unused)]
        #[inline]
        pub fn readl<T: FromStr>(&mut self) -> T {
            self.read_until(b'\n')
        }

        #[allow(unused)]
        #[inline]
        pub fn read_vec<T: FromStr>(&mut self) -> Vec<T> {
            return self.read_until::<String>(b'\n').trim().split_whitespace().map(|c| c.parse().ok().unwrap()).collect();
        }

        #[inline]
        pub fn read_until<T: FromStr>(&mut self, delim: u8) -> T {
            loop {
                self.buf.clear();
                let len = self.reader
                    .read_until(delim, &mut self.buf)
                    .expect("failed reading bytes");
                match len {
                    0 => panic!("early eof"),
                    1 if self.buf[0] == delim => (),
                    _ => {
                        if self.buf[len - 1] == delim {
                            self.buf.truncate(len - 1);
                        }
                        break;
                    }
                }
            }

            let elem = unsafe { str::from_utf8_unchecked(&self.buf) };
            elem.parse().unwrap_or_else(|_| panic!(format!("failed parsing: {}", elem)))
         }
    }
}


fn main(){
    let stdin = stdin();
    let mut r = utils::StdinReader::new(stdin.lock());
    let n:usize = r.readl();
    let mut ds = vec![];
    for i in 0..n {
        let tar:i16 = r.readl();
        ds.push(tar);
    }

    ds.sort();

    let mut pre_d = 0;

    let mut res = 0;

    for d in ds {
        if(pre_d == d) {

        }else{
            res += 1;
        }
        pre_d = d;
    }
    println!("{}",res);
}


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

using namespace std;

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

	string s;
	cin >> s;
	vector<int> ans(s.size(), 0);

	int num = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'R') {
			num++;
		}
		else if(num != 0){
			ans[i] += num / 2;
			ans[i - 1] += num / 2;
			if (num % 2 == 1)ans[i - 1]++;
			num = 0;
		}
	}
	num = 0;
	for (int i = s.size()-1; i >= 0; i--) {
		if (s[i] == 'L') {
			num++;
		}
		else if (num != 0) {
			ans[i] += num / 2;
			ans[i + 1] += num / 2;
			if (num % 2 == 1)ans[i + 1]++;
			num = 0;
		}
	}

	for (int i = 0; i < ans.size(); i++) {
		cout << ans[i] << " ";
	}

}

Measured memory_bytes: 1104
N, M = [int(v) for v in input().split()]
H = [int(v) for v in input().split()]
is_good = [True] * N
for i in range(M):
    A, B = [int(v) - 1 for v in input().split()]
    if H[A] <= H[B]:
        is_good[A] = False
    if H[A] >= H[B]:
        is_good[B] = False
print(sum(is_good))

Measured memory_bytes: 20096
#include <cstdio>

using namespace std;

int main()
{
    int m,f,b;
    scanf( "%d %d %d\n", &m, &f, &b );
    int ret = b - m;
    if( ret < 0 )
    {
        printf("%d\n", 0 );
    }
    else if( f < ret )
    {
        printf("NA\n");
    }
    else
    {
        printf( "%d\n", ret );
    }
    return 0;
}


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

#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;

typedef long long ll;

int main(){

    int a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;

    int ans = INT_MAX;

    for(int i = 0; i <= 200000; i = i + 2){
        int tmp = i * c;

        tmp += max(x - i / 2, 0) * a;
        tmp += max(y - i / 2, 0) * b;

        ans = min(ans, tmp);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException{
		Traveling solver = new Traveling();
		solver.readInput();
		solver.solve();
		solver.writeOutput();
	}

	static class Traveling {

		private int n;
		private int t[];
		private int x[];
		private int y[];
		private Scanner scanner;
		private String output;

		public Traveling() {
			scanner = new Scanner(System.in);
		}

		public void readInput() {
			n = Integer.parseInt(scanner.next());

			t = new int[n];
			x = new int[n];
			y = new int[n];

			for(int i=0; i<n; i++) {
				t[i] = Integer.parseInt(scanner.next());
				x[i] = Integer.parseInt(scanner.next());
				y[i] = Integer.parseInt(scanner.next());
			}

			return ;
		}

		public void solve() {
			for(int i=0; i<n; i++) {
				if(t[i] < (x[i]+y[i]) || (t[i]%2 != (x[i]+y[i])%2)) {
					output = "No";
					return;
				}
			}
			output = "Yes";
		}
		public void writeOutput() {
			System.out.println(output);
			return ;
		}
	}
}

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

int main() {
  int n,x,y;
  cin >> n >> x >> y;
  int a[n];
  r(i,n)a[i]=0;
  r(i,n){
    for(int j=i+1;j<=n-1;j++){
      a[min(abs(j-i),min(abs(x-1-i)+1+abs(y-1-j),abs(y-i-1)+1+abs(x-j-1)))]++;
    }
  }
  r(i,n-1)cout<<a[i+1]<<endl;
}

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

using namespace std;

string s;
int n;

int main () {
	cin >> n;
	cin >> s;
	for(int i = 0; i < s.size(); i++) {
		if(int(s[i]) + n > 'Z') {
			cout << char(int(s[i]) + n - 26);
		}
		else {
			cout << char(s[i] + n);
		}
	}
	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T, class U> inline bool chmax(T& a,U b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class U> inline bool chmin(T& a,U b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (auto &e : a) cin >> e;
    
    long long ans = 1;
    vector<int> v(n+1, 0);
    for (const auto &e : a) ans += v[e]++;
    for (const auto &e : a) cout << ans - v[e] << '\n';
    return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	std::string a, b, c; cin >> a >> b >> c;
	
	if(a.back() == b[0] and b.back() == c[0]) printf("YES\n");
	else printf("NO\n");
	return 0;
}


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

int main()
{
    vector<tuple<int, int, char, lli, string>> v;
    int n, i;
    int value, weight;
    char type;
    lli date;
    string name;
    cin >> n;
    while (n--)
    {
        cin >> value >> weight >> type >> date >> name;
        v.push_back(make_tuple(value, weight, type, date, name));
    }
    sort(v.begin(), v.end());
    for (i = 0; i < v.size(); i++)
    {
        cout << get<0>(v[i]) << ' ' << get<1>(v[i]) << ' ' << get<2>(v[i]) << ' ' << get<3>(v[i]) << ' ' << get<4>(v[i]) << endl;
    }
}


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

void minCost(int index, int k, vector<int> &arr, vector<int> &dp){
    //Base cases
    
    if(index == arr.size() - 1){
        dp[index] = 0;
        return;
    }

    int minCostFromIndex = INT_MAX;
    for (int i = 1; i <= k; i++)
    {
        if(index + i >= arr.size()){
            break;
        }
        if(dp[index + i] == -1){
            minCost(index + i, k, arr, dp);
        }
        minCostFromIndex = min(minCostFromIndex, dp[index + i] + abs(arr[index + i] - arr[index]));
    }
    
    dp[index] = minCostFromIndex;

}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n, k;
    cin >> n >> k;
    vector<int> arr(n);
    for (int i = 0; i < n; i++)
    {
        cin >> arr[i];
    }

    vector<int> dp(n, -1); // the ith position gives minCost from ith to N
    minCost(0, k, arr, dp);

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

Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
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;
}
int main(){
    ll n;
    cin>>n;
    map<ll,ll>mp;
    ll ans = 0;
    for (ll i = 0; i < n; i++){
        string s;
        cin >> s;
        for (ll t = 0; t < s.size() - 1;t++){
            if (s.substr(t, 2) == "AB") ans++;
        }
            if (s[0] == 'B' and s[s.size() - 1] == 'A')
                mp[0]++;
            else if (s[0] == 'B')
                mp[1]++;
            else if (s[s.size() - 1] == 'A')
                mp[2]++;
    }
    if (!mp[0]) ans += min(mp[2], mp[1]);
    else if(!mp[2] and !mp[1])
        ans += mp[0] - 1;
    else ans+=mp[0]+min(mp[2], mp[1]);
    cout << ans << endl;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;
template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
long long mod = 998244353;
#define REP(i, n) for (long long i = 0; i < (n); i++)

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}

long long moddiv(long long a, long long b) { return (a * modpow(b, mod - 2)) % mod; }

long long nCkmod(long long n, long long k) {
    long long denomi = 1;
    REP(i, n) {
        denomi *= (i + 1);
        denomi %= mod;
    }
    long long numera = 1;
    for (int i = n - k; i > 0; i--) {
        numera *= i;
        numera %= mod;
    }
    REP(i, k) {
        numera *= (i + 1);
        numera %= mod;
    }
    return moddiv(denomi, numera);
}

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}
double memo[101][61][50][50];
signed main() {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    char want = s[0];
    char now = s[0];
    int cnt = 0;
    REP(i, n) {
        if (s[i] != now && s[i] != want) {
            k--;
        }
        now = s[i];
        if (s[i] != want && k >= 0) {
            if (s[i] == 'L') {
                s[i] = 'R';
            } else if (s[i] == 'R') {
                s[i] = 'L';
            }
            //cout << s << endl;
        }
    }
    int unhappy = 0;
    REP(i, n - 1) {
        if (s[i] == 'R' && s[i + 1] == 'L') {
            unhappy += 2;
        }
    }
    if (s[0] == 'L') {
        unhappy++;
    }
    if (s[n - 1] == 'R') {
        unhappy++;
    }
    cout << n - unhappy << endl;
}

Measured memory_bytes: 512
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        PrintWriter out = new PrintWriter(System.out);
        Scanner sc = new Scanner(System.in);
        Task task = new Task();
        task.solve(sc, out);
        out.flush();
        sc.close();
    }
    static class Task{
        public void solve(Scanner sc, PrintWriter out){
            long N = nlong(sc);
            long M = nlong(sc);

            if (N >=2 && M >= 2){
                out.println((N-2)*(M-2));
            }else if (N == 1 && M !=1 ){
                out.println(M-2);
            }else if (N !=1 && M == 1){
                out.println(N-2);
            }else {
                out.println(1);
            }



        }
    }

    static int nint(Scanner sc){
        return Integer.parseInt(sc.next());
    }
    static long nlong(Scanner sc){
        return Long.parseLong(sc.next());
    }
    static double ndouble(Scanner sc){
        return Double.parseDouble(sc.next());
    }
    static float nfloat(Scanner sc){
        return Float.parseFloat(sc.next());
    }
    static String nstr(Scanner sc){
        return  String.valueOf(sc.next());
    }
    static long[] longLine(Scanner sc, int size){
        long[] lLine = new long[size];
        for (int i = 0; i < size; i++) {
            lLine[i] = nlong(sc);
        }
        return lLine;
    }
    static int[] intLine(Scanner sc, int size){
        int[] iLine = new int[size];
        for (int i = 0; i < size; i++) {
            iLine[i] = nint(sc);
        }
        return iLine;
    }
    static String[] strLine(Scanner sc, int size){
        String[] strLine = new String[size];
        for (int i = 0; i < size; i++) {
            strLine[i] = nstr(sc);
        }
        return strLine;
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;cin>>n;
    ll ary[n];
    rep(i,n) cin>> ary[i];

    ll ruisekiwa[n+1];
    ruisekiwa[0] = 0;
    map<ll, ll> mp;
    mp[0] = 1;
    rep(i,n)
    {
        ruisekiwa[i+1] = ruisekiwa[i]+ary[i];
        auto tmp_iter = mp.find(ruisekiwa[i+1]);
        if (tmp_iter == mp.end())
        {
            mp[ruisekiwa[i+1]] = 1;
        }
        else
        {
            mp[ruisekiwa[i+1]] ++;
        }
    }
    ll ans = 0;
    for (auto iter = mp.begin(); iter!=mp.end();iter++)
    {
        ans += iter->second * (iter->second-1) / 2;
    }
    // for (auto iter = mp.begin(); iter!=mp.end();iter++)
    // {
    //     cout << iter->first << " " << iter->second << endl;
    // }

    cout << ans << endl;

    
}


Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fr(i,j,n)   for(int i=j;i<(n);++i)
#define bk(i,j,n)   for(int i=j;i>n;--i)
#define mset(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define pop pop_back
#define mod 1000000007
#define all(x) x.begin(),x.end()
#define inf 1e18
#define iosbase ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F first
#define S second
#define bye return

int main()
{
    ll x,a1=0,a2=0,ans=0;
    cin>>x;

    a1=x/500;
    a2=x/5;
    ans=(a1*500)+(a2*5);

    cout<<ans<<endl;
    
    bye 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string names;
int main()
{
//	freopen("input.txt","r",stdin);
//	freopen("output.txt","w",stdout);
	cin>>names;
	int l=names.size(),ans=0;
	for(int i=0;i<l;i++)
	{
	if(names[i]=='C')ans=10086;
	else if(names[i]=='F'&&ans==10086)
	{
		cout<<"Yes";
		return 0;
	}
	}
	cout<<"No";
	return 0;
	return 0;
}

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

int main() {
	int K;
	cin >> K;
	if (K % 2 == 0) {
		cout << (K / 2) * (K / 2) << endl;
	} else {
		cout << ((K+1) / 2) * (K-1)/2 << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
  int N,  m = 0;
  int ans = 0;
  cin >> N;
  vector<int> p(N);

  for(int i = 0; i < N; i++){
    cin >> p.at(i);
  }

  for(int i = 0; i < N; i++){
    ans += p.at(i);
    if(p.at(i) > p.at(m)){
      m = i;
    }
  }

  ans -= p.at(m) / 2;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256