akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define out(str) cout << str << endl

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

int D,N,ans;

int main(){
    cin >> D >> N;
    if(N==100) N++;
    ans = N*pow(100,D);
    out(ans);
    return 0;
}

Measured memory_bytes: 256
S = input()
S = S + "R"
odd_count = 0
even_count = 0
ans = [0] * len(S)
for i in range(len(S) - 1):
    if i % 2 == 0:
        even_count += 1
    else:
        odd_count += 1
    if S[i] == 'R' and S[i + 1] == 'L':
        right_index = i + 1
        left_index = i
        start = i
    if S[i] == "L" and S[i + 1] == "R":
        if start % 2 == 1:
            ans[left_index] = odd_count
            ans[right_index] = even_count
        else:
            ans[left_index] = even_count
            ans[right_index] = odd_count
        odd_count = 0
        even_count = 0
for i in range(len(S) - 1):
    print(ans[i] , end = " ")

Measured memory_bytes: 4864
N,M=map(int,input().split())
a=[int(input()) for i in range(M)]
tf=[0]*(N+1)
for i in a:
  tf[i]=1
dp=[0]*(N+1)
dp[0]=1
dp[1]=0 if 1 in a else 1
mod=10**9+7
 
for i in range(2,N+1):
    if tf[i] == 1:
        continue
    else:
        dp[i]=(dp[i-1]+dp[i-2])%mod
 
print(dp[N])

Measured memory_bytes: 8612
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

//		String Sx = "?fb??fb?f?b?";
//		String T = "fb";
		String Sx = sc.nextLine();
		String T = sc.nextLine();

		// マッチングした文字列の中で辞書順最小を取得するためのリスト
		List<String> matchStrs = new ArrayList<>();

		String SxMatch;
		String SxRep;
		Pattern p;
		Matcher m;

		for (int i = Sx.length() - T.length(); i >= 0 ; i--) {
			// Tの長さ分のSxの文字列を生成
			SxMatch = Sx.substring(i, i + T.length());

			// 文字列?を正規表現[a-z]?に置換する
			SxRep = SxMatch.replaceAll("\\?", "[a-z]");

			// 文字列の頭から順番に正規表現でパターンマッチングする
			p = Pattern.compile(SxRep);
			m = p.matcher(T);

			if (m.find()) {
				// 見つかった場合
				// マッチングした部分文字列についてはTで置換、残りの?についてはaで置換
				String forwardT = Sx.substring(0, i);
				String BehindT = Sx.substring(i+T.length(), Sx.length());
				String S = (forwardT + T + BehindT).replaceAll("\\?", "a");
//				System.out.println(S);
				matchStrs.add(S);
			}
		}

		if (!matchStrs.isEmpty()) {
			// マッチング文字列が見つかった場合は辞書順にソートして最小の文字列を出力
			String[] strs = matchStrs.toArray(new String[matchStrs.size()]);
			Arrays.sort(strs);
//			System.out.println("----------------");
			System.out.println(strs[0]);
		} else {
			// 見つからなかった場合
			System.out.println("UNRESTORABLE");
		}
	}
}

Measured memory_bytes: 21844
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

char line[10000];
char str1[10000];
char str2[10000];
char str3[10000];
char temp[10000];
char ans[10000];

int main() {
  map<string, int> mapto;
  mapto["yotta"] = 24;
  mapto["zetta"] = 21;
  mapto["exa"] = 18;
  mapto["peta"] = 15;
  mapto["tera"] = 12;
  mapto["giga"] = 9;
  mapto["mega"] = 6;
  mapto["kilo"] = 3;
  mapto["hecto"] = 2;
  mapto["deca"] = 1;
  mapto["deci"] = -1;
  mapto["centi"] = -2;
  mapto["milli"] = -3;
  mapto["micro"] = -6;
  mapto["nano"] = -9;
  mapto["pico"] = -12;
  mapto["femto"] = -15;
  mapto["ato"] = -18;
  mapto["zepto"] = -21;
  mapto["yocto"] = -24;

  int test;
  scanf("%d ", &test);
  while (test--) {
    int base = 0;
    fgets(line, 9999, stdin);
    int v = sscanf(line, "%s %s %s", str1, str2, str3);
    if (v == 3) {
      memcpy(temp, str3, sizeof(temp));
      memcpy(str3, str2, sizeof(temp));
      memcpy(str2, temp, sizeof(temp));
      assert(mapto.count(str3));
      base = mapto[str3];
    }
    int len = strlen(str1);
    int dir = 1;
    if (str1[0] == '0') { dir = -1; }
    else { base--; }
    bool end = false;
    int index = 0;
    REP(i, len) {
      if (dir == 1) {
        if (str1[i] == '.') { end = true; continue; }
        if (!end) { base += dir; }
        if (index == 1) {
          ans[index++] = '.';
        }
        ans[index++] = str1[i];
      } else {
        if (str1[i] == '.') { continue; }
        if (str1[i] != '0') { end = true; }
        if (!end) { base += dir; }
        if (end) {
          if (index == 1) {
            ans[index++] = '.';
          }
          ans[index++] = str1[i];
        }
      }
    }
    ans[index] = 0;
    printf("%s * 10^%d %s\n", ans, base, str2);
  }
}

