akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <cmath>
#include <tuple>
#include <cassert>
#include <array>
#include <iomanip>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using ti = tuple<int, int, int>;

const double eps=1e-14;
const int mod = 1e9 + 7;
const int inf = ((1<<30)-1);
const ll linf = (1LL<<60);

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if(s == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
    return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std ;
#define ll int
#define pb push_back
#define __ ios_base::sync_with_stdio(false); cin.tie(NULL);

void scan(ll &n) { scanf("%lld",&n) ; }
void scan(ll &n, ll &m) { scanf("%lld%lld",&n,&m) ; }
void scan(vector<ll> &v) { ll n = v.size() ; for(ll i=0 ;i<n;i++) scanf("%lld",&v[i]) ; }
const int N = 3 * 1e5 + 32 ;
ll row[N] , col[N] ;
map<pair<ll,ll>,ll> mp ;
void solve() {

    ll n , m , u , v , i,z ;
    ll mxc , mxr ;
    mxc = mxr = 0 ;
    cin>> n >> m >> z;
    ll ans = 0 ;
    for (i =0  ;i< z; i++) {
        cin >> u >> v ;
        mp[{u,v}]++ ;
        row[u] ++ , col[v]++ ;
        mxc = max(mxc,col[v]) ;
        mxr = max(mxr,row[u]) ;
    }
    vector<ll>vc , vr ;
    for(i = 0 ;i <= n ; i++) {
        if (row[i] == mxr) vr.pb(i) ;
    }
    for (i = 0 ;i<= m ; i++)    if (col[i]== mxc) vc.pb(i) ;

    n = vr.size() , m = vc.size() ;
    ll mm = 1 ;
    for (i = 0 ; i< n; i++) {
        for (ll j = 0; j<m ; j++) {
            if ( mp[{vr[i],vc[j]}] == 0) {
                mm = 0 ;
            }
        }
        if (!mm) break ;
    }
    cout << mxc + mxr - mm << endl ;
}

int main() {

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

	ll t = 1 ;
	//cin >> t ;
	for (ll cz = 1 ;cz <= t ; cz++) {
       // cout << "Case " <<cz <<": " ;
        solve() ;
	}
    return 0 ;
}







Measured memory_bytes: 45496
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <utility>
#include <random>
#include <chrono>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

using namespace std;

using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using PIL = pair<int, LL>;
using PLL = pair<LL, LL>;
// const int mod = 1e9 + 7;
// const int mod = 998244353;

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

LL f[100010];
int n, w, x, y;

inline void work() {
    memset(f, -1, sizeof(f));
    f[0] = 0;
    
    cin >> n >> w;
    int totv = 0;
    for (int i = 0; i < n; ++i) {
        cin >> x >> y;
        totv += y;
        for (int j = totv; j >= y; --j) {
            if (f[j - y] != -1) {
                f[j] = min(f[j] == -1 ? LONG_MAX : f[j], f[j - y] + x);
            }
        }
    }
    int ans = 0;
    for (int i = totv; i > 0; --i) {
        if (f[i] != -1 && f[i] <= w) {
            ans = i;
            break;
        }
    }
    cout << ans << "\n";
}

int main() {
    // freopen("input.txt", "r", stdin);
    quickread();
    work();
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
int main()
{
    int p=0,m=0;
    char s[5];
    scanf("%s",s);
    for(int i=0; i<4; i++)
        if(s[i]=='+')
            p++;
        else
            m++;
    printf("%d\n",p-m);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using ll=long long;
using ld=long double;
#define inf INT_MAX  
const ll infll=1ll*inf*inf;
#define mode 998244353
#define mod 1000000007
const long double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define pb push_back
#define mp make_pair
#define ub upper_bound 
#define lb lower_bound 
#define far(i,a,b) for (ll i = a; i <= b; i++)
#define rev(i,a,b) for (ll i = a; i >= b; i--)
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define sz(a) int((a).size())
#define ftr(c,i) for(auto i = begin(c); i != end(c); i++)
#define rtr(c,i) for(auto i = rbegin(c); i != rend(c); i++)
#define pre(c,x) ((c).find(x) != (c).end())
#define cpre(c,x) (find(all(c),x) != (c).end())
#define mll map<ll,ll>
#define vs vector<string>
#define vi vector<int>
#define vl vector<ll>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define vii vector<pii >
#define vll vector<pll >
#define vvl vector<vector<ll> >
#define vvi vector< vector<int > >
#define W(t) while(t --)
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout <<(ll)(it-arr.begin()) << ')' <<  *it << ' '; cout << endl;
#define printii(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << it->ff<<' '<<it->ss << endl; cout << endl;
#define MID(i,j) ((i)+(j))/2
#define nl '\n' 
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
ll max(ll a,ll b) {return (a>b? a:b);}
ll min(ll a,ll b) {return (a>b? b:a);}
ll gcd(ll a,ll b) {return (b==0)? a:gcd(b,a%b); }
ll gcd(ll a,ll b,ll & x,ll & y) {
    if (a == 0) {
        x = 0;
        y = 1;
        return b;
    }
    ll x1, y1;
    ll d = gcd(b % a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}
ll modinv(ll a,ll b){
	ll x,y;
	gcd(a, b, x, y);
	return (x%b + b)%b;
}
ll ceiling(ll a,ll b){ 
        if(a%b==0) return a/b;
        else return a/b+1;
}
ll bpow(ll a,ll b,ll m){
	a%=m;
	ll res=1;
	while(b>0){
		if(b&1) res=(res*a)%m;
		b>>=1;
		a=a*a%m;
	}
	return res;
}
vvl mat_mul(vvl mat1,vvl mat2,ll mod1){
        vvl res(sz(mat1),vl(sz(mat2[0]),0));
        far(i,0,sz(mat1)-1){
                far(j,0,sz(mat2[0])-1){
                        far(k,0,sz(mat1[0])-1){
                                res[i][j]=(res[i][j]+(mat1[i][k]*mat2[k][j])%mod1)%mod1;          
                        }   
        }   
        }   
        return res;
}
vvl mat_exp(vvl mat,ll p,ll mod1){ 
        vvl res(sz(mat),vl(sz(mat[0]),0));
        far(i,0,sz(mat)-1) res[i][i]=1;
        while(p>0){
                if(p&1) res=mat_mul(res,mat,mod1);   
                mat=mat_mul(mat,mat,mod1);
                p>>=1;
        }   
        return res;
}
const int N=1e6+5;
ll n,m,q,t,k,x,y,z;
int main()
{
	fio;
	cin >> n >> k;
	vi a(n+5);
	far(i,1,n) cin >> a[i];
	far(i,0,min(n,k)){
		far(j,0,i){
			map<pii,int> rk;
			far(k,1,j){
				rk[mp(a[k],k)];
			}
			rev(k,n,n-(i-j)+1) rk[mp(a[k],k)];
			x=0;
			y=0;	
			for( auto it:rk){
				if(it.ff.ff<0 && y<k-i) y++;
				else x+=it.ff.ff;
			}
			z=max(z,x);
			
		}
	}
	cout << z << nl;
}


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

using namespace std;
const int mod = 10000;
int n,k;
int y[102];
int dp[102][4][4];
int main(){
	cin >> n >> k;
	for(int i = 0;i < k;i++){
		int t;
		cin >> t;
		cin >> y[t];
	}
	for(int i = 1;i <= 3;i++){
		if(y[1] >= 1 && y[1] != i)continue;
		dp[1][1][i] = 1;
	}
	for(int i = 2;i <= n;i++){
		for(int j = 1;j <= 3;j++){
			if(y[i] >= 1 && y[i] != j)continue;
			for(int q = 1;q <= 3;q++){
				if(q == j)continue;
				dp[i][1][j] += dp[i-1][1][q] + dp[i-1][2][q];
			}
			dp[i][2][j] += dp[i-1][1][j];
			dp[i][1][j] %= mod;
			dp[i][2][j] %= mod;
		}
	}
	int ans = 0;
	for(int i = 1;i <= 3;i++){
		for(int j = 1;j <= 2;j++){
			ans += (dp[n][j][i]);
			ans %- mod;
		}
	}
	cout << ans % mod << endl;
	return 0;
}


Measured memory_bytes: 1164
#include<stdio.h>
#define MAX 10000
#define NIL -1

struct Node{ int p, l, r;};
struct Node T[MAX];
int n;

void preParse(int u){
  if(u == NIL)return ;
  printf(" %d", u);
  preParse(T[u].l);
  preParse(T[u].r);
}

void inParse(int u){
  if(u == NIL) return ;
  inParse(T[u].l);
  printf(" %d", u);
  inParse(T[u].r);
}

void postParse(int u){
  if(u == NIL)return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d", u);
}

int main(){
  int i, v, l, r, root;

  scanf("%d", &n);
  for(i=0;i<n;i++){
    T[i].p = NIL;
  }

  for(i=0;i<n;i++){
    scanf("%d %d%d", &v, &l, &r);
    T[v].l=l;
    T[v].r = r;
    if(l != NIL) T[l].p = v;
    if(r != NIL) T[r].p = v;
  }

  for(i=0;i<n;i++)if(T[i].p == NIL) root = i;

  printf("Preorder\n");
  preParse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  postParse(root);
  printf("\n");

  return 0;
}



Measured memory_bytes: 2056
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define rep1(i,n)for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=(int)(n)-1;0<=i;i--)
#define rrep1(i,n) for(int i=(int)(n);1<=i;i--)

#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define endl "\n"

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

typedef long long lint;

using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b,h;
	cin>>a>>b>>h;
	cout<<(a+b)*h/2<<endl;
}

Measured memory_bytes: 256
def openlist(i):
    S = format(i, "b")
    ret = [0] * 10
    for j, i in enumerate(reversed(range(len(S)))):
        ret[-1*(j+1)] = int(S[i])
    return ret


n = int(input())
F = [list(map(int, input().split())) for _ in range(n)]
P = [list(map(int, input().split())) for _ in range(n)]

ans = -1 * 10 ** 9
for i in range(1, 2**10):
    S = openlist(i)
    # print(S)
    opstore = [sum([S[x]==1 and F[k][x]==1 for x in range(10)]) for k in range(n)]
    tmp_ans = sum([P[k][opstore[k]] for k in range(n)])
    ans = max(ans, tmp_ans)
print(ans)

Measured memory_bytes: 3064
import collections
N, K = map(int, input().split())

ans = []
for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    ans.extend(A)

count = 0
for i in range(1, N+1):
    if i not in ans:
        count += 1

print(count)


Measured memory_bytes: 9548
#include <iostream>
#include <string>
#include <algorithm>

int main() {
  size_t N;
  std::string S;
  std::cin >> N >> S;

  size_t left = 0;
  size_t right = std::count(S.begin()+1, S.end(), 'E');
  size_t res = right;
  for (size_t i = 1; i < N; ++i) {
    if (S[i] == 'E') --right;
    if (S[i-1] == 'W') ++left;
    res = std::min(res, left+right);
  }
  std::cout << res << std::endl;
}


Measured memory_bytes: 832
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from math import *

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)

s,t = input(),input()

def str_to_list(x):
    l = []
    for i in range(len(x)):
        l.append(ord(x[i]))
    return l

def list_to_str(l):
    l = list(map(chr,l))
    return ''.join(l)

s = str_to_list(s)
s.sort()
s = list_to_str(s)
t = str_to_list(t)
t.sort(reverse=True)
t = list_to_str(t)
judge(s<t)

Measured memory_bytes: 65724
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iomanip>

using namespace std;

#define remove_duplicate(a) sort(a.begin(), a.end()); a.resize(distance(a.begin(), unique(a.begin(), a.end())));

typedef long long longint;

const longint MAXN = 1e5 + 10;
longint n, a[3 * MAXN];


int main(){
    #define file "in"
    //freopen(file".inp", "r", stdin); freopen(file".out", "w", stdout);

    cin >> n;
    for (longint i = 1; i <= 3 * n; i++) cin >> a[i];
    sort (a + 1, a + 3 * n + 1, greater<longint>());
    longint res = 0;
    for (longint i = 2; i <= 2 * n; i += 2) res += a[i];

    cout << res;
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	cout << (n + 1) / 2 << endl;
}

Measured memory_bytes: 256
S = input()
ans = ''
ans2 = ''
counter = 0
counter2 = 0
for i in range(int(len(S)/2)):
    ans += '10'
    ans2 += '01'
if len(S) % 2 == 1:
    ans += '1'
    ans2 += '0'

for i in range(len(S)):
    if S[i] != ans[i]:
        counter += 1
    if S[i] != ans2[i]:
        counter2 += 1
print(min(counter, counter2))

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
int main()
{
	 string s,t;
	 cin>>s>>t;
	// sort(s.begin(),s.end());
	 //sort(t.begin(),t.end());
	// cout<<s<<endl;
//	cout<<t<<endl;
int a[50]={0},vis[50]={0};
	//int dif=0;
	int flag=0;
	 for(int i=0;i<s.length();i++)
	 {
	    if(!a[s[i]-96])
	    {           if(!vis[t[i]-96])
	    	     {a[s[i]-96]=t[i]-96;
	    	       vis[t[i]-96]=1;
				  } 
				  else
				  {
				  	flag=1;break;
				  }
		}
	   if(a[s[i]-96]&&a[s[i]-96]==t[i]-96)
	   {continue;
	   	
	   }
	   else {
	   	flag=1;break;
	   }
	 }
	 if(flag)cout<<"No"<<endl;
	 else cout<<"Yes"<<endl;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int mx = max(a, max(b, c));
  int sum = a + b + c;
  if(mx % 2 != sum % 2) mx++;
  cout << (3 * mx - sum) / 2 << endl;
}

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

int main() {
	int A, B, C, X;
	cin >> A >> B >> C >> X;
	int ans = 0;
	for (int x = 0; x <= A; x++) {
		for (int y = 0; y <= B; y++) {
			for (int z = 0; z <= C; z++) {
				if (500 * x + 100 * y + 50 * z == X) {
					ans++;
				}
			}
		}
	}
	cout << ans << endl;
}

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

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;

  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (S.substr(i, 3) == "ABC") ans++;
  }

  cout << ans << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int n = 101;

