akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
// vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

const int N = 2111;
int n, k;
vii G(N);
int res = 0;

void dfs(int now, int par, int d, int ma) {
    if (d > ma) res++;
    for (int v: G[now]) {
        if (v == par) continue;
        dfs(v, now, d + 1, ma);
    }
}

signed main() {
    fio();
    cin >> n >> k;
    rep (i, n - 1) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    
    ll ans = INF;
    if (k % 2 == 0) {
        rep (i, n) {
            res = 0;
            dfs(i, -1, 0, k / 2);
            chmin(ans, res);
        }
    }
    else {
        rep (i, n) {
            for (int v: G[i]) {
                if (i > v) continue;
                res = 0;
                dfs(i, v, 0, k / 2);
                dfs(v, i, 0, k / 2);
                chmin(ans, res);
            }
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 3904
#include<iostream>

using namespace std;

int main(){
  int N, M, C;
  cin >> N >> M >> C;
  int B[M], A[N][M];

  for(int i = 0; i < M; i++){
    cin >> B[i];
  }
  for (int i = 0; i < N; i++){
    for (int j = 0; j < M; j++){
      cin >> A[i][j];
    }
  }

  int ans = 0;
  for (int i = 0; i < N; i++){
    int s = 0;
    for (int j = 0; j < M; j++){
      s += A[i][j] * B[j];
    }
    s += C;
    if(s > 0){
      ans++;
    }
  }
  
  printf("%d\n", ans);
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define deb(x) cout<< #x << " " << x << "\n";
#define MAX 9223372036854775807
#define MIN -9223372036854775807
#define PI 3.141592653589
#define setbits(n) __builtin_popcountll(n)
const ll mod=1e9+7;

#define MAXN  1000001 
  
int spf[MAXN]; 
  
void sieve() 
{ 
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++) 
        spf[i] = i; 
    for (int i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (int i=3; i*i<MAXN; i++) { 
        if (spf[i] == i) { 
            for (int j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 
  

vector<int> getfact(int x) 
{ 
    vector<int> ret; 
    while (x != 1) { 
        ret.push_back(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
} 

int ch[MAXN];

int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll T=clock();
    
    sieve();
    ll n;
    cin>>n;
    vector<ll> a(n);
    for(ll i=0;i<n;i++)
        cin>>a[i];
    bool ok=true;
    for(int i=0;i<n;i++){
        vector<int> p=getfact(a[i]);
        for(int i=0;i<p.size();i++){
            if(ch[p[i]]==1){
                ok=false;
                break;
            }
        }
        for(int i=0;i<p.size();i++)
            ch[p[i]]=1;
    }
    if(ok){
        cout<<"pairwise coprime";
        return 0;
    }
    ll g=a[0];
    for(int i=1;i<n;i++)
        g=__gcd(g,a[i]);
    if(g==1)
        cout<<"setwise coprime";
    else
        cout<<"not coprime";


    cerr<<"\n\nTIME: "<<(double)(clock()-T)/CLOCKS_PER_SEC<<" sec\n";
    T = clock();
    return 0;
}

Measured memory_bytes: 18924
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
ll gcd(ll a, ll b)
{
	if (b == 0)return a;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region LCM
ll lcm(ll a, ll b)
{
	return a / gcd(a, b) * b;
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion

vector<vector<int>> v(200100);
vector<int> imos(200100, 0);

void dfs(int now, int p, int counter)
{
	imos[now] += counter;
	for (auto next : v[now])
	{
		if (next == p)continue;
		dfs(next, now, imos[now]);
	}
}

int main()
{
	int n, q; cin >> n >> q;
	rep(i, n - 1)
	{
		int a, b; cin >> a >> b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	rep(i, q)
	{
		int p, x; cin >> p >> x;
		imos[p] += x;
	}
	dfs(1, 0, 0);
	for (int i = 1; i <= n; ++i)cout << imos[i] << " ";
}

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

int main(){
  int N, M;
  cin >> N >> M;
  vector<vector<int>> G(N, vector<int>(N));
  int A, B;
  for(int i=0; i<M; i++){
    cin >> A >> B;
    G.at(A-1).at(B-1)=1;
    G.at(B-1).at(A-1)=1;
  }
  vector<int> V(0);
  for(int i=1; i<N; i++){
    V.push_back(i);
  }
  int Ans=0;
  do{
    int k=1;
    int now=0;
    for(int i=0; i<N-1; i++){
      if(G.at(now).at(V.at(i))==1){
        now=V.at(i);
      }
      else{
        k=0;
        break;
      }
    }
    Ans+=k;
  }while(next_permutation(V.begin(), V.end())==true);
  cout << Ans << endl;
}
  

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int n,a[100][100]={0};
  int i,j,u,k,v;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      a[u-1][v-1]=1;
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      printf("%d",a[i][j]);
      if(j!=n-1)printf(" ");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 652
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

    int a;
    vector<int> v;

    for (int i = 0; i < n; i++) {
        cin >> a;
        v.push_back(a);
    }

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

    cout << v.back() - v.front() << endl;
}


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
class Sieve2: #√nまでの素因数で試し割り 前処理O(√nloglogn+√n/logn)
    def __init__(self,n):
        self.primes=[]
        self.f=[0]*(int(n**0.5)+1) #ふるい（素数ならその値）
        self.f[0]=self.f[1]=-1
        for i in range(2,int(n**0.5)+1): #素数リスト作成
            if self.f[i]: continue
            self.primes.append(i)
            self.f[i]=i
            for j in range(i*i,int(n**0.5)+1,i):
                if not self.f[j]:
                    self.f[j]=i  #最小の素因数を代入

    def prime_fact(self,x): #素因数分解 {2:p,3:q,5:r,...}
        fact_dict=dict()
        for p in self.primes:
            if p*p>x:break
            while x%p==0:
                x//=p
                fact_dict[p]=fact_dict.get(p,0)+1
        if x>1:fact_dict[x]=fact_dict.get(x,0)+1
        return fact_dict

def main():
    n = int(input())
    Sieve = Sieve2(n)
    prime_dict = Sieve.prime_fact(n)
    ans = 0
    for fact in prime_dict.values():
        f = fact
        x = 1
        while f > 0:
            if f >= x:
                ans += 1
            f -= x
            x += 1
    print(ans)


if __name__=='__main__':
    main()

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

#define rep(i, l, n) for(int i=(l); i<(int)(n); i++)
#define REP(i, n) for(int i=1; i<=(int)(n); i++)

using namespace std;

int main(){
    int N, K;
    int sum = 0;
    cin >> N >> K;
    vector<int> p(N);

    rep(i, 0, N) {
        cin >> p[i];
    }

    sort(p.begin(), p.end());
    rep(i, 0, K) {
        sum += p[i];
    }

    cout << sum << endl;

    return 0;
}



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

using namespace std;

#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()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const bool debug = 0;

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

int main() {
 int w, h, c;
 cin >> w >> h >> c;
 
 int g = gcd(w, h);
 cout << (w/g) * (h/g) * c << endl;
	return 0;
}

Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long
#define mod 1000000007
#define do double
#define loop(i,n) for(int i=0;i<n;i++)
#define lop(a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define mkp make_pair

typedef vector <int> vi;
typedef map <int,int> mii;
typedef set <int> si;
typedef pair <int,int> pii;
typedef unordered_map <int,int> um;
typedef unordered_set <int> us;
typedef multiset <int> ms;
typedef vector < pair <int,int> > vpii;
// Driver code 
int main() 
{ 
    int n;
    cin>>n;
    ll a[n],sum=0;
       loop(i,n)
       {  cin>>a[i];
          sum+=a[i];
       }

    ll dp[n+1][n+1]={};
    for(int l=1;l<=n;l++)
    {
        for(int i=0;i<n-l+1;i++)
        {
            int j=i+l-1;
            if(i==j)
                dp[i][j]=a[i];
            else if(j-i==1)
                dp[i][j]= max(a[i],a[j]);
            else dp[i][j] = max(a[i] + min(dp[i+2][j],dp[i+1][j-1]),a[j] + min(dp[i][j-2],dp[i+1][j-1]));
        }
    }
    
    cout<<2*dp[0][n-1]-sum<<"\n";

} 



Measured memory_bytes: 70656
H,W=map(int,input().split())
if(W % 2 == 0):
    w=int(W/2)
    ans=w*H
else:
    if(H % 2 == 0):
        h=int(H/2)
        ans=W*h
    else:
        w=int(W/2)
        h=int(H/2)
        ans=W*h+w+1
if(W==1):
    ans=1
if(H==1):
    ans=1
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main ()
{
	int n,i,j,l=0;
	vector<int> v;
	cin>>n;
	for(i=0;i<n;i++)
	{
		int m;
		cin>>m;
		v.push_back(m);
	}
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
			if(j!=i)
			{
				l=l+v[i] * v[j];
			}
		}
	}
	cout<<l/2;
	return 0;	
}

Measured memory_bytes: 256
#include <iostream>
#include <list>
#include <queue>
#include <set>

using namespace std;

int solve( list<int> *router, int from, int to, int ttl ){
	set<int> history;
	queue<int> q;
	int dist[101];

	for( int i = 0;i < 101;i++ ) dist[i] = 9999999;

	history.insert( from );
	q.push( from );
	dist[from] = 1;

	while( !q.empty() ){
		int u = q.front();

		if( dist[u] > ttl ){
			q.pop();
			continue;
		}

		if( u == to ){
			return dist[u];
		}

		for( list<int>::iterator it = router[u].begin(); it != router[u].end(); it++ ){
			int v = *it;
			if( history.count( v ) ) continue;
			history.insert( v );
			dist[v] = dist[u] + 1;
			q.push( v );
		}
		q.pop();
	}
	return -1;
}



int main(void)
{
	int n;
	list<int> router[101];

	cin >> n;

	for( int i = 0;i < n;i++ ){
		int hoge;
		int number;
		int piyo;

		cin >> number >> hoge;

		for( int j = 0;j < hoge;j++ ){
			cin >> piyo;
			router[number].push_back( piyo );
		}
	}

	cin >> n;
	int from,to,ttl;
	for( int i = 0;i < n;i++ ){
		cin >> from >> to >> ttl;
		int answer = solve( router, from, to, ttl );
		if( answer == -1 ) cout << "NA" << endl;
		else cout << answer << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn=1e5+10;
typedef long long ll;
ll pa[maxn],na[maxn],pb[maxn],nb[maxn];
ll n,c;
ll p1[maxn],n1[maxn];
ll p2[maxn],n2[maxn];
inline void init()
{
    memset(pa, 0, sizeof(pa));memset(na, 0, sizeof(na));
    memset(pb, 0, sizeof(pb));memset(nb, 0, sizeof(nb));
    memset(p1, 0, sizeof(p1));memset(n1, 0, sizeof(n1));
    memset(p2, 0, sizeof(p2));memset(n2, 0, sizeof(n2));
}
int main()
{
    while (scanf("%lld%lld",&n,&c)!=EOF) {
        init();
        for(int i=1;i<=n;i++)scanf("%lld%lld",&pa[i],&pb[i]),na[n-i+1]=c-pa[i];
        for(int i=1;i<=n;i++)nb[i]+=nb[i-1]+pb[n-i+1];
        for(int i=1;i<=n;i++)pb[i]+=pb[i-1];
        //for(int i=1;i<=n;i++)cout<<pa[i]<<" "<<na[i]<<endl;
        for(int i=1;i<=n;i++)
        {
            p1[i]=pb[i]-pa[i];
            p2[i]=pb[i]-pa[i]*2;
        }
        for(int i=1;i<=n;i++)p1[i]=max(p1[i],p1[i-1]),p2[i]=max(p2[i],p2[i-1]);
        for(int i=1;i<=n;i++)
        {
            n1[i]=nb[i]-na[i];
            n2[i]=nb[i]-na[i]*2;
        }
        for(int i=1;i<=n;i++)n1[i]=max(n1[i],n1[i-1]),n2[i]=max(n2[i],n2[i-1]);
        ll mm=0;
        for(int i=1;i<=n;i++)
        {
            mm=max(mm,n1[i]+p2[n-i]);mm=max(mm,n1[i]);mm=max(mm,p1[i]);mm=max(mm,n2[i]+p1[n-i]);
        }
        printf("%lld\n",mm);
    }
    return 0;
}

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

//#define int long long
using ll = long long;
const int INF = 1<<29;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var)  std::cout<<var<<std::endl
#define PI (acos(-1))
#define rep(i, n)   for(int i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(int i=1, i##_length=(n); i<=i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define pb push_back
inline bool isnatural(double a) { return a>=0 && ceil(a)==floor(a); }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/

signed main() {
	ll N;
	cin >> N;

	/*
	N-1は必ず当てはまる　N/N-1=1 N%N-1=1
	N-i/i *i +i が条件を満たす　iの上限はいくつか？？　和の公式で総和は出せそう


	*/

	ll ans=0;
	ll n=N;
	for(ll i=1 ; i*i<=n ; ++i)
	{
			ll t=(i+1)*i+i;
			if(N<t){
				break;
			}
		if(n%i == 0)
		{

			ll aa=N/i;
			ans+=aa-1;
		}
	}



	p(ans);
	return 0;
}



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

int main(){
    int a, b;
    cin >> a;
    for(int i=1; i <= a; i++){
        b = i;
        if(b % 3 == 0)cout << ' ' << i;
        else{
            while(b){
                if(b%10 == 3){
                    cout << ' ' << i;
                    break;
                }
                b /= 10;
            }
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define ll long long
#define db long double
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

using namespace std;

struct Vertex {
	int go[26];
	int cnt_sons[26];
};

vector<Vertex> bor;

int create_vertex() {
	Vertex w;
	for (int i = 0; i < 26; ++i) {
		w.go[i] = -1;
		w.cnt_sons[i] = 0;
	}
	bor.pb(w);
	return bor.size() - 1;
}

int go(int a, int b) {
	if (bor[a].go[b] == -1) {
		bor[a].go[b]= create_vertex();
	}
	return bor[a].go[b];
}

int main(){
#ifdef LOCAL
	freopen("B_input.txt", "r", stdin);
	//freopen("B_output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int n;
	cin >> n;

	vector<string> v;
	for (int i = 0; i < n; ++i) {
		string s;
		cin >> s;
		reverse(all(s));
		v.pb(s);
	}

	create_vertex();
	for (int i = 0; i < n; ++i) {
		vector<int> tut(26, 0);
		for (auto x : v[i]) tut[x - 'a']++;

		int cur = 0;
		for (auto x : v[i]) {
			for (int j = 0; j < 26; ++j) {
				if (tut[j]) bor[cur].cnt_sons[j]++;
			}

			cur = go(cur, x - 'a');
			tut[x - 'a']--;

		}

	}

	ll ans = 0;

	for (int i = 0; i < n; ++i) {
		int cur = 0;
		for (int j = 0; j + 1 < v[i].size(); ++j) {
			cur = go(cur, v[i][j] - 'a');
		}

		ans += bor[cur].cnt_sons[v[i].back() - 'a'] - 1;

	}

	cout << ans;



}


Measured memory_bytes: 223076
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int s = a%60;
		int m = a/60;
		int h = m/60;
		m = m%60;
		
		System.out.println(h+":"+m+":"+s);
	}
}

Measured memory_bytes: 26060
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <map>
using namespace std;
typedef long long int ll;

constexpr ll mod=1e9+7;


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s,t; cin >> t >> s;
    int res=1e9;
    int n=s.size(); int m=t.size();
    for(int i=0;i+n-1<m;i++){
        int cnt=0;
        for(int j=0;j<n;j++){
            if(s[j]==t[i+j])cnt++;
        }
        res=min(res,n-cnt);
    }
    cout << res << endl;
}


Measured memory_bytes: 3644
#listの要素をキー、その出現数を値として持つディクショナリを返す
def count(list):
    dict = {}
    for i in range(len(list)):
        dict[list[i]] = dict.get(list[i], 0) + 1
    return dict

n = int(input())
s = []
for _ in range(n):
    s.append(input())

dic = count(s)
lst = sorted(dic.items(), key=lambda x: x[1], reverse=True)
value_max = lst[0][1]
output = []

for name in lst:
    if name[1] == value_max:
        output.append(name[0])
    else:
        break

output.sort()
print(*output,sep="\n")

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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
typedef std::vector<long> LI;
typedef std::queue<long> QI;
#define rep(i,n) for(long i = 0; i < (long)n; ++i)
const double pi = M_PI;
const long mod = 1000000007;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(long& x) { if( scanf("%ld", &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
template<> void scan1(LI& xs) { for(long &x : xs) scan1(x); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      long xs[26] = {};
      std::string ss; scan(ss);
      for(char c : ss) {
         xs[c-'a'] += 1;
      }
      for(long i = 0; i < 26; ++i) {
         if( xs[i] == 0 ) {
            printf("%c\n", (char)(i + 'a'));
            return;
         }
      }
      puts("None");
   }
};

int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}



Measured memory_bytes: 512
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;

int main(int argc, char* argv[])
{
    int i;
    for(i=0; i<10000; i++) {
        int a,b;
        scanf("%d%d", &a, &b);
        if(a==0 && b==0) break;
        if(a>b) swap(a,b);
        printf("%d %d\n", a,b);        
    }
    return 0;
}



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

int main() {
  int a, b;
  cin >> a >> b;
  if (a % 2 != 0 && b % 2 != 0) {
    cout << "Odd" << endl;
  }
  else {
    cout << "Even" << endl;
  }
}

Measured memory_bytes: 3596
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <string>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,P> pip;
typedef long long ll;
const int inf=1<<30;
const double pi=acos(-1);

int n;
vector<char> cnum(8);
vi num(8);

int rui(int x){
	int ans=1;
	for(int i=0;i<x;i++) ans*=10;
	return ans;
}

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		int M=0,m=0;
		for(int j=0;j<8;j++) cin>>cnum[j];
		for(int j=0;j<8;j++) num[j]=cnum[j]-'0';
		sort(num.begin(),num.end());
		for(int j=0;j<8;j++) M+=num[j]*rui(j);
		for(int j=0;j<8;j++) num[j]*=-1;
		sort(num.begin(),num.end());
		for(int j=0;j<8;j++) m+=-num[j]*rui(j);
		cout<<M-m<<endl;
	}
}

Measured memory_bytes: 1212
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <list>
#include <cctype>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)

locale l = locale::classic();

int main(){
    bool again=false;
    while(1){
    string s;
    cin >> s;
    if(cin.eof()) break;
    if(again) cout << ' ';
    rep(i,s.size()){
        if(isupper(s[i])) cout << tolower(s[i],l);
        else if(islower(s[i])) cout << toupper(s[i],l);
        else cout << s[i];
    }
    again=true;
    }
    cout << endl;
}


Measured memory_bytes: 3188
fun main(args: Array<String>) {
    readLine()
    val elements = readLine()
        ?.split(" ".toRegex())
        ?.map(String::toInt)
        ?.toIntArray()
        ?: intArrayOf()
    readLine()
    val questions = readLine()
        ?.split(" ".toRegex())
        ?.map(String::toInt)
        ?.toIntArray()
        ?: intArrayOf()
    println(questions.joinToString("\n") {
        if (elements.canMake(it)) {
            "yes"
        } else {
            "no"
        }
    })
}

fun IntArray.canMake(m: Int): Boolean {
    return this.canMake(0, m)
}

fun IntArray.canMake(i: Int, m: Int): Boolean {
    if (m == 0) {
        return true
    }
    if (i > this.size - 1) {
        return false
    }
    return this.canMake(i + 1, m) || this.canMake(i + 1, m - this[i])
}


Measured memory_bytes: 30784
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_number(A, B) :-
    get_number(A),
    get_number(B).

get_number(A, B, C) :-
    get_number(A, B),
    get_number(C).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)
    sub_string

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

    match: =, \=

    numeric: <,=<, >, >= (eval)
    lexicographically: @<. @=<, @>, @>=
    value?: =:=, =\= (eval)
    identical: ==, \==
*/

f([A,A,A,B]).
f([A,B,B,B]).

main :-
    get_string(S),
    string_chars(S, S2),
    f(S2) -> writeln("Yes") ; writeln("No").


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

int main(){
int a,b,c,d,x,y,g,h,i,j;
cin>>a>>b>>c>>d>>x>>y>>g>>h;
i=a*x+b*y+g*(a/10)+h*(b/20);
j=c*x+d*y+g*(c/10)+h*(d/20);

if(i>j){cout<<"hiroshi"<<endl;}
if(i<j){cout<<"kenjiro"<<endl;}
if(i==j){cout<<"even"<<endl;}

return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace __gnu_pbds;
using namespace std;
/*
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
*/
#define ull unsigned long long int
#define ll long long int
#define ld long double
#define MAX 1000000007
//1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>
#define piii pair<int,pii>
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FO ifstream fin("a.in");ofstream fout("a.out");
#define TEST int testcase;cin>>testcase;while(testcase--)
#define FTEST int testcase;fin>>testcase;while(testcase--)
#define all(x) (x).begin(),(x).end()
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
#define endl "\n"
#define plll pair<ll,pll>
#define plii pair<ll,pii>
#define no {cout<<"no"<<endl;return;}
#define yes {cout<<"yes"<<endl;}
#define rep(i,N) for(int i=0;i<N;i++)
const int maxn=1e6;
const int mod=998244353;
typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;
int n,q,k;
void solve(){
    cin>>n;
    q=n/2+n%2;
    double d1=n,d2=q;
    cout<<setprecision(10)<<d2/d1;
}
int main(){
    IO
    //TEST
    solve();

    return(0);
}
/*
1
aabce
ace
*/


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

vector <vector <int> > DP;

int main(){
    ios_base::sync_with_stdio(0);
    int N, K;
    cin >> N >> K;
    vector <long long> V(N);
    for (int i = 0; i < N; i++){
        cin >>V[i];
    }
    DP.resize(K+1, vector <int>(2));
    DP[0][0] = 1;
    DP[0][1] = 0;
    for (int i = 1; i <= K; i++){
        for (int Zaczyna = 0; Zaczyna < 2; Zaczyna++){
            DP[i][Zaczyna] = (Zaczyna+1)%2;
            for (int j = 0; j < N; j++){
                if (i >= V[j]){
                    int KtoWygrywa = DP[i - V[j]][(Zaczyna+1)%2];
                    if (KtoWygrywa == Zaczyna){
                        DP[i][Zaczyna] = Zaczyna;
                    }
                }  
            }
        }
    }

    // for (int Zaczyna = 0; Zaczyna < 2; Zaczyna++){
    //     for (int i = 0; i <= K; i++){
    //         cerr << DP[i][Zaczyna] << " ";
    //     }
    //     cerr << "\n";
    // }
    cout << (DP[K][0] == 0 ? "First" : "Second");
}

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

using namespace std;
typedef long long ll;

const ll mod=1000000007;
const int oo=1000000000;
int dx[8]={1,-1,0,0,1,-1,1,-1};
int dy[8]={0,0,1,-1,1,-1,-1,1};
const int N=102050;
int pre1[3*N],pre2[3*N];
int main(){
    int n;
    cin>>n;
    string x;
    cin>>x;
    for(int i=0;i<x.size();i++){
        pre1[i+1]=pre1[i];
        pre2[i+1]=pre2[i];
        if(x[i]=='E')pre1[i+1]++;
        else pre2[i+1]++;
        //cout<<pre1[i]<<' '<<pre2[i]<<endl;
    }

    int mn=1000000000;
    for(int i=1;i<=n;i++){
        //cout<<pre2[i-1]<<' '<<pre1[i+1]<<endl;
        mn=min(mn,pre2[i-1]+pre1[n]-pre1[i]);
        //if(mn==1)cout<<i<<endl;
    }
    if(mn==1000000000)
        cout<<0;
    else
        cout<<mn;
    return 0;
}


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

char str[25]; 
long long dp[10][10] = {0};
long long MI[10] = {1}, cnt = 0;

int main () {
	for (int i = 1; i <= 6; ++i)
		MI[i] = MI[i-1] * 10;
	cin >> str;
	int len = strlen (str);
	for (int i = 1; i < len-1; ++i) {
		cnt *= 10;
		cnt += (str[i]-'0');
	}
	++cnt;
	for (long long i = 1; i <= 9; ++i)
		for (long long j = 1; j <= 9; ++j) {
			if (i == j && (len == 1 && i <= str[0]-'0' || len > 1))
				dp[i][j]++;
			if (len == 1)
				continue;
			for (int k = 1; k < len-1; ++k)
				dp[i][j] += MI[k-1];
			if (i < str[0]-'0') {
				dp[i][j] += MI[len-2];
				continue;
			}
			if (i > str[0]-'0')
				continue;
			dp[i][j] += cnt;
			if (j > str[len-1]-'0')
				--dp[i][j];
		}
	long long ans = 0;
	for (int i = 1; i <= 9; ++i)
		for (int j = 1; j <= 9; ++j)
			ans += dp[i][j] * dp[j][i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3480
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
  }
  int flag=0;
  for(int i=0;i<n;i++){
    flag += (a.at(i)==flag+1);
  }
  cout<<(flag ? n-flag : -1)<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int k,n;
    int sum = 0;

    cin >> k >> n;

    int a[n];

    for(int i = 0; i < n; i++){
        cin >> a[i];
        
    }
    int max = 0;
    for(int i = n - 1; i > 0; i--){
        int diff = a[i] - a[i - 1];
        if(max <= diff){
            max = diff;
        }
    }

    int c = k-a[n-1] + a[0] ;
    if(max <= c){
        max = c;
    }

    cout << k - max << endl;




}

Measured memory_bytes: 1024
q = int(input())
bin_q = format(0, '064b')
qlist = list(bin_q)

for _ in range(q):
    query = list(map(int, input().split()))
    command = query[0]

    if command == 0:    # test
        i = 63 - query[1]
        print(qlist[i])
    elif command == 1:  # set
        i = 63 - query[1]
        qlist[i] = '1'
    elif command == 2:  # clear
        i = 63 - query[1]
        qlist[i] = '0'
    elif command == 3:  # flip
        i = 63 - query[1]
        if qlist[i] == '0':
            qlist[i] = '1'
        else:
            qlist[i] = '0'
    elif command == 4:  # all
        c = qlist.count('1')
        if c == 64:
            print(1)
        else:
            print(0)
    elif command == 5:  # any
        c = qlist.count('1')
        if c > 0:
            print(1)
        else:
            print(0)
    elif command == 6:  # none
        c = qlist.count('1')
        if c == 0:
            print(1)
        else:
            print(0)
    elif command == 7:  # count
        c = qlist.count('1')
        print(c)
    elif command == 8:  # val
        bin_q = ''.join(str(q) for q in qlist)
        dec_q = int(bin_q, 2)
        print(dec_q)



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


int main() {
int N,X;
  cin >> N >>X;
  vector<int> L(N);
  for(int i=0;i<N;i++) cin >> L[i];
  int d =0;
  int count =0;
  while(d <= X ){
	
    if(count == N+1) break;
    d += L[count];
    count++;
  }
cout <<count <<endl;
}


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

using namespace std;

typedef long long ll;
#define PI 3.14159265




int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int N, k;
    cin >> N >> k;
    vector<int> arr(N + 1);
    for(int i = 0; i < k; i++){
        int d;
        cin >> d;
        for(int j = 0; j < d; j++){
            int a;
            cin >> a;
            arr[a]++;
        }
    }
    int ans = 0;
    for(int i = 1; i <= N; i++){
        if(arr[i] == 0){ans++;}

    }
    cout << ans << endl;

}


Measured memory_bytes: 3628
//include <iostream>
#include <stdio.h>
#include <algorithm>
//#include <tuple>
#include <cmath>
#include <string>
#include <vector>


#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define lb lower_bound
using namespace std;

int a,b,q;
ll s[100005];
ll t[100005];
ll x[100005];


int main() {
	s[0] = -1 * (1LL << 60);
	t[0] = -1 * (1LL << 60);

	scanf("%d%d%d",&a, &b, &q);
	rep(i, a) {
		scanf("%lld",&s[i+1]);
	}
	rep(i, b) {
		scanf("%lld",&t[i+1]);
	}
	rep(i, q){
		scanf("%lld",&x[i]);
	}

	s[a+1] = 1LL << 60;
	t[b+1] = 1LL << 60;
  
  	/*rep(i,a+2){
    	printf("%lld ",s[i]);
    }
    //*/
	rep(i, q) {
		ll rm, lm;
		auto ite_s = lb(s, s + a+2, x[i]);
		auto ite_t = lb(t, t + b+2, x[i]);

		/*
		printf("s=%lld,t=%lld\n", *ite_s, *ite_t);
		//*/

		ll s[2]={*ite_s,*(ite_s-1)};
      	ll t[2]={*ite_t,*(ite_t-1)};
      	
      	ll ans=1LL<<60;
      
      	rep(j,2){
        	rep(k,2){
            	ans=min(ans,min(abs(x[i]-s[j])+abs(t[k]-s[j]),
                       		abs(x[i]-t[k])+abs(t[k]-s[j])));
            }
        }
      
      	printf("%lld\n", ans);
	}


	return 0;



}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int k;
    cin >> k;
    vector<long long> a;
    for (int i=1;i<=9;i++) a.push_back(i);
    while (1) {
        if (k <= a.size()) {
            cout << a[k-1] << endl;
            return (0);
        }
        k -= a.size();
        vector<long long> old;
        swap(a,old);
        for (long long x : old) {
            for (int i=-1;i<=1;i++) {
                int d = x % 10 + i;
                if (d < 0 || 9 < d) continue;
                long long nx = 10 * x + d;
                a.push_back(nx);
            }
        }
    }
}

Measured memory_bytes: 1712
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < a.length; i++) {
			a[i]  = sc.nextInt();
		}
		
		int max = 0;
		int sum = 0;
		for (int i = 0; i < a.length; i++) {
			if (i < k - 1) {
				sum += a[i];
				continue;
			}
			sum += a[i];
			max = Math.max(max, sum);
			sum -= a[i - k + 1];
		}
		System.out.println((max - k) * 0.5 + k);
	}
}




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

using namespace std;
using ll = long long;
using pint = pair<int, int>;

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

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

int main() {
	ll A, B, C, D;
	cin >> A >> B >> C >> D;

	ll ans = B - A + 1;
	ll tmp = (B / C - (A-1) / C) + (B / D - (A-1) / D) - (B / lcm(C, D) - (A-1) / lcm(C, D));

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


Measured memory_bytes: 3644
import sys
import fractions

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

S = sr()
bit = len(S)-1
Sum = 0
for b in range(2 ** bit):
    bb = b
    i = 1
    offset = 0
    s = list(S)
    while bb:
        if bb & 1:
            s.insert(i+offset, ',')
            offset += 1
        bb >>= 1
        i += 1
    Sum += sum(map(int, ''.join(s).split(',')))
print(Sum)


Measured memory_bytes: 5076
from collections import deque


def BFS():
    color=[["white" for _ in range(w)] for _ in range(h)]
    queue=deque([])
    ans=0

    for i in range(h):
        for j in range(w):
            if color[i][j]=="white" and S[i][j]=="#":
                queue.append([i,j])
                color[i][j]="gray"
                black,white=0,0

                while len(queue)>0:
                    c,d=queue.popleft()
                    if S[c][d]=="#":black +=1
                    else:white +=1

                    sign="." if S[c][d]=="#" else "#"
                    for a,b in [[1,0],[-1,0],[0,1],[0,-1]]:
                        X,Y=c+a,d+b
                        if 0<=X<h and 0<=Y<w:
                            if S[X][Y]==sign and color[X][Y]=="white":
                                color[X][Y]="gray"
                                queue.append([X,Y])
                    color[c][d]="black"
                ans +=black*white

    return ans


h,w=map(int,input().split())
S=[list(input()) for _ in range(h)]
print(BFS())

Measured memory_bytes: 78068
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<climits>
#include<map>
#define ll long long
using namespace std;
int main() {
	ll n;
	cin >> n;
	vector<ll>a(n + 2), count(n + 2,0);
	for (ll i = 1; i <= n; i++) {
		a[i] = i;
		//cout << a[i] << endl;
	}
	for (ll i = 1; i <= n; i++) {
		while (a[i] %2 != 1) {
			a[i] /= 2;
			count[i]++;
		}
		//cout << count[i] << endl;
	}
	ll max = 0,maxi=0;
	for (ll i = 1; i <= n; i++) {
		if (count[i] >= max) {
			maxi=i;
			max = count[i];
		}
	}
	cout << maxi << endl;
	
}


Measured memory_bytes: 256
mod = 10**9+7

def comb(n, r):
    x = 1
    y = 1
    if n-r<r:
        r = n-r
    for i in range(r):
        x *= n-i
        y *= (i+1)
        x %= mod
        y %= mod
    return x * pow(y, mod-2, mod) % mod

n, a, b = map(int, input().split())

print((pow(2, n, mod)-comb(n, a)-comb(n, b)-1)%mod)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

int n, k;
int cnt[3010][3010];
int d[2][1010][1010];
int ans;

signed main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		int x, y; char c; cin >> x >> y >> c;
		if (c == 'B')y += k;
		x %= 2 * k;
		y %= 2 * k;
		cnt[x][y]++;
		cnt[x + k][y + k]++;
		cnt[x][y + k]--;
		cnt[x + k][y]--;
	}
	for (int i = 0; i < 3 * k; i++)for (int j = 0; j < 3 * k; j++)cnt[i][j + 1] += cnt[i][j];
	for (int i = 0; i < 3 * k; i++)for (int j = 0; j < 3 * k; j++)cnt[i + 1][j] += cnt[i][j];
	for (int i = 0; i < 3 * k; i++)for (int j = 0; j < 3 * k; j++) {
		int s = (i / k + j / k) % 2;
		d[s][i%k][j%k] += cnt[i][j];
	}
	for (int i = 0; i < 2; i++)for (int j = 0; j < k; j++)for (int l = 0; l < k; l++)ans = max(ans, d[i][j][l]);
	cout << ans << endl;
}

Measured memory_bytes: 43520
#include<bits/stdc++.h>
using namespace std;
int n,m,x,y;
int a[110],b[110];
int main() {
	cin>>n>>m>>x>>y;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<m;i++)
		cin>>b[i];
	if(x>=y) {
		cout<<"War";
		return 0;
	}
	sort(a,a+n);
	sort(b,b+m);
	if(a[n-1]>=b[0]) {
		cout<<"War";
		return 0;
	}
	if(a[n-1]>=y || b[0]<=x) {
		cout<<"War";
		return 0;
	}
	cout<<"No War";
	return 0;
} 

Measured memory_bytes: 256
#include<iostream>

using namespace std;

const static int MAX_N = 100000;

int N;
int a[MAX_N];

int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }

  int cnt = 0;
  int cnto = 0;
  int cnte = 0;
  for (int i = 0; i < N; i++) {
    if (a[i] % 4 == 0) cnt += 1;
    else if (a[i] % 2 == 1) cnto += 1;
    else if (a[i] % 2 == 0) cnte += 1;
  }

  
  if (cnt >= cnto + (cnte % 2) - 1) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


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

using namespace std;
int main(){
	long long L,R;
	cin>>L>>R;
	if(R-L>2019) cout<<0<<endl;
	else{
		long long ans=3000;
		for( int i=L;i<=R;i++){
			for(int j=i+1;j<=R;j++){
				ans=min(ans,(long long)((long long)i%2019*(long long)j%2019)%2019);
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner s=new Scanner(System.in);
		long n=s.nextLong();
		double kk=(n/1.08);
		long k=(long)kk;
		if((long)(k*1.08)==n)
		System.out.println(k);
		else if((long)((k+1)*1.08)==n)
		System.out.println(k+1);
		else
		System.out.println(":(");
	}
}

Measured memory_bytes: 23892
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations

def main():
    H, W, K = map(int, input().split())
    C = [input() for _ in range(H)]

    res = 0

    for h in list(product([0, 1], repeat=H)):
        for w in list(product([0, 1], repeat=W)):
            hash_count = 0
            for row in range(H):
                if h[row]:
                    continue
                else:
                    for col in range(W):
                        if C[row][col] == '#' and w[col] == 0:
                            hash_count += 1
            
            if hash_count == K:
                res += 1
    
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 10368
#####################################
N,A,B = map(int,input().split())
H = [int(input()) for _ in range(N)]

from math import ceil

ng,ok = 0,10**9+1
while abs(ok-ng)>1:
    mid = (ng+ok)//2
    cnt = 0
    for i in range(N):
        cnt += max(ceil((H[i] - B*mid)/(A-B)) ,0)
    if cnt <= mid:
        ok = mid
    else:
        ng = mid

print(ok)


Measured memory_bytes: 7072
n = int(input())
a = input()
b = input()
c = input()

cnt = 0
for i in range(n):
    if len(set([a[i], b[i], c[i]])) == 3:
        cnt += 2
    if len(set([a[i], b[i], c[i]])) == 2:
        cnt += 1
print(cnt)

Measured memory_bytes: 3064
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1e9
#define LINF 1e18
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
#define int long long
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
struct edge{int to,cost;};
typedef pair<int,int> P;

bool isupper(char c){if('A'<=c&&c<='Z')return 1;return 0;}
bool islower(char c){if('a'<=c&&c<='z')return 1;return 0;}
bool isPrime(int x){if(x==1)return 0;if(x==2)return 1;if(x%2==0)return 0;for(int i=3;i*i<=x;i++)if(x%i==0)return 0;return 1;}
bool iskaibun(string s){for(int i=0;i<s.size()/2;i++)if(s[i]!=s[s.size()-i-1])return 0;return 1;}
bool isnumber(char c){return ('0'<=c&&c<='9');}
bool isalpha(char c){return (isupper(c)&&islower(c));}
void printvi(vector<int> v){rep(i,0,v.size()){if(i)cout<<" ";cout<<v[i];}cout<<endl;}
void printvil(vector<int> v){rep(i,0,v.size()){cout<<v[i]<<endl;}}
void printvvi(vector<vector<int>> v){
    rep(i,0,v.size()){
        rep(j,0,v[i].size())cout<<v[i][j];
        cout<<endl;
    }
}
void printvstr(vector<string> v){
    rep(i,0,v.size()){
        cout<<v[i]<<endl;
    }
}

signed main (){
    int n;
    cin>>n;
    if(n<1200)cout<<"ABC"<<endl;
    else cout<<"ARC"<<endl;
}
/*

*/


Measured memory_bytes: 256