Measured memory_bytes: 0
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    a = LI()
    a.sort()
    if n&1:
        n >>= 1
        if a != sorted([2*i for i in range(n+1)]+[2*i for i in range(1,n+1)]):
            print(0)
        else:
            print(pow(2,n,mod))
    else:
        n >>= 1
        if a != sorted([2*i+1 for i in range(n)]+[2*i+1 for i in range(n)]):
            print(0)
        else:
            print(pow(2,n,mod))
    return

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


Measured memory_bytes: 52464
#include <cstdio>
#include <cmath>
#include <algorithm>
#pragma warning(disable:4996)
using namespace std;


int main()
{
	int n;
	scanf("%d", &n);
	int ans = 0;
	
	for (int i = 1; i <= n; i++) {
		int cnt = 0;
		int x = i;
		while (x != 0) {
			cnt++;
			x /= 10;
			
		}
		if (cnt % 2 == 1)ans++;
	}
	printf("%d", ans);
}

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


def main():
    n, k = map(int,  input().split())
    s = input()
    k = k - 1
    replaced = s[k]
    if replaced.isupper():
        replaced = replaced.lower()
    else:
        replaced = replaced.upper()

    result = s[:k] + replaced + s[k+1:]
    print(result)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Abc160E
    {
        public static void Main()
        {
            var xyabc = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var x = xyabc[0];
            var y = xyabc[1];
            var a = xyabc[2];
            var b = xyabc[3];
            var c = xyabc[4];

            var p = Console.ReadLine().Split(' ').Select(s => long.Parse(s)).OrderByDescending(i => i).Take(x);
            var q = Console.ReadLine().Split(' ').Select(s => long.Parse(s)).OrderByDescending(i => i).Take(y);
            var r = Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToList();

            r.AddRange(p);
            r.AddRange(q);
            r.Sort();
            long score = r.GetRange(r.Count-x-y, x+y).Sum();
            Console.WriteLine(score);
        }
    }
}


Measured memory_bytes: 49096
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

bool is_prime(int n) {
	if (n == 2 || n == 3) {
		return true;
	}

	if (n < 2 || n%2 == 0) {
		return false;
	}
	
	for (int i = 3; i < n; i = i+2) {
		if (n%i == 0) {
			return false;
		}
	}
	return true;
}