int func(int x) {
  if (x == 0) return 0;
  return func(x/10) + x%10; 
}

void solve() {
  int n, a, b;
  cin >> n >> a >> b;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    int x = func(i);
    if (a <= x && x <= b) ans += i;
  }
  cout << ans << endl;
}

int main() {
  solve();
  return 0;
}

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

template <typename T> void output(T, int);
int gcd(int a, int b);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    ll n, T;
    cin >> n >> T;
    ll t[n];
    rep(i, n) { cin >> t[i]; }

    ll count = 0;

    ll start = t[0];
    ll end = t[0] + T;
    repd(i, 1, n) {
        if (t[i] < end) {
            count += t[i] - t[i - 1];
        } else {
            count += T;
        }
        end = t[i] + T;
    }

    count += T;

    cout << count << endl;
    return 0;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}

void prime_map(map<ll, ll> &m, ll num) {
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }

    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }
        return;
    } else {
        prime_map(m, num);
    }
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

const int N = 2001;

int ps[3][N + 1][N + 1];

int v[3][N][N];

void init() {
	for (int t = 0; t < 3; t++) {
		for (int i = 1; i <= N; i++) {
			for (int j = 1; j <= N; j++) {
				ps[t][i][j] = ps[t][i - 1][j] + ps[t][i][j - 1] - ps[t][i - 1][j - 1] + v[t][i - 1][j - 1];
			}
		}
	}
}

