akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
using namespace std;

int N; map<int,int> M;
void input()
{
    cin>>N;
    for(int i=0; i<N-1; ++i){
        int a; cin>>a; M[a]++;
    }
}

void solve()
{
    for(int i=1;i<=N;++i){
        cout<<M[i]<<endl;
    }
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

Measured memory_bytes: 12956
object Main {
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val n = sc.nextInt()
    val sList = List.fill(n)(sc.next())
    val m = sc.nextInt()
    val tList = List.fill(m)(sc.next())

    val sGrouped = sList.groupBy(s => s).mapValues(_.size).toList
    val tGrouped = tList.groupBy(s => s).mapValues(-_.size).toList

    val list = (sGrouped ::: tGrouped).groupBy(s => s._1).mapValues(s => s.map(_._2).sum).toList
    val max = list.maxBy(l => l._2)

    if (0 < max._2) {
      println(max._2)
    } else {
      println(0)
    }
  }
}

Measured memory_bytes: 27696
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000001
#define r(i,a,b)    for(i=a;i<b;i++)
#define ra(i,a,b)   for(i=a;i<=b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ss          set<ll int>
using namespace std;
 
#define N 1000000
#define M 100000000

struct unit {
  ll int a[N];  
};

ll fact (ll int x)
{if(x==1 || x==0)return 1;
else return x*fact(x-1);}

ll power(ll int x,ll int n)
{if(n==0)return 1;
else if(n%2 == 0)return power(x*x,n/2);
else return x*power(x*x,(n-1)/2);}

bool cmp (const pii&a,const pii&b)
{ return((a.F-a.S) > (b.F-b.S));
/*if(a.S<=b.S){if(a.S==b.S)return a.F<b.F;else return a.S<b.S;}
else return a.S<b.S;*/}

void solve()
{
  ll i,j,k,l,m,n,a=0,cnt=0;
  string s1="";
  string s2="";
  cin>>s1>>s2;
  r(i,0,sz(s1))
  {
    if(s1[i]!=s2[i])
      cnt++;
  }
  cout<<cnt;
    
}


int main()
{
    cin.tie(0), cin.sync_with_stdio(0), cout.tie(0), cout.sync_with_stdio(0);
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    
}
//pr12

Measured memory_bytes: 3780
#include<iostream>
using namespace std;
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a+b>c+d) cout<<"Left"<<endl;
	if(a+b==c+d) cout<<"Balanced"<<endl;
	if(a+b<c+d) cout<<"Right"<<endl;
	return 0;
}

Measured memory_bytes: 256
#prag\
ma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;

bool dp[4001][16001];
int x,y,tx,ty,ax[4001],ay[4001];

void dfsx(int t,int n){
	if(dp[t][n+8000]) return;
	if(t<tx){
		dfsx(t+1,n+ax[t]);
		dfsx(t+1,n-ax[t]);
	}
	dp[t][n+8000]=1;
}

void dfsy(int t,int n){
	if(dp[t][n+8000]) return;
	if(t<ty){
		dfsy(t+1,n+ay[t]);
		dfsy(t+1,n-ay[t]);
	}
	dp[t][n+8000]=1;
}