int main(void) {
	int N = 1100000;
	vector<bool> prime(N);
	for (int i = 0; i < N+1; ++i) {
		prime[i] = true;
	}
	prime[0] = false;
	prime[1] = false;
	for (int i = 2; i <= sqrt(N); ++i) {
		if (is_prime(i)) {
			for (int j = 2; i*j < N+1; ++j) {
				prime[i*j] = false;
			}
		}
	}
	int a,d,n;
	while (cin >> a >> d >> n, n) {
		int count = 0;
		bool find = false;
		for (int i = a; !find && i < N; i = i+d) {
			if (prime[i]) {
				++count;
				if (count == n) {
					cout << i << endl;
					find = true;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3060
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int n, k;
    scan(n, k);
    auto t = new int[](n);
    auto d = new long[](n);
    iota(n).each!(i => scan(t[i], d[i]));
    t[] -= 1;

    auto c = new long[][](n, 0);
    foreach (i ; 0 .. n) {
        c[t[i]] ~= d[i];
    }

    long[] top;
    long[] nkr;

    foreach (i ; 0 .. n) {
        c[i].sort!"a > b"();
        if (!c[i].empty) {
            top ~= c[i].front;
            nkr ~= c[i][1 .. $];
        }
    }

    auto m = top.length.to!int;

    top.sort!"a > b"();
    nkr.sort!"a > b"();

    debug {
        writeln(top);
        writeln(nkr);
    }

    auto ts = new long[](m + 1);
    foreach (i ; 1 .. m + 1) {
        ts[i] = top[i-1] + ts[i-1];
    }
    auto ns = new long[](nkr.length + 1);
    foreach (i ; 1 .. nkr.length + 1) {
        ns[i] = ns[i-1] + nkr[i-1];
    }

    long ans;

    foreach (i ; 1 .. n + 1) {
        if (i > k || i > m) {
            break;
        }
        if (k - i > nkr.length) {
            continue;
        }
        long tmp = ts[i] + ns[k - i] + 1L * i * i;
        ans = max(ans, tmp);
    }

    writeln(ans);
}





void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


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

#define rep(j, n) for (int i = j; i < n; i++)
#define repj(k, n) for (int j = k; j < n; j++)
#define repd(j, n) for (int i = j; i > n; i--)

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

int main() {
	ll n, w;
	cin >> n >> w;
	vector<ll> h(n),v(n);
	rep(0, n) {
		cin >> h[i] >> v[i];
	}
	vector<vector<ll>> dp(n+1,vector<ll>(w+1));
	rep(0, w+1) {
		dp[0][i] = 0;
	}
	rep(0,n) {
		repj(0,w+1) {
			if (j<h[i]) {
				dp[i+1][j] = dp[i][j];
			}
			else {
				dp[i+1][j] = max(dp[i][j], dp[i][j - h[i]] + v[i]);
			}
		}
	}
	cout << dp[n][w] << endl;
	return 0;
}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b,ll c){if(a==b)out(c);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}
int main(){
    ll n,k,c;cin>>n>>k>>c;
    string s;cin>>s;
    vi v;
    rep(i,n)if(s[i]=='o')v.pb(i);
    ll m=v.size();
    vi dp(m);
    for(int i=m-1;i>=0;i--){
        ll nx=lb(v,v[i]+c+1);
        if(nx==m)dp[i]=1;
        else dp[i]=dp[nx]+1;
    }
    vi dp2(m);
    ll cnt=0,b=-inf;
    rep(i,m){
        dp2[i]=cnt;
        if(v[i]-b>c){
            b=v[i];
            cnt++;
        }
    }
    rep(i,m){
        ll s=dp2[i];
        if(i<m-1)s+=dp[i+1];
        if(s<k)out(v[i]+1);
    }
}

Measured memory_bytes: 6516
if __name__ == '__main__':

	input()
	A = list(map(int,input().split()))
	leng = len(A)
	m_cnt = 0
	max_val = 0

	for i in range(leng-1):
		if A[i] >= A[i+1]:
			m_cnt += 1
		else:
			if max_val < m_cnt:
				max_val = m_cnt
			m_cnt = 0
	max_val = max(m_cnt,max_val)
	print(max_val)


Measured memory_bytes: 14252
#include <stdio.h>

char a[256], b[256], c[256];
int aa=0, bb=0, cc=0;

char a_() {
	aa++;
	return a[aa-1];
}

char b_() {
	bb++;
	return b[bb-1];
}

char c_() {
	cc++;
	return c[cc-1];
}

int main() {
	int i, c_c;
	scanf("%s%s%s", a, b, c);
	c_c = a_();
	while (1) {
		if (c_c == 'a') {
			if((c_c=a_()) == 0) {
				printf("A\n");
				break;
			}
		} else if (c_c == 'b') {
			if ((c_c=b_()) == 0) {
				printf("B\n");
				break;
			}
		} else if (c_c == 'c') {
			if ((c_c=c_()) == 0) {
				printf("C\n");
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main ()
{
    char n;
    cin>>n;
    int i=(int)n;
    if(i>=65 && i<=90)
    {
        cout<<"A";
    }
    if(i>=97 && i<=122)
    {
        cout<<"a";
    }
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;
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;

#define fread           freopen("input.txt","r",stdin)
#define fwrite          freopen("output.txt","w",stdout)
#define eb              emplace_back
#define em              emplace
#define pb              push_back
#define Mp              make_pair
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())
#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define memo(ara,val)   memset(ara,val,sizeof(ara))
#define II              ( { int a ; read(a) ; a; } )
#define LL              ( { ll a ; read(a) ; a; } )
#define DD              ({double a; scanf("%lf", &a); a;})
#define rep(i,n)        for(int i=0;i<n;i++)
#define rep1(i,n)       for(int i=1;i<=n;i++)
#define rrep(i,a,n)     for(int i=a;i<=n;i++)
#define per(i,n,a)      for(int i=n;i>=a;i--)
#define pf(n)           printf("%lld",n)
#define pfi(n)          printf("%d",n)
#define sp              printf(" ")
#define ln              printf("\n")
#define sc(x)           scanf("%lld",&x)
#define scw(x)          scanf("%I64d",&x)
#define sci(x)          scanf("%d",&x)
#define sc2(x,y)        scanf("%lld %lld",&x,&y)
#define sc3(x,y,z)      scanf("%lld %lld %lld",&x,&y,&z)
#define Found(a, b)     a.find(b) != a.end()
// bool operator< (const node& sx) const { return sx.val < val; }
//set<ll,greater<ll> >st;
//priority_queue<ll , vector<ll> , greater<ll> >
template<class T>inline bool read(T &x){ int c=getchar();int sgn=1;
  while(~c&&c<'0'|c>'9'){if(c=='-')sgn=-1;c=getchar();}
  for(x=0; ~c&&'0'<=c&&c<='9'; c=getchar())x=x*10+c-'0';x*=sgn;return ~c;
}
const ll N = 100005;
const ll MOD = 1e9+7;
int main(){
    string s;
    cin >> s;
    sort(all(s));
    if(s[0]==s[1] && s[2]==s[3] && s[0]!=s[3]) puts("Yes");
    else puts("No");
}












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

#define pb push_back 
#define x first 
#define y second 
#define MOD 1000000007

using namespace std;
typedef long long ll;
typedef pair< int , int > PII;
const int dirx[] = {-2,-1,1,2, 1, -1};
const int diry[] = {0,1,1,0, -1, -1};
inline void debugMode() {
    #ifndef ONLINE_JUDGE
    freopen("input.in", "r", stdin);
    freopen("output.out", "w", stdout);
    #endif
}

int n, a[100100], b;
string s;
 
int main(){
	//	debugMode();
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	cout << 24 + 24 - n;
	
	return 0;
}


Measured memory_bytes: 892
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<set>
#include<cstring>
#include<iterator>
#include<bitset>
using namespace std;
 
struct edge {int /*from,*/to,cost;};
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,int>,int> PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
typedef vector<edge> VE;
static const int MOD = 1000000007;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define np next_permutation
#define pq priority_queue
#define UB upper_bound
#define LB lower_bound
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define MAX(a,b,c) max((a),max((b),(c)))
#define MIN(a,b,c) min((a),min((b),(c)))
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
//#define int ll

#define MAXN 214514

int par[MAXN];     //親
int depth[MAXN];    //木の深さ

int ar[MAXN];
int br[MAXN];

int n,k,l;

//n要素で初期化
void init(int n){
    REP(i,n){
        par[i] = i;
        depth[i] = 0;
    }
}

//木の根を求める
int find(int x){
    if(par[x]==x) return x;
    else return par[x] = find(par[x]);
}

//xとyの属する集合を併合
void unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x==y) return;

    if(depth[x]<depth[y]){
        par[x] = y;
    } else {
        par[y] = x;
        if(depth[x] == depth[y]) depth[x]++;
    }
}

//xとyが同じ集合に属するか否か
bool same(int x, int y){
    return find(x) == find(y);
}

signed main(){
    scanf("%d%d%d",&n,&k,&l);
    init(n);
    REP(i,k){
        int t1,t2;
        scanf("%d%d",&t1,&t2);
        t1--;t2--;
        unite(t1,t2);
    }
    REP(i,n) ar[i] = find(i);
    init(n);
    REP(i,l){
        int t1,t2;
        scanf("%d%d",&t1,&t2);
        t1--;t2--;
        unite(t1,t2);
    }
    REP(i,n) br[i] = find(i);

    vector<P> sex;
    REP(i,n) sex.pb(mp(ar[i],br[i]));
    SORT(sex);

    REP(i,n){
        P cur = mp(ar[i],br[i]);
        printf("%d ",UB(all(sex),cur)-LB(all(sex),cur));
    }
    printf("\n");
    return 0;
}

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

int main(){ 
  ll x;
  cin >> x;
  int res = 0;
  ll now = 100;
  while (now < x) {
    now += now * 0.01;
    res++;
  } 
  cout << res << endl;
  return 0;
} 

Measured memory_bytes: 3636
import java.util.Scanner;
public class Main {
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);
        while(true){
            int H = scan.nextInt();
            int W = scan.nextInt();
            if(H == 0 && W == 0){
                break;
            }
            for(int i=0; i<H; i++){
                for(int j=0; j<W; j++){
                    if((i+j) % 2 == 0){
                        System.out.print("#");
                    }else{
                        System.out.print(".");
                    }
                }
                System.out.println("");
            }
            System.out.println("");
        } 
        scan.close();
    }
}


Measured memory_bytes: 34616
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5+10;
#define LL long long
struct Point {
    LL x, y, id;
};
vector<Point> vecx, vecy;
bool cmpx (Point a, Point b) {
    return a.x < b.x;
}
bool cmpy (Point a, Point b) {
    return a.y < b.y;
}
struct Edge {
    LL from, to, d;
    bool operator < (const Edge &rhs) const {
        return d > rhs.d;
    }
};
LL x[maxn], y[maxn], n, ans;
vector<Edge> edges[maxn];
bool in[maxn];
priority_queue<Edge> pq;
LL cal (LL a, LL b) {
    return min (abs(x[a]-x[b]), abs(y[a]-y[b]));
}
void put_in (LL a) {
    for (LL i = 0; i < edges[a].size(); i++) {
        Edge e = edges[a][i];
        //printf ("%lld %lld %lld\n", e.from, e.to, e.d);
        pq.push (edges[a][i]);
    }
}
int main () {
    scanf ("%lld", &n);
    for (LL i = 1; i <= n; i++) {
        scanf ("%lld%lld", &x[i], &y[i]);
        vecx.push_back ({x[i], y[i], i});
        vecy.push_back ({x[i], y[i], i});
    }
    sort (vecx.begin(), vecx.end(), cmpx);
    sort (vecy.begin(), vecy.end(), cmpy);
    for (LL i = 0; i < vecx.size(); i++) {
        if (i != 0)
            edges[vecx[i].id].push_back ({vecx[i].id, vecx[i-1].id, cal(vecx[i].id, vecx[i-1].id)});
        if (i != vecx.size()-1)
            edges[vecx[i].id].push_back ({vecx[i].id, vecx[i+1].id, cal(vecx[i].id, vecx[i+1].id)});
    }
    for (LL i = 0; i < vecy.size(); i++) {
        //printf ("%lld: %lld\n", i+1, vecy[i].id);
        if (i != 0)
            edges[vecy[i].id].push_back ({vecy[i].id, vecy[i-1].id, cal(vecy[i].id, vecy[i-1].id)});
        if (i != vecy.size()-1)
            edges[vecy[i].id].push_back ({vecy[i].id, vecy[i+1].id, cal(vecy[i].id, vecy[i+1].id)});
    }
    in[1] = true;
    put_in (1);
    while (!pq.empty()) {
        Edge e = pq.top(); pq.pop();
        if (in[e.to]) continue;
        else {
            //printf ("%lld %lld %lld\n", e.from, e.to, e.d);
            in[e.to] = true;
            put_in (e.to);
            ans += e.d;
        }
    }
    printf ("%lld\n", ans);
}


Measured memory_bytes: 30244
#include <iostream>
#include <string>

class Baseball{
public:
    Baseball();
    void init();
    int getPoint();
    void hit();
    void homerun();
    // @return false - the inning ends.
    bool out();
    
private:
    int point;
    unsigned int outs;
    bool base[3];
};

Baseball::Baseball(){
    init();
}

void Baseball::init(){
    point = 0;
    outs = 0;
    for (int i=0; i<3; ++i) {
        base[i] = false;
    }
}

inline int Baseball::getPoint(){
    return point;
}

void Baseball::hit(){
    if (base[2]) {
        ++point;
    }
    for (int i=2; i>0; --i) {
        base[i] = base[i-1];
    }
    base[0] = true;
}

void Baseball::homerun(){
    ++point;    // batter's point
    // runner's point
    for (int i=0; i<3; ++i) {
        if (base[i]) {
            ++point;
        }
    }
    
    for (int i=0; i<3; ++i) {
        base[i] = false;
    }
}

bool Baseball::out(){
    ++outs;
    if (outs > 2) {
        return false;
    }else{
        return true;
    }
}


int main(){
    int n;  // number of data sets
    
    std::cin >> n;
    
    for (int i=0; i<n; ++i) {
        Baseball inning;
        std::string str;
        
        while (true) {
            std::getline(std::cin,str);
            if (str=="HIT"){
                inning.hit();
            }
            else if (str=="HOMERUN"){
                inning.homerun();
                
            }
            else if (str=="OUT"){
                if (!inning.out()) {
                    break;
                }
            }
        }
        
        // output
        std::cout << inning.getPoint() << std::endl;
    }
    
    return 0;
}

Measured memory_bytes: 1212
#include<cstdio>
using namespace std;
int i,n,minn,maxx,x;
int main()
{
	scanf("%d",&n);
	minn=1000;maxx=0;
	for (i=1;i<=n;i++)
	{
		scanf("%d",&x);
		if (x<minn) minn=x;
		if (x>maxx) maxx=x;
	}
	printf("%d\n",maxx-minn);
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
int i,j;
char s[100001],ans;
  scanf("%s",s);
  for(i='a';i<='z';i++){
  for(j=0;s[j]!='\0';j++){
  if(s[j]==i){
    j=114514;
    break;}
  }
    if(j!=114514){
      ans=i;
    printf("%c",ans);
      return 0;
    }
  }
  printf("None");
  return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,m,k;
    int dp[15];
    while(cin>>m>>k)
    {
        dp[0]=1;
        for(i=1;i<=m;i++)
        {
            dp[i]=min(dp[i-1]*2,dp[i-1]+k);
        }
        cout<<dp[m]<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main (int argc, char* argv[])
{
  int N, K; cin >> N >> K;

  int ans = 0;
  for (int i = 1; i <= N; i++) {
    if (i + K - 1 <= N) {
      ans++;
    }
  }

  cout << ans << endl;
  return 0;
}


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

class Main{
	static int mod=1000000007;

	public static void main(String[] $){
		System.err.println();
		Scanner s=new Scanner(System.in);

		char[]t=s.next().toCharArray();
		int n=t.length;
		int[]a=new int[n];
		int[]b=new int[n];
		Arrays.fill(a,1);
		Arrays.fill(b,0);
		for(int i=0;i<n;++i) {
			if(t[i]=='R'&&t[i+1]=='R') {
				a[i+1]+=b[i];
				b[i+1]+=a[i];
				a[i]=0;
				b[i]=0;
			}
		}
		for(int i=n-1;i>=0;--i) {
			if(t[i]=='L'&&t[i-1]=='L') {
				a[i-1]+=b[i];
				b[i-1]+=a[i];
				a[i]=0;
				b[i]=0;
			}
		}

		for(int i=0;i<n;++i) {
			if(t[i]=='R'&&t[i+1]!='R') {
				a[i+1]+=b[i];
			}
		}
		for(int i=n-1;i>=0;--i) {
			if(t[i]=='L'&&t[i-1]!='L') {
				a[i-1]+=b[i];
			}
		}

		System.out.println(Arrays.stream(a).mapToObj(String::valueOf).collect(Collectors.joining(" ")));
	}
}


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

using namespace std;

using int64 = long long;
const int INF = 1 << 30;

int dp[1000000];

int rec(int idx) {
  if(idx == 0) return 0;
  if(~dp[idx]) return dp[idx];
  int ret = rec(idx - 1) + 1;
  for(int i = 6, j = 1; i <= idx; i *= 6, j++) {
    ret = min(ret, 1 + rec(idx - i));
  }
  for(int i = 9, j = 1; i <= idx; i *= 9, j++) {
    ret = min(ret, 1 + rec(idx - i));
  }
  return dp[idx] = ret;
}

int main() {
  int N;
  cin >> N;
  memset(dp, -1, sizeof(dp));
  cout << rec(N) << endl;
}

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

int main(){
    string a, b;
    cin >> a >> b;
    string c = a + b;
    int ans;
    ans = atoi(c.c_str());
    for(int i = 0; i < 1100; i++){
        if(i * i == ans){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

int main(void){
  int n;
  long long ans;
  int h[200010];
  
  cin >> n;
  for (int i=0; i<n; i++) cin >> h[i];
  ans = 0;
  for (int i=1; i<n; i++){
    if (h[i-1]>h[i]){
      ans += h[i-1]-h[i];
      h[i] = h[i-1];
    }
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 4376
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

/*
0. まずこういうのは基本的に左から見ていくしかない
1. すべて同じ色に揃えたいので，あるセルについて一つ前と異なるならその異なる部分を変える
	（Wide Flip も同じような考え方になる）
2. すべてのセルを選ぶので，各セルに区間の左端か右端かをそれぞれ N 個ずつ定める
3. 各セルが L か R かどうかが決まればどう区間をとっても操作後の結果は変わらない
*/

int main(){
	int n; cin >> n;
	string s; cin >> s;
	ll ans = 1, l = 1, r = 0;
	if( s.front() == 'W' || s.back() == 'W' ) ans *= 0;
	for( int i = 0; i < 2*n-2; ++i ){
		if( s[i] != s[i+1] ) ++l;
		else{
			ans *= l-r;
			ans %= mod;
			++r;
			if( s[i+1] == 'W' ) s[i+1] = 'B';
			else s[i+1] = 'W';
		}
		// cout << l << ' ' << r << endl;
	}
	++r;
	if( l != n || r != n ) ans *= 0;
	for( int k = 1; k <= n; ++k ){
		ans *= k;
		ans %= mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
package main

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

func main() {
	X, Y, Z := sc.nextInt(), sc.nextInt(), sc.nextInt()
	fmt.Println(Z, X, Y)
}

var (
	sc scanner
)

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

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

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

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

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

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

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

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

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


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices.ComTypes;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            Char input = Convert.ToChar(Console.ReadLine());

            if (Char.IsUpper(input))
            {
                Console.WriteLine("A");
                return;
            }
            Console.WriteLine("a");
        }
    }
}


Measured memory_bytes: 25828
#include <cstdio>
#include <cctype>
#include <utility>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

const auto gcu = getchar_unlocked;
const auto pcu = putchar_unlocked;
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _sc _il bool scan
_T T in(int c){T n=0;int m=1;while(isspace(c)){c=gcu();}if(c=='-')m=-1,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
_il int in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _ot _il void out
#define _ol _il void outl
_ot(bool b) {pcu('0'+b);}
_ot(const char *s){while(*s)pcu(*s++);}
_ot(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_ot(string s){for(char c:s)pcu(c);}
#endif
_T _ot(T n){static char b[20];char *p=b,m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=n%10*m+'0',n/=10;while(p!=b)pcu(*--p);}
_ol(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _ot(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _ot(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _ol(T&&... t){out(move(t)...);outl();}

int main() {
	for (int N, M; N = in(), M = in();) {
		vector<int> t(N), u;
		for (int &p: t)
			p = in();
		t.push_back(0);
		for (auto i = t.begin(); i != t.end(); i++)
			for (auto j = i; j != t.end(); j++)
				if (*i + *j <= M)
					u.push_back(*i + *j);
		sort(u.rbegin(), u.rend());
		u.erase(unique(u.begin(), u.end()), u.end());
		int r = 0;
		for (auto i = u.begin(), e = u.end(); i != e; i++) {
			e = lower_bound(i + 1, e, M - *i, greater<int>());
			r = max(r, *i + *e);
		}
		outl(r);
	}
}


Measured memory_bytes: 6248
#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
using namespace std;
////////////// Prewritten code follows. Look down for solution. ////////////////
#define x first
#define y second
#define LEN(x) ((int)(x).size())
#define ALL(x) x.begin(), x.end()
using ll = long long;
using llu = long long unsigned;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;
using vpii = vector<pii>;

const ld EPS = 1e-9;
inline int cmp(ld x, ld y = 0, ld tol = EPS) {
	return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
}

const int MOD = 1;
inline int mod(ll x, int m = MOD) {
	return (int)(((x%m) + m)%m);
}

template<typename T, typename M = __gnu_pbds::null_type>
using ordered_set = __gnu_pbds::tree<T, M, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

////////////////////////// Solution starts below. //////////////////////////////

int n, k;
int v[110];

int main () {
	// ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // cout.precision(10);
	cin >> n >> k;
	int d;
	for(int i = 0; i < k; i++) {
		cin >> d;
		for(int j = 0; j < d; j++) {
			int x;
			cin >> x;
			v[x]++;
		}
	}
	int ans = 0;
	for(int i = 1; i <= n; i++)
		ans += v[i] == 0;
	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 3624
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        int r;
        try(Scanner cin = new Scanner(System.in)) {
            r = cin.nextInt();
        }
        String contest = r >= 2800  ? "AGC" : r >= 1200 ? "ARC" : "ABC";
        System.out.println(contest);
    }

}

Measured memory_bytes: 23252
import sys
import fractions

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N, K = [int(x) for x in input().split()]
    A = [int(x) for x in input().split()]

    A.sort()

    if N == 1:
        if A[0] == K:
            print("POSSIBLE")
        else:
            print("IMPOSSIBLE")
        return

    g = fractions.gcd(A[0], A[1])

    for a in A:
        g = fractions.gcd(g, a)

    for a in A:
        if a >= K:
            if (K - a) % g == 0:
                print("POSSIBLE")
                return
    else:
        print("IMPOSSIBLE")


if __name__ == '__main__':
    main()


Measured memory_bytes: 16276
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static long[] dp = new long[100010];
    static long rec(int i, int[] hs) {
        if (dp[i] < Long.MAX_VALUE) {
            return dp[i];
        }

        if (i == 0) {
            return 0;
        }

        long min = rec(i - 1, hs) + Math.abs(hs[i] - hs[i - 1]);
        if (i >= 2) {
            long b2 = rec(i - 2, hs) + Math.abs(hs[i] - hs[i - 2]);
            min = Math.min(min, b2);
        }

        dp[i] = min;
        return dp[i];
    }

    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int n = std.nextInt();
        int[] hs = new int[n];
        for (int i = 0; i < n; i++) {
            hs[i] = std.nextInt();
        }

        Arrays.fill(dp, Long.MAX_VALUE);
        dp[0] = 0;
        
        System.out.println(rec(n - 1, hs));
    }
}


Measured memory_bytes: 61516
n = gets.to_i
a_nums = gets.split.map(&:to_i)
b_nums = []
c_num = []
c_num.push(a_nums.pop) if a_nums.size.even?

a_nums.each_with_index do |num, index|
  if index.odd?
    b_nums.push(num)
  else
    b_nums.unshift(num)
  end
end

unless c_num.empty?
  b_nums.push(c_num.shift)
  b_nums.reverse!
end

puts b_nums.join(" ")


Measured memory_bytes: 25568
l = list(map(int, [input() for i in range(5)]))
time = []
for i in range(5):
    last = l[i]
    total = 0
    for j in range(5):
        if j == i:
            continue
        if l[j] % 10 == 0:
            total += l[j]
        else:
            total += l[j] + (10 - l[j] % 10)

    total += last
    time.append(total)

print(min(time))


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
 
    int N;
    int ans = 0;
    cin >> N;
    
    for(int i = 1; i <= N; i+=2){
        int count = 0;
        int j = 1;
        int num = i;
        
        while(j != N+1){
            if(num % j == 0){
                count++;
            }
            j++;
        }
        if(count == 8){
            ans++;
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
void main() {
    int n = readln.chomp.to!int;
    int k = readln.chomp.to!int;
    int x = readln.chomp.to!int;
    int y = readln.chomp.to!int;
    writeln(n > k ? x * k + (n - k) * y : x * n);
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Array;
import java.util.*;
import java.util.Map.Entry;

public class Main{
	
	public static void main(String[] args) throws IOException{
		//File file = new File("input.txt");
		//Scanner in = new Scanner(file);
		Scanner in = new Scanner(System.in);
		
		long N = in.nextLong();
		long M = in.nextLong();
		long ans = (N - 2) * (M - 2);
		if(N == 1 && M >= 3) ans = M - 2;
		if(M == 1 && N >= 3) ans = N - 2;
		if(M == 1 && N == 1) ans = 1;
		System.out.println(ans);
	}
}


Measured memory_bytes: 23124
from bisect import bisect_left
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()

# 累積和の計算
cum = [a[-1]]
for i in range(2, n+1):
    cum.append(cum[-1] + a[n-i])

# val以上となるペアの個数cntを二分法で計算、同時に総和sumも計算
def judge(val):
    cnt = 0
    sum = 0
    for ai in a:
        if ai + a[-1] < val:
            continue
        d = val - ai
        i = n - bisect_left(a, d)
        sum += cum[i-1] + ai * i
        cnt += i
    return cnt, sum

l = 0
r = 2 * a[-1]

# ペアの和の最小値を二分探索
while True:
    if r - l == 1:
        cnt, sum = judge(r)
        if cnt > m:
            print(m * r)
        else:
            print(sum + (m-cnt) * l)
        break
    mid = (l + r) // 2
    cnt, sum = judge(mid)
    if cnt < m:
        r = mid
    else:
        l = mid


Measured memory_bytes: 56652
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

main() {
    int N; cin >> N; double sum=0; int k=1; int x[N];
    rep(i,N){
        cin >> x[i];
        sum+=(double)1/x[i];
    }
    cout << fixed << setprecision(8) << (double)1/sum << endl;

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;

namespace AtCoder.Abc
{
    //https://atcoder.jp/contests/abc141/tasks/abc141_a
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            long n = long.Parse(Console.ReadLine());

            if (n % 2 == 0)
            {
                Console.WriteLine((n / 2) - 1);
            }
            else
            {
                Console.WriteLine((n - 1) / 2);
            }
        }
    }
}


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

int main() {
  string a;
  cin >> a;
  if(a.at(0) == '7' || a.at(1) == '7' || a.at(2) == '7'){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
 
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ll long long
 
using namespace std;

int main() {
	ios::sync_with_stdio(false);
    int n, m, q;
    cin >> n >> m >> q;
    vector<int> v[n];
    for (int i = 0; i < m; i++) {
        int l, r;
        cin >> l >> r;
        --l, --r;
        v[r].pb(l);
    }
    for (int i = 0; i < n; i++) sort(v[i].begin(), v[i].end());
    while (q--) {
        int l, r;
        cin >> l >> r;
        --l, --r;
        int ans = 0;
        for (int i = l; i <= r; i++) {
            int e1 = lower_bound(v[i].begin(), v[i].end(), l) - v[i].begin();
            ans += (v[i].size() - e1);
        }
        cout << ans << '\n';
    }
   	return 0;
}  

Measured memory_bytes: 2176
from __future__ import print_function

import sys

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd
# fractions.gcd() を用いること
# math.log2()はatcoderでは対応していない．留意せよ．

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


def lcm(n, m):
    return int(n * m / gcd(n, m))


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def find_gcd(list_l):
    x = reduce(gcd, list_l)
    return x


def main():
    n = int(input().strip())
    if n % 2 == 1:
        ans = 0
    else:
        ans = 0
        for i in range(1, 10**6):
            if 2*5**i > n:
                break
            ans += n//(2*5**i)

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 61292
#include <iostream>
#include <vector>
#include <algorithm> // std::min_element
#include <iterator>  // std::begin, std::end


using namespace std;
 
int main() {
    long long n, a, b, c, d, e;
    cin >> n >> a >> b >> c >> d >> e;
    vector<long long> v{a, b, c, d, e};
  
    long long min_val =  *std::min_element(v.begin(),v.end());
    long long need_time = n / min_val;
    if (n % min_val != 0){
      need_time += 1;
    }
    need_time += 4;
    cout << need_time << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PI acos(-1.0)
#define pb push_back
#define F first
#define S second
using namespace std;
typedef long long ll;
const int N=2e5+5;
const int MOD=1e9+7;
ll a[N];
//struct node{
//    ll v;
//    ll d;
//}p[N];
//ll sum;
//ll ans[N];

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int n;
    cin >>n;
    for(int i=1;i<=n;i++)   cin >>a[i],a[i]-=i;
    sort(a+1,a+1+n);
    ll mid=n/2;
    ll b[4]={a[mid],a[mid+1]};
    ll ans=1e18;
    for(int i=0;i<=1;i++){
        ll tb=b[i];
        ll res=0;
        for(int j=1;j<=n;j++){
            res+=abs(a[j]-tb);
        }
        ans=min(ans,res);
    }
    cout << ans << endl;

    return 0;
}


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

#define ALL(a) (a).begin(), (a).end()
#define ll long long

using namespace std;

signed main(){
    ll a,b,c,x,y; cin >> a >> b >> c;
    cin >> x >> y;
    
    ll ans = 0;
    if(2*c <= a+b){
        int cnt = min(x,y);
        ans += 2*c*cnt;
        y -= cnt;
        x -= cnt;
    }
    if(2*c <= a){
        ans += 2*c*x;
        y -= x;
        x = 0;
    }
    if(2*c <= b){
        ans += 2*c*y;
        x -= x > 0 ? y:0;
        y = 0;
    }
    if(x > 0){
        ans += x*a;
    }
    if(y > 0){
        ans += y*b;
    }
    cout << ans << endl;


    return 0;
}



Measured memory_bytes: 256
/*
 * abc153c.cpp
 * Copyright (C) 2020 itachi <itachi@itachi-Z510>
 *
 * Distributed under terms of the MIT license.
 */

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    vector<long long> v;
    int n,k;
    cin >> n >> k;
    v.resize(n);
    for (int i=0;i<n;i++) {
        cin >> v[i];
    }
    sort(v.begin(),v.end());
    long long count = 0;
    for (int i=0;i<n-k;i++) {
        count += v[i];
    }
    cout << count << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

int main(void) {

    int i, j, k;
    long long n, m;
    long long sum = 0;
    long long temp;
    vector<long long> a;
    vector<long long> ans;

    cin >> n;

    ans.resize(n);
    for (i = 0; i < n; i++){
        ans[i] = 0;
    }

    for (i = 1; i < n; i++) {
        cin >> temp;
        ans[temp - 1]++;
    }

    for (i = 0; i < n; i++) {
        cout << ans[i] << endl;
    }
    return 0;    
}

Measured memory_bytes: 4788