int s(int t, int i1, int j1, int i2, int j2) {
	return ps[t][i2][j2] - ps[t][i1][j2] - ps[t][i2][j1] + ps[t][i1][j1];
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);	
	
	int n, m, q;
	cin >> n >> m >> q;
	vector<vector<int>> a(n, vector<int> (m));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			char c;
			cin >> c;
			a[i][j] = c - '0';
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			v[0][i][j] = a[i][j];
		}
	}
	for (int i = 1; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (a[i][j] && a[i - 1][j]) v[1][i][j] = 1;
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 1; j < m; j++) {
			if (a[i][j] && a[i][j - 1]) v[2][i][j] = 1;
		}
	}
	init();
	while (q--) {
		int i1, j1, i2, j2;
		cin >> i1 >> j1 >> i2 >> j2;
		i1--;
		j1--;
		int ans = s(0, i1, j1, i2, j2);
		ans -= s(1, i1 + 1, j1, i2, j2);
		ans -= s(2, i1, j1 + 1, i2, j2);
		cout << ans << '\n';
	}
}

Measured memory_bytes: 112624
// contest.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//
#include "bits/stdc++.h"
//実装が重そうな問題はある程度考えてから書く
//初期化を忘れずに（特に二分探索とか）
//コーナーケースを考えて（特に場合分けとか）
//不可解すぎるバグは配列外参照（配列の長さ）を検討
#define YES "YES"
#define NO "NO"
#define YESNO OUT(three(solve(),YES,NO))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(a);i>=(LL)(b);i--)
#define REP(i,b) FOR(i,zero,b)
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define int LL
#define zero 0LL

