akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mkp make_pair
#define SZ(x) ((int)(x).size())
#define MEM(x,a) memset(x,a,sizeof(x))
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1000000007,N=1e5+5,M=1e5+5,INF=0x3f3f3f3f;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
//head

bool check(ll n,ll k){
    while(n%k==0)n/=k;
    return (n%k==1);
}
int main(void){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int ans=0;
    ll n;
    cin>>n;
    --n;
    if(n>1)++ans;
    for(ll i=2;i*i<=n;++i){
        if(n%i==0){
            ans+=2;
            //cout<<i<<endl<<n/i<<endl;
        }
        if(i*i==n)--ans;
    }
    ++n;
    ++ans;
    for(ll i=2;i*i<=n;++i){
        if(n%i==0){
            ans+=check(n,i);
            if(i*i!=n){
                ans+=check(n,n/i);
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

#define MAX 200000
int A[MAX];

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

    rep(i,n) cin >> A[i];

    sort(A, A + n);

    rep(i,n-1){
        if(A[i] == A[i+1]){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt();
    vector <int> v(n);
    generate(all(v),nxt);
    map <int,ll> m;
    for(int i=0;i<n;i++)
        m[v[i]]+=1;
    ll test=0;
    for(auto it=m.begin();it!=m.end();it++)
        test+=((it->second)*(it->second-1))/2;
    for(int i=0;i<n;i++)
    {
        ll temp=test-((m[v[i]]*(m[v[i]]-1))/2);
        temp+=(((m[v[i]]-2)*(m[v[i]]-1))/2);
        cout<<temp<<endl;
    }

    return 0;   
}


 
 


Measured memory_bytes: 10368
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mset(x, y) memset((x), (y), sizeof(x))
#define sz(x) ((int)(x).size())
#define rep(i, a, b) for(i = a; i < b; i++)
#define per(i, a, b) for(i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define cerr cout
#define endl '\n'
using namespace std;

string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cerr << " " << to_string(H); debug_out(T...);}
#define pr(...) cerr << "[" << #__VA_ARGS__ << "] :", debug_out(__VA_ARGS__)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ld eps = 1e-7;
const ll mod = 1000000007;
const ll N = 998244353;

ll binpow(ll b, ll p){ ll ans = 1; while(p > 0){if(p & 1) ans = (ans * b) % mod; b = (b * b) % mod; p >>= 1;}return ans;}
ll modinv(ll x){return binpow(x, mod - 2);}

const int mxn = 2e5 + 100;
int a[mxn], n, k;

bool ok(int x)
{
	int i, cnt = 0;
	rep(i, 0, n)
	{
		if(a[i] <= x)
			break;
		cnt += (a[i] - 1) / x;
	}
	return cnt <= k;
}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int i;
	cin >> n >> k;
	rep(i, 0, n)
		cin >> a[i];
	sort(a, a + n, greater<int>());
	int l = 1, r = a[0], mid;
	while(l <= r)
	{
		mid = (l + r) / 2;
		if(ok(mid))
			r = mid - 1;
		else
			l = mid + 1;
	}
	cout << l;
}

Measured memory_bytes: 4336
# include <iostream>
# include <vector>
# include <map>


using namespace std;
int n; vector<int> a;


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

    map<int, int> count;
    for (int _a: a) {
        if (count.find(_a) == count.end()) count[_a] = 1;
        else count[_a]++;
    }

    bool has_answer = false;
    if (count.size() == 3)  {  // { ok if count[a] == count[b] == count[c] else ng }
        int _xor;
        int size = -1;
        for (pair<int, int> _c: count) {
            if (size == -1) {
                size = _c.second;
                _xor = _c.first;
                continue;
            }
            _xor ^= _c.first;
            has_answer = (size == _c.second);  // something wrong
        }
        has_answer &= (_xor == 0);
    }

    if (count.size() == 2)  {  // { ok if 2*count[a] == count[0] }
        int size = -1;
        for (pair<int, int> _c: count) {
            if (size == -1) {
                size = (_c.first == 0) ? 2*_c.second: _c.second;
                continue;
            }
            has_answer = (size == _c.second);
        }
    }

    if (count.size() == 1)  {  // { ok if count[0] == n and n%3 == 0}
        has_answer = (count.find(0) != count.end());
    }

    cout << (has_answer ? "Yes": "No") << endl;
    return 0;
}



Measured memory_bytes: 4224
import numpy as np

h, w = map(int, input().split())
max_value = h + w
values = []

for i in range(h):
  values.append([0 if i == '#' else max_value for i in list(input())])
values = np.array(values)

for x in range(w - 1):
  values[:, x+1] = np.minimum(values[:, x] + 1, values[:, x+1])
for x in range(w - 1, 0 , -1):
  values[:, x-1] = np.minimum(values[:, x-1], values[:, x] + 1)
for x in range(h - 1):
  values[x+1, :] = np.minimum(values[x, :] + 1,values[x+1, :])
for x in range(h - 1, 0, -1):
  values[x-1, :] = np.minimum(values[x, :] + 1, values[x-1, :])

print(np.max(values))

Measured memory_bytes: 28968
'use strict'
const main = (input: string) => {
    const std: string = input
    if (std === 'SUN') {
        console.log(7)
    } else if (std === 'MON') {
        console.log(6)
    } else if (std === 'TUE') {
        console.log(5)
    } else if (std === 'WED') {
        console.log(4)
    } else if (std === 'THU') {
        console.log(3)
    } else if (std === 'FRI') {
        console.log(2)
    } else if (std === 'SAT') {
        console.log(1)
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim())

Measured memory_bytes: 11468
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<cstring>
#include<string>
using namespace std;
string s;
int n,ans=0;
int main(){
	cin>>n>>s;
	for(int i=1;i<s.size();i++)
	    if(s[i]!=s[i-1]) ans++;
	cout<<ans+1<<endl;
}

Measured memory_bytes: 512
s = input()
s = s.replace('BC', 'D')
ans = 0
x = 0

#AとDだけでできた部分を考える(B,Cを挟む場合x=0とすることでreset)
#Aが出てくるたび、そのAより右にあるDは、Aを超える操作を挟むので、試行回数が増える。
for i in range(len(s)):
  if s[i] == 'A': 
    x +=1
  elif s[i] == 'D':
    ans += x
  else:
    x =0
    
print(ans)

Measured memory_bytes: 3500
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N;

int main() {
  INCANT;
  cin >> N;
  int a;
  int mx = 0;
  int sm=0;
  rep(i, N) {
    cin >> a;
    mx = max(a, mx);
    sm+=a;
  };
  cout << sm-mx/2 << "\n";
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<string>
#include<cmath>

int main () {
  std::map<std::string,int> blue;
  std::map<std::string,int> data;
  std::map<std::string,int> red;
  int b_num, r_num;
  std::cin >> b_num;
  for (int i=0; i<b_num; i++) {
    std::string str;
    std::cin >> str;
    data[str] = 1;
    if (!blue.count(str)) {
      blue[str] = 1;
    }
    else {
      blue.at(str)++;
    }
  }
  std::cin >> r_num;
  for (int i=0; i<r_num; i++) {
    std::string str;
    std::cin >> str;
    data[str] = 1;
    if (!red.count(str)) {
      red[str] = 1;
    }
    else {
      red.at(str)++;
    }
  }
  int sum = 0;
  for (auto p: data) {
    int temp_sum=0;
    auto key = p.first;
    if (blue.count(key)) {
      temp_sum += blue.at(key);
    }
    if (red.count(key)) {
      temp_sum -= red.at(key);
    }
    sum = std::max(sum ,temp_sum);
  }
  std::cout << sum << std::endl;
}

Measured memory_bytes: 256
//@source: 
//@create: 19:01:41 Sunday 02/08/2020
//@author: nghethuat102
#include <bits/stdc++.h>
using namespace std;

#define len(x) (int) x.size()
#define all(x) x.begin(), x.end()
#define discrete(x) sort(all(x), x.erase(unique(all(x)), x.end())

void solve() {
    int n;
    long long D;
    cin >> n >> D;
    D = D * D;
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
        long long x, y;
        cin >> x >> y;
        cnt += (D >= x * x + y * y);
    }
    cout << cnt << "\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1;
    for (int it = 1; it <= t; ++it) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define all_acc(x) (x).begin(),(x).end(),0LL
#define int long long
using namespace std;
using P=pair<int,int>;
using Graph=vector<vector<int>>;
using ll=long long;

void output(vector<int> s){
    int n=s.size();
    for(int i=0;i<n;i++){
        if(i!=0) cout<<" ";
        cout<<s[i];
    }
    cout<<endl;
}

// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

const long long MAX=10;
long long MOD=pow(10,9)+7;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
//前処理にO(n)、計算にはO(1)かかる。
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;
    }
}

// 二項係数計算
//上のやつとセット。これはn<10^7くらいじゃないと使えない。
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//mは素数じゃなくてもええで
// mod. m での a の逆元 a^{-1} を計算する
//aのmod mにおける逆元を求めてくれる
//aをmで割って、その後bの逆元を求めると分かる。
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

//n>=10^9とかで、kは10^7より小さいくらい
int nCk(int n,int k,int mod){
   int bunbo=1;
   int bunsi=1;
   for(int i=0;i<k;i++){
       bunbo=(bunbo*((n-i)% mod))% mod;
       bunsi=bunsi*((k-i)% mod)% mod;
   }
   int bunsi_inv=modinv(bunsi,mod);
   return ((bunbo%mod) * (bunsi_inv%mod))% mod;

}

signed main(){ 
   int n; cin>>n;
    map<string,int> result;

    for(int i=0;i<n;i++){
        string ri; cin>>ri;
        result[ri]++;
    }

    cout<<"AC x "<<result["AC"]<<endl;
    cout<<"WA x "<<result["WA"]<<endl;
    cout<<"TLE x "<<result["TLE"]<<endl;
    cout<<"RE x "<<result["RE"]<<endl;
}  

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
const int MX = 2005;

typedef long long ll;

#define f first
#define s second

int N;
vector<pair<ll,int>> v; // happiness, position
ll dp[MX][MX];

ll solve_dp(int l, int r) {
    if (r < l) return 0;
    ll& res = dp[l][r];
    if (res != -1) return res;
    int pos = l+N-1-r;
    res = max(res,v[pos].f*abs(l-v[pos].s)+solve_dp(l+1,r));
    res = max(res,v[pos].f*abs(r-v[pos].s)+solve_dp(l,r-1));
    return res;
}

int32_t main() {

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

    cin >> N; v.resize(N);

    for (int i = 0; i < N; ++i) {
        cin >> v[i].f; v[i].s = i;

        for (int j = 0; j < N; ++j) {
            dp[i][j] = -1;
        }
    }

    sort(v.rbegin(),v.rend());

    cout << solve_dp(0,N-1) << "\n";

}


Measured memory_bytes: 35124
integer N
double precision,allocatable,dimension(:)::p
double precision,allocatable,dimension(:,:)::DP
double precision ans
read*,N
allocate(p(N))
read*,p

allocate(DP(0:N,0:N))
DP=0
DP(0,0)=1
do i=1,N
  DP(i,0)=DP(i-1,0)-DP(i-1,0)*p(i)
  do j=1,i
    DP(i,j)=DP(i-1,j-1)*p(i) + DP(i-1,j)-DP(i-1,j)*p(i)
  end do
end do
ans=0
do i=N/2+merge(1,0,mod(N,2)==1),N
  ans=ans+DP(N,i)
end do

print"(F0.15)",ans
end

Measured memory_bytes: 70528
#include <stdio.h>

int max(int a, int b, int c){

    int res = a;
    
    if(res < b){
        res = b;
    }
  	if(res < c){
        res = c;
    }

    return res;
}

int main(){
    int a, b;

    scanf("%d %d", &a, &b);

    printf("%d", max(a + b, a - b, a * b));

}

Measured memory_bytes: 128
n=int(input())
a=list(map(int,input().split()))
import numpy as np
dp=np.full((3,n+1),-pow(10,15))
dp[:,0]=0
dp[1,1]=a[0]
for i in range(2,n+1):
    #l,r=max(1,n//2-(n-i+1)//2),(i+1)//2+1
    l,r=max(1,i//2-1),(i+1)//2+1
    if i%3==2:
        now,pre,prepre=2,1,0
    elif i%3==0:
        now,pre,prepre=0,2,1
    elif i%3==1:
        now,pre,prepre=1,0,2
    dp[now,l:r]=np.maximum(dp[pre,l:r],dp[prepre,l-1:r-1]+a[i-1])
print(dp[now,n//2])

Measured memory_bytes: 39492
import { Hash } from "crypto";
import { access } from "fs";

class Input {
    private lines: string[];
    constructor(lines: string[]) {
        this.lines = lines;
    }

    public string(): string { return this.lines.shift() as string; }
    public int(): number { return parseInt(this.string()); }
    public intArray(): number[] { return this.string().split(" ").map(n => parseInt(n)); }
    public stringArray(): string[] { return this.string().split(" "); }

    public allLines(): string[] { return this.lines; }
    public allLinesInt(): number[] { return this.lines.map(s => parseInt(s)); }
    public allLinesIntArray(): number[][] { return this.lines.map(s => s.split(" ").map(n => parseInt(n))); }
    public allLinesStringArray(): string[][] { return this.lines.map(s => s.split(" ")); }
}


function calc(stdin: Input) {
    const first = stdin.intArray();
    const N = first[0];
    const A = first[1];
    const B = first[2];
    const C = first[3];
    const ls = stdin.allLinesInt();

    const pattern = 4 ** N;
    let min = 1000000000000;

    for (let i = 0; i < pattern; i++) {
        let a = 0;
        let b = 0;
        let c = 0;
        let aCount = 0;
        let bCount = 0;
        let cCount = 0;
        for (let j = 0; j < N; j++) {
            switch ((i >> (j << 1)) & 3) {
                case 1:
                    a += ls[j];
                    aCount++;
                    break;
                case 2:
                    b += ls[j];
                    bCount++;
                    break;
                case 3:
                    c += ls[j];
                    cCount++;
                    break;
            }
        }
        if (aCount > 0 && bCount > 0 && cCount > 0) {
            const mergePoint = (aCount - 1) * 10 + (bCount - 1) * 10 + (cCount - 1) * 10;
            const point = mergePoint + calcPoint(A, B, C, a, b, c);
            if (point < min)
                min = point;
        }
    }

    return min;
}

function calcPoint(A: number, B: number, C: number, num1: number, num2: number, num3: number) {
    let a = num1;
    let b = num2;
    let c = num3;

    if (a < b) {
        a = num2;
        b = num1;
    }
    if (c > a) {
        c = b;
        b = a;
        a = num3;
    } else if (c > b) {
        c = b;
        b = num3;
    }

    return Math.abs(c - C) + Math.abs(b - B) + Math.abs(a - A);
}

function main(stdin: string) {
    console.log(calc(new Input(stdin.split("\n"))));
}

if (require.main && require.main.filename.indexOf("Main") >= 0) {
    main(require('fs').readFileSync('/dev/stdin', 'utf8'));
} else {
    main(`
8 1000 800 100
300
333
400
444
500
555
600
666
`.trim());
}

Measured memory_bytes: 7500
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
using namespace std;
//using namespace boost::multiprecision;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}



int main(){
  
  long long n;
  cin>>n;
  long long a[n], b[n];
  REP(i,n){
    cin>>a[i];
  }
  REP(i,n){
    cin>>b[i];
  }
  int ans = 0;
  REP(k,29){
    vector<long long> ta(n), tb(n);
    long long t = (1LL<<k);
    REP(i,n){
      ta[i] = a[i]%(2*t);
      tb[i] = b[i]%(2*t);
    }
    sort(ALL(ta));
    sort(ALL(tb));
    long long cnt = 0;
    REP(i,n){
      cnt += lower_bound(ALL(tb), 2*t-ta[i]) - lower_bound(ALL(tb), t-ta[i]);
      cnt += lower_bound(ALL(tb), 4*t-ta[i]) - lower_bound(ALL(tb), 3*t-ta[i]);
    }
    if(cnt%2 == 1){
      ans += (1LL<<k);
    }
  }
  cout<<ans<<endl;
  return 0; 
}


Measured memory_bytes: 8512
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e16+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N,M,X;
    cin >> N >> M >> X;
    vector<int>C(N);
    vector<vector<int>>A(N,vector<int>(M));
    for(int i = 0; i < N; i++) {
        cin >> C[i];
        for(int j = 0; j < M; j++) {
            cin >> A[i][j];
        }
    }
    int ans = INF;
    for(int bit = 0; bit < (1 << N); bit++) {
        int cnt = 0;
        vector<int>res(M);
        for(int i = 0; i < N; i++) {
            if(1 & (bit >> i)) {
                cnt+=C[i];
                for(int j = 0; j < M; j++) {
                    res[j]+=A[i][j];
                }
            }
        }
        bool ok = true;
        for(int i = 0; i < M; i++) {
            if(res[i] < X) {
                ok = false;
            }
        }
        if(ok) {
            ans = min(ans,cnt);
        }
    }
    if(ans == INF) {
        cout << -1 << endl;
    }
    else {
        cout << ans << endl;
    }
}


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

using namespace std;

const int max_n = 200222, inf = 1000111222;

int n, l, a[max_n];
long long sum[max_n];

long long get_sum(int l, int r) {
    if (l > r) {
        return 0;
    }
    if (l == 0) {
        return sum[r];
    }
    return sum[r] - sum[l - 1];
}

long long solve() {
    sum[0] = a[0];
    for (int i = 1; i < n; ++i) {
        sum[i] = a[i] + sum[i - 1];
    }
    long long ans = a[n - 1];
    for (int i = 0; i + 1 < n; ++i) {
        int cnt = n - i;
        long long res = -a[i];
        if (cnt % 2) {
            res -= 2 * get_sum(i + 1, i + cnt / 2 - 1);
            res -= a[i + cnt / 2];
            res += 2 * get_sum(i + cnt / 2 + 1, n - 1);
        } else {
            res -= 2 * get_sum(i + 1, i + cnt / 2 - 1);
            res += a[i + cnt / 2];
            res += 2 * get_sum(i + cnt / 2 + 1, n - 1);
        }
        res = 1LL * l * (cnt - 1) - res + a[i];
        ans = max(ans, res);
    }
    return ans;
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    scanf("%d%d", &l, &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
    }
    long long ans = solve();
    reverse(a, a + n);
    for (int i = 0; i < n; ++i) {
        a[i] = l - a[i];
    }
    ans = max(ans, solve());
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 2560
#include "stdio.h"
int main(void)
{
	int num,n[10000],max,min,i;
	long sum;
	scanf("%d",&num);
	sum=0;
	for(i=0;i<num;i++){
		scanf("%d",&n[i]);
		sum = sum + n[i];
		if(i==0){
			max = n[i]; min = n[i];
		}
		if(max < n[i])
			max = n[i];
		if(min > n[i])
			min = n[i];
	}

	printf("%d %d %ld\n",min,max,sum);
	return 0;
}


Measured memory_bytes: 636
N = int(input())
d = []
j = 0

count = N
same = 0

for i in range(0, N):
	d.append(int(input()))


d_new = sorted(d, reverse = True)
while j < N - 1:
	if d_new[j] == d_new[j + 1]:
		same += 1
	j += 1
ans = count - same
print(str(ans))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<string,ll>;



int main(){
	ll K;
	cin >> K;
	ll X;
	cin >> X;
	ll L=max(-1000000LL,X-K+1),R=min(1000000LL,X+K-1);
	for(ll i=L;i<=R;i++){cout<<i<<" "
	;}
	cout<<endl;

return 0;
}  



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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)

int main(){
   string s,t; 
  cin >> s >> t ;
  int m=s.size();
  int n=t.size();
  if(m+1!=n) cout << "No" <<endl;
  else{
    bool a=true;
  rep(i,m){
    if(s.at(i)!=t.at(i))a=false;
  }
  if(a)cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 3624
def popcount_parity(x):
    x ^= x >> 1
    x ^= x >> 2
    x ^= x >> 4
    x ^= x >> 8
    x ^= x >> 16
    x ^= x >> 32
    x ^= x >> 64
    x ^= x >> 128
    x ^= x >> 256
    x ^= x >> 512
    x ^= x >> 1024
    x ^= x >> 2048
    x ^= x >> 4096
    x ^= x >> 8192
    x ^= x >> 16384
    x ^= x >> 32768
    x ^= x >> 65536
    x ^= x >> 131072
    x ^= x >> 262144
    x ^= x >> 524288
    return x & 1

N = int(input()) - 1
s = 1
while N:
    l = N & -N
    s |= s << l
    N ^= l

A = input()
if "2" in A:
    a = int(A.replace("1", "0").replace("3", "0").replace("2", "1"), 2)
    print(popcount_parity(a & s))
else:
    a = int(A.replace("1", "0").replace("3", "1"), 2)
    print(popcount_parity(a & s) * 2)

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

const int N = 1e5 + 10;

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll a, b;
	cin >> a >> b;
	ll g = __gcd(a, b);
	a *= b;
	a /= g;
	cout << a << endl;
}

Measured memory_bytes: 256
import numpy as np
N,M=map(int,input().split())
connect=np.zeros((M,N))
for i in range(M):
	c = list(map(int,input().split()))[1:]
	for sw in c:
		connect[i][sw-1]=1
req=np.array(list(map(int,input().split())))
ptns=[]
for i in range(2**N):
	ptns.append(list(format(i, '0{}b'.format(N))))
ptns=np.array(ptns).astype(np.uint8)
ans=0
for i in range(2**N):
	co = np.mod(np.sum(ptns[i] * connect, axis=1),2)
	co = co.reshape((1,-1))
	if np.sum(co!=req)==0:
		ans+=1
print(ans)

Measured memory_bytes: 21760
from collections import defaultdict
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

N, Q = map(int, input().split())
G = defaultdict(list)
for i in range(N - 1):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1  # 0-indexed
    G[a].append(b)
    G[b].append(a)

# print('G', G)

V = [0] * N
for _ in range(Q):
    p, x = map(int, input().split())
    p = p - 1  # 0-indexed
    V[p] += x


def dfs(v, p):
    if p != -1:
        V[v] += V[p]
    for idx in G[v]:
        if idx == p:
            continue
        dfs(idx, v)


dfs(0, -1)

# print('V', V)

print(' '.join(map(str, V)))


Measured memory_bytes: 244780
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e2 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	string s;
	cin >> n >> s;
	if (n >= 3200) cout << s << endl;
	else cout << "red" << endl;
	return 0;
}

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

ans=0
for index, value in enumerate(A):
    ans+=B[value-1]
    if index >= 1:
        if A[index-1] == A[index] - 1:
            ans+=C[value-2]
print(ans)

Measured memory_bytes: 3064
use std::io::Read;

fn main() {
    let mut buf = String::new();

    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();

    let n: usize = iter.next().unwrap().parse().unwrap();

    let items : Vec<i32> = (0..n).map(|_|
        iter.next().unwrap().parse().unwrap()
    ).collect();

    let zero = 0;
    let ordinality : Vec<i32> = (2..n).map(|i| (items[i-2] - items[i-1]) * (items[i] - items[i-1])
    ).filter(|v| v.lt(&zero)).collect();


    println!("{}", ordinality.len());
}

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

int main() {
  vector<int> a(3);
  for (int i=0; i<3; i++) cin >> a.at(i);
  sort(a.begin(), a.end());
  cout << a.at(0) << ' ' << a.at(1) << ' ' << a.at(2) << endl;
  
}




Measured memory_bytes: 3120
s=input()
k=int(input())
lens=len(s)
alp="azyxwvutsrqponmlkjihgfedcb"

ans=[]
for i in range(lens):
    d=alp.index(s[i])
    if k>=d:
        k-=d
        ans.append("a")
    else:
        ans.append(s[i])

las=ans.pop()
alp="abcdefghijklmnopqrstuvwxyz"
ans.append(alp[(alp.index(las)+k)%26])

print("".join(ans))

Measured memory_bytes: 73988
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
using namespace std;

int main()
{
  int a,b;
  cin>>a>>b;
  if(a>=13){
    cout<<b<<endl;
  }else if(a>=6){
    cout<<b/2<<endl;
  }else{
    cout<<0<<endl;
  }

}


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

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> stones;
	for(int i = 0; i < n; i++){
		int temp;
		cin >> temp;
		stones.push_back(temp);
	}
	int dp[n];
	for(int i = 0; i < n; i++){
		dp[i] = 2147483647;
	}
	dp[0] = 0;
	for(int i = 0; i < n; i++){
		for(int j = i + 1; j <= i + k; j++){
			if(j < n){
				dp[j] = min(dp[j], dp[i] + abs(stones[i] - stones[j]));
			}
		}
	}
	
	cout << dp[n - 1] << endl;
	
	return 0;
}

Measured memory_bytes: 1144
// ===================================
//   author: M_sea
//   website: http://m-sea-blog.com/
// ===================================
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#define re register
using namespace std;

inline int read() {
    int X=0,w=1; char c=getchar();
    while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
    while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
    return X*w;
}

const int N=20000+10;

int h,n;
int a[N],b[N];
int dp[N];

int main() {
    h=read(),n=read();
    for (re int i=1;i<=n;++i) a[i]=read(),b[i]=read();
    memset(dp,0x3f,sizeof(dp)); dp[0]=0;
    for (re int i=1;i<=n;++i)
        for (re int j=a[i];j<=20000;++j)
            dp[j]=min(dp[j],dp[j-a[i]]+b[i]);
    int ans=2e9;
    for (re int i=h;i<=20000;++i) ans=min(ans,dp[i]);
    printf("%d\n",ans);
    return 0;
}


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

int main(){
  int h,n,i,k,wa=0;
  cin>>h>>n;
  for(i=0;i<n;i++){
    cin>>k;
    wa+=k;
  }
  if(wa>=h){
    cout<<"Yes";
  }else{
    cout<<"No";
  }
}

Measured memory_bytes: 256
n, k = map(int, input().split())
a = list(map(int, input().split()))
#print(a)
lis = [0] * (max(a)+1)
#print(lis)
for i in range(n):
    lis[a[i]-1] += 1
lis.sort()

#print(lis)

ans = 0
for i in range(len(lis)-k):
    ans += lis[i]

print(ans)

Measured memory_bytes: 25004
from collections import defaultdict

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

d = defaultdict(int)
n = readInt()
for i in range(n):
	d[readChar()]+=1

print("AC x",d["AC"])
print("WA x",d["WA"])
print("TLE x",d["TLE"])
print("RE x",d["RE"])


Measured memory_bytes: 9480
def resolve():
    n, m = map(int, input().split())
    ans = list()

    for i in range(n):
        ans.append(0)    

    for i in range(m):
        a, b = map(int, input().split())
        ans[a-1] +=1
        ans[b-1] +=1
    
    for i in range(n):
        print(ans[i])
resolve()

Measured memory_bytes: 3060
n=gets().to_i
A=gets().chomp.split(" ").map(&:to_i)
e=0
ans=0

while true
    for i in 0..n-1
        if A[i]%2!=0
            e=1
        end
    end
    if e==1
        break
    end
    for i in 0..n-1
        A[i]=A[i]/2
    end
    ans+=1
end

puts ans

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

bool dp[222222];

vector<vector<int>> v(222222);
int d[222222];

void makeDP(){
	dp[1] = true;
	for(int i = 3;i < 222222;i++){
		if(dp[i-1] == false || dp[i-2] == false)dp[i] = true;
		else dp[i] = false;
	}
}

P dfs(int a){
	REP(i, 222222)d[i] = 1;
	P ret;
	queue<P> q;
	q.push(MP(a, 1));
	while(!q.empty()){
		auto now = q.front();q.pop();
		ret = now;
		int node = now.FI;
		int dist = now.SE;
		REP(i, v[node].size()){
			if(d[v[node][i]] == 1){
				d[v[node][i]] = dist + 1;
				q.push(MP(v[node][i], dist + 1));
			}
		}
	}
	return ret;
}

int tyokkei(){
	auto fi = dfs(0);
	auto se = dfs(fi.FI);
	return se.SE;
}

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

	int n;cin >> n;
	REP(i, n-1){
		int a, b;cin >> a >> b;a--;b--;
		v[a].PB(b);
		v[b].PB(a);
	}

	makeDP();
	if(dp[tyokkei()])cout << "First" << endl;
	else cout << "Second" << endl;

	return 0;
}


Measured memory_bytes: 16932
from collections import deque
from bisect import bisect_left

N = int(input())
S = list(input())

d = {s:[] for s in "RGB"}
for i, s in enumerate(S):
  d[s].append(i)
if d["R"] and d["G"] and d["B"]:
  ans = len(d["R"])*len(d["G"])*len(d["B"])
  for r in d["R"]:
    for g in d["G"]:
      M = max(r, g)
      m = r+g-M
      if M+M-m < N and S[M+(M-m)] == "B":
        ans -= 1
      if m-(M-m) >= 0 and S[m-(M-m)] == "B":
        ans -= 1
      if (M+m)%2 == 0 and S[(M+m)//2] == "B":
        ans -= 1
  print(ans)
else:
  print(0)


Measured memory_bytes: 69992
#include <algorithm>
#include <iostream>

using namespace std;

int result[30];

void show(int d) {
  for (int i = 0; i < d-1; i++) {
    cout << result[i] << ' ';
  }
  cout << result[d-1] << endl;
}

void rec(int d, int n, int r) {
  if (r)
    for (int i = min(n, r); i > 0; i--) {
      result[d] = i;
      rec(d+1, i, r-i);
    }
  else
    show(d);
}

int main() {
  for (;;) {
    int n;
    cin >> n;
    if (!n) return 0;
    rec(0, n, n);
  }
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    vector<ll> S(N + 1, 0);
    rep(i, N) {
        S[i + 1] += S[i] + A[i];
    }
    map<ll, ll> cnt;
    rep(i, N + 1) {
        cnt[S[i]] ++;
    }
    ll ans = 0;
    for (P p : cnt) {
        ans += (p.second - 1) * p.second / 2;
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 15104
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    ll K; cin >> K;

    int n = 50;
    ll base = 49LL + K / 50;
    K = K % 50;
    vll a(n);
    rep(i, 50 - K){
        a[i] = base - K;
    }
    rep(i, K){
        a[50 - K + i] = base + 50 - K + 1;
    }

    cout << n << endl;
    rep(i, n){
        cout << (i ? " ":"") << a[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
*A, = map(int, input().split())
F = {}
for i, a in enumerate(A):
    try:
        F[a] += 1
    except:
        F[a] = 1
for i in range(1, n+1):
    try:
        print(F[i])
    except:
        print(0)


Measured memory_bytes: 33528
#include<stdio.h>
int main()
{
	int a,b,c;
	int i,j,k,s;
	scanf("%d%d%d",&a,&b,&c);
	i=a+b;
	j=a+c;
	k=b+c;
	s=i;
	if(i>j)
	s=j;
	if(s>k)
	s=k;
	printf("%d",s);
} 

Measured memory_bytes: 128
#include<stdio.h>

int main(void){

    long int a,b,k,tmp = 0;

    scanf("%ld %ld %ld",&a,&b,&k);

    if(a<=k){
        tmp = b-(k-a);
        a = 0;
        if(tmp<=0) b = 0;
        else b = tmp;
    }else a = a-k;
    printf("%ld %ld",a,b);
    return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"

using namespace std;

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

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back


int main(){
    
    int a,b;
    int t1,t2;
    while( cin>>a>>b ){
        if(a==0&&b==0)break;
        if(a<b)swap(a,b);
        int c=0;
        while(1){
            c++;
            t1=b;
            t2=a%b;
            a=t1,b=t2;
            if(b==0){
                cout<<a<<" "<<c<<endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
int n,a[100005]={0};
int main()
{
	cin>>n;
	int i,j;
	for(i=1;i<=n;i++)
	{
		int temp;
		scanf("%d",&temp);
		a[temp]++;
	}
	int sum=0,res=0;
	for(i=1;i<=100005;i++)
	{
		sum+=a[i];
		if(a[i]>1)res+=a[i]-1;
	}
	if(res%2==0)
	{
		cout<<sum-res;
	}
	else
	{
		cout<<sum-res-1;
	}
	return 0;
 } 

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define Endl endl
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;


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

	
}



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

int sum(int x) {
	int count = 0;
	while (x != 0) {
		count += x % 10;
		x = (x - x % 10) / 10;
	}
	return count;
}
int main() {
	int N, A, B, count = 0;
	cin >> N >> A >> B;
	for (int i = 1; i <= N; i++) {
		if (A <= sum(i) && sum(i) <= B) count += i;
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template<typename T> inline void read(T &x)
{
    x=0;char c=getchar();bool flag=false;
    while(!isdigit(c)){if(c=='-')flag=true;c=getchar();}
    while(isdigit(c)){x=(x<<1)+(x<<3)+(c^48);c=getchar();}
    if(flag)x=-x;
}
int n;
int main()
{
    read(n);
    if(n==(n&(-n)))
    {
        puts("No");
        return 0;
    }
    printf("Yes\n1 2\n2 3\n3 %d\n%d %d\n%d %d\n",n+1,n+1,n+2,n+2,n+3);
    for(int i=4;i+1<=n;i+=2) printf("1 %d\n1 %d\n%d %d\n%d %d\n",i,i+1,i,i+1+n,i+1,i+n);
    if(!(n&1))
    {
        for(int i=2;i<n;++i) 
        {
            if(i==3) continue;
            int p=n^i^1;
            if(p!=3&&p<n)
            {
                printf("%d %d\n%d %d\n",i,n,p,2*n);
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3740
package main

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

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	ps := make([]int, n)
	for i := range ps {
		sc.Scan()
		ps[i], _ = strconv.Atoi(sc.Text())
		ps[i]--
	}
	cs := make([]int, n)
	for i := range cs {
		sc.Scan()
		cs[i], _ = strconv.Atoi(sc.Text())
	}

	ans := int(-1e10)
	for i := 0; i < n; i++ {
		p := i
		m := make(map[int]bool)
		ms := make([]int, 0)
		var mx int
		for {
			if _, ok := m[ps[p]]; ok {
				break
			}
			p = ps[p]
			ms = append(ms, p)
			m[p] = true
		}

		loop := len(ms)
		var lsum int
		for j := range ms {
			lsum += cs[ms[j]]
		}

		ls := cs[ms[0]]
		mx = ls
		for j := 1; j < min(k, loop); j++ {
			ls += cs[ms[j]]
			mx = max(mx, ls)
		}

		if k >= loop && lsum >= 0 {
			ls := lsum * ((k / loop) - 1)
			mx = max(mx, ls)

			for j := 0; j < (k%loop)+loop; j++ {
				ls += cs[ms[j%loop]]
				mx = max(mx, ls)
			}
		}
		ans = max(ans, mx)
	}
	fmt.Println(ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


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

int main(void){
 


    string S;
    cin>>S;
    int N,T,t;
    N=S.size();
    T=0;
    t=0;

    if(S[0]!='A'){
        cout<<"WA"<<endl;
                return 0;  
    }

    for(int i=2;i<=(N-2);i++){
        if(S[i]=='C'){
            T=T+1;
        }
    }
    if(T!=1){
         cout<<"WA"<<endl;
                return 0;  
    }
    
    T = 0;
    for(int i=1;i<N;i++){    
        if('a' <=S[i] && S[i] <= 'z'){
            t=t+1;
        }else if (S[i] == 'C'){
            T=T+1;
        }else{
            cout<<"WA"<<endl;
            return 0;       
        } 
    }

    if(T==1){
        cout<<"AC"<<endl;
                  
    }else{
      cout<<"WA"<<endl;
               
    }
         

    return 0;
}

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

ll gcd (ll a,ll b){
	if(a%b==0){
		return b;
	}
	gcd(b ,a%b);
}
int main() {
	ll n,a[100010],ans;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	ans=gcd( max(a[0],a[1]),min(a[0],a[1]) );
	for(int i=1;i<n;i++){
		ans=gcd(max(ans,a[i]),min(ans,a[i]));
	}
	cout <<ans;
}

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

int main()
{
  ll x; cin >> x;
  ll ans = (x / 11)*2;

  if (x % 11 != 0) {
    ans++;
    if (x % 11 > 6) {
      ans++;
    }
  }

  cout << ans;
}

Measured memory_bytes: 256
n,a,b=map(int,input().split())
num9=10**9+7
num2=pow(2,n,num9)-1
def cul(num1,num2):
    num=1
    for i in range(num1-num2+1,n+1):
        num*=i
        num%=num9
    for i in range(1,num2+1):
        num*=pow(i,num9-2,num9)
        num%=num9
    return num
print((num2-cul(n,a)-cul(n,b))%num9)


Measured memory_bytes: 9028
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    bool nn=false;bool ss=false;bool ee=false;bool ww=false;
    for(int i=0;i<=s.size()-1;i++){
      if(s.at(i)=='S'){ss=true;}
      if(s.at(i)=='N'){nn=true;}
      if(s.at(i)=='W'){ww=true;}
      if(s.at(i)=='E'){ee=true;}
    }
    if(ee!=ww){cout<<"No"<<endl;}
    else if(ss!=nn){cout<<"No"<<endl;}
    else{cout<<"Yes"<<endl;}
    return 0;
}

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

int p[100002];

int main(){
  int N; scanf("%d", &N);
  for(int i = 1; i <= N; i++) scanf("%d", &p[i]);

  int ans = 0;
  for(int i = 0; i <= N; i++) ans += abs(p[i + 1] - p[i]);

  for(int i = 1; i <= N; i++){
    int v = ans;
    v -= abs(p[i] - p[i - 1]) + abs(p[i + 1] - p[i]);
    v += abs(p[i + 1] - p[i - 1]);

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

Measured memory_bytes: 1536
def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))

INF = 1 << 29

DIV = (10**9) + 7

def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def ncr(n, r, mod=DIV):
	r = min(r, n-r)
	ret = 1
	for i in range(1, r+1):
		ret = ret * (n-i+1) % mod
		ret = ret * mod_inv(i, mod) % mod
	return ret

def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max,mod=DIV):
    fac,finv,inv = [0]*max, [0]*max, [0]*max
    fac[0]=fac[1]=1
    finv[0]=finv[1]=1
    inv[1]=1
    for i in range(2,max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod -inv[mod%i] * (mod//i)%mod
        finv[i] = finv[i-1]*inv[i]%mod
    class CONV:
        def __init__(self):
            pass
        def ncr(self,n,k):
            if(n<k):
                return 0
            if(n<0 or k<0 ):
                return 0
            return fac[n]*(finv[k]*finv[n-k]%mod)%mod
    return CONV()


def main():
    n,a,b = isRaw()
    ans = pow(2,n,DIV)-1
    ans = (ans - ncr(n,a)+DIV)%DIV
    ans = (ans -ncr(n,b)+DIV)%DIV
    return ans
    


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 41580