int main()
{
	string s;
	cin>>s>>x>>y;
	bool fx=1;
	for(int i=0;i<s.length();i++){
		if(s[i]=='F'){
			if(fx) ax[tx]++;
			else ay[ty]++;
		}
		else{
			if(fx) fx=0,tx++;
			else fx=1,ty++;
		}
	}
	if(s[s.length()-1]=='F'){
		if(fx) tx++;
		else ty++;
	}
	dfsx(1,ax[0]);
	bool xx=dp[tx][8000+x]?1:0;
	memset(dp,0,sizeof(dp));
	dfsy(0,0);
	bool yy=dp[ty][8000+y]?1:0;
	if(xx&&yy) cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 62976
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    ll n; cin>>n;
    cout << n * (n - 1) / 2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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


int main()
{
llong n,m;
cin>>n>>m;
pair<llong,llong> drink[100100];
for(int i=0; i<n; i++)
{
    llong a,b;
    cin>>a>>b;
    drink[i].first=a;
    drink[i].second=b;
}
sort(drink,drink+n);
llong cost=0;
int cnt=0;
while(1)
{
    if(drink[cnt].second<m)
    {
        cost+=drink[cnt].first*drink[cnt].second;
        m-=drink[cnt].second;
    }
    else
        {
        cost+=drink[cnt].first*m;
        break;
        }
    cnt++;
}
cout<<cost<<endl;
}

Measured memory_bytes: 1920
# -*- coding: utf-8 -*-
def inpl(): return tuple(map(int, input().split()))

N = int(input())
A = inpl()
B = inpl()
for a, b in zip(A, B):
    if a < b:
        print(-1)
        exit()
        
M = max(max(A), max(B))

S = [i for i in range(1, M+1)]
T = len(S)

def dfs(a, b, G):
    visited = [False]*(M+1)
    Q = [a]
    while Q:
        p = Q.pop()
        if visited[p]:
            continue
        else:
            visited[p] = True
            for q in G[p]:
                if q == b:
                    return True
                if not visited[q]:
                    Q.append(q)
    else:
        return False

found = False
for i in range(M, 0, -1):
    del S[S.index(i)]
    G = [set() for _ in range(M+1)]
    for j in range(1, M+1):
        for s in S:
            G[j].add(j%s)
    
    for a, b in zip(A, B):
        if a==b:
            continue
        if not dfs(a, b, G):
            S.append(i)
            break
    else:
        found = True

ans = 0
for s in S:
    ans += 2**s

if found:
    print(ans)
else:
    print(-1)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
#include<sstream>
#define FOR(i,a,b) for(int i = (a),i##_end_ = (b);i<=i##_end_;i++)
#define ROF(i,a,b) for(int i = (a),i##_end_ = (b);i>=i##_end_;i--)
#define MST(a,x) memset(a,x,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define ll long long
#define PB push_back
#define PH push
#define MP make_pair
#define FT first
#define SD second
#define N 100005
#define M 20000005
#define INF 1000000007
#define MOD 1000000007
#define MOD2 1000000009
#define eps 1e-8
#define DEBUG_
#ifdef DEBUG_
#define DEBUG(...) fprintf(stderr,__VA_ARGS__)
#else
#define DEBUG(...)
#endif // DEBUG
using namespace std;

int a[3*N];
int main()
{
    int n;
    cin>>n;
    FOR(i,1,3*n)cin>>a[i];
    sort(a+1,a+3*n+1);
    ll ans = 0;
    int p = 3*n-1;
    FOR(i,1,n)
    {
        ans+=a[p];
        p-=2;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1408
n, m, c = map(int, input().split())
lis_b = list(map(int, input().split()))
ans = 0
for _ in range(n):
  goukei = 0
  lis_a = list(map(int, input().split()))
  for a, b in zip(lis_a, lis_b):
    goukei += a * b
  goukei += c
  if goukei > 0:
    ans += 1
    
print(ans)

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

def lcm(x,y):
    return (x * y) // gcd(x,y)

n = int(input())
now = int(input())
for i in range(n-1):
    t = int(input())
    now = lcm(now,t)
print(now)

Measured memory_bytes: 3060
// Copyright 2020 yaito3014
#include <iostream>

int main() {
  int A, B, C;
  std::cin >> A >> B >> C;
  int K;
  std::cin >> K;
  for (int i = 0; i < K; ++i) 
    if (A >= B)
      B *= 2;
    else if (B >= C)
      C *= 2;
  std::cout << (A < B && B < C ? "Yes":"No") << '\n';
}


Measured memory_bytes: 3476
#include <cstdio>

int main() {
    int a,b,c;
    std::scanf("%d%d%d",&a,&b,&c);

    int kosuu = 0;
    for (int i = a;i <= b;i++) {
        if (c%i == 0) {
            kosuu++;
        }
    }

    std::printf("%d\n",kosuu);
  
}


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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;

#define rep(i,N) for(int i=0; i < (int)N; i++)
#define all(v) (v).begin(),(v).end()

const int INF = 1000000002;
const int mod = 1000000007;

int main(){
	ll n, k; cin >> n >> k;
	ll ans = 0;
	for(ll i=k; i<=n+1; i++){
		ans += ((2*n-i+1)*i/2 - (i-1)*i/2 +1) %mod;
		ans %= mod; 
	}

	cout << ans << endl;

}


Measured memory_bytes: 3624
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    int64_t w, h, x, y;
    cin >> w >> h >> x >> y;

    double area = w * h / 2.0;

    cout << setprecision(24);

    if (x * 2 == w && y * 2 == h)
    {
        cout << area << " " << 1 << endl;
    }
    else
    {
        cout << area << " " << 0 << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n)
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int n;
int a[111111];


int main()
{
    int n, ans = 1;
    cin>>n;
    REP(i,n) cin>>a[i];
    bool up = true, down = true;
    REP(i,n-1) {
        if (up && down) {
            if (a[i] < a[i+1]) {
                down = false;
            } else if (a[i] > a[i+1]) {
                up = false;
            }
        } else if (up) {
            if (a[i] > a[i+1]) {
                down = true;
                ans++;
            }
        } else if (down) {
            if (a[i] < a[i+1]) {
                up = true;
                ans++;
            }
        }
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
//const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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 (a>b) { a=b; return 1; } return 0; }
const ll mod = 1000003;

ll f[2000200], finv[2000200];

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

ll modinv(ll a) {
  return modpow(a, mod - 2);
}

ll nCr(ll n, ll r) {
  if (r < 0 || r > n) return 0;
  return f[n] * finv[n - r] % mod * finv[r] % mod;
}

ll nHr(ll n, ll r) {
  return nCr(n + r - 1, r);
}

void init() {
  f[0] = 1, finv[0] = 1;
  FOR(i, 1, 2000200) {
    f[i] = i * f[i - 1] % mod;
    finv[i] = modinv(f[i]);
  }
}

ll calc(ll l, ll r) {
  if (l <= mod && mod <= r) return 0;
  return f[r] * finv[l - 1] % mod;
}

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

  init();

  int q;
  cin >> q;
  while (q--) {
    ll x, d, n;
    cin >> x >> d >> n;

    if (d == 0) cout << modpow(x, n) << '\n';
    else {
      ll res = x * modinv(d) % mod;
      ll ans = calc(res, res + n - 1) * modpow(d, n) % mod;
      cout << ans << '\n';
    }
  }


  




  
  return 0;
}

Measured memory_bytes: 34880
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    
    int n,k; cin>>n>>k;
    double tmp,p[n+1],s[n+1],res;
 
        cin>>tmp;
        p[0]=(tmp+1)/2;
        s[0]=p[0];
    
    for(int i=1;i<n;++i){
        cin>>tmp;
        p[i]=(tmp+1)/2;
        s[i]=s[i-1]+p[i];
    }
    
    res = s[k-1];
//    cout<<setprecision(10)<<res<<endl;
  
    for(int j=k;j<n;++j){
        res = max(res,s[j]-s[j-k]);
//    cout<<setprecision(10)<<res<<endl;
    }
    
    cout<<setprecision(10)<<res<<endl;
    
	return 0;
}

Measured memory_bytes: 3328
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::{Cell, Ref, RefCell, RefMut};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let (n, m) = read!(usize, usize);
    let mut s: Vec<Vec<usize>> = Vec::with_capacity(m);
    for i in 0..m {
        s.push(read![[usize]].into_iter().skip(1).map(|x| x - 1).collect());
    }
    let p: Vec<usize> = read![[usize]];

    let mut ans = 0;
    // bit全探索 スイッチ数は高々10なので計算量的には問題なさそう
    'bits: for bits in 0..2usize.pow(n as u32) {
        let tmp = vec![false; n];
        let status: Vec<bool> = tmp
            .into_iter()
            .enumerate()
            .map(|(index, _)| 1 << index & bits != 0)
            .collect();
        'inner: for i in 0..m {
            let num_on = s[i].iter().filter(|&&x| status[x]).count();
            if num_on % 2 == p[i] {
                continue 'inner;
            } else {
                continue 'bits;
            }
        }
        ans += 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

#ifndef _DEBUG
#define main_ main
#endif
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<bool> vb;
typedef vector<string> vs;

template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
	return left.second > right.second;
}

void init_global() {}

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

	int W,A,B; cin >> W>>A>>B;
	if (A > B) swap(A, B);

	int ans = max(B - (A + W), 0);

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007;
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,1,-1,1,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}
int main() {
    int a,b;
    cin >> a >> b;
    if(a > 2*b){
        cout << a-2*b << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
using namespace std;
char a[10],b[10];
int main(){
	int ans=0;
	scanf("%s",a);
	if(a[0]=='1') ans++;
	if(a[1]=='1') ans++;
	if(a[2]=='1') ans++;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
a11,a12,a13=map(int,input().split())
a21,a22,a23=map(int,input().split())
a31,a32,a33=map(int,input().split())
n=int(input())

card = [a11,a12,a13,a21,a22,a23,a31,a32,a33]
def isBingo() :
    if ( (card[0] == -1 and card[1] == -1 and card[2] == -1) \
      or (card[3] == -1 and card[4] == -1 and card[5] == -1) \
      or (card[6] == -1 and card[7] == -1 and card[8] == -1) \
      or (card[0] == -1 and card[3] == -1 and card[6] == -1) \
      or (card[1] == -1 and card[4] == -1 and card[7] == -1) \
      or (card[2] == -1 and card[5] == -1 and card[8] == -1) \
      or (card[0] == -1 and card[4] == -1 and card[8] == -1) \
      or (card[2] == -1 and card[4] == -1 and card[6] == -1) \
      ) :
        return True
    else :
        return False

ans = "No"
for x in range(n) :
    s = int(input())
    if s in card :
        card[card.index(s)] = -1
    if( isBingo() ) :
        ans = "Yes"

print(ans)


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	static final int maxBinary = 60;
	static long[] pow2 = new long[60];
	static{
		long n = 1;
		for(int i = 0; i < maxBinary; i++){
			pow2[i] = n;
			n *= 2;
		}
	}
	static long mod = 1_000_000_007;
	static boolean[] toBinary(long l){
		boolean[] ary = new boolean[60];
		for(int i = 0; i < 60 ; i++){
			ary[i] = l / pow2[i] % 2 == 1;
		}
		return ary;
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		boolean[][] binaryArys = new boolean[n][];
		for(int i = 0; i < n; i++){
			binaryArys[i] = toBinary(sc.nextLong());
		}
		long sum = 0;
		for(int i = 0; i < maxBinary; i++){
			int trueNum = 0;
			int falseNum = 0;
			for(int k = 0; k < n; k++){
				if(binaryArys[k][i]){
					trueNum++;
				}else{
					falseNum++;
				}
			}
			sum += (trueNum * (falseNum * (pow2[i] % mod) % mod)) % mod;
			sum %= mod;
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 118036
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ld double
#define mp make_pair
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define pll pair <ll,ll>
#define nl "\n"
ll dp[100005],vis[100005],in[100005];
vector <ll> adj[100005];
ll ulmax;
void dfs(ll x)
{
	vis[x]=1;
	ll maxi=0;
	for(auto it:adj[x])
	{
		if(!vis[it])
			dfs(it);
		maxi=max(maxi,dp[it]);
	}
	dp[x]=maxi+1;
	ulmax=max(ulmax,dp[x]);
}
int main()
{
	ios_base::sync_with_stdio(false);
	ll n,m,i;
	cin>>n>>m;
	for(i=0;i<m;i++)
	{
		ll u,v;
		cin>>u>>v;
		adj[u].pb(v);
		in[v]++;
	}
	vector <ll> vert;
	for(i=1;i<=n;i++)
	{
		if(!in[i])
			vert.pb(i);
	}
	for(i=0;i<vert.size();i++)
	{
		dfs(vert[i]);
	}
	cout<<ulmax-1<<nl;
	return 0;
}

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

int dp[5][4096];
int main(){
	dp[0][0]=1;
	for(int i=0;i<4;i++)
		for(int j=0;j<=1000*i;j++)
			for(int k=0;k<=1000;k++)
				dp[i+1][j+k] += dp[i][j];
	int n;
	while(cin>>n)cout<<dp[4][n]<<endl;
	return 0;
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
vector<int> g[100001];
int from[100001];
int cnt[100001];
int n,m;
int main(){
    cin>>n>>m;
    for(register int i=0;i<n-1+m;i++){
        int a,b;
        scanf("%d%d",&a,&b);
        cnt[b]++;
        g[a].push_back(b);
    }
    queue<int> q;
    for(int i=1;i<=n;i++)
        if(!cnt[i])
            q.push(i);
    while(!q.empty()){
        int now=q.front();
        q.pop();
        for(int i=0;i<g[now].size();i++){
            int to=g[now][i];
            cnt[to]--;
            if(!cnt[to]){
                q.push(to);
                from[to]=now;
            }
        }
    }
    for(register int i=1;i<=n;i++)
        cout<<from[i]<<endl;
    return 0;
}

Measured memory_bytes: 7040
/* 
	Author : Ritesh Singh
*/

#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair < int , pair < int , int > > mp;
#define rep(i , j , n) for(long long i = j ; i <= n ; i++)
#define per(i , j , n) for(long long i = j ; i >= n ; i--)


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 	int n; cin>>n;
 	cout<<!n;
    
}

Measured memory_bytes: 3616
a, b, c, x = int(input()), int(input()), int(input()), int(input())
ans = 0
for i in range(a + 1):
  for j in range(b + 1):
    v = x - 500 * i - 100 * j
    if v < 0:
      continue
    if v % 50 == 0 and v // 50 <= c:
      ans += 1
print(ans)


Measured memory_bytes: 2940
n   =gets.to_i
t = Array.new(101)
t[0] = true
(0..100).each do |i|
  t[i + 7] = true if(i + 7 <= 100 and t[i] == true)
end
(0..100).each do |i|
  t[i + 4] = true if(i + 4 <= 100 and t[i] == true)
end
puts t[n]? "Yes" : "No"

Measured memory_bytes: 1788
#!/usr/bin/env python3

def main():
    S = input()

    f = False

    if S[0] == 'A':
        if S.count('C') == 1:
            i = S.index('C')
            if 2 <= i and i < len(S) - 1:
                if S[1:i].islower() and S[i+1:].islower():
                    f = True


    print('AC' if f else 'WA')


if __name__ == '__main__':
    main()



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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
const ll mod = 1e9 + 7;
const ll INF = 10000000000;

int main() {
	int N;
	cin >> N;
	int ans = 0;
	bool flag = false;
	rep(i, N) {
		int p;
		cin >> p;
		if (p - 1 == i) {
			if (!flag) {
				ans++;
				flag = true;
			}
			else flag = false;
		}
		else flag = false;
	}
	cout << ans << endl;
	return 0;
}


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

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
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;
}

int main(){
  COMinit();
  ll n,k;
  cin>>n>>k;
  k=min(n-1,k);
  ll ans=0;
  for(int i=0;i<=k;i++){
    ans+=(COM(n-i-1+i,i)%MOD)*(COM(n,i)%MOD);
    ans%=MOD;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 12160
#include <stdio.h>
  
int main(){
   int a, b, f, n;
   int x[3000]={ 0 };
   int y[3000]={ 0 };
   n=0;
   while(1){
      scanf("%d %d",&a, &b);
      if(a == 0&&b == 0){
         break;
      }
      x[n]=a;
      y[n]=b;
      n++;
   }
   for(f=0;f < n;f++){
      if(x[f] >= y[f]){
         printf("%d %d\n",y[f], x[f]);
      }else{
         printf("%d %d\n",x[f], y[f]);
      }
   }
   return 0;
}

Measured memory_bytes: 2724
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9

int main(){
	int n,y;
	cin>>n>>y;
	vi a(n),b(n);
	rep(i,n){
	    cin>>a[i]>>b[i];
	}
	
	int mx=*max_element(all(a));
	sort(rall(b));
	int ans=0;
	for(int i=0;i<b.size();i++){
	    if(b[i]<mx)break;
	    y-=b[i];
	    ans++;
	    if(y<=0){
	        cout<<ans<<endl;return 0;
	    }
	}
	ans+=(int)ceil((double)y/mx);
	        cout<<ans<<endl;return 0;
}


Measured memory_bytes: 1024
import java.util.*;
import java.lang.*;

class Main
{
    public static void main (String[] args) throws java.lang.Exception
	{
    	int combiNum[] = new int[51];
		for(int a = 0; a < 10; a++) {
			for (int b = 0; b < 10; b++) {
				for (int c = 0; c < 10; c++) {
					for (int d = 0; d < 10; d++) {
						combiNum[a + b + c + d]++;
					}
				}
			}
		}
		
		Scanner in = new Scanner(System.in);
		
		while(in.hasNext()) {
			System.out.println(combiNum[in.nextInt()]);
		}
    }
}

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

#define add push_back
#define inf 2147000000

#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main(void){
	int a[3];
	int n;
	scanf("%d",&n);
	rep(q,n){
		scanf("%d%d%d",&a[0],&a[1],&a[2]);
	
		sort(a,a+3);
		
		if(a[0]*a[0] + a[1]*a[1] == a[2]*a[2]){
			cout<<"YES\n";
		}else{
			cout<<"NO\n";
		}
	}
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

    static final long inf = (long)1e16;

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n + 1];
        for(int i = 1; i <= n; i++){
            a[i] = sc.nextInt();
        }
        long[][] dp = new long[n + 1][2];
        dp[1][0] = a[1];
        dp[1][1] = -inf;
        for(int i = 2; i <= n; i++){
            dp[i][0] = Math.max(dp[i - 1][0], dp[i - 1][1]) + a[i];
            long A = dp[i - 1][0] - 2L * a[i - 1] - a[i];
            long B = dp[i - 1][1] + 2L * a[i - 1] - a[i];
            dp[i][1] = Math.max(A, B);
        }
        System.out.print(Math.max(dp[n][0], dp[n][1]));
    }
}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()

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

string s;

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

	cin >> s;
	REP(i,s.size()-1) {
		if(s[i]==s[i+1]) {
			cout << i+1 << ' ' << i+2 << endl;
			return 0;
		}
		if (i<s.size()-2&&s[i]==s[i+2]) {
			cout << i+1 << ' ' << i+3 << endl;
			return 0;
		}
	}

	cout << "-1 -1" << endl;

	return 0;
}


Measured memory_bytes: 512
string = input()
for i in range(int(input())):
    process = input().split()
    num_a = int(process[1])
    num_b = int(process[2])
    if process[0] == 'replace':
        string = string[:num_a] + process[3] + string[num_b+1:]
    elif process[0] == 'reverse':
        string = string[:num_a] + string[num_a:num_b+1][::-1] + string[num_b+1:]
    elif process[0] == 'print':
        print(string[num_a:num_b+1])



Measured memory_bytes: 5608
#include <bits/stdc++.h>
 
using namespace std;
 
template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#endif


typedef long long ll; 
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
const ll mod = 998244353;
 
#define mp make_pair
#define pb push_back
#define lb lower_bound

ll binpow(ll a, ll n) {
	if (n == 0)
		return 1;
	if (n % 2 != 0) return binpow(a, n-1)*a; else {
		ll b = binpow(a, n/2);
		return b*b;
	}
}

ll gcd(ll a, ll b) {
	while(b) {
		a %= b;
		swap(a, b);
	}
	return a;
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

void solve() {
	int n, m;
	cin >> n >> m;
	cout << (n*(n-1) / 2) + (m*(m-1) / 2) << endl;
}
 
int main() {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

	int t = 1;
	//cin >> t;
	while (t--) {
		solve();
	}
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int i, H, W;
	char S[402][402] = {};
	scanf("%d %d", &H, &W);
	for (i = 1; i <= H; i++) scanf("%s", &(S[i][1]));
	
	int j, k, x, y, comp[402][402] = {}, q[160001][2], head, tail;
	long long count[2], ans = 0;
	for (i = 1, k = 0; i <= H; i++) {
		for (j = 1; j <= W; j++) {
			if (comp[i][j] != 0) continue;
			comp[i][j] = ++k;
			count[0] = 0;
			count[1] = 0;
			q[0][0] = i;
			q[0][1] = j;
			for (head = 0, tail = 1; head < tail; head++) {
				y = q[head][0];
				x = q[head][1];
				if (S[y][x] == S[i][j]) count[0]++;
				else count[1]++;
				if (comp[y+1][x] == 0 && S[y+1][x] != 0 && S[y+1][x] != S[y][x]) {
					comp[y+1][x] = k;
					q[tail][0] = y + 1;
					q[tail++][1] = x;
				}
				if (comp[y-1][x] == 0 && S[y-1][x] != 0 && S[y-1][x] != S[y][x]) {
					comp[y-1][x] = k;
					q[tail][0] = y - 1;
					q[tail++][1] = x;
				}
				if (comp[y][x+1] == 0 && S[y][x+1] != 0 && S[y][x+1] != S[y][x]) {
					comp[y][x+1] = k;
					q[tail][0] = y;
					q[tail++][1] = x + 1;
				}
				if (comp[y][x-1] == 0 && S[y][x-1] != 0 && S[y][x-1] != S[y][x]) {
					comp[y][x-1] = k;
					q[tail][0] = y;
					q[tail++][1] = x - 1;
				}
			}
			ans += count[0] * count[1];
		}
	}
	
	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 3676
import sys

def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_array(): return list(get_ints())
def input(): return sys.stdin.readline().strip()


n, m = get_ints()
Arr = get_array()
Sum = sum(Arr)
if Sum > n:
	print(-1)
else:
	print(n - Sum)


Measured memory_bytes: 68156
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int s(0); 
  cin >> s;
  
  int cnt(0); 
  const int s1 = static_cast<int>( s / 100.0 );
  if( s1 == 1 )
  {
      cnt++; 
  }
  const int s2 = static_cast<int>( (s - s1 * 100.0) / 10.0 );
  if( s2 == 1 )
  {
      cnt++; 
  }
  const int s3 = static_cast<int>( (s - s1 * 100.0 - s2 * 10.0) );
  
  if( s3 == 1 )
  {
      cnt++; 
  }
  cout << cnt << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  for(int i=0;i<n;i++) cin >> vec[i];
  
  sort(vec.begin(),vec.end());
  
  double ans=vec[0];
  for(int i=1;i<n;i++){
    ans += vec[i];
    ans /= 2;
  }

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

Measured memory_bytes: 256
from collections import deque

def main():
    n, m = map(int, input().split())
    route = [[] for _ in range(n+1)]
    for _ in range(m):
        a, b = map(int, input().split())
        route[a].append(b)
        route[b].append(a)
    ans = [None]*(n+1)
    q = deque([1])
    while q:
        parent = q.pop()
        children = route[parent]
        for child in children:
            if ans[child] is None:
                ans[child] = parent
                q.appendleft(child)
    print("Yes")
    print("\n".join(list(map(str, ans[2:]))))

if __name__ == "__main__":
    main()

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


using ll = long long int;

using namespace std;

int my_pow10(int d)
{
    int r = 1;
    while(d--)
    {
        r *= 10;
    }
    return r;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int a, b, n, d, n0, m;
    
    cin >> n;
    
    n0 = n;
    
    d = 0;
    
    while(n0)
    {
        n0 /= 10;
        ++d;
    }
    
    int last, first, a0;
    
    ll k;
    k = 0;
    b = 0;
    
    for(a = 1; a <= n; ++a)
    {
        last = a % 10;
        first  = last;
        a0 = a;
        while(a0)
        {
            first = a0 % 10;
            a0 /= 10;
        }
            
        if (last == 0) 
            continue;
        
        for(int d0 = 1; d0 <= d; ++d0)
        {
            if (d0 == 1)
            {
                if (d == 1)
                {
                    k += ((first <= n) && (first == last));
                }
                else
                {
                    k += (first == last);
                }
            }
            if (d0 == 2)
            {
                if (d == 2)
                {
                    k += ((last * 10 + first) <= n);
                }
                else
                {
                    k += 1;
                }
            }
            if (d0 > 2)
            {
                if (d0 == d)
                {

                    b = last * my_pow10(d - 1) + first;
                    m = (last + 1) * my_pow10(d - 1) - 1;
                    m = min(n, m);
                    if (b <= m)
                    {
                        k++;
                        k += (m - b) / 10;
                        
                    }
                }
                else
                {
                    k += my_pow10(d0 - 2); 
                }
            }
        }

    }
    
    cout << k;
    
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace Math_Functions
{
    class Triangle
    {
        static void Main(string[] args)
        {
            var token = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var a = token[0];
            var b = token[1];
            var C = token[2] * Math.PI / 180;
            Console.WriteLine(a * b * Math.Sin(C) / 2);
            Console.WriteLine(a + b + Math.Sqrt(a * a + b * b - 2 * a * b * Math.Cos(C)));
            Console.WriteLine(b * Math.Sin(C));
        }
    }
}

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

main()
{
    int n,m,x,y;
    //vector<int>g[100005];
    cin>>n>>m;
    int h[n+1],flag[n+1],ans=0;
    fill(flag,flag+n+1,1);
    for(int i=1;i<=n;i++) cin>>h[i];
    while(m--){
        cin>>x>>y;
        //cout<<h[x]<<h[y]<<endl;
        if(h[x]<=h[y]) flag[x]=0;//cout<<x<<endl;
        if(h[y]<=h[x]) flag[y]=0;//cout<<y<<endl;
    }
    for(int i=1;i<=n;i++)
        if(flag[i]) ans++;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 4424
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
char in[5];
int main(){
	scanf("%s",in);
	if(strlen(in)==3)swap(in[0],in[2]);
	printf("%s\n",in);
}


Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795


using ll=long long;

class mod_ll
{
public:
	ll m_v;
	static const ll m_m=1000000007; // prime value ex. 1000000009
	mod_ll(ll v=0) : m_v(v) {}
	mod_ll operator = (ll rhs)
	{
		m_v=rhs%m_m;
		return *this;
	}
	ll operator ()(){return m_v;}
	mod_ll operator = (mod_ll rhs)
	{
		m_v=rhs.m_v;
		return *this;
	}
	mod_ll operator += (ll rhs)
	{
		m_v=(m_v+rhs)%m_m;
		return *this;
	}
	mod_ll operator += (mod_ll rhs)
	{
		m_v=(m_v+rhs.m_v)%m_m;
		return *this;
	}
	mod_ll operator + (mod_ll rhs)
	{
		auto ret=*this;
		return ret+=rhs;
	}
	mod_ll operator -= (mod_ll rhs)
	{
		m_v=(m_v-rhs.m_v+m_m)%m_m;
		return *this;
	}
	mod_ll operator - (mod_ll rhs)
	{
		auto ret=*this;
		return ret-=rhs;
	}
	mod_ll operator *= (ll rhs)
	{
		m_v=(m_v*rhs)%m_m;
		return *this;
	}
	mod_ll operator *= (mod_ll rhs)
	{
		m_v=(m_v*rhs.m_v)%m_m;
		return *this;
	}
	mod_ll operator * (mod_ll rhs)
	{
		mod_ll ret=*this;
		return ret*=rhs;
	}
	mod_ll operator ^ (ll rhs)
	{
		mod_ll t=*this;
		mod_ll ret(1LL);

		for(;rhs>0;rhs>>=1)
		{
			if(rhs&1) ret*=t;
			t*=t;
		}
		return ret;
	}
	mod_ll operator /= (mod_ll rhs)
	{
		return *this*=(rhs^(m_m-2));
	}
	mod_ll operator /= (ll rhs)
	{
		mod_ll t(rhs);
		return *this/=t;
	}
	mod_ll operator / (mod_ll rhs)
	{
		mod_ll ret=*this;
		return ret/=rhs;
	}
};


mod_ll mod_fact(int n)
{
	static vector<mod_ll> memo(1);

	if((int)memo.size()<=n)
	{
		if(memo.size()==1)
		{
			memo[0]=1;
		}
		for(int i=memo.size();i<=n;i++)
		{
			memo.push_back(memo.back()*i);
		}
	}
	return memo[n];
}


mod_ll mod_nCr(int n, int r)
{
	mod_ll bunsi=mod_fact(n);
	mod_ll bunbo=mod_fact(n-r)*mod_fact(r);
	return bunsi/bunbo;
}


mod_ll mod_nCr2(int n, int r)
{
	mod_ll bunsi(1);
	mod_ll bunbo(1);
	if(r*2>n) r=n-r;

	for(int i=0;i<r;i++)
	{
		bunsi*=(n-i);
		bunbo*=(i+1);
	}
	return bunsi/bunbo;
}


mod_ll mod_nPr(int n, int r)
{
	mod_ll ret(1);

	for(int i=0;i<r;i++)
	{
		ret*=(n-i);
	}
	return ret;
}


int main(void)
{
	int n, a, b;
	while(scanf("%d%d%d", &n, &a, &b)==3)
	{
		mod_ll two(2), ans;
		ans=(two^n)-1;
		ans-=mod_nCr2(n, a)+mod_nCr2(n, b);
		printf("%lld\n", ans());
	}
	return 0;
}


Measured memory_bytes: 256
package main

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

func newScanner() *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	// buf := make([]byte, 10000)
	// scanner.Buffer(buf, 1000000)
	return scanner
}

func scanInt() int {
	if sc.Scan() {
		t := sc.Text()
		if v, err := strconv.Atoi(t); err == nil {
			return v
		}
		panic(fmt.Sprintln("Could't scan int from input", t))
	}
	panic(sc.Err())
}

func scanInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = scanInt()
	}
	return a
}

func scanString() string {
	if sc.Scan() {
		return sc.Text()
	}
	panic(sc.Err())
}

var sc *bufio.Scanner = newScanner()

func main() {
	n, m := scanInt(), scanInt()
	ac := make(map[int]int)
	wa := make(map[int]int)

	for i := 0; i < m; i++ {
		p, s := scanInt(), scanString()
		if s == "AC" {
			ac[p] = 1
		} else if ac[p] == 0 {
			wa[p]++
		}
	}

	ans := [2]int{}
	for i := 1; i <= n; i++ {
		ans[0] += ac[i]
		if ac[i] == 1 {
			ans[1] += wa[i]
		}
	}
	fmt.Println(ans[0], ans[1])
}


Measured memory_bytes: 6912
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
const int N=200000+7;
int n,v[N],i,x,cnt,K,ans;vector<int>d;
int main(){
	for(scanf("%d%d",&n,&K),i=1;i<=n;++i)scanf("%d",&x),(v[x]++)==0?cnt++:0;
//	printf("%d\n",cnt);
	if(cnt<=K)puts("0");
	else{
		for(i=0;i<=n;++i)if(v[i])d.push_back(v[i]);
		sort(d.begin(),d.end());
		for(i=0;i<cnt-K;++i)ans+=d[i];
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 2168
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	auto rot1 = [](vi &v){
		swap(v[9], v[20]);
		swap(v[15], v[17]);
		swap(v[6], v[29]);
		swap(v[3], v[26]);
		swap(v[0], v[23]);
	};
	auto rot2 = [](vi &v){
		swap(v[2], v[21]);
		swap(v[5], v[24]);
		swap(v[8], v[27]);
		swap(v[11], v[18]);
		swap(v[12], v[14]);
	};
	auto rot3 = [](vi &v){
		swap(v[0], v[27]);
		swap(v[1], v[28]);
		swap(v[2], v[29]);
		swap(v[14], v[15]);
		swap(v[18], v[20]);
	};
	auto rot4 = [](vi &v){
		swap(v[6], v[21]);
		swap(v[7], v[22]);
		swap(v[8], v[23]);
		swap(v[12], v[17]);
		swap(v[9], v[11]);
	};
	int n; cin >> n;
	while(n--){
		unordered_set<vi> vis;
		queue<pair<int, vi>> q;
		vi v(30), goal =  {1,1,1,1,1,1,1,1,1,2,2,2,4,4,4,6,6,6,5,5,5,3,3,3,3,3,3,3,3,3};
		rep(i, 30) cin >> v[i];
		q.emplace(0, v);
		
		vis.insert(v);
		while(!q.empty()){
			int c = q.front().first;
			vi v = q.front().second; q.pop();
			if(v == goal){
				cout << c << endl;
				goto END;
			}
			rep(i, 4){
				vi nv = v;
				if(i == 0) rot1(nv);
				if(i == 1) rot2(nv);
				if(i == 2) rot3(nv);
				if(i == 3) rot4(nv);
				if(vis.count(nv)) continue;
				vis.insert(nv);
				q.emplace(c + 1, nv);
			}
		}
		cout << 8 << endl;
		END:;
	}
	
	return 0;
}


Measured memory_bytes: 3176
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>

#define pb push_back
#define mp make_pair

using namespace std;

template<typename T>inline void upmin(T &x,T y) { y<x?x=y:0; }
template<typename T>inline void upmax(T &x,T y) { x<y?x=y:0; }

typedef unsigned int u32;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod pi=acos(-1);
const int oo=1<<30;
const LL OO=1e18;

const int N=1e5+100;

int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}

char s[N];
int v[N],fa[N];
const int m=26;
inline int find(int x) { return fa[x]==x?x:fa[x]=find(fa[x]); }
inline void merge(int x,int y) { if ((x=find(x))^(y=find(y))) fa[y]=x,(v[x]+=v[y])%=m; }
int main()
{
	scanf("%s",s+1);
	int n=strlen(s+1),T=gi(),i,l,r;
	for (i=1;i<=n+1;i++) v[fa[i]=i]=(s[i]-s[i-1]+m)%m;
	for (l=1,r=n+1;l<r;l++,r--) merge(l,r);
	while (T--) l=gi(),r=gi(),merge(l,r+1);
	for (i=1;i<=n+1;i++) if (fa[i]==i&&v[i]) return puts("NO"),0;
	puts("YES");
	return 0;
}


Measured memory_bytes: 1152
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n,m;
    cin>>n>>m;
    int all=1<<n;
    if(n==1){
        if(m==0){
            cout<<"0 0 1 1"<<endl;
        }
        else cout<<"-1"<<endl;
        return 0;
    }
    if(m>=all){
        cout<<-1<<endl;
        return 0;
    }
    rep(i,all){
        if(i!=m)cout<<i<<" ";
    }
    cout<<m<<" ";
    rep(i,all){
        if(all-i-1!=m)cout<<all-i-1<<" ";
    }
    cout<<m<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acosl(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	//const ll p = 998244353;

	ll x, n;
	cin >> x >> n;
	set<ll> st;
	while (n--) {
		ll p;
		cin >> p;
		st.insert(p);
	}

	for (ll i = 0; ; i++) {
		if (st.find(x - i) == st.end()) {
			cout << x - i << endl;
			return 0;
		}
		if (st.find(x + i) == st.end()) {
			cout << x + i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#include <algorithm>
#define Freopen(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout);
#define int long long
using namespace std;
int a[10010],n,k;
signed main()
{
	scanf("%lld%lld",&n,&k);
	for(int i=1;i<=k;i++)
	{
		int di,A;
		scanf("%lld\n",&di);
		for(int j=1;j<=di;j++)
			scanf("%lld\n",&A),a[A]++;
	}
	int ans=0;
	for(int i=1;i<=n;i++)
		if(!a[i])ans++;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3824
n, m = gets.chomp.split(' ').map(&:to_i)
a = []
b = []

m.times do
  c, d = gets.chomp.split(' ').map(&:to_i)
  a << d if c == 1
  b << c if d == n
end

puts (a & b).empty? ? 'IMPOSSIBLE' : 'POSSIBLE'


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

int main(){
  int a;
  cin >> a;
  cout << a + pow(a,2) + pow(a,3) << endl;
}


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

int main() {
    string s; cin >> s;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == s[i+1]) {
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;

    return 0;
}

Measured memory_bytes: 256