using namespace std;
template<typename T> inline void maximize(T &a, T b) { a = max(a, b); }
template<typename T> inline void minimize(T &a, T b) { a = min(a, b); }
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l<r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l>r ? l = r, 1 : 0; }
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr, Vpr, greater<pr> > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
const int SIZE1 = 5 * 1e5 + 1000;
const int SIZE2 = 5010;
const int SIZE3 = 400;
const int SIZE = SIZE3;
const LL p = 7 + 1e9;
const LL INF = 1LL << 60;
const long double EPS = 1e-7;
string s;
ut N, M, K, X, L, Y;
// ut A,B,C,D,E,F,G,H,I,J,O,P,Q,R,T,U;
VI edges[SIZE];
LL vals[SIZE], nums[SIZE], maps[SIZE2][SIZE2], answer = zero;
ut H, W;
////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////
void init() {

}
int k = 0;
VI v[SIZE];
LL solve() {
	cin >> N;
	VI A(N);
	REP(i, N) {
		cin >> A[i];
	}
	sort(ALL(A));
	if (N % 2) {
		LL ans1 = 0, ans2 = 0;
		LL c = N / 2 + 1;
		LL ans = 0;
		REP(i, c) {
			if (c - i <= 2) {
				ans += A[i];
			}
			ans -= A[i] * 2;
		}
		FOR(i, c, N) {
			ans += A[i] * 2;

		}
		ans1 = ans;
		ans = 0;
		c--;
		REP(i, c) {
			ans -= A[i] * 2;
		}
		FOR(i, c, N) {
			if (i == c or i == c + 1) {
				ans -= A[i];
			}
			ans += A[i] * 2;
			
		}
		ans2 = ans;
		return max(ans1, ans2);
	}
	else {
		LL ans = 0;
		REP(i, N / 2) {
			if (i == N / 2 - 1) ans += A[i];
			ans -= A[i] * 2;
		}
		FOR(i, N / 2, N) {
			if (i == N / 2)ans -= A[i];
			ans += A[i] * 2;
		}
		return ans;
	}
	
}
signed main() {
	cout << solve() << endl;
	cin >> N;
	return 0;
}


Measured memory_bytes: 1024
#include <map>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 256, M = 1e7 + 10;

inline void Read(int &x) {
	x = 0; register char cc = '\0'; int fff = 1;
	for (; cc < '0' || cc > '9'; cc = getchar())
		if (cc == '-') fff = -1;
	for (; cc >= '0' && cc <= '9'; cc = getchar())
		x = (x << 1) + (x << 3) + (cc & 15);
	x *= fff;
}

map<int, int> mp;
bool vis[N], Pr[M + 10], G[N][N];
int n, tot, fans, fsum, cnt0, cnt1, p[M], bel[N], a[N], buf0[N], buf1[N];

inline int Abs(int x) {
	return x >= 0 ? x : -x;
}

inline void Getprime() {
	Pr[0] = Pr[1] = true;
	for (int i = 2; i <= M; ++i) {
		if (!Pr[i]) p[++tot] = i;
		for (int j = 1; j <= tot && i * p[j] <= M; ++j) {
			Pr[i * p[j]] = true/* false */;
			if (i % p[j] == 0) break;
		}
	}
	Pr[2] = true;
}

bool Find(int x) {
	for (int j = 1; j <= cnt1; ++j)
		if (G[x][j] && (!vis[j])) {
			vis[j] = true;
			if ((!bel[j]) || (Find(bel[j]))) {
				bel[j] = x;
				return true;
			}
		}
	return false;
}

inline void Hungary() {
	for (int i = 1; i <= cnt0; ++i) {
		memset(vis, false, sizeof(vis));
		if (Find(i)) ++fsum;
	}
}

int main()
{
	Getprime();
	Read(n);
	for (int i = 1; i <= n; ++i) {
		Read(a[i]);
		mp[a[i]] ^= 1;
		mp[a[i] + 1] ^= 1;
	}
	for (map<int, int> :: iterator it = mp.begin(); it != mp.end(); ++it)
		if (it -> second) {
			if ((it -> first) & 1) buf1[++cnt1] = it -> first;
			else buf0[++cnt0] = it -> first;
		} // exist (cnt0 & 1) == (cnt1 & 1)
	for (int i = 1; i <= cnt0; ++i)
		for (int j = 1; j <= cnt1; ++j)
			if (!Pr[Abs(buf0[i] - buf1[j])])
				G[i][j] = true;
	Hungary();
	fans = fsum + ((cnt0 - fsum) / 2) * 2 + ((cnt1 - fsum) / 2) * 2 + ((cnt0 - fsum) & 1) * 3;
	printf("%d\n", fans);
	
	return 0;
}


Measured memory_bytes: 14336
import math
import itertools

n = int(input())
towns = []
for i in range(n):
    x,y = map(int,input().split())
    towns.append([x,y])

ans=0
for i in range(n-1):
    for j in range(i+1,n):
        ans += math.sqrt((towns[i][0]-towns[j][0])**2 + (towns[i][1] - towns[j][1])**2)

