akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define rusha scanf("%d",&n);rep(i,1,n)scanf("%d",&a[i]);
#define rushb scanf("%d",&t);while(t--)
#define debug(x) cout<<" L-B-W-- "<<x<<" --N-B\n"
#define pb push_back
#define pii pair<int,int>
#define vii vector<int>
#define fi first
#define se second
#define mem(a,b) memset(a,b,sizeof a)
#define all(x) (x.begin(),x.end())
#define judgef printf("%s\n",f?"Yes":"No")
#define Judgef printf("%s\n",f?"YES":"NO")
#define sz(x) ((int)(x).size())
#define sf(x) (sizeof(x))
using namespace std;
typedef long long ll;
typedef double db;
const double pai = acos(-1.0);
const double eps = 1e-8;
const int mod=998244353;
//const int mod=1e9+7;
const int inf=1e9+7;
//const ll inf=0x7f7f7f7f1234abcd;
const int maxn=2e5+10;
inline ll ksm(ll x,ll y){ll res=1;while(y){if(y&1)res=res*x%mod;x=x*x%mod;y>>=1;}return res;}
inline ll inv(ll a,ll p){if(a==1)return 1;return (p-p/a)*inv(p%a,p)%p;}
inline ll lcm(ll a,ll b){return a * b / __gcd(a, b);}
int t,n,m,k;
int main(){
    string a,b;
    cin>>a>>b;
    b.erase(b.end()-1);
    if(a==b) puts("Yes");
    else puts("No");
    return 0;
}


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

#define N 200009
int n;
long long a[N];
long long cnt[N];
long long ANS;

int main()
{
	cin >> n;
	for(int i = 1;i<=n;i++)
	{
		cin >> a[i];
		cnt[a[i]]++;
	}
	for(int i = 1;i<=n;i++)ANS += cnt[i]*(cnt[i]-1)/2;
	//cout << ANS << endl;//
	for(int i = 1;i<=n;i++)cout << ANS-(cnt[a[i]]-1) << endl;
	return 0;
}

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

const int mod = 1e9+7;

ll power(ll a, ll b, ll c) {
    if (b <= 0) return 1;
    ll temp = power(a, b / 2, c) % c;
    if (b % 2 == 0) {
        return (temp * temp) % c;
    }
    return (((a * temp) % c) * temp) % c;
}

struct NchooseK {
    int range, mod;
    vector<ll> fact,ifact;
    NchooseK(int currMod) {
        this->mod = currMod;
        range = (int)2e5+3;
        fact.resize(range+1);
        ifact.resize(range+1);
        calcFacts();
    }
    void calcFacts() {
        fact[0] = 1;
        for(ll i = 1; i <= range; ++i) {
            fact[i] = (1LL*fact[i-1]*i)%this->mod;
        }
        ifact[range] = power(fact[range], this->mod-2, this->mod);
        for(int i = range-1; i >= 0; --i) {
            ifact[i] = (1LL*ifact[i+1]*(i+1))%this->mod;
        }
    }
    ll modFact(ll n, ll &e) {
        if(n <= 1) return 1;
        ll res = modFact(n/this->mod, e);
        e += n/this->mod;
        if ((n/this->mod)%2 == 1) return res*(fact[n%this->mod]*(this->mod-1)%this->mod)%this->mod;
        return res*fact[n%this->mod]%this->mod;
    }
    ll calcChoose(ll n, ll k) {
        ll e1 = 0, e2 = 0, e3 = 0;
        ll a1 = modFact(n, e1);
        ll a2 = modFact(k, e2);
        ll a3 = modFact(n-k, e3);
        if (e1-e2-e3 > 0) return 0;
        return (a1*power(a2*a3%this->mod, this->mod-2, this->mod)%this->mod);
    }
    ll choose(int n, int k) {
        if(k < 0 || k > n || n < 0) return 0;
        return ((1LL*fact[n]*ifact[k])%this->mod * 1LL*ifact[n-k])%this->mod;
    }
};

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    NchooseK nk(mod);
    int r, c, n;
    cin >> r >> c >> n;
    vector<pair<int, int>> arr(n);
    for(int i = 0; i < n; ++i) {
        cin >> arr[i].first >> arr[i].second;
    }
    arr.push_back({r,c});
    sort(arr.begin(), arr.end());
    vector<int> ways(arr.size(),0);
    for(int i = 0; i < (int)arr.size(); ++i) {
        ways[i] = nk.choose(arr[i].first + arr[i].second-2, arr[i].first-1);
        for(int j = 0; j < i; ++j) {
            if(arr[j].first <= arr[i].first && arr[j].second <= arr[i].second) {
                ways[i] -= ways[j] * nk.choose(arr[i].second - arr[j].second + arr[i].first - arr[j].first, arr[i].first - arr[j].first) % mod;
                ways[i] = (ways[i] % mod + mod) % mod;
            }
        }
    }
    /*
    cout << "ways\n";
    for(int i = 0; i < (int)arr.size(); ++i) {
        cout << i << ' ' << arr[i].first << ' ' << arr[i].second << '\t' << ways[i] << '\n';
    }
    */
    cout << ways.back() << '\n';
    return 0;
}


























Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define int long long
using namespace std;
int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

