akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <utility>
#include <functional>
#include <queue>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>      // std::setprecision
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor_ct.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/pending/disjoint_sets.hpp>
#include <boost/icl/interval_map.hpp>
#include <boost/graph/graph_traits.hpp>
#include <boost/graph/strong_components.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>
#include <boost/graph/kruskal_min_spanning_tree.hpp>
#include <boost/graph/graph_utility.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
using namespace std;
using namespace boost::math;

int main() {
	long long N, K;

	cin >> N >> K;
  
    vector<int> A(N);
  
    for (auto& i : A)
      cin >> i;
  
    long long appear[2001] = {0}, added[2001] = {0};
    long long koke = 0;
  
    REP(i, N) {
      appear[A[i]]++;
      for (int j : boost::irange(A[i] + 1, 2001)) {
        koke = (koke + appear[j]) % 1000000007LL;
        added[j]++;
      }
    }

    auto kdan = K * (K-1LL) / 2LL % 1000000007LL;
  long long hoge = 0;
    REP(i, 2001) {
      appear[i] = appear[i] * added[i] % 1000000007LL;
      appear[i] = appear[i] * kdan % 1000000007LL;
      hoge += appear[i] % 1000000007LL;
    }
    
	cout << (hoge + (koke * K) % 1000000007LL) % 1000000007LL << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static final long mod = 1000000007;

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int S = sc.nextInt();
			if (S < 3) {
				System.out.println(0);
				return;
			}
			long[] dp = new long[S + 1];
			dp[3] = 1;
			for (int i = 4; i <= S; i++) {
				dp[i] = (dp[i - 3] + dp[i - 1]) % mod;
			}
			System.out.println(dp[S]);
		}
	}
}

Measured memory_bytes: 35696
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n;
  while(1){
    cin>>n;
    if(n==0)break;
    stack<int> s;
    while(n){
      s.push(n%8);
      n/=8;
    }
    while(s.size()){
      int a=s.top();
      s.pop();
      int d[8]={0,1,2,3,5,7,8,9};
      cout<<d[a];
    }
    cout<<endl;
  }
}

Measured memory_bytes: 3080
n, m = map(int, input().split())

# n+k = m//2-k, 2k = m//2 - n, k = (m//2 - n) // 2

# min(n+k, (m-2k)//2) = min(n+k, m//2 - k)

p = (m // 2 - n) // 2
ans = min(n, m//2)
for k in range(max(0, p-10), p+10):
  v = min(n+k, m//2-k)
  if v >= 0:
    ans = max(ans, v)
  
print(ans)

Measured memory_bytes: 3060
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部変数
static FILE *szpFpI;											// 入力
static int siN;													// N
static int siM;													// M

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
#endif

// 実行メイン
int
fMain(
	int piTNo					// <I> テスト番号 1～
)
{
	int i;
	char lc1Buf[1024], lc1Out[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", piTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", piTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// N・M - 取得
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d%d", &siN, &siM);

	// 検索範囲
	int liRng = (int)sqrt((double)siM);

	// 最大約数 - 検索
	int liMax = 0;
	for (i = 1; i <= liRng; i++) {

		// 約数チェック
		if (siM % i != 0) {
			continue;
		}
		int liDiv = siM / i;

		// 配列の作成可能チェック
		if (siN <= i) {					// 可能
			liMax = liDiv;
			break;
		}

		// 配列の作成可能チェック
		if (siN > liDiv) {				// 不可能
			break;
		}
		liMax = i;
	}
	
	// 結果 - セット
	sprintf(lc1Out, "%d\n", liMax);

	// 結果 - 表示
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, lc1Out)) {
		siRes = -1;
	}
#else
	printf("%s", lc1Out);
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", piTNo);
	}
	else {
		printf("NG %d\n", piTNo);
	}
#endif

	return 0;
}

int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		fMain(i);
	}
#else
	fMain(0);
#endif

	return 0;
}



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