print(2*ans/n)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int S=sc.nextInt();
		int m,h;
		m=S/60;
		h=m/60;
		System.out.println(h%24+":"+m%60+":"+S%60);
	}

}

Measured memory_bytes: 26364
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace AizuOnlineJudge
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine();

            var n = int.Parse(Console.ReadLine());

            for(var i = 0; i < n; ++i)
            {
                var arr = Console.ReadLine().Split(' ');
                var a = int.Parse(arr[1]);
                var b = int.Parse(arr[2]);
                switch(arr[0])
                {
                    case "print":
                        Console.WriteLine(str.Substring(a, b - a + 1));
                        break;
                    case "reverse":
                        str = str.Substring(0, a) + string.Join("", str.Substring(a, b - a + 1).Reverse()) + str.Substring(b+1, str.Length - 1 - b);
                        break;
                    case "replace":
                        str = str.Substring(0, a) + arr[3] + str.Substring(b + 1, str.Length - 1 - b);
                        break;
                    default: break;
                }
            }
        }
    }
}


Measured memory_bytes: 20316
N = int(input())
A_LIST = list(map(int, input().split(' ')))
B_LIST = list(map(int, input().split(' ')))
C_LIST = list(map(int, input().split(' ')))
              
# print(N)#
# print(A_LIST)
# print(B_LIST)
# print(C_LIST)

ans = 0 
prev_a = 0
for a in A_LIST:
  # print("A {}".format(a))
  # print("prev_a {}".format(prev_a))
  ans += B_LIST[a-1]
  if prev_a + 1  == a and a != 1:
#    print("a:{}".format(str(a)))
    ans += C_LIST[a - 2]
#  print("ans:{}".format(str(ans)))
  
  prev_a = a
print(ans)

Measured memory_bytes: 38384
program lazy_faith
  implicit none
  integer    :: a, b, q, i, k
  integer(8) :: s(0:100001), t(0:100001), x
  integer(8) :: infty = 10_8**12_8
  read(*,*) a, b, q
  s(0) = -infty
  do i = 1, a
    read(*,*) s(i)
  end do
  s(a+1) = infty
  t(0) = -infty
  do i = 1, b
    read(*,*) t(i)
  end do
  t(b+1) = infty
  call merge_sort(a,s(1:a))
  call merge_sort(b,t(1:b))
  do k = 1, q
    read(*,*) x
    call answer(a,s,b,t,x)
  end do
  stop
contains
  subroutine answer(a,s,b,t,x)
    implicit none
    integer, intent(in)    :: a, b
    integer(8), intent(in) :: s(0:a+1), t(0:b+1), x
    integer                :: i, j
    integer(8)             :: m(4)
    i = bisearch(a,s,x)
    j = bisearch(b,t,x)
    m(1) = min(abs(s(i  )-x),abs(t(j  )-x)) + abs(s(i  )-t(j  ))
    m(2) = min(abs(s(i  )-x),abs(t(j-1)-x)) + abs(s(i  )-t(j-1))
    m(3) = min(abs(s(i-1)-x),abs(t(j  )-x)) + abs(s(i-1)-t(j  ))
    m(4) = min(abs(s(i-1)-x),abs(t(j-1)-x)) + abs(s(i-1)-t(j-1))
    write(*,'(i0)') minval(m)
    return
  end subroutine answer

  !min{i | x < y(i)}
  function bisearch(n,c,x) result(idx)
    implicit none
    integer, intent(in)    :: n
    integer(8), intent(in) :: c(0:n+1), x
    integer                :: idx, i, btm, top, mid
    btm = 0
    top = n+1
    do while (top-btm.gt.1)
      mid = (btm+top)/2
      if (x.lt.c(mid)) then
        top = mid
      else
        btm = mid
      end if
    end do
    idx = top
    return
  end function bisearch

  subroutine merge_sort(n,c)
    implicit none
    integer, intent(in)       :: n
    integer(8), intent(inout) :: c(n)
    integer                   :: num, lng, i, ubnd
    num = n
    lng = 1
    do while (num.gt.1)
      do i = 1, num/2
        ubnd = min(2*i*lng,n)
        call merge(c(2*(i-1)*lng+1:(2*i-1)*lng),c((2*i-1)*lng+1:ubnd))
      end do
      lng = 2*lng
      num = (num+1)/2
    end do
    return
  end subroutine merge_sort

  subroutine merge(c1,c2)
    implicit none
    integer(8), intent(inout) :: c1(:), c2(:)
    integer(8)                :: c(size(c1)+size(c2))
    integer                   :: i1, i2, n1, n2
    i1 = 1
    i2 = 1
    n1 = size(c1)
    n2 = size(c2)
    do while (i1.le.n1.and.i2.le.n2)
      if (c1(i1).le.c2(i2)) then
        c(i1+i2-1) = c1(i1)
        i1 = i1+1
      else
        c(i1+i2-1) = c2(i2)
        i2 = i2+1
      end if
    end do
    if (i1.le.n1) then
      c(i1+i2-1:n1+n2) = c1(i1:n1)
    else if (i2.le.n2) then
      c(i1+i2-1:n1+n2) = c2(i2:n2)
    end if
    c1 = c(1:n1)
    c2 = c(n1+1:n1+n2)
    return
  end subroutine merge
end program lazy_faith