signed main(){
    int N,M;
    cin >> N >> M;
    
    vector<pair<int,int>> A(N);
    for(int i=0;i<N;i++){
        cin >> A[i].first >> A[i].second;
    }
    
    sort(A.begin(),A.end());
    
    int ans = 0,i = 0;
    while(M>0){
        A[i].second--;
        ans += A[i].first;
        M--;
        if(A[i].second==0) i++;
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define loop(i,a,b) for(ll i=a; i<b; i++)
#define revloop(i,a,b) for(ll i=a; i>=b; i--)
#define pb push_back
#define vl vector<ll>
#define vvl vector<vl>
#define pl pair<ll,ll>
#define vpl vector<pl>
#define all(c) (c).begin(), (c).end()
#define sz(a) ((a).size())
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i!=(c).end(); i++))
#define mp make_pair
#define ss second
#define ff first
const ll INF = 1e13;
const ll N = 200001;
const ll mod= 1000000007;
bool prime(ll x)
{
	if(x<2) return false;
	for(ll i=2; i*i<=x; i++) if(x%i==0) return false;
	return true;
}
vl fac(N);
void fact()
{
	fac[0]=1;
	loop(i,1,N) fac[i]=(fac[i-1]*i)%mod;
}

void solve()
{
  ll n;
  cin>>n;
  double p[n+1];
  double dp[n+1][n+1], res=0;
  loop(i,1,n+1) cin>>p[i];
  loop(i,0,n+1) loop(j,0,n+1) dp[i][j]=0;
  dp[1][0] = 1-p[1];
  loop(i,2,n+1) dp[i][0] = dp[i-1][0]*(1-p[i]);
  dp[1][1]=p[1];
  loop(i,2,n+1) dp[i][i] = dp[i-1][i-1]*p[i];
  loop(i,1,n+1)
  {
  	loop(j,1,i)
  	 dp[i][j] = dp[i-1][j]*(1-p[i]) + dp[i-1][j-1]*p[i];
  }
  loop(i,n/2 +1, n+1) res+=dp[n][i];
  cout<< fixed << setprecision(10) << res;
  return;
}

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--) solve();
 return 0;
}

Measured memory_bytes: 72192
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); (i)--)
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
using namespace std;
typedef long long lint;

int main(){
    string s; int k; cin >> s >> k;
    int n = s.size();
    string a = "abcdefghijklmnopqrstuvwxyz";
    rep(i, n){
        if(i == n-1){
            s[i] = a[(s[i]-'a'+k) % 26];
            break;
        }
        int need = 26 - (s[i] - 'a');
        if(need > k || need == 26) continue;
        s[i] = 'a';
        k -= need;
    }
    cout << s << endl;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		long n = scan.nextLong();

		String nString = String.valueOf(n);
		String[] nStringArray = new String[nString.length()];

		for (int i = 0; i < nString.length(); i++) {
		    nStringArray[i] = String.valueOf(nString.charAt(i));
		}

		scan.close();

		long sumAll = 0;
		for(int bit = 0; bit < (1 << nString.length() - 1); bit++) {
			long sum = 0;
			String numString = "";
			for(int i = 0; i < nString.length(); i++) {
				if((bit & (1<<i)) != 0) {
					if(numString == "") {
						sum += Integer.valueOf(nStringArray[i]);
						continue;
					}
					numString = numString + nStringArray[i];
					sum += Integer.valueOf(numString);
					numString = "";
				}else {
					numString = numString + nStringArray[i];
				}
			}
			sum += Long.valueOf(numString);

			sumAll += sum;
		}
		System.out.println(sumAll);
	}

}

Measured memory_bytes: 23380
import java.util.*;
class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] l = new int[n];
		int ans = 0;

		for(int i=0;i<n;i++){
			l[i] = sc.nextInt();
		}

		Arrays.sort(l);

		for(int j=0;j<k;j++){
			ans += l[n-j-1];
		}

		System.out.println(ans);
		}
	}

Measured memory_bytes: 35828
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

a, b = rm()
print(*list(range(b-a+1,b+a)))












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

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

map<ll, ll> primefact(ll n) {
    map<ll, ll> res;
    for(ll i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            res[i]++;
            n /= i;
        }
    }
    if(n != 1) res[n] = 1;
    return res;
}

ll a, b;

int main() {
    cin >> a >> b;
    if(b < 0) {
        if((b - a) % 2) {
            cout << "Positive"
                 << "\n";
        } else {
            cout << "Negative"
                 << "\n";
        }
    } else if(b == 0 || a <= 0) {
        cout << "Zero"
             << "\n";
    } else {
        cout << "Positive"
             << "\n";
    }
    return 0;
}


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

signed main() {
  int N;
  map<int, int> m;
  cin >> N;
  for(int i=1; i<=N; i++) {
    int a; cin >> a;
    m[a]=i;
  }

  for(int i=1; i<=N; i++) cout << m[i] << (i==N ? "\n" : " ");

}


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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n; cin >> n;
  ll ans = 1;
  ll all = 1;
  for(int i=0;i<n;++i) {
    int a; cin >> a;
    all *= 3;
    if(a % 2 == 0) ans *= 2;
  }
  cout << all - ans << endl;



}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n,t,cub,rec,per;
   while(scanf("%d%d",&n,&t)!=EOF)
   {
     rec=n*t;
     per=2*(n+t);
     cout<<rec<<" "<<per<<endl;
   }
}




Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 1000000007
#define INF 800000000
#define MAX 1000