int main(){
  int N;cin>>N;
  int ans=0;
  for(int i=3;i<=9;i++){
    int x=1;
    rep(j,i) x*=3;
    rep(j,x){
      string num="";
      int a=j,cnt[3]={};
      rep(k,i){
        int b=a%3;
        num+=(b==0?'3':(b==1?'5':'7'));
        cnt[b]++;
        a/=3;
      }
      if(stoi(num)>N) continue;
      int flag=1;
      rep(k,3) if(cnt[k]==0) flag=0;
      if(flag) ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int gcd(int a,int b){
	if(a%b){return gcd(b,a%b);}
	else{return b;}
}
int main(void){
	int n,m,i,ans;
	int x[100000];
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++){
		scanf("%d",&x[i]);
		x[i]=m<x[i]?x[i]-m:m-x[i];
	}
	if(n==1){printf("%d",x[0]);}
	else{
		ans=gcd(x[0],x[1]);
		for(i=2;i<n;i++){
			ans=gcd(ans,x[i]);
		}
		printf("%d",ans);
	}
	return 0;
}

Measured memory_bytes: 2116
<?php
	$n = fgets(STDIN);
	$value = explode(' ', rtrim(fgets(STDIN)));
	$cost = explode(' ', rtrim(fgets(STDIN)));
	
	$ans = 0;
	$real_value = 0;
	
	for ($i=0; $i<$n; $i++) {
		$real_value = $value[$i] - $cost[$i];
		if (0 < $real_value) {
			$ans += $real_value;
		}
	}
	
	echo $ans;
?>





Measured memory_bytes: 4604
# coding: utf-8
import sys
import itertools


def sr(): return sys.stdin.readline().rstrip()


def ir(): return int(sr())


def lr(): return list(map(int, sr().split()))


S = sr()
SIZE = len(S)
ans = 0


def dfs(depth, p_list):
    global ans

    if depth == SIZE - 1:
        sum_list = []
        T = S
        for j, p in enumerate(p_list):
            if p:
                sum_list.append(int(S[SIZE - len(T): j + 1]))
                T = S[j + 1:]
        if T:
            sum_list.append(int(T))
        # print(p_list, sum_list, T)
        ans += sum(sum_list)

        return

    for i in range(2):
        p_list[depth] = i
        dfs(depth + 1, p_list)


def main():

    p_list = [0] * (SIZE - 1)
    dfs(0, p_list)

    print(ans)


main()


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
using namespace std;

#define ll long long
#define pint pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(VECTOR) (VECTOR).begin(),(VECTOR).end()

int main(){

	string S;
	cin >> S;
	if(S[5] == '0' && S[6] <= '4')cout << "Heisei" << endl;
	else cout << "TBD" << endl;

	return 0;
}

Measured memory_bytes: 256
x, y = gets.split.map(&:to_i)
ary = [4, 6, 9, 11]
ary2 = [1, 3, 5, 7, 8, 10, 12]

if ary.include?(x) && ary.include?(y)
  puts "Yes"
elsif ary2.include?(x) && ary2.include?(y)
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 14244
import scala.io._

object Main {
	def main(args: Array[String]) {
		val input = Source.fromInputStream(System.in)
		val lines = input.getLines.toSeq

		var kindArare = List("P", "Y", "W", "G")
		var arares = lines(1).split(" ")
		var count = 0
		arares.foreach{
			s =>
			kindArare = kindArare.map{
				t =>
				if(s == t) {
					count += 1
					""
				}else{t}
			}
		}
		if (count > 3){
			println("Four")
		}else{
			  println("Three")
		}
	}
}


Measured memory_bytes: 27328
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mxn= 5e5+5;
// check for forloop
// intialize variable
// overflow
// go for easy solution
#define mod 1000000007
ll INF = 1000000000000000005LL;
#define endl '\n'
void rishabh(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
int main(){
    rishabh();
    ll n,m;
    cin>>n>>m;
    if (m<=n*2){
        cout<<m/2;
        return 0;
    }
    m=m-2*n;
    cout<<n+m/4;
}

Measured memory_bytes: 3604
n,m=map(int,input().split())
p=list(map(int,input().split()))
pi=[0 for i in range(n+1)]
for i,j in enumerate(p,1):
    pi[j]=i
class unionfind:
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)
    def find(self, x):
        if(self.root[x] < 0):
            return x
        else:
            self.root[x] = self.find(self.root[x])
            return self.root[x]
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if(x == y):
            return 
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    def same(self, x, y):
        return self.find(x) == self.find(y)
    def count(self, x):
        return -self.root[self.find(x)]
uf=unionfind(n)
for i in range(m):
    x,y=map(int,input().split())
    uf.unite(x,y)
ans=0
for i in range(1,n+1):
    if uf.same(i,pi[i]):
        ans+=1
print(ans)


Measured memory_bytes: 14812
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
using namespace std;

int main(){
  int k, x;
  cin >> k >> x;
  if (500 * k >= x) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

int main() {
    ll n, m, X, Y; cin >> n >> m >> X >> Y;
    vector<int> x(n); for (int i = 0; i < n; ++i) cin >> x[i];
    vector<int> y(m); for (int i = 0; i < m; ++i) cin >> y[i];
    bool ok = false;
    for (int i = X + 1; i <= Y; ++i) {
        bool check = true;
        for (int j = 0; j < n; ++j) {
            if (i <= x[j]) {
                check = false;
                break;
            }
        }
        for (int j = 0; j < m; ++j) {
            if (i > y[j]) {
                check = false;
                break;
            }
        }
        if (check) {
            ok = true;
            break;
        }
    }
    if (ok) cout << "No War" << endl;
    else cout << "War" << endl;
}

Measured memory_bytes: 3632
/*input
1
2
3
4
5
6
7
8
9
10
*/
fn read_line() -> String {
    let mut return_ = format!("");
    std::io::stdin().read_line(&mut return_).ok();
    return_.pop();
    return_
}

fn main() {
    let mut total = 0;
    for _ in 0..10 {
        total = total + read_line().parse::<i32>().unwrap();
    }
    println!("{}", total);
}



Measured memory_bytes: 5032
#include <stdio.h>          // printf(), scanf()

int
main(int argc, char** argv)
{
	int n;
	int i;

	scanf("%d", &n);
	int e = n;
	for (i = 2; i * i <= n; ++i)
	{
		if (n % i == 0)
		{
			e = e / i * (i - 1);
			while (n % i == 0)
				n /= i;
		}
	}

	if (n != 1)
		e = e / n * (n - 1);

	printf("%d\n", e);
	return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
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; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる





int main() {
  string s;
  cin>>s;
  int n=s.size();

  int wa=0;
  rep(i,n){
    wa+=s[i]-'0';
  }

  int x=stoi(s);

  cout << (x%wa==0?"Yes":"No") << endl;

}

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

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> L(N);
    for(int i=0;i<N;++i) cin >> L[i];
    sort(L.begin(), L.end());

    int ans = 0;
    for(int i=0;i<N;++i){
        for(int j = i + 1; j < N; ++j){
            for(int k = j + 1; k < N; ++k){
                if(L[i] == L[j] || L[j] == L[k]) continue;
                if(L[k] < L[i] + L[j]){
                    ++ans;
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <cctype>
using namespace std;
#define fo(i, a, b) 	for (int i=a; i<(b); i++)
#define forev(i, b, a) 	for (int i = (b)-1; i >= a; i--)
typedef long long int	lli;
typedef long double		ld;
#define all(x) x.begin(), x.end()
#define sortall(x) sort(all(x))
#define enl	"\n"
#define fast	ios_base::sync_with_stdio(0); cin.tie(0);
// #define PI 3.1415926535897932384626
// const int MOD = 1000000007; // const ll INF = 1e18; // const int MX = 100001;
//==================================================================================

int main() {
	fast;
	// int t; cin >> t; while (t--)
	char a; cin >> a;

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

	return 0;
}

Measured memory_bytes: 3636
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

// Use g++ compiler for this include to work.
#include <bits/stdc++.h>

using namespace std;

// Constants 
#define INF 1e18
#define EPS 1e-9
#define MOD 1000000007
 
// // for using in pairs
#define F first
#define S second
 
// Macros
#define all(x) begin(x), end(x)
 
// aliases
using ll = long long;
using ull = unsigned long long;
using ui = unsigned int;
using ld = long double;

// Temporary macro.
#define int long long

// Operator overloads.
/**
 * The type of element in the vector should have overload for << operator with ostream. 
 */
template<typename T>
ostream& operator<<(ostream &stream, vector<T> v)
{
	for (const auto &it : v)
		stream << it << " ";
	return stream;
}

/**
 * Both types in the pair should have overload for << operator with ostream. 
 */
template<typename T1, typename T2>
ostream& operator<<(ostream &ostream, pair<T1, T2> p)
{
	ostream << p.first << " " << p.second;
	return ostream;
}

template<typename T>
void swap(T &a, T &b)
{
	T t = a;
	a = b;
	b = t;
}

// Utility functions.
void swap(int &a, int &b)
{
	int t = a;
	a = b;
	b = t;
}

int GCD(int a, int b)
{
	if (!b)
		return a;
	return GCD(b, a % b);
}

int LCM(int a, int b)
{
	return (a * b) / GCD(a, b);
}

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

//////////////////// START CODE HERE ///////////////////////////


void solve(int tc)
{
	int n, k;
	cin >> n >> k;

	int a[n];
	for (int i = 0; i < n; i++)
		cin >> a[i];

	int dp[n];
	dp[0] = 0;

	for (int i = 1; i < n; i++)
	{
		dp[i] = INF;
		for (int j = max((int)0, i - k); j < i; j++)
			dp[i] = min(dp[i], dp[j] + abs(a[i] - a[j]));
	}

	cout << dp[n - 1] << "\n";
}

int32_t main()
{	
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

	ios_base::sync_with_stdio(false);
	cin.tie(0);

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

	return 0;
}


Measured memory_bytes: 5204
#include <iostream>


int main() {
    using namespace std;
    
    int N;
    cin >> N;
    unsigned long long a[N], c = 0;
    for(int i = 0; i < N; i++) {
        cin >> a[i];
        while(a[i] % 2 == 0) {
            a[i] /= 2;
            c++;
        }
    }

    cout << c << endl;
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
typedef unsigned int ui;
int main(){
	int n;
	int i, j;
	int isprime[246913];
	fill(isprime, isprime + 246913, 1);
	isprime[0] = isprime[1] = 0;
	for (i = 2; i <= 246912; i++) {
		if (isprime[i] == 1) {
			for (j = i * 2; j <= 246912; j += i) {
				isprime[j] = 0;
			}
		}
	}
	int sum[246913] = {};
	sum[0] = 0;
	for (i = 1; i <= 246912; i++) {
		sum[i] = sum[i - 1] + isprime[i];
	}
	while (cin >> n) {
		if (n == 0)break;
		cout << sum[2 * n] - sum[n] << endl;
	}
	return 0;
}


Measured memory_bytes: 5012
#include<bits/stdc++.h>
//using namespace std;
#define rep(i,j,n) for(ll i=(ll)(j);i<(ll)(n);i++)
#define REP(i,j,n) for(ll i=(ll)(j);i<=(ll)(n);i++)
#define per(i,j,n) for(ll i=(ll)(j);(ll)(n)<=i;i--)
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(ll)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(ll)(key)))
#define pb push_back
#define mp std::make_pair
#define endl "\n"
using std::cin;
using std::cout;
using std::vector;
using std::string;
using std::upper_bound;
using std::lower_bound;
using vi=vector<ll>;
using vii=vector<vi>;
using pii=std::pair<ll,ll>;
const ll MOD=1e9+7;
//const ll MOD=998244353;
//const ll MOD=100000;
const ll MAX=1e7;
const ll INF=(1ll<<60);
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
struct Binary_indexed_tree{
    int N;
    vi bit;
    Binary_indexed_tree(int n):N(n){
        bit.resize(N+1,0);
    }
    void add(int x,int a){
        for(x;x<=N;x+=(x&-x)) bit[x]+=a;
    }
    ll sum(int x){
        ll ret=0;
        for(x;x>0;x-=(x&-x)) ret+=bit[x];
        return ret;
    }
};
struct Union_Find{
    ll N;
    vi par;
    vi siz;
    Union_Find(int n):N(n){
        par.resize(N);
        siz.resize(N,1);
        rep(i,0,N) par[i]=i;
    }
    ll root(ll X){
        if(par[X]==X) return X;
        return par[X]=root(par[X]);
    }
    bool same(ll X,ll Y){
        return root(X)==root(Y);
    }
    void unite(ll X,ll Y){
        X=root(X);
        Y=root(Y);
        if(X==Y) return;
        par[X]=Y;
        siz[Y]+=siz[X];
        siz[X]=0;
    }
    ll size(ll X){
        return siz[root(X)];
    }
};
ll modpow(ll X,ll Y){
    ll sum=X,cnt=1;
    vi A;
    while(cnt<=Y){
        A.pb(sum);
        sum*=sum;
        sum%=MOD;
        cnt*=2;
    }
    int M=A.size();
    ll ret=1;
    REP(i,1,M){
        if(Y>=(1ll<<M-i)){
            Y-=(1ll<<M-i);
            ret*=A[M-i];
            ret%=MOD;
        }
    }
    return ret;
}
ll fac[MAX],finv[MAX],inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
ll COM(ll n,ll r){
    if(n<r||n<0||r<0) return 0;
    return fac[n]*finv[r]%MOD*finv[n-r];
}
signed main(){
    ll N; cin>>N;
    string S; cin>>S;
    ll M=S.size();
    vii dp(N+1,vi(N+2));
    dp[0][0]=1;
    rep(i,0,N){
        REP(j,0,N){
            dp[i+1][j+1]+=dp[i][j]*2%MOD;
            dp[i+1][j+1]%=MOD;
            dp[i+1][std::max(0ll,j-1)]+=dp[i][j];
            dp[i+1][std::max(0ll,j-1)]%=MOD;
        }
    }
    ll ans=dp[N][M];
    ans*=modpow(modpow(2,MOD-2),M);
    ans%=MOD;
    cout<<ans<<endl;
}


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

int main(){
    int n; cin>>n;
    double ans,a[11];
    string s[11];
    for(int i=0;i<n;i++){
        cin>>a[i];
        cin>>s[i];
    }
    ans=0.0;
    for(int i=0;i<n;i++){
        if(s[i]=="JPY"){
            ans+=a[i];
        }else{
            ans+=a[i]*380000;
        }
    }
    cout<<setprecision(20)<<ans<<endl;
    return 0;
}

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

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

  int x = (a + d - 1) / d;
  int y = (c + b - 1) / b;

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


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
# define ll int64_t
# define str string
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;



#define INF 2000000000
#define MAX_V 10



bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<ll,ll> a,pair<ll,ll> b){
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll modpow(ll a,ll n,ll mod1) {
    ll res=1;
    while(n>0){
        if(n&1) res=res*a%mod1;
        a = a*a%mod1;
        n >>= 1;
    }
    return res;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

ll gcd(ll a,ll b) { return b ? gcd(b, a%b) : a; }

ll lcm(ll a,ll b){
   return a/gcd(a,b)*b;
}
const ll MAX = 5100000;
const ll MOD = 1000000007;
 
ll fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

using graph = vector<vector<ll>>;
pair<pair<ll,ll>,ll> p[100010];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,x;
    cin>>n>>x;
    
    cout<<3*n-3*gcd(n,x)<<endl;
    return 0;
}


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

int main() {
  int n;
  cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++){
    int l;
    cin>>l;
    a.at(i)=l;
  }
  int dp[100010];
  dp[0]=0;
  dp[1]=abs(a.at(1)-a.at(0));
  for(int i=2;i<n;i++){
    dp[i]=min(dp[i-2]+abs(a.at(i)-a.at(i-2)),dp[i-1]+abs(a.at(i)-a.at(i-1)));
  }
  cout<<dp[n-1]<<endl;
              
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n,m,i,p;
    string s,t;char l;
    cin>>s>>t;
    n=t.size();
    l=t[n-1];
    s=s+l;
    if(s==t)
    cout<<"Yes";
    else
    cout<<"No";


    return 0;
  
}


Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  ll score = 0;
  score += A[0];
  for (int i = 2; i < N; ++i) {
    score += A[i / 2];
  }
  cout << score << endl;
  return 0;
}


Measured memory_bytes: 4424
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <iostream>
#include <cmath>
#include <queue>

using namespace std;

typedef long long ll;

const int N = 100100;

ll a[7],tmp[7];
ll K = 0;


int main(){
	//freopen("input.txt","r",stdin);
	for (int i = 0; i < 7; ++i){
		scanf("%lld",&a[i]);
	}
	vector<int> x;
	for (int i = 1 ; i <= 6; ++i){
		x.push_back(i);
	}
	do{
		ll R = a[1] * 2;
		for (int i = 0; i < 7; ++i){
			tmp[i] = a[i];
		}
		for (int i = 0; i < x.size(); ++i){
			if(x[i] == 1 || x[i] == 6){
				ll mn = min(min(tmp[0],tmp[3]),tmp[4]);
				tmp[0] -= mn;
				tmp[3] -= mn;
				tmp[4] -= mn;
				R += 6 * mn;
			}
			if(x[i] == 2){
				R += tmp[0]/2 * 4;
				tmp[0] %= 2;
			}
			if(x[i] == 3){
				R += tmp[3]/2 * 4;
				tmp[3] %= 2;
			}
			if(x[i] == 4){
				R += tmp[4]/2 * 4;
				tmp[4] %= 2;
			}
		}
		K = max(K,R);
	}while(next_permutation(x.begin(),x.end()));
	printf("%lld\n", K/2);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n, m, a[110], vote = 0, ans=0;
  scanf("%d%d", &n, &m);
  for(int i =0;i<n;i++){
    scanf("%d", &a[i]);
    vote+=a[i];
  }
  for(int i =0;i<n;i++){
    if(vote<=a[i]*4*m)
     ans++; 
  }
  if(ans >= m)
    printf("Yes\n");
  else printf("No\n");
  return 0;
}


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

int main(){
	double x[3],y[3],xp,yp;
	while(cin>>x[0]>>y[0]>>x[1]>>y[1]>>x[2]>>y[2]>>xp>>yp){
		bool ans=true;
		//xが一番小さい点と大きい点を見つける
		int Xmin=0,Xmax=0;
		double tan[2],tanP;
		
		int k=0;
		int Yflg=0; //xの値が同じだった場合、自分よりyが大きい場合１、小さい場合−１とする
		
		for(int i=1;i<3;i++){
			if(x[Xmin]>x[i]) Xmin=i;
			if(x[Xmax]<x[i]) Xmax=i;
		}
		//x座標の一番小さい点とそれ以外の点との傾き(tan)を求める
		for(int i=0;i<3;i++){
			if(i!=Xmin){
				if(x[i]==x[Xmin]){ //もしxの一番小さい点が2つあった場合
					if(y[i]>y[Xmin]) Yflg=1;
					if(y[i]<y[Xmin]) Yflg=-1;
				}else{ //それ以外
					tan[k++]=(y[i]-y[Xmin])/(x[i]-x[Xmin]);
				}
			}
		}
		if(xp<=x[Xmin]){ //点pのxが一番小さなx以下の場合、三角形の中にpは入っていない
			ans=false;
		}else{ //それ以外
			tanP=(yp-y[Xmin])/(xp-x[Xmin]);
		}
		//点Pとの角度が他の2点の間にない場合、pは三角形の中には入っていない
		if((Yflg==0) && !((tan[0]<tanP && tan[1]>tanP)||(tan[1]<tanP && tan[0]>tanP))){
			ans=false;
		}else if((Yflg==1) && !(tan[0]<tanP)){
			ans=false;
		}else if((Yflg==-1) && !(tan[0]>tanP)){
			ans=false;
		}

		//x座標の一番大きい点とそれ以外の点との傾き(tan)を求める
		k=0; Yflg=0;
		for(int i=0;i<3;i++){
			if(i!=Xmax){
				if(x[i]==x[Xmax]){ //もしxの一番小さい点が2つあった場合
					if(y[i]>y[Xmax]) Yflg=1;
					if(y[i]<y[Xmax]) Yflg=-1;
				}else{ //それ以外
					tan[k++]=(y[i]-y[Xmax])/(x[Xmax]-x[i]);
				}
			}
		}
		if(xp>=x[Xmax]){ //点pのxが一番大きなx以上の場合、三角形の中にpは入っていない
			ans=false;
		}else{ //それ以外
			tanP=(yp-y[Xmax])/(x[Xmax]-xp);
		}
		//点Pとの角度が他の2点の間にない場合、pは三角形の中には入っていない
		if((Yflg==0) && !((tan[0]<tanP && tan[1]>tanP)||(tan[1]<tanP && tan[0]>tanP))){
			ans=false;
		}else if((Yflg==1) && !(tan[0]<tanP)){
			ans=false;
		}else if((Yflg==-1) && !(tan[0]>tanP)){
			ans=false;
		}

		if(ans) cout<<"YES"<<endl;
		else    cout<<"NO"<<endl;
	}
	return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> jobs(m);
  rep(i,n) {
    int a, b;
    cin >> a >> b;
    if (a > m) continue;
    jobs[m-a].push_back(b);
  }
  priority_queue<int> q;
  ll ans = 0;
  for (int i = m-1; i >= 0; --i) {
    for (int b : jobs[i]) {
      q.push(b);
    }
    if (!q.empty()) {
      ans += q.top();
      q.pop();
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5632
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

typedef struct{
	int n;
	char city[13];
	int p;
} STORE;

int main(int argc, char const *argv[])
{
	int n;
	char temp[13];
	STORE store[103];
	scanf("%d",&n);

	for (int i = 0; i < n; ++i){
		store[i].n = i + 1;
		scanf("%s %d", store[i].city, &store[i].p);
	}
	for (int i = 0; i < n; ++i){
		for (int j = i + 1; j < n; ++j){
			if(strcmp(store[i].city, store[j].city) > 0){
				store[n] = store[i];
				store[i] = store[j];
				store[j] = store[n];
			}
			else if(strcmp(store[i].city, store[j].city) == 0){
				if(store[i].p < store[j].p){
					store[n] = store[i];
					store[i] = store[j];
					store[j] = store[n];
				}
			}
		}
	}
	for (int i = 0; i < n; ++i)	printf("%d\n", store[i].n);
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cctype>
#include <numeric>
using namespace std;

#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)

int T, n[10];
char c[10];
bool visit[1<<10], enable;

void f(int S) {
  if (visit[S])
    return;
  visit[S] = true;
  
  if (S == (1<<9)-1) {
    enable = true;
    return;
  }

  for (int i = 0; i < 9; ++i) {
    if (!(S >> i & 1)) {
      for (int j = i+1; j < 9; ++j) {
        if (c[i] != c[j]) continue;
        if (!(S >> j & 1)) {
          for (int k = j+1; k < 9; ++k) {
            if (c[j] != c[k]) continue;
            if (!(S >> k & 1)) {
              int tN[] = { n[i], n[j], n[k] };
              sort(tN, tN + 3);
              if (((n[i] == n[j]) && (n[j] == n[k])) ||
                  ((tN[0] + 1 == tN[1]) && (tN[1] + 1 == tN[2]))) {
                f(S | (1<<k) | (1<<j) | (1<<i));
              }
            }
          }
        }
      }
    }
  }
  
}

int main() {
  cin >> T;
  rep(loop, T) {
    rep(i,9) cin >> n[i];
    rep(i,9) cin >> c[i];
    fill(visit, visit + (1<<10), false);
    enable = false;
    f(0);
    printf("%d\n", (enable) ? 1 : 0);

  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll n, m, a, b, edge[10][10], use[10], ans;

void dfs(ll s, ll cnt){
	if(cnt == n){
		ans++;
	}
	else{
		use[s] = 1;
		rep(i, 1, n){
			if(edge[s][i] == 1 && use[i] == 0){
				dfs(i, cnt+1);
			}
		}
		use[s] = 0;
	}
}

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> n >> m;
	memset(edge, 0, sizeof(edge));
	rep(j, 1, m){
		cin >> a >> b;
		edge[a][b] = 1;
		edge[b][a] = 1;
	}
	
	memset(use, 0, sizeof(use));
	ans = 0;
	dfs(1, 1);
	
	print(ans)
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  cin >> N;
  vl X(N);
  REP(i, N) cin >> X[i];
  // 以下を満たす時ゴールできる
  // 1.点xより若い点が全てゴールできる(orしている)
  // 2.点xの位置をp、xより若い点の数をyとすると、0~p-1に空白がy個以上ある

  // つまり、後何個自分より若い点がゴールすると自分もゴールできるようになるか考えれば良い(ほんまか)
  vl count(N, 0);
  ll now = 0;
  ll yo = -1;
  REP(i, N) {
    yo += 2;
    count[i] = now;
    if (yo > X[i]) {
      now++;
      yo = X[i];
    }
  }
  vl po(N + 1, 0);
  // 一匹ゴールすると、空きは2つできる
  REP(i, N) { po[ceil((long double)count[i] / 2)]++; }
  ll ans = 1;

  now = po[0];
  REP(i, N - 1) {
    // cout << now << endl;
    ans *= now;
    ans %= MOD;
    now += po[i + 1] - 1;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    int n, m, k;
    cin>>n>>m>>k;

    rep(i, n + 1) {
        rep(j, m + 1) {
            if (i * m + j * (n - i) - i * j == k) {
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
}

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

vector<int> divisors(int n)
{
    vector<int> ret;
    for (int i = 1; i * i <= n; ++i)
    {
        if (n % i == 0)
        {
            ret.push_back(i);
            if (n / i != i)
                ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}

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

    vector<int> aNum = divisors(a);
    vector<int> bNum = divisors(b);
    vector<int> inter;
    set_intersection(aNum.begin(), aNum.end(), bNum.begin(), bNum.end(), back_inserter(inter));

    sort(inter.begin(), inter.end(), greater<int>());
    cout << inter[k - 1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <math.h>
#include<string>
using namespace std;

int sub(int i,int next,int x){
    if(i)   return x + next;
    else    return x - next;
}
string tostring(int i){
    if(i)   return  "+";
    else    return  "-";
}
int main(){
    int N;
    cin >> N;
    int x[4]; 
    for (int i = 0; i < 4 ; i ++){
        x[i] = N % 10;
        N = (N-x[i])/10;
    }
    string answer;
    for (int i = 0; i < 2; i ++){
        for (int j = 0; j < 2; j ++){
            for (int l = 0; l < 2; l ++){
                int ans = x[3];
                ans = sub(l,x[2],ans);
                ans = sub(j,x[1],ans);
                ans = sub(i,x[0],ans);
                if(ans == 7){
                    cout << x[3] << tostring(l) << x[2] << tostring(j) << x[1] << tostring(i) << x[0] << "=7" << endl;
                    return 0;
                }
            }
        }
    }
}

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

dp = [0]*N

for i in range(N-1):
    if i == 0:
        dp[i+1] = abs(h[i]-h[i+1])
    else:
        dp[i+1] = min(abs(h[i]-h[i+1]) + dp[i], abs(h[i-1]-h[i+1]) + dp[i-1])


print(dp[N-1])

Measured memory_bytes: 13928
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll N=200010;
ll a[N],n,tot,seq[N];
int main(){
	scanf("%lld",&n);
	for(ll i=1;i<=n;++i){
		scanf("%lld",&seq[i]);
		a[seq[i]]++;
	}
	tot=0;
	for(ll i=1;i<=n;++i){
		tot+=((a[i]-1)*a[i])>>1;
	}
	for(ll i=1;i<=n;++i){
		ll tmp=tot-a[seq[i]]+1;
		printf("%lld\n",tmp);
	}
}

Measured memory_bytes: 4736
N,M = map(int,input().split())

if N == 1 or M == 1:
    if N == 1 and M == 1:
        ans = 1
    else:
        ans = max(0,max(N,M) -2)
else:
    ans = (N-2) * (M-2)
    
print(ans)

Measured memory_bytes: 2940
mod = 10**9+7
import sys
import math
from collections import Counter, defaultdict, deque
import copy

# from itertools import product, permutations, combinations, combinations_with_replacement
# from itertools import accumulate
# from operator import itemgetter
# from bisect import bisect_left,bisect
# from heapq import heappop,heappush
# from math import ceil,floor
# from copy import deepcopy
# from heapq import heappop,heappush,heapify
# import heapq


# def combinations(n, r):
# 	return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

# def gcd(a, b):
# 	if b == 0:
# 		return a
# 	else:
# 		return gcd(b, a%b)
 
# def lcm(a, b):
# 	return a // gcd(a, b) * b

# l = ['a', 'a', 'a', 'a', 'b', 'c', 'c']
# c = Counter(l)

# d = defaultdict(int)

sys.setrecursionlimit(10 ** 6)

int1 = lambda x: int(x) - 1

# リストの要素を改行を挟んで表示する
p2D = lambda x: print(*x, sep="\n")
# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())

def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())

# 入力全てを整数に変換したものの配列を受け取る
# def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI(): return list(map(lambda x:int(x), sys.stdin.readline().split()))
def HI(): return list(map(lambda x:int(x)*(-1), sys.stdin.readline().split()))


N, A=MI()
X = LI()

X = [x-A for x in X]
d = defaultdict(int)
d[0] = 1
for x in X:
	# new_dic = defaultdict(int)
	for k,v in list(d.items()):
		d[k+x] = d[k+x]+v
	# new_dic[x] = d[x] + 1
	# d = new_dic
print(d[0]-1)







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

int N, M;
list<int> players;

bool check(int n, string s)
{
  if(n % 5 == 0 && n % 3 == 0)
    return s == "FizzBuzz";
  if(n % 5 == 0)
    return s == "Buzz";
  if(n % 3 == 0)
    return s =="Fizz";
  return s == to_string(n);
}

int main()
{
loop:
  cin >> M >> N;
  if(!N)
    return 0;

  players.clear();
  for(int i = 0; i < M; i++)
    players.push_back(i + 1);
  auto p = players.begin();
  for(int i = 1; i <=N; i++)
  {
    string s;
    cin >> s;
    if(players.front() == players.back())
      continue;
    if(!check(i, s))
      p = players.erase(p);
    else 
      ++p; 
    if(p == players.end())
      p = players.begin();
  }
  for(auto v : players)
  {
    cout << v;
    if(v != players.back())
      cout << " ";
  }
  cout << endl;
  goto loop;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> x(n);
  rep(i,n) cin >> x[i];
  
  vector<int> y=x;
  sort(y.begin(),y.end());
  int a=1000000007;
  for(int i=*y.begin();i<=*y.rbegin();++i){
    int v=0;
    rep(j,n){
      v+=(y[j]-i)*(y[j]-i);
    }
    a = min(a,v);
  }
  cout << a << endl;
  return 0;
}


Measured memory_bytes: 3520
q = gets.to_i
q.times do
    a, b, c = gets.split.map(&:to_i)
    n1 = [a, b, c].min
    a -= n1; b -= n1; c -= n1
    n2 = [a / 2, b].min
    a -=  2 * n2; b -= n2;
    n3 = a / 3
    puts n1 + n2 + n3
end

Measured memory_bytes: 6104
n, c = gets.split.map(&:to_i)
stc = n.times.map {gets.split.map(&:to_i)}.sort_by{|e| e[0]}

memo = Array.new(c+1)
stc.each do |s, t, cc|
    if memo[cc]
        memo[cc] = t
    elsif i = memo.index{|e| e && e < s}
        memo[i] = nil
        memo[cc] = t
    else
        memo[cc] = t
    end
end

p memo.compact.size

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

int main()
{
 	vector<int> v(6, 6); for(int i = 1; i <= 5; ++i) cin >> v[i];
  	cout << find(v.begin(), v.end(), 0)- v.begin();
  
  	return 0;
}


Measured memory_bytes: 3452
package main
import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
  "sort"
)

type Str []string
func (S Str) Len() int { return len(S) }
func (S Str) Less(i, j int) bool { return S[i] < S[j] }
func (S Str) Swap(i, j int) { S[i], S[j] = S[j], S[i] }

func Solve() {
  var N, L, c int
  NextInt(&N, &L)
  S := make([]string, N)
  for i := range S { S[i] = NextLine() }
  sort.Sort(Str(S))
  cnt := 0
  for j, s := range S[0] {
    if s == '1' { cnt ^= (L - j) & (j - L) }
  }
  for i := range S[1:] {
    c = 0
    for S[i][c] == S[i + 1][c] { c++ }
    for j := c + 1; j < len(S[i]); j++ {
      if S[i][j] == '0' { cnt ^= (L - j) & (j - L) }
    }
    for j := c + 1; j < len(S[i + 1]); j++ {
      if S[i + 1][j] == '1' { cnt ^= (L - j) & (j - L) }
    }
  }
  for j, s := range S[N - 1] {
    if s == '0' { cnt ^= (L - j) & (j - L) }
  }
  if cnt > 0 {
    Write("Alice")
  } else {
    Write("Bob")
  }
}

func main() {
  Solve()
  Output()
}

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt(A ...*int) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.Atoi(L[i])
  }
}
func NextIntVec(A *[]int) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]int, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.Atoi(l)
  }
}
func NextFloat(A ...*float64) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.ParseFloat(L[i], 64)
  }
}
func NextFloatVec(A *[]float64) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]float64, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.ParseFloat(l, 64)
  }
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func WriteIntVec(A []int) {
  S := make([]string, len(A))
  for i, a := range A {
    S[i] = strconv.Itoa(a)
  }
  Write(strings.Join(S, " "))
}
func Output() {
  _ = writer.Flush()
}
func MaxInt(A ...int) int {
  max := A[0]
  for _, a := range A {
    if max < a { max = a }
  }
  return max
}
func MinInt(A ...int) int {
  min := A[0]
  for _, a := range A {
    if a < min { min = a }
  }
  return min
}
func SumInt(A ...int) int {
  sum := 0
  for _, a := range A {
    sum += a
  }
  return sum
}
func AbsInt(x int) int {
  if x < 0 { x = -x }
  return x
}

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

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

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

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

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

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

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
use std::collections::{HashMap,HashSet};
use std::cmp::{max,min};
fn main(){
    input!{
        n:usize,
        m:usize,
        mut pyn:[(usize,usize);m],
    }
    let mut v = vec![Vec::new();n];
    for (j,&(p,y)) in pyn.iter().enumerate(){
        v[p-1].push((y,j));
    }
    for v in &mut v {
        v.sort();
    }
    for (j,&(p,y)) in pyn.iter().enumerate(){
        let num = v[p-1].binary_search(&(y,j)).unwrap() + 1;
        println!("{:06}{:06}",p,num)
    }
}

Measured memory_bytes: 17916