Measured memory_bytes: 3688
#include <iostream>
#include<iomanip>
#include<vector>
using namespace std;
void dfs(vector<int> v[],int src,bool vi[],int ans[])
{
    vi[src]=1;
    int l1=v[src].size();
    for (int i=0;i<l1;i++)
    {
        int p=v[src][i];
        if (!vi[p])
        {
            dfs(v,p,vi,ans);
        }
        ans[src]=max(ans[src],1+ans[p]);
    }
}
int main()
{ int n,m;cin>>n>>m;vector<int> v[n];bool b[n]={0};
for (int i=0;i<m;i++){
    int x,y;cin>>x>>y;v[x-1].push_back(y-1);b[y-1]=1;
}
int ans[n]={0};bool vi[n]={0};
dfs(v,0,vi,ans);int rans=0,c=0;

for (int i=0;i<n;i++)
{
   if (b[i]==0)
   {dfs(v,i,vi,ans);rans=max(rans,ans[i]);}
}


cout<<rans;
 return 0;   
}

Measured memory_bytes: 13824
#include <iostream>
#include <cmath>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <set>
#include <string>


int main() {
 int holiday, homeworkNum, date;
 cin >> holiday >> homeworkNum;
 date = 0;
 rep(i, homeworkNum){
     int takeTime;
     cin >> takeTime;
     date = date + takeTime;
 }
 if (holiday - date < 0){
     cout << -1;
 }else{
     cout << holiday - date;
 }

}


Measured memory_bytes: 3640
#include <iostream>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  //ここまで入力

  //i番目までで東，西を向いている人が何人いるか
  //実装の仕様上，1つ余分に配列を確保している
  int east_num[N+1] = {0};
  int west_num[N+1] = {0};
  rep(i, N){
    if(S[i] == 'E')
      east_num[i]++;
    else if(S[i] == 'W')
      west_num[i]++;
    east_num[i+1] = east_num[i];
    west_num[i+1] = west_num[i];
  }

   int count = 0;
  int ans = N;

  //1番左の人がリーダーのときは
  //2番目以降で東を向いている人を数えればよい
  ans = east_num[N-1] - east_num[0];

  //i番目の人を基準に，東と西を向いている人を数える
  count = 0;
  for(int i=1; i<N-1; i++){
    count += east_num[N-1] - east_num[i];
    count += west_num[i-1];
    //最小値の更新
    if(count < ans)
      ans = count;
    count = 0;
  }

  //1番右の人がリーダーのときは
  //N-1番目までの人で西を向いている人を数えればよい
  count = west_num[N-2];
  if(count < ans)
    ans = count;

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


Measured memory_bytes: 3076
score = [0, 0]
n = gets.chomp.to_i
n.times{
    a, b =gets.chomp.split
    if a > b
        score[0] += 3
    elsif a < b
        score[1] += 3
    else
        score[0] += 1
        score[1] += 1
end
}
puts score.join(" ")

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

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    ll idx = 1;
    rep(i, n){
        cin >> a.at(i);
        // cout << idx << ' ' << a.at(i) <<endl;
        if(idx==a.at(i)) idx+=1;
    }
    if(idx>1) cout << n-idx+1 << endl;
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 1792
from scipy.sparse.csgraph import dijkstra
from scipy.sparse import csr_matrix


N, M, S = map(int, input().split())
uvab = [list(map(int, input().split())) for i in range(M)]
cd = [list(map(int, input().split())) for i in range(N)]

max_a = max([x[2] for x in uvab])
num_coins = max_a * M # <= 50 * 100 = 5,000
num_states = N * (num_coins + 1) # <= 50 * 5,001 = 250,050

d = []
row = []
col = []

for u, v, a, b in uvab:
  u -= 1; v -= 1
  i = (num_coins + 1) * u
  j = (num_coins + 1) * v
  for n in range(a, num_coins+1):
    d.extend([b, b])
    row.extend([i+n, j+n])
    col.extend([j+n-a, i+n-a])

for i, _cd in enumerate(cd):
  get, time = _cd
  start = i * (num_coins + 1)
  end = (i + 1) * (num_coins + 1)
  for j in range(start, end):
    if j + get < end:
      d.append(time)
      row.append(j)
      col.append(j + get)
    else:
      break

g = csr_matrix((d, (row, col)), shape=(num_states, num_states))

start_idx = min(S, num_coins)
dist = dijkstra(g, indices=start_idx).astype(int)
ans = []
for i in range(1, N):
  start = i * (num_coins + 1)
  end = (i + 1) * (num_coins + 1)
  _ans = float('inf')
  for j in range(start, end):
    _ans = min(_ans, dist[j])
  ans.append(_ans)

print(*ans, sep='\n')

Measured memory_bytes: 191736
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

#define pb push_back
#define mp make_pair
#define mod 1000000007

vector<int> g[1<<20];
vector<int> v(1<<20, INT_MIN);
vector<int> llimit(1<<20, -1000000);
vector<int> ulimit(1<<20, 1000000);

bool dfs(int c, int p, int oe) {

    if(v[c] != INT_MIN) {
        if(v[c]%2 != oe) {
            return 0;
        }
    }

    for(int u:g[c]) {
        if(u != p) {
            if(not dfs(u, c, oe^1)) return 0;
            llimit[c] = max(llimit[u]-1, llimit[c]);
            ulimit[c] = min(ulimit[u]+1, ulimit[c]);
        }
    }

    if(v[c] != INT_MIN) {
        llimit[c] = max(v[c], llimit[c]);
        ulimit[c] = min(v[c], ulimit[c]);
    }

    if(llimit[c] > ulimit[c]) return 0;
    return 1;
}