int main(){
  int N;
  cin>>N;
  vector<ll> a(N);
  for(int i=0;i<N;i++){
    cin>>a.at(i);
  }

  ll ans1=0,ans2=0;
  vector<ll> sum(N+1,0);
  if(a.at(0)<=0){
    ans1+=1-a.at(0);
    sum.at(1)=1;
  }else{
    sum.at(1)=a.at(0);
  }
  for(int i=2;i<=N;i++){
    sum.at(i)=sum.at(i-1)+a.at(i-1);
    if(sum.at(i)==0){
      if(sum.at(i-1)>0){
        sum.at(i)=-1;
      }else{
        sum.at(i)=1;
      }
      ans1++;
    }else if(sum.at(i)*sum.at(i-1)>0){
      if(sum.at(i-1)<0){
        ans1+=1-sum.at(i);
        sum.at(i)=1;
      }else{
        ans1+=1+sum.at(i);
        sum.at(i)=-1;
      }
    }
  }

  if(a.at(0)>=0){
    ans2+=1+a.at(0);
    sum.at(1)=-1;
  }else{
    sum.at(1)=a.at(0);
  }
  for(int i=2;i<=N;i++){
    sum.at(i)=sum.at(i-1)+a.at(i-1);
    if(sum.at(i)==0){
      if(sum.at(i-1)>0){
        sum.at(i)=-1;
      }else{
        sum.at(i)=1;
      }
      ans2++;
    }else if(sum.at(i)*sum.at(i-1)>0){
      if(sum.at(i-1)<0){
        ans2+=1-sum.at(i);
        sum.at(i)=1;
      }else{
        ans2+=1+sum.at(i);
        sum.at(i)=-1;
      }
    }
  }
  cout<<min(ans1,ans2)<<endl;
}


Measured memory_bytes: 1792
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
a = [int(readline()) for i in range(n)][::-1]
ans = 0
for i in range(n - 1):
    ans += a[i] // 2
    if a[i] % 2 == 1 and a[i + 1] != 0:
        a[i + 1] -= 1
        ans += 1
ans += a[-1] // 2
print(ans)


Measured memory_bytes: 7832
object Main extends App {
  val inputs: Seq[String] = scala.io.Source.stdin.getLines().toList
  val n = inputs(0).toInt
  val lines = inputs.tail

  solve(lines)

  def solve(lines: Seq[String]): Unit = {
    val resultMap = scala.collection.mutable.HashMap(("WA", 0), ("TLE", 0), ("AC", 0), ("RE", 0))
    lines.foreach { v =>
      resultMap.update(v, resultMap(v) + 1)
    }

    println(s"AC x ${resultMap("AC")}")
    println(s"WA x ${resultMap("WA")}")
    println(s"TLE x ${resultMap("TLE")}")
    println(s"RE x ${resultMap("RE")}")
  }
}

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

int main(){
   ll N; cin>>N;
   ll A[N];
   map<ll, ll> map;
   ll sum = 0;
   rep(i, N){
       cin>>A[i];
       map[A[i]-1]++;
   }

    for(auto m : map){
        sum += (m.first+1)*m.second;
    }

   ll Q; cin>>Q;
   ll B[Q], C[Q];
   rep(i, Q) cin>>B[i]>>C[i];
    rep(i, Q){
        sum -= map[B[i]-1]*(B[i]-1);
        sum += (map[B[i]-1])*(C[i]-1);
        map[C[i]-1] += map[B[i]-1];
        map.erase(B[i]-1);
        cout << sum << endl;
    }
}


Measured memory_bytes: 9896
// RGB Triplets

func main() {
  let n = Int(readLine()!)!
  let s = Array(readLine()!)
  var removes = 0
  var counts: [Character:Int] = [
    "R" : 0,
    "G" : 0,
    "B" : 0
  ]

  for i in 0..<n {
    let m = min(i, n-i-1)
    if m > 0 {
      for j in 1...m {
        if s[i-j] != s[i] && s[i] != s[i+j] && s[i+j] != s[i-j] {
          removes += 1
        }
      }
    }
    counts[s[i]]! += 1
  }

  print(counts["R"]! * counts["G"]! * counts["B"]! - removes)
}

main()

Measured memory_bytes: 8012
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define forin(in) for(int i=0; i<(int)in.size(); i++) cin>>in[i]
#define forout(out) for(int i=0; i<(int)out.size(); i++) cout<<out[i]<<endl
#define rep(i, n) for(int i=0; i<(n); i++)