bool dfs2(int c, int p, int lv, int uv) {
    llimit[c] = max(lv, llimit[c]);
    ulimit[c] = min(uv, ulimit[c]);

    if(llimit[c] > ulimit[c]) return 0;
    v[c] = ulimit[c];

    for(int u:g[c]) {
        if(u != p) {
            if(not dfs2(u, c, ulimit[c]-1, ulimit[c]+1)) return 0;
        }
    }

    return 1;
}

int main() {
    int n,x,y,k;
    cin>>n;
    for(int i=1;i<n;i++) {
        cin>>x>>y;
        g[x].pb(y);
        g[y].pb(x);
    }

    cin>>k;
    while(k--) {
        cin>>x>>y;
        v[x] = y;
    }

    if((not dfs(x, -1, y%2)) or (not dfs2(x, -1, y, y))) {
        cout<<"No";return 0;
    }

    cout<<"Yes"<<endl;
    for(int i=1;i<=n;i++) cout<<v[i]<<endl;


    return 0;
}


Measured memory_bytes: 48768
s = input()

if s == "SUN":
    print(7)
elif s == "MON":
    print(6)
elif s == "TUE":
    print(5)
elif s == "WED":
    print(4)
elif s == "THU":
    print(3)
elif s == "FRI":
    print(2)
else:
    print(1)

Measured memory_bytes: 3060
#include <stdio.h>
int main (void){
    int a,b,c;
    int i;
    int t=0;
    scanf("%d%d%d",&a,&b,&c);
    for(i=a;i<=b;i++){
        if(c%i==0)t++;
    }
    printf("%d\n",t);
    return 0;
}


Measured memory_bytes: 2104
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

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

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

int gcd(int a, int b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

//-----------------------ここから-----------


int main(void){
  int n, k;

    cin >> n >> k;

    vector<int> h(n);
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }

    sort(h.begin(), h.end());

    int ans = 1e9;
    for(int i = 0; i < n - k + 1; i++){
        ans = min(ans, h[i + k - 1] - h[i]);
    }
    
    cout << ans << endl;
    
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
// atoi : atoi(str.c_str())
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)

int main(){
  int n;
  cin >> n;
  vector<int> dp(1000000,1e9);
  dp.at(0) = 0;
  rep(i,n){
    dp.at(i+1) = min(dp.at(i+1), dp.at(i)+1 );
    for(int j=6;j<=n;j *= 6){
      dp.at(i+j) = min(dp.at(i+j), dp.at(i)+1 );
    }
    for(int j=9;j<=n;j *= 9){
      dp.at(i+j) = min(dp.at(i+j), dp.at(i)+1 );
    }
  }
  cout << dp.at(n) << endl;
}


Measured memory_bytes: 4096
n = int(input())
l = list(map(int, input().split()))
l_1 = sorted(l)[::-1]
cnt = 0
for i in range(n):
    kizyun = l_1[i]
    for j in range(i+1, n):
        kizyun_2 = l_1[j]
        for k in range(j+1, n):
            kizyun_3 = l_1[k]
            if kizyun_2-kizyun_3 < kizyun < kizyun_2+kizyun_3 and l_1[i] != l_1[j] != l_1[k]:
                cnt += 1
print(cnt)

Measured memory_bytes: 9008
import sys
from fractions import gcd
from itertools import permutations, combinations, accumulate
from collections import deque
from heapq import heappush, heappop, heapify
from collections import deque
import math

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

MOD = 10**9 + 7

def main():
    a, b, x = tuple(map(int,input().split()))
    pi = 3.141592653589

    ng = 90
    ok = 0

    if (a**2 * b)/2 < x:
        tan = 2 * ((b / a) - (x / a ** 3))
        while abs(ng-ok) > 10**(-7):
            mid = (ng + ok) /2
            if math.tan(math.radians(mid)) <= tan:
                ok = mid
            else:
                ng = mid
    else:
        tan = (a * b**2) / (2 * x)
        while abs(ng-ok) > 10**(-7):
            mid = (ng + ok) /2
            if math.tan(math.radians(mid)) <= tan:
                ok = mid
            else:
                ng = mid

    print(ok)



if __name__ == '__main__':
    main()

Measured memory_bytes: 65260
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll fac[200000+5];   //阶乘
ll inv[200000+5];   //逆元

ll quickmod(ll a, ll b){
    ll ans = 1;
    while (b) {
        if (b&1) {
            ans = ans * a % mod;
        }
        a = a*a % mod;
        b >>= 1;
    }
    return ans;
}

void getFac(){
    fac[0] = inv[0] = 1;
    for (int i = 1; i<=200005; i++) {
        fac[i] = fac[i-1] * i % mod;
        inv[i] = quickmod(fac[i], mod-2);     //i的阶乘的逆元
    }
}

ll getC(ll n, ll m){
    return fac[n] * inv[n-m] % mod * inv[m] % mod;
}

int main(){
    ll h, w, a, b;
    scanf("%lld%lld%lld%lld", &h, &w, &a, &b);
    ll c = h-a;
    ll ans = 0;
    getFac();
    for (ll i = 1; i<=c; i++) {
        ans += getC(i+b-2, b-1) * getC(h-i+w-b-1, w-b-1) % mod;
        ans %= mod;
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 3456
#include<iostream>
#define ll long long
#define MAXN 55
#define mod 998244353
#define INF 0x3f3f3f3f
#define ld long double
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    #define int ll
    int n;
    cin>>n;
    int s=0;
    for(int i=1;i<=n;i++){

        if(i%3!=0&&i%5!=0){
            s+=i;
        //    cout<<i<<' ';
        }
    }
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 3640
from collections import deque


def solve(string):
    n, *ab = map(int, string.split())
    next_ = [dict([]) for _ in range(n + 1)]
    queue = deque([1])
    for a, b in zip(*[iter(ab)] * 2):
        next_[a][b] = 0
        next_[b][a] = 0
    while len(queue) > 0:
        c = queue.popleft()
        _next = next_[c]
        use = set(range(1, len(_next.keys()) + 1)) - set(next_[c].values())
        _next = (k for k, v in _next.items() if v == 0)
        for _n, u in zip(_next, use):
            queue.append(_n)
            next_[c][_n] = u
            next_[_n][c] = u
    return str("{}\n{}".format(max(map(lambda x: len(x.keys()), next_)),
                               "\n".join(str(next_[a][b]) for a, b in zip(*[iter(ab)] * 2))))


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 50604
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long k = sc.nextLong();
        long minsub = Math.abs(n-k)+1;
        long t = n%k;
        long answer = Math.min(t,k-t);
        System.out.print(answer);
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


using namespace std;
int H, W;
char M[51][51];
int ans;
int wc = 0;
bool flag = false;
int main(){
    cin >> H >> W;
    rep(i, H){
        rep(j, W){
            cin >> M[i][j];
            if (M[i][j] == '.') {
                wc++;
            }
        }
    }

    queue<pair<int, pair<int, int>>> Q;
    Q.push(make_pair(0, make_pair(0, 0)));
    while(!Q.empty()) {
        pair<int, pair<int, int>> q = Q.front();
        Q.pop();
        int sy = q.second.first;
        int sx = q.second.second;
        int c = q.first;
        if (M[sy][sx] == '#') {
            continue;
        } else {
            c++;
            M[sy][sx] = '#';
            if (sy == H-1 && sx == W - 1) {
                flag = true;
                ans = c;
                break;
            }

            if (sy + 1 < H && M[sy+1][sx] == '.') {
                Q.push(make_pair(c, make_pair(sy+1, sx)));
            }
            if (sy - 1 >= 0 && M[sy-1][sx] == '.') {
                Q.push(make_pair(c, make_pair(sy-1, sx)));
            }
            if (sx + 1 < W && M[sy][sx+1] == '.') {
                Q.push(make_pair(c, make_pair(sy, sx+1)));
            }
            if (sx -1 >= 0 && M[sy][sx-1] == '.') {
                Q.push(make_pair(c, make_pair(sy, sx-1)));
            }
        }
    }

    if (flag) {
        cout << wc - ans << endl;
    } else {
        cout << -1 << endl;
    }


}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int W, H, x, y, r;

	cin >> W >> H >> x >> y >> r;

	if ((x + r <= W && x - r >= 0) && (y + r <= H && y - r >= 0))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;  
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
 
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
 
const int MOD = 1e9 + 7; 
const int N = 1e5+10; 
const int INF = 1e9 + 5; 
int gcd(int x, int y) 
{
	if (y==0) return x; 
	return gcd(y, x%y); 
}
int main(void) 
{

	#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
	#endif


	int k; 
	cin >> k; 
	ll ans=0; 
	for (int a=1; a<=k; a++) 
		for (int b=1; b<=k; b++) 
			for (int c=1; c<=k; c++) 
				ans += gcd(a, gcd(b, c)); 

	cout << ans << '\n'; 

	return false; 
}


Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define Max2(a, b) ((a) > (b)) ? (a) : (b)

typedef long long ll;

using namespace std;

int N, K;
string S;

int main(){
    cin >> N >> K;
    cin >> S;
    int head = 0, tale = 0, m = 0, cnt = 0;
    while(cnt < K){
        if(S[tale] == '1'){
            tale++;
            continue;
        }
        while(S[tale] == '0') tale++;
        cnt++;
        if(cnt == K){
            while(S[tale] == '1') tale++;
        }
    }
    m = tale - head;
    while(tale < N){
        while(S[head] == '1') head++;
        while(S[head] == '0') head++;
        while(tale < N && S[tale] == '0') tale++;
        while(tale < N && S[tale] == '1') tale++;
        m = Max2(m, tale - head);
    }
    cout << m << endl;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
using namespace std;
#define int long long
#define V vector
#define vel V<int>
#define rep(i,n) for(int i=0;i<n;i++)
#define mkp make_pair
#define pin pair<int,int>
pin solve(V<pin>& ab, int ex) {
	if (!ex) { return mkp(1,0); }
	V<V<pin>> qab(2);
  int sz=ab.size();
  qab[0].reserve(sz);
  qab[1].reserve(sz);
	for (pin &x : ab) {
		qab[x.second & 1].push_back(mkp(x.first / 2,x.second / 2));
		if (x.first & 1) { qab[(x.second + 1) & 1].push_back(mkp(x.first / 2,(x.second + 1) / 2)); }
	}
  vel c(2);
	rep(i, 2) {
		for (pin &x : qab[i]) {
			int qc = (2 * x.first + x.second)%3;
          c[i]^=(qc+1);
		}
	}
	rep(i, 2) {
		if (!c[1 - i]) {
			pin ans = solve(qab[i], ex - 1);
			ans.first *= 2; ans.second *= 2; ans.second += i;
			return ans;
		}
	}
	for(pin &v:ab) { v.first++; }
	pin ans = solve(ab, ex); ans.first--;
	return ans;
}
signed main() {
	long long inf = 2e17;
	int n; scanf("%lld", &n);
	V<pin> ab(n);
	rep(i, n) {
		long long a, b; scanf("%lld", &a); scanf("%lld", &b);
		ab[i] = { a + inf,b + inf };
	}
	pin ret = solve(ab, 70);
	cout << ret.first - inf << " " << ret.second - inf << "\n";
}

Measured memory_bytes: 11136