int main(){
    int n; cin>> n;
    vector<ll> h(n);
    forin(h);
    for(int i=1; i<n; i++){
        if(h[i-1] > h[i]){
            cout<< "No" << endl;
            return 0;
        }else{
            if(h[i] != h[i-1]) h[i]--;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 4052
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var nab = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var ar = Array.ConvertAll(ReadLine().Split(' '), long.Parse);
        ar = ar.OrderByDescending(v => v).ToArray();
        var max = ar.Take(nab[1]).Average(v => (double)v);
        WriteLine(max.ToString("0.#######"));
        var ct = ar.Count(v => v == ar[nab[1] - 1]);
        var ctf = ar.Take(nab[1]).Count(v => v == ar[nab[1] - 1]);
        if (ctf != nab[1])
        {
            var res = (long)ct;
            for(var i = 0; i < ctf-1; i++)
            {
                res *= ct - (i + 1);
                res /= (i + 2);
            }
            WriteLine(res);
            return;
        }
        var r = 0L;
        for(var i = ctf; i <= Min(nab[2], ct); i++)
        {
            var pro = (long)ct;
            for(var j = 1; j < i; j++)
            {
                pro *= ct - j;
                pro /= (j + 1);
            }
            r += pro;
        }
        WriteLine(r);
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}


Measured memory_bytes: 13524
#include <bits/stdc++.h>
using namespace std;
int main(){
  int H,W,s=1;cin>>H>>W;char x;
  for(int i=0;i<H*W;i++){
    cin>>x;if(x=='#')s++;
  }
  if(s==H+W)cout<<"Possible"<<endl;
  else cout<<"Impossible"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
int a[101010];
long long sum[101010];
char s[101010][2];
int la;
int ne[101010];
int main()
{
	int n;
	long long now=0,ans=-1010101010101010ll;
	scanf("%d%d",&n,&a[1]);
	s[1][0]='+';
	la=0;
	for(int i=2;i<=n;i++)
	{
		scanf("%s%d",s[i],&a[i]);
		if(s[i][0]=='-')
		{
			ne[la]=i;
			la=i;
		}
	}
	ne[la]=n+1;
	sum[0]=0;
	for(int i=1;i<=n;i++)
		sum[i]=sum[i-1]+a[i];
	for(int i=1;i<=n;i++)
	{
		if(s[i][0]=='+')
			now+=a[i];
		else
		{
			ans=max(ans,now+sum[n]-sum[ne[i]-1]-(sum[ne[i]-1]-sum[i-1]));
			now-=a[i];
		}
	}
	ans=max(ans,now);
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
#define ll long long int
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
int main()
{
    FAST();
    ll n,i,j,k,t,a,b,c,d,p,q,x,y;
    cin>>a>>b>>c>>d;
    while(a>0&&c>0)
    {
        if(a>0)
          c=c-b;
        if(c>0)
        {
            a=a-d;
        }
    }
    if(a<=0)
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;
    return 0;
}



Measured memory_bytes: 3584
# coding: utf-8

cnt = 0
m = 0
G = []
A = []

def insertionSort(A, n, g):
    global cnt
    for i in range(g,n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v

def shellSort(A, n):
    global m
    h = 1
    m += 1
    G.append(h)
    for i in range(99):
        if 3*h + 1 > n:
            break
        m += 1
        h = 3*h + 1
        G.append(h)
    G.reverse()
    for i in range(0,m):
        insertionSort(A, n, G[i])

def printA(A, n):
    for i in range(n):
        print(A[i])

def printG(G, m):
    for i in range(m):
        print(G[i],end="")
        if i == m - 1:
            print()
        else:
            print(" ",end="")

n = int(input().rstrip())
for i in range(n):
    A.append(int(input().rstrip()))

shellSort(A, n)
print(m)
printG(G, m)
print(cnt)
printA(A,n)


Measured memory_bytes: 45512
#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>
using namespace std;
int main() {
  string s;
  stringstream ss;
  int a,b,c;
  cin >> a >> b >> c;
  int maxnum = max(a,max(b,c));
  cout << a * b * c / maxnum /2 << endl;
  return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        int k = scanner.nextInt();
        int ans = 1;

        int a_result = 0;
        int b_result = 0;

        for (int i = 0; i < n; i++) {
            a_result = ans * 2;
            b_result = ans + k;

            ans = a_result < b_result ? a_result : b_result;
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
def task():
    n = int(input())
    time_task = []
    for i in range(n):
        a,b = map(int,input().split())
        time_task.append([b,a])
    #print(sorted(time_task))
    time_task.sort()

    total_time = 0
    for j in range(n):
        total_time += time_task[j][1]
        limit = time_task[j][0]
        if total_time > limit:
            return 'No'
    return 'Yes'

print(task())

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

int main() {
  int i, j, k;
  bool judge=false;
  string S, test;
  
  cin >> S;
  
  string divide[4] = {"dream","dreamer","erase","eraser"};
  
  rep(i,4) reverse(divide[i].begin(),divide[i].end());
  reverse(S.begin(),S.end());
  
  for(i=0;i<S.size();){
    judge=false;
    rep(j,4){
      test=divide[j];
      if (S.substr(i,test.size())==test){
        i+=test.size();
        judge=true;
        break;
      }
    }
    
    if(!judge){
      cout << "NO" << endl;
      return 0;
    }
  }
  
  cout << "YES" << endl;
  
}

Measured memory_bytes: 3760
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


char buf[5];

int main(){

	int ans = 0;

	scanf("%s",buf);

	for(int i = 0; buf[i] != '\0'; i++){

		if(buf[i] == '1'){

			ans += 1;
		}
	}

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

	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  vector<pair<int, int>> p(m);

  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());

  rep(i, m) cin >> p[i].second >> p[i].first;
  sort(p.rbegin(), p.rend());

  int i = 0;
  int j = 0;

  while (a[i] < p[j].first && i < n && j < m) {
    a[i] = p[j].first;
    i++;
    if (p[j].second > 1)
      p[j].second--;
    else
      j++;
  }

  ll ans = 0;

  rep(i, n) ans += 1LL * a[i];
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1408
def gcd(a, b):
  if b == 0:
    return a
  return gcd(b, a%b)

def permutation(n):
    if n == 1:
        return 1
    elif n == 2:
        return 3
    else:
        return 6

def solve():
    n = int(input())
    s = 0
    for i in range(1, n + 1):
        for j in range(i, n + 1):
            for k in range(j, n + 1):
                diff = 1
                if j != k:
                    diff += 1
                if i != j:
                    diff += 1
                s += gcd(i, gcd(j, k)) * permutation(diff)

    print(s)
    return s

solve()


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

int main(){
  int n,a;
  cin >> n >> a;
  if (n%500 <= a) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;n--;
  string ans;
  while(n>=0) {
    ll r=n%26;
    ans+='a'+r;
    n/=26;n--;
  }
  if(ans.length()==0) ans+='a';
  reverse(ALL(ans));
  print(ans);
  return 0;
}

Measured memory_bytes: 3608
N = int(input())
c = list(input())

count_r = c.count('R')
count = 0

for i in range(N):
	if count_r == 0: break
	if c[i] == 'W':
		count += 1
		count_r -= 1
	if c[i] == 'R':
		count_r -= 1

print(count)

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

int main () {
  int N;
  cin >> N;
  
  vector<int> vec(N);
  for ( int i = 0 ; i < N ; i ++){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  
  int kagami;
  kagami = 0 ;
  for ( int i = 0 ; i < N ; i ++){
    if ( i == 0){
      kagami ++;
    }
    else if ( vec.at(i)>vec.at(i-1)){
      kagami++;
    }
    else {
      continue;
    }
  }
    cout << kagami << endl;
  }
  

Measured memory_bytes: 256
//Let's join Kaede Takagaki Fan Club !!
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define all(x) x.begin(),x.end()
template<class T>
void dmp(T a){
	rep(i,a.size()) cout << a[i] << " ";
	cout << endl;
}
template<class T>
bool chmax(T&a, T b){
	if(a < b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
bool chmin(T&a, T b){
	if(a > b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
void g(T &a){
	cin >> a;
}
template<class T>
void o(const T &a,bool space=false){
	cout << a << (space?' ':'\n');
}
//ios::sync_with_stdio(false);
const ll mod = 1000000007;//998244353
template<class T>
void add(T&a,T b){
	a+=b;
	if(a >= mod) a-=mod;
}
struct UF{
	int par[2000005],ran[2000005];
	void init(){ for(int i=0;i<2000005;i++) par[i] = i, ran[i] = 0; }
	int find(int x){ if(x == par[x]) return x; else return par[x] = find(par[x]); }
	void unite(int x,int y){
		x = find(x); y = find(y); if(x==y) return;
		if(ran[x] < ran[y]) par[x] = y;
		else{
			par[y] = x;
			if(ran[x] == ran[y]) ran[x]++;
		}
	}
	bool same(int x,int y){ return find(x)==find(y); }
}uf;


ll modpow(ll x,ll n){
	ll res=1;
	while(n>0){
		if(n&1) res=res*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return res;
}
ll F[2000005],R[2000005];
void make(){
	F[0] = 1;
	for(int i=1;i<2000005;i++) F[i] = F[i-1]*i%mod;
	R[2000004] = modpow(F[2000004], mod-2);
	for(int i=2000003;i>=0;i--) R[i] = R[i+1] * (i+1) % mod;
}
ll C(int a,int b){
	return F[a]*R[b]%mod*R[a-b]%mod;
}
void solve(){
	int n, m, k;
	string f[10];
	cin >> n >> m >> k;
	rep(i, n) cin >> f[i];
	int ans = 0;
	rep(mask, (1<<n)) rep(mask2, (1<<m)){
		string e[10];
		rep(j, 10) e[j] = f[j];
		rep(i, n) if(((mask>>i)&1)) rep(j, m) e[i][j] = 'X';
		rep(j, m) if(((mask2>>j)&1)) rep(i, n) e[i][j] = 'X';
		int cnt = 0;
		rep(i, n) rep(j, m) cnt += e[i][j] == '#';
		if(cnt == k) ans++;
	}
	cout<<ans<<endl;
}

int main(){
	uf.init();
	make();
	solve();
}

Measured memory_bytes: 50456
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;

    int ans = 0;
    rep(a, 10) rep(b, 10) rep(c, 10){
        bool flag1 = false, flag2 = false, flag3 = false;
        int i = 0;
        while(i < n){
            if (!flag1) if (s[i] - '0' == a) flag1 = true, i++;
            if (flag1 && !flag2) if (s[i] - '0' == b) flag2 = true, i++;
            if (flag1 && flag2 && !flag3) if (s[i] - '0' == c) flag3 = true, i++;
            i++;
        }
        if (flag1 && flag2 && flag3) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
t=int(input())
x=[int(i)for i in input().split()]
ans=0
max=0

for j in range(t):
	if x[j]>max:
		max=x[j]
	elif x[j]+1<max:
		ans=1
if ans==0:
	print('Yes')
else:
	print('No')

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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()

int main() {
  int A, B;
  cin >> A >> B;
  int x = A+B;
  if(x>23)x -= 24;
  
  cout << x << endl;
  
  return 0;
}

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

using namespace std;

int main(){
    int k;
    cin >> k;
    vector<int64_t> A(k);
    copy_n(istream_iterator<int64_t>(cin), k, A.begin());

    int64_t l = 2, r = 2; 
    for (int i = k - 1; i >= 0; i--){
        auto a = A[i];
        if (l % a != 0)
            l = l / a * a + a;
        if (r % a != 0)
            r = r / a  * a;
        if (l > r){
            cout << -1 << endl;
            return 0;
        }
        r += a - 1;
    }

    cout << l << " " << r << endl;
}

Measured memory_bytes: 1024
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys,collections,itertools,re,math,fractions,decimal,random,array,bisect,heapq

# decimal.getcontext().prec = 50
# sys.setrecursionlimit(10000)
# MOD = 10**9 + 7

def solve(f):
    n, k = f.read_int_list()
    s = f.read_str()

    diff = 0
    for i in xrange(n-1):
        if s[i] != s[i+1]:
            diff += 1

    return n-1-max(0, diff-2*k)


class Reader(object):
    def __init__(self, filename=None):
        self.file = open(filename) if filename is not None else None
        self.case = 1

    def __readline(self):
        return self.file.next().strip() if self.file else raw_input()

    def next_case(self):
        self.file.next()
        self.case += 1

    def read_int(self): return int(self.__readline())
    def read_float(self): return float(self.__readline())
    def read_long(self): return long(self.__readline())
    def read_decimal(self): return decimal.Decimal(self.__readline())
    def read_str(self): return self.__readline()

    def read_int_list(self): return map(int, self.__readline().split())
    def read_float_list(self): return map(float, self.__readline().split())
    def read_long_list(self): return map(long, self.__readline().split())
    def read_decimal_list(self): return map(decimal.Decimal, self.__readline().split())
    def read_str_list(self): return self.__readline().split()

if __name__ == '__main__':
    filename = sys.argv[1] if len(sys.argv) > 1 else None
    f = Reader(filename)
    if f.file:
        while True:
            print "Case #%d\n"%f.case, solve(f)
            try:
                f.next_case()
            except StopIteration:
                break
    else:
        print solve(f)


Measured memory_bytes: 6144
#include <stdio.h>
#define IN 100000000

int min(int r,int s){
  if(r<s) return r;
  return s;
}
int main(){
  int i,j,a,b,n,r[101],M[101][101];
   
  scanf("%d",&n);
   
  for(i=1;i<=n;i++)  scanf("%d %d",&r[i-1],&r[i]);
   
  for(i=1;i<=n;i++)   M[i][i]=0;
   
  for(i=2;i<=n;i++){
    for(j=1;j<=n-i+1;j++){
      b = i + j - 1;
      M[j][b] = IN;
      for (a=j;a<=b-1;a++){
    M[j][b]=min(M[j][b],M[j][a] + M[a+1][b] + r[j-1]*r[a]*r[b]);
      }
    }
  }
  printf("%d\n",M[1][n]);
  return 0;
}

Measured memory_bytes: 636
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mk make_pair
#define rint register int
using namespace std;
inline int read(){int w=1,s=0;char ch=getchar();while(!isdigit(ch)){if(ch=='-')w=-1;ch=getchar();}while(isdigit(ch)){s=s*10+ch-'0';ch=getchar();}return w*s;}
struct node{int to,next,flow;ll w;} e[1000010];
int h[2100],tot=1,n,X[1000100],Y[1000100],m;
ll Ans=0,V[1000010];int opt[100001],A[10010],B[10010],S,T,L[2010],R[2001];
int inq[2019],flow[2019],Pre[2019],edg[2019];ll dis[2019];
inline void add(int from,int to,int flow,ll w)
{
	e[++tot].next=h[from];h[from]=tot;e[tot].to=to;e[tot].flow=flow;e[tot].w=w;
	e[++tot].next=h[to]  ;h[to]=tot;  e[tot].to=from;e[tot].flow=0;e[tot].w=-w;
}
queue<int> q;
inline bool Spfa()
{
	q.push(S);
	memset(dis,-0x3f,sizeof(dis));inq[S]=0;
	flow[S]=1e9;
	dis[S]=0;
	while(!q.empty())
	{
		int u=q.front();q.pop();
		inq[u]=0;
		for(rint i=h[u];i;i=e[i].next)
		{	int to=e[i].to;if(!e[i].flow) continue;
			if(dis[to]<dis[u]+e[i].w)
			{	dis[to]=dis[u]+e[i].w;
				flow[to]=min(flow[u],e[i].flow);
				Pre[to]=u;edg[to]=i;
				if(!inq[to]) q.push(to),inq[to]=1;
			}
		}
	}return dis[T]>=0;
}
inline void MCMF(int mid)
{
	int fw=0;ll C=0;
	while(Spfa())
	{
		int k=T;
		while(k!=S)
		{
			e[edg[k]].flow-=flow[T];
			e[edg[k]^1].flow+=flow[T];
			k=Pre[k];
		}
		fw+=flow[T];
		C+=dis[T];
	}
	if(fw==mid) Ans=max(Ans,C);
}
inline void Solve()
{
	S=4*n+1,T=S+1;
	for(rint i=1;i<=n;++i)
	{
		tot=1;
		memset(h,0,sizeof(h));
		memset(L,0,sizeof(L));
		memset(R,0x3f,sizeof(R));
		for(rint j=1;j<=i;++j) add(S,n+n+j,1,0),add(n+n+j+i,T,1,0);
		for(rint j=1;j<=n;++j) add(j,n+j,1,V[j]);
		for(rint j=1;j<=m;++j)
		{
			if(B[j]>=i) continue; 
			if(opt[j]==0)
				R[i-B[j]]=min(A[j]-1,R[i-B[j]]);
			else if(opt[j]==1)
				L[B[j]+1]=max(A[j]+1,L[B[j]+1]);
		}
		for(rint j=2;j<=i;++j) L[j]=max(L[j-1],L[j]);
		for(rint j=i-1;j>=1;--j) R[j]=min(R[j+1],R[j]);
		for(rint j=1;j<=i;++j)
			for(rint k=1;k<=n;++k)
				if(X[k]>=L[j]&&X[k]<=R[j]) add(n+n+j,k,1,0);
		memset(L,0,sizeof(L));
		memset(R,0x3f,sizeof(R));
		for(rint j=1;j<=m;++j)
		{
			if(B[j]>=i) continue; 
			if(opt[j]==2)
				R[i-B[j]]=min(A[j]-1,R[i-B[j]]);
			else if(opt[j]==3)
				L[B[j]+1]=max(A[j]+1,L[B[j]+1]);
		}
		for(rint j=2;j<=i;++j) L[j]=max(L[j-1],L[j]);
		for(rint j=i-1;j>=1;--j) R[j]=min(R[j+1],R[j]);
		for(rint j=1;j<=i;++j)
			for(rint k=1;k<=n;++k)
				if(Y[k]>=L[j]&&Y[k]<=R[j]) add(n+k,n+n+i+j,1,0);
		MCMF(i);
	}
}
int main()
{	
	n=read();
	for(rint i=1;i<=n;++i) X[i]=read(),Y[i]=read(),cin>>V[i];
	m=read();
	for(rint i=1;i<=m;++i)
	{
		char s[10];scanf("%s",s+1);
		if(s[1]=='L') opt[i]=1;
		if(s[1]=='R') opt[i]=0;
		if(s[1]=='D') opt[i]=3;
		if(s[1]=='U') opt[i]=2;
		A[i]=read(),B[i]=read();
	}
	Solve();
	cout<<Ans;
	return 0;
}	

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

int digit(ll N){
  int ans=0;
  while(N>0){
    ans++;
    N/=10;
  }
  return ans;
}

int main(){
  ll N;
  cin>>N;
  ll x=(ll)sqrtl(N);
  for(ll i=x;i>0;i--){
    if(N%i==0){
      cout<<max(digit(i),digit(N/i))<<endl;
      break;
    }
  }
}


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

#define fi first
#define se second
#define FO(x, n) for (int x = 0; x < n; ++x)
#define FOR(x, a, b) for (int x = a; x < b; ++x)
#define RFO(x, n) for (int x = n - 1; x >= 0; --x)
#define RFOR(x, a, b) for (int x = b - 1; x >= a; --x)
#define FOR_ITER(x, a) for(auto x = a.begin(); x != a.end(); ++x)



using namespace std;
typedef unsigned char byte;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;
typedef pair<ll, ll> pll;
inline bool feq(const double& a, const double& b) { return fabs(a - b) < 1e-10; }

using namespace std;

int n, m;
vector<string> a;
vector<string> b;

bool cmp(int iIdx, int jIdx){
    FOR(i, iIdx, (iIdx + m)){
        FOR(j, jIdx, (jIdx + m)) {
            if (a.at(i).at(j) != b.at(i - iIdx).at(j - jIdx)) {
                return false;
            }
        }
    }
    return true;
}

int main(){
//    int n, l;
//    cin >> n >> k;
//    vector<bool> dislike(10, false);
//
//    FOR(i, 0, k) {
//        int t;
//        cin >> t;
//        dislike[t] = true;
//    }



cin >>n>>m;
a.resize(n);
b.resize(m);

FO(i, n){
    cin >> a.at(i);
}
FO(i, m){
    cin >> b.at(i);
}

FO(i, (n - m + 1)) {
    FO(j, (n - m + 1)) {
        if(cmp(i, j)) {
            cout<<"Yes"<< endl;
            return 0;
        }
    }

}

cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 256
fun main() {
    var (a, b, c,k) = readListInt()
    var ans = 0

    if (a >= k) {
        println(k)
        return
    }
    ans += a
    k -= a
    if (b >= k) {
        println(ans)
        return
    }
    k -= b
    ans -= k
    println(ans)

}

private fun read() = readLine()!!

private fun readInt() = read().toInt()

private fun readLong() = read().toLong()

private fun readDouble() = read().toDouble()

private fun readListString() = read().split(" ")

private fun readListInt() = readListString().map { it.toInt() }

private fun readListLong() = readListString().map { it.toLong() }

private fun readListDouble() = readListString().map { it.toDouble() }




Measured memory_bytes: 36328
import java.util.Scanner;

public class Main {

	int n;
	int array[];
	public static void main(String args[]) {
		new Main().run();
	}
	Main() {
		Scanner scan = new Scanner(System.in);
		n = scan.nextInt();
		array = new int[n];
		for (int i = 0; i < n; i++) {
			array[i] = scan.nextInt();
		}
	}
	void run() {
		int p = partition(array,0,n);
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < n; i++) {
			if (p == i)
				sb.append((i==0?"":" ") + "[" + array[i] + "]");
			else 
				sb.append((i==0?"":" ") + array[i]);
		}
		System.out.println(sb);
	}
	int partition(int[] A, int p, int r) {
		int x = A[r-1];
		int i = p - 1;
		for (int j = p; j < r- 1; j++) {
			if (A[j] <= x) {
				i++;
				int tmp = A[i];
				A[i] = A[j];
				A[j] = tmp;
			}
 		}
		int tmp = A[i+1];
		A[i+1] = A[r-1];
		A[r-1] = tmp;
		return i+1;
	}
}



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

int main() {
  long long N, M;
  cin >> N >> M;
  if (N == 1 && M == 1) cout << M << endl;
  else if (N == 1) cout << M - 2 << endl;
  else cout << llabs((N - 2) * (M - 2)) << endl;
  return 0;
}

Measured memory_bytes: 256
A,B,C,D,E,F = map(int,input().split())

maxE = 0
maxWS = [100*A,0]
for a in range(0,F+1,100*A):
	for b in range(0,F-a+1,100*B):
		if a +b == 0:
			continue
		for c in range(0,F-a-b+1,C):
			for d in range(0,F-a-b-c+1,D):
				
				e = (c+d)/(a+b+c+d)
				
				if not (c+d)/(a+b) <= E/100:
					continue
				
				if maxE < e:
					maxE = e
					maxWS = [a+b+c+d,c+d]
				
print(maxWS[0],maxWS[1])

Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>
using namespace std;
int N, W, w[101], v[101], ans;
long long dp[101][100001];
int main() {
  scanf("%d %d", &N, &W);
  for(int i = 1; i <= N; i++) {
    scanf("%d %d", &w[i], &v[i]);
    v[0] += v[i];
  }
  for(int i = 1; i <= v[0]; i++) dp[0][i] = 1e9;
  for(int i = 1; i <= N; i++) {
    for(int j = 1; j <= v[0]; j++) {
      if(j >= v[i]) dp[i][j] = min(dp[i-1][j], dp[i-1][j-v[i]]+w[i]);
      else dp[i][j] = dp[i-1][j];
      if(dp[i][j] <= W) ans = max(ans, j);
    }
  }
  printf("%d", ans);
}

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int,V,greater<int>>

#define pb(a) push_back(a)
#define mp make_pair

#define dump(x)  cout << #x << " = " << (x) << "\n";
#define COUT(x) cout<<(x)<<"\n"

int main()
{
    int n = 0;
    cin >> n;
    int x = n;
    int num = 0;
    while (x > 0)
    {
        num += x % 10;
        x = x / 10;
    }
    if (n % num == 0)
    {
        COUT("Yes");
    }
    else
    {
        COUT("No");
    }

    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#include <climits>
#include <memory>
#include <numeric>
#include <utility>


#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
#define PI 3.14159265358979323846264338327950L;
const int INF2 = 1001001001;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
const ll LINF = 1e18;
using namespace std;
using Graph = vector<vector<int>>;



int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


	void init(int n)
	{
		for (int i = 0; i < n; i++) par[i] = i;
		for (int i = 0; i < n; i++) r[i] = 0;
	}

	int find(int x)
	{
		if (par[x] == x)return x;
		else return find(par[x]);
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

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

const int MAX_N = 110000;

int memo[MAX_N];

int rec(int n) {
	if (n == 0)return 0;
	if (memo[n] != -1)return memo[n];

	int res = n;

	for (int pow6 = 1; pow6 <= n; pow6 *= 6)res = min(res, rec(n - pow6) + 1);

	for (int pow9 = 1; pow9 <= n; pow9 *= 9)res = min(res, rec(n - pow9) + 1);

	return memo[n] = res;
}

int calc(int x) {
	int ret = 0;
	while (x % 2 == 0) {
		x /= 2;
		ret++;
	}

	return ret;
}

int a[12][12];
int D;
ll G;
vector<ll> P, C;

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

	string s,t;
	cin >> s >> t;

	vector<int> start(26,-1);
	vector<int> goal(26,-1);
	rep(i, 0, s.size()) {
		int a = s[i] - 'a';
		int b = t[i] - 'a';
		if (start[a] != -1 || goal[b] != -1) {
			if (start[a] != b || goal[b] != a) {
				cout << "No" << endl;
				return 0;
			}

		}
	else {
		start[a] = b;
		goal[b] = a;
		}
	}

	cout << "Yes" << endl;

	
}
	

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

int N;

int check[1050];

void PRIME(void) {
	for (int i = 2; i <= 1000; i++) {
		if (check[i] == 0) {
			for (int j = i * 2; j <= 1000; j += i) {
				check[j] = 1;
			}
		}
	}

}

vector<int> V;

int alpha[1050];

int main(void) {
	cin >> N;

	PRIME();

	for (int i = 2; i <= 1000; i++) {
		if (check[i] == 0) { V.push_back(i); }
	}


	for (int k = 2; k <= N; k++) {
		//cout << "k= " << k << endl;
		int tmp = k;
		while (tmp > 1) {
			//cout << "tmp= " << tmp << endl;
			for (int i = 0; i < (int)V.size(); i++) {
				
			     if (tmp>=V[i] && tmp%V[i] == 0) { alpha[i]++; tmp /= V[i]; }
			}
		}
	}

	/*for (int i = 0; i < (int)V.size(); i++) {
		cout << V[i] << " " << alpha[i] << endl;
	}*/

	long long int ans = 1;

	for (int i = 0; i < (int)V.size(); i++) {
		ans *= (long long int)(alpha[i] + 1);
		ans %= 1000000007;
	}

	cout << ans << endl;

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define fi first
#define se second
#define pii pair<int, int>

signed main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> adj(n, vector<int>(n, 0));
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    adj[u][v] = adj[v][u] = 1;
  }
  int ans = 0;
  vector<int> per;
  for (int i = 1; i < n; i++) {
    per.push_back(i);
  }
  do {
    bool is_ans = adj[0][per[0]];
    for (int i = 1; i < sz(per); i++) {
      if (!adj[per[i]][per[i - 1]]) is_ans = false;
    }
    if (is_ans) ans++;
  } while(next_permutation(per.begin(), per.end()));
  cout << ans << "\n";
}



Measured memory_bytes: 256