akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int lb(int l,int r,long long n,long long *d){
  int m=(l+r)/2;
  if(l==r)return m;
  return n<=d[m]?lb(l,m,n,d):lb(m+1,r,n,d);
}
int ub(int l,int r,long long n,long long *d){
  int m=(l+r)/2;
  if(l==r)return m;
  return n<d[m]?ub(l,m,n,d):ub(m+1,r,n,d);
}
long long R=1,C=1,H[2000010],N[2000010];
//評価関数（いまはMIN）
int hyouka(int a,int b){
  if(C<b)return 1;
  if(C<a||b==0)return 0;
  return N[H[a]]<N[H[b]]?1:0;
}
//挿入関数
void hin(long long a){
  int i=C++;
  for(N[H[0]=R]=a;hyouka(0,i/2);i/=2)H[i]=H[i/2];
  H[i]=R++;
}
//取り出す関数
int hout(){
  int rt=H[1],i,j=2,k=H[--C];
  for(i=1;hyouka(i,C);i=j)H[i]=H[j=i*2+1-hyouka(i*2,i*2+1)];
  H[j/2]=k;
  return rt;
}
int main(){
  long long n,d[200010],i,j,k,l,a,ans=0,f[200010]={};
  scanf("%lld",&n);
  for(i=0;i<n;i++){
    scanf("%lld",&a);
    hin(a);
  }
  for(i=0;i<n;i++)d[i]=N[hout()];     
  for(i=0;i<n;i++){
    k=lb(0,n,d[i],d);
    l=ub(0,n,d[i],d);
    if(k+1!=l)f[i]=1;
    for(j=2;1;j++){
      k=lb(0,n,d[i]*j,d);
      //printf("%lld %lld %lld\n",k,d[i],d[k]);
      if(k==n)break;
      if(d[k]==d[i]*j)f[k]=1;
    }
    //printf("%lld\n",d[i]);
  NEXT:;
  }
  for(i=0;i<n;i++){
    if(f[i]==0)ans++;
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 7932
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int S, W, ret;
	ret = scanf("%d %d", &S, &W);

	if (S > W)
		printf("safe\n");
	else
		printf("unsafe\n");
	
	fflush(stdout);
	return EXIT_SUCCESS;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int D;
  cin>>D;
 
  vector<int64_t> c(27,0);
  for(int i=1;i<=26;++i) cin>>c[i];
 
  vector<vector<int64_t>> s(D+1,vector<int64_t>(27,0));
  for(int i=1;i<=D;++i){
    for(int j=1;j<=26;++j){
      cin>>s[i][j];
    }
  }
 
  vector<int> t(D+1);
  for(int i=1;i<=D;++i) cin>>t[i];
 
  int64_t score=0;
 
  vector<set<int>> next(27);
 
  for(int i=1;i<=D;++i){
    next[t[i]].insert(i);
  }
  for(int i=1;i<=26;++i){
    next[i].insert(0);
  }
 
  for(int i=1;i<=D;++i){
    score += s[i][t[i]];
    for(int j=1;j<=26;++j){
      int l=0;
      for(auto x:next[j]){
        if(x<=i) l=x;
        else break;
      }
      score -= c[j]*(i-l);
    }
  }
 
  int M;
  cin>>M;
   
  for(int i=0;i<M;++i){
    int d,q;
    cin>>d>>q;
 
    //up
    int l=0,r=D+1;
    for(auto p=next[q].begin();p!=next[q].end();++p){
      if(*p<=d) l=*p;
      else{
        r=*p;
        break;
      }
    }
 
    score += s[d][q]+((r-d)*(d-l))*c[q];
    next[q].insert(d);
    
 
    //down
    
    next[t[d]].erase(d);
    
    l=0,r=D+1;
    for(auto p=next[t[d]].begin();p!=next[t[d]].end();++p){
      if(*p<=d) l=*p;
      else{
        r=*p;
        break;
      }
    }
    
    score -= s[d][t[d]]+((r-d)*(d-l))*c[t[d]];
 
    //out
    cout<<score<<endl;
    
    //update
    t[d]=q;
  }
  
  //check
  /*
  for(int i=1;i<=26;++i){
  cout<<i<<" ";
  for(auto x:next[i]) cout<<x<<" ";
  cout<<endl;
  }
  */
  
 
}

Measured memory_bytes: 3744
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <set>
#include <map>
#include <stack>
#include <cmath>
#include <regex>
#include <iomanip>
#include <climits>
#include <utility>
#include <queue>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;
const dd PI = 3.1415926435;

class UnionFind
{
public:
    UnionFind(int N) : par(N)
    {
        for (ll i = 0; i < N; i++)
        {
            par[i] = i;
        }
    }

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

    void unite(int x, int y)
    {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry)
            return;
        par[rx] = ry;
    }

    bool same(int x, int y)
    {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

private:
    vector<int> par;
};

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

ll fact(ll n)
{
    if (n == 0)
    {
        return 1;
    }
    if (n == 1)
    {
        return 1;
    }
    return n * fact(n - 1) % MOD;
}

ll pow_fast(ll n, ll k)
{
    if (k == 0)
    {
        return 1;
    }
    if (k == 1)
    {
        return n;
    }

    if (k % 2 == 0)
    {
        ll tmp = pow_fast(n, k / 2LL);
        return tmp * tmp % MOD;
    }
    else
    {
        ll tmp = pow_fast(n, k / 2LL);
        tmp *= tmp;
        tmp %= MOD;
        return tmp * n % MOD;
    }
}

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

struct Dish
{
    ll time;
    ll taste;
};
int main()
{
    ll A, B, K;
    cin >> A >> B >> K;

    set<ll> st;
    for (ll i = 0; i < K; i++)
    {
        if (A + i > B) break; 
        st.insert(A + i);
    }
    for (ll i = 0; i < K; i++)
    {
        if (B - i < A) break;
        st.insert(B - i);
    }
    for (auto &&e : st)
    {
        cout << e << endl;
    }
    
}

Measured memory_bytes: 3620
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define RREP(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcount((unsigned int)x);};

const ll mod = 1e9+7;

const ll size = 3100;
ll fact[size+100], finv[size+100];

ll nCk(ll n, ll k){
    if(n < k) return 0;
    return fact[n] * (finv[k]*finv[n-k]%mod) %mod;
}

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

ll inv(ll x){
    return modpow(x, mod-2);
}

void prepare(){
    fact[0] = 1;
    rep(i, size-1) fact[i+1] = fact[i]*(i+1)%mod;
    finv[size-1] = inv(fact[size-1]);
    for (ll i = size-1; i > 0; i--) {
        finv[i-1] = finv[i]*i%mod;
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N, K; cin >> N >> K;
    prepare();
    ll rc = N-K;
    ll bc = K;
    
    FOR(i, 1, K+1){
        ll ans = nCk(rc+1, i);
        ll rem = bc-i;
        ans = ans * nCk(rem+i-1, rem) %mod;
        cout << ans << endstr;
    }
    return 0;
}


Measured memory_bytes: 384
#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);
        if(a.at(i)%2==0&&a.at(i)%3!=0&&a.at(i)%5!=0){
            cout<<"DENIED"<<endl;
            return 0;
        }



    }
    cout<<"APPROVED"<<endl;




    return 0;
}

Measured memory_bytes: 256
from fractions import gcd
n=int(input())
a=list(map(int,input().split()))
k=[0]
l=[0]
for i in range(n-1):
    k.append(gcd(k[i],a[i]))
    l.append(gcd(l[i],a[n-i-1]))
ans=0
for i in range(n):
    ans=max(ans,gcd(k[i],l[n-i-1]))
print(ans)


Measured memory_bytes: 16136
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 500000
#define INF 1000000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 1000000;
const int MOD = 1000000007;
int main(){
	ll n;
	cin>>n;
	ll ans=(ll)(n-1)*(n)/2;
	OUT(ans);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
long long int min(long long int x, long long int y){return x<y?x:y;}
int main(void){
	int n,i;
	scanf("%d",&n);
	long long a,sum=0,osum=0,esum=0,o=0,e=0;
	for(i=0;i<n;i++){
		scanf("%lld",&a);
		osum+=a;
		esum+=a;
		if(i%2==0){
			if(osum<=0){
				o+=1-osum;
				osum=1;
			}
			if(esum>=0){
				e+=1+esum;
				esum=-1;
			}
		}else{
			if(osum>=0){
				o+=1+osum;
				osum=-1;
			}
			if(esum<=0){
				e+=1-esum;
				esum=1;
			}
		}
	}
	o = min(o,e);
	printf("%lld",o);
	return 0;
}

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

using namespace std;

const int MAXN = 200005;

int n, naso;
int par[MAXN], bio[MAXN], cik[MAXN], mex[MAXN], val[MAXN], c[MAXN];
vector <int> v[MAXN];

void dfs (int x) {
    bio[x] = 1;
    for (auto sus : v[x]) {
        if (bio[sus] == 1) {
            if (!naso) naso = x;
        } else if (bio[sus] == 0) dfs(sus);
    }
    bio[x] = 2;
}

void calc (int x) {
    if (val[x] != -1) return;
    for (auto sus : v[x]) {
        if (cik[sus]) continue;
        calc(sus);
    }
    for (int i=0; i<=v[x].size(); i++) mex[i] = 0;
    for (auto sus : v[x]) {
        if (cik[sus]) continue;
        mex[val[sus]] = 1;
    }
    for (int i=0; i<=v[x].size(); i++) {
        if (mex[i] == 0) {
            val[x] = i;
            return;
        }
    }
}

int f (int x) {
    for (int i=0; i<=v[x].size(); i++) mex[i] = 0;
    for (auto sus : v[x]) {
        mex[c[sus]] = 1;
    }
    for (int i=0; i<=v[x].size(); i++) if (mex[i] == 0) return i;
}

bool ok () {
    for (int i=1; i<=n; i++) {
        if (f(i) != c[i]) return 0;
    }
    return 1;
}

bool probaj (int x, int br) {
    for (int i=1; i<=n; i++) {
        c[i] = val[i];
    }
    c[x] = br;
	int curr = x;
	while (1) {
        if (curr != x) c[curr] = f(curr);
        curr = par[curr];
        if (curr == x) break;
	}
	return ok();
}

int main () {
    memset(val, -1, sizeof val);
	cin >> n;
	for (int i=1; i<=n; i++) {
		cin >> par[i];
		v[par[i]].push_back(i);
	}
	for (int i=1; i<=n; i++) {
        if (bio[i] == 0 && naso == 0) dfs(i);
	}
	int curr = naso;
	while (1) {
        cik[curr] = 1;
        curr = par[curr];
        if (curr == naso) break;
	}
	for (int i=1; i<=n; i++) {
        calc(i);
	}
	if (probaj(naso, val[par[naso]])) {
        cout << "POSSIBLE";
	} else if (probaj(par[naso], val[par[naso]])) {
        cout << "POSSIBLE";
	} else {
        cout << "IMPOSSIBLE";
	}
	return 0;
}


Measured memory_bytes: 22656
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <string.h>
using namespace std;
int dp[400000]={};
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int n;
	cin>>n;
	for(int i=1;i<=300000;i++)dp[i]=100000;
	vector<int> hoge;
	hoge.push_back(1);
	for(int i=6;i<=100000;i*=6){
		hoge.push_back(i);
	}
	for(int i=9;i<=100000;i*=9){
		hoge.push_back(i);
	}
	for(int i=0;i<=100000;i++){
		for(int j=0;j<hoge.size();j++){
			int mee=i+hoge[j];
			if(dp[mee]>dp[i]+1){
				dp[mee]=dp[i]+1;
			}
		}
	}
	cout<<dp[n]<<endl;
	return 0;
}

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

using namespace std;

typedef long long LL;

int N;
LL v[300010];

int main()
{
	scanf("%d",&N);
	for (int i=1;i<=3*N;i++)scanf("%lld",&v[i]);
	sort(v+1,v+3*N+1);
	LL res = 0;
	for (int i=3*N-1;i>N;i-=2)
		res+=v[i];
	printf("%lld\n",res);
}

Measured memory_bytes: 2560
#include <stdio.h>
main()
{
	int H, W, i,j;

	while(1){
		scanf("%d %d", &H, &W);
		if(H == 0 && W == 0) break;
		
		for(i = 1; i <= H; i++){
			if(i % 2 != 0){
				for(j = 1; j <= W; j++){
					if(j % 2 != 0){
						printf("#");
					}else{
						printf(".");
					}
				}
			}else{
				for(j = 1; j <= W; j++){
					if(j % 2 != 0){
						printf(".");
					}else{
						printf("#");
					}
				}
			}
			printf("\n");
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
#define INF 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

class segtree{
public:
	static const int N=1<<17;
	vector<int> vec[1<<18];
	segtree(){
	}

	void update(int k,int v){
		k+=N-1;
		vec[k].push_back(v);
		while(k>0){
			k=(k-1)/2;
			vec[k].push_back(v);
		}
	}
	void init(){
		for(int i=0;i<N*2-1;i++){
			sort(vec[i].begin(),vec[i].end());
			vec[i].erase(unique(vec[i].begin(),vec[i].end()),vec[i].end());
		}
	}

	int query(int a,int b,int v,int k=0,int l=0,int r=N){
		if(b<=l || r<=a)return INF;
		if(a<=l && r<=b){
			if(vec[k].size()==0)return INF;
			int v1=lower_bound(vec[k].begin(),vec[k].end(),v)-vec[k].begin();
			if(v1==vec[k].size())return abs(vec[k][v1-1]-v);
			if(v1==0)return abs(vec[k][v1]-v);
			return min(abs(vec[k][v1-1]-v),abs(vec[k][v1]-v));
		}
		int mid=(l+r)/2;
		int vl=query(a,b,v,k*2+1,l,mid);
		int vr=query(a,b,v,k*2+2,mid,r);
		return min(vl,vr);
	}
};



struct query{
	static const int B=330;
	int l,r,d,id;
	query(){}
	query(int l1,int r1,int d1,int ii){
		l=l1;
		r=r1;
		d=d1;
		id=ii;
	}
	bool operator<(const query& qu)const{
		if((l/B)==(qu.l/B)){
			return r<qu.r;
		}
		return l<qu.l;
	}
};

segtree seg;
int n,Q;
int a[100005];
query q[100005];

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(int i=0;i<n;i++){
		seg.update(i,a[i]);
	}
	seg.init();
	scanf("%d",&Q);
	for(int i=0;i<Q;i++){
		scanf("%d%d%d",&q[i].l,&q[i].r,&q[i].d);
		q[i].r++;
		printf("%d\n",seg.query(q[i].l,q[i].r,q[i].d));
	}
	return 0;
}



Measured memory_bytes: 22876
// M
#include<bits/stdc++.h>
using namespace std;
const int N = 3003, Mod = 998244353;
int n, m, a, b, dp[N][N][2];
int main()
{
	scanf("%d%d%d%d", &a, &b, &n, &m);
	dp[a][b][0] = 1;
	for (int i = a; i <= n; i ++)
		for (int j = b; j <= m; j ++)
			if (i > a || j > b)
			{
				// dp[i][j][0] : i * j and we cannot take the last row
				dp[i][j][0] = (dp[i][j - 1][1] + dp[i][j - 1][0] * 1LL * i) % Mod;
				dp[i][j][1] = (dp[i - 1][j][0] + dp[i - 1][j][1]) * 1LL * j % Mod;
			}
	return !printf("%d\n", (dp[n][m][0] + dp[n][m][1]) % Mod);
}


Measured memory_bytes: 74032
#include <bits/stdc++.h>
#define lli long long int
#define vec2 vector<vector<lli>> 
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define FRE freopen("explicit.in","r",stdin);freopen("explicit.out","w",stdout)
#define mp make_pair
#define pll pair <lli,lli>
#define vll vector <lli>
#define pq2 priority_queue<pair<lli,lli>>
#define f first
#define s second
#define pb push_back
#define pf push_front
#define minii LLONG_MAX
#define ld long double 
const long double pi = 3.1415926535898;
#define dec greater<lli>()
//const lli mod=1000000007;
const lli mod=100000000;
using namespace std;
lli lcm (lli a, lli b) {return ((a*b)/__gcd(a,b));}
lli modpower (lli a,lli b)
{
    if(b==0) return 1;
    lli c=modpower(a,b/2)%mod;
    if (b%2) return (((a*c)%mod)*c)%mod;
    else return (c*c)%mod;
}
lli power (lli a,lli b)
{
    if(b==0) return 1;
    lli c=power(a,b/2);
    if (b%2) return (a*c*c);
    else return c*c;
}
lli sieve (int n)
{
    bool qrr[n+1];
    for (int i=0;i<=n;i++)
    qrr[i]=1;qrr[0]=0;qrr[1]=0;
    for (int i=2;i*i<=n;i++)
    {
        if (qrr[i]==1)
        {
            for (int j=i*i;j<=n;j+=i)
            {qrr[j]=0;}
        }
    }
    return 0;
}
int main()
{
    fio;
    lli n,k;
    cin>>n>>k;
    lli a[n];
    for (int i=0;i<n;i++)
    cin>>a[i];
    bool b[k+1];
    memset(b,0,sizeof(b));
    for (int i=0;i<=k;i++)
    {
        if (b[i]==1) continue;
        for (int j=0;j<n;j++)
        {if (i+a[j]<=k)
            b[i+a[j]]=1;}
    }
    if (b[k]==1) cout<<"First";
    else cout<<"Second";
    return 0;
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define de(x) cout<<#x<<" = "<<x<<"\n"
#define dd(x) cout<<#x<<" = "<<x<<" "
#define mes(p) memset(p,0,sizeof(p))
#define per(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(x) x.begin(),x.end()
#define rson mid+1,r,rt<<1|1
#define sz(x) (int)x.size()
#define lson l,mid,rt<<1
#define pb push_back
#define mp make_pair
//#define ls (rt<<1)
#define se second
//#define rs (ls|1)
#define fi first
typedef pair <int ,int > pi;
typedef vector <int > vi;
typedef long long ll;
const int maxn  = 1e6+5;
int n, a[maxn], b[maxn];
int main(){	
	ios_base::sync_with_stdio(0);
    cin.tie(0);
	cin >> n;
	rep(i,0,n) cin >> a[i], b[i]= a[i];
	sort(a,a+n);
	int t=0 ;
	rep(i,0,n) if(b[i]!=a[i]) t++;
	if(t>2) cout << "NO";
	else cout <<"YES";
	return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define rep(i, s, n) for(int i = s; i < n; i++)
#define rrep(i, s, n) for(int i = s; i > (s)-(n); i--)
#define pr(s) std::cout << s << std::endl
#define prb(s) std::cout << s
using namespace std;



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


  string c1, c2, c3;
  cin >> c1 >> c2 >> c3;

  pr(c1.substr(0, 1) + c2.substr(1, 1) + c3.substr(2, 1));

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;
const int MOD = 1e9 + 7;

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

    int N, M;
    cin >> N >> M;
    vector<bool> isaccepted(N);
    vector<int> wacnt(N);
    int cntwa = 0, cntac = 0;
    for (int i = 0; i < M; ++i) {
        int p;
        string S;
        cin >> p >> S;
        p--;
        if (isaccepted[p])
            continue;
        if (S == "AC") {
            cntwa += wacnt[p];
            cntac++;
            isaccepted[p] = true;
        }
        if (S == "WA")
            wacnt[p]++;
    }

    cout << cntac << " " << cntwa << endl;
    return 0;
}


Measured memory_bytes: 640
n,k=map(int,input().split())
s = list(input())
cnt=0
now=s[0]
for i in range(1,n):
    if now==s[i]:continue
    else:
        cnt+=1
        now=s[i]

ans=n-1-cnt
#syo=cnt//2
#print(ans)
print(min(n-1,ans+2*k))


Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
string s;
int a[4],n;
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s;
		if(s=="AC") a[0]++;
		if(s=="WA") a[1]++;
		if(s=="TLE") a[2]++;
		if(s=="RE") a[3]++;
	}
	printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n",a[0],a[1],a[2],a[3]);
} 

Measured memory_bytes: 3764
def slove():
    import sys
    input = sys.stdin.readline
    a, b, c = list(map(int, input().rstrip('\n').split()))
    if a % 2 == 0 or b % 2 == 0 or c % 2 == 0:
        print(0)
    else:
        print(min(a * b, b * c, c * a))


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38384
#include <cmath>
#include <stdio.h>
#include <iostream>

using namespace std;

int main()
{
    int n, k;
    double ans = 0;
    scanf("%d %d", &n, &k);

    for(int i=1; i<=n; i++)
    {
        if(k < i)
        {
            ans = ans + (n-k);
            break;
        }
        //double p = ceil(log2(double(k)/double(i)));
        double p = ceil(log2((double)k/i));
        ans += pow(0.5, p);
    }
    ans /= n;

    printf("%.12f\n", ans);
}


Measured memory_bytes: 256
#include <stdio.h>
int Min(int a, int b){
    return a>b?b:a;
}
 void bubble_sort(int a[], int n)
 { 
    int res = 0; 
    for(int i = 0; i<n; i++){ 
        for(int j=n-1; j>=i+1;j--){ 
            if(a[j] < a[j-1]) { 
                int temp = a[j]; 
                a[j] = a[j-1]; 
                a[j-1] = temp; 
                res++; 
                
            } 
            
        } 
        
    }
 }
 int find(int a[], int b[], int i, int n){
     for(int k = 0; k < n; k++){
         if(a[i] == b[k]) return k;
     }
     
 }
int main()
{
    int n;
    scanf("%d",&n);
    int a[n+1];
    int b[n];
    int v[n+1];
    for(int i = 0; i<n; i++){
        scanf("%d",&a[i]);
        b[i] = a[i];
        v[i] = 0;
    }
    bubble_sort(b,n);
    int total_cost = 0;
    int min = 10005;
    for(int i = 0; i<n; i++){
        if(min>a[i]) min = a[i];
        int cost = 0;
        int length = 0;
        int min_cycle = 10005;
        if(v[i] == 1) continue;
        int temp = i;
        if(a[i] == b[i]) continue;
        while(a[temp]!=b[i]){
            v[temp] = 1;
            length++;
            cost+=a[temp];
            if(min_cycle>a[temp]) min_cycle = a[temp];
            temp = find(a,b,temp,n);
            
        }
        v[temp] = 1;
        length++;
        cost+=a[temp];
        if(min_cycle>a[temp]) min_cycle = a[temp];
        //printf("min:%d\n",min);
        //printf("min_cycle:%d\n",min_cycle);
        if(length>2)
        {cost = cost+Min((length-2)*min_cycle, min_cycle+min*(length+1));}
        total_cost += cost;
        if(min>min_cycle) min = min_cycle;
        
    }
    printf("%d\n",total_cost);
    return 0;
}


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

const string INF = "~";

class Edge {
public:
    int from, to;
    string cost;
    Edge(int f, int t, string c) :from(f), to(t), cost(c) {}
};

int n, a, s, g;
vector<Edge> edge;

string BellmanFord() {
    vector<string> memo(n, INF);
    memo[g] = "";
    for(int step = 0; step <= 6 * n; ++step) {
        for(const auto& e: edge) {
            int u = e.to;
            int v = e.from;
            string cost = e.cost;
            if(memo[u] == INF) continue;
            if(cost + memo[u] < memo[v]) {
                memo[v] = cost + memo[u];
                if(v == s && step >= n) return INF;
            }
        }
    }
    return memo[s];
}

int main() {
    while(cin >> n >> a >> s >> g, n | a | s | g) {
        edge.clear();
        for(int i = 0; i < a; ++i) {
            int x, y;
            string lab;
            cin >> x >> y >> lab;
            edge.push_back(Edge(x, y, lab));
        }
        string answer = BellmanFord();
        cout << (answer != INF ? answer : "NO") << endl;
    }
}

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

int main() {
  int N;
  cin >> N;
  int64_t ans = 0;
  for (int i = 0; i < N + 1; i++){
    if (i % 3 != 0 && i % 5 != 0){
      ans += i;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3672
#include <iostream>
#include <algorithm>
#define MAX 300000
using namespace std;

int a[MAX+1];
int l[MAX+2];
int main(void){
  	int N,Q;
 	cin >> N >> Q;

  	for(int i=0;i<N;i++){
    	int tmp;
    	cin >> tmp;
    	a[tmp]++;
  	}
  	int cmin=-1;

  	for(int i=0;i<=MAX+1;i++){
    	l[i]=cmin;
    	if(a[i])
      		cmin=i;
  	}

  	for(int i=0;i<Q;i++){
  		int mod,ans=0;
  		cin >> mod;
  		int j=l[MAX+1];
  		while(j!=-1){
  	  		ans=max(ans,j%mod);
  	  		j=l[j-j%mod];
  	  	}
    cout << ans << endl;
    }
}

Measured memory_bytes: 3504
#include <iostream>
#include <sstream>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <list>
#include <algorithm>
#include <ctime>
#include <limits>
#include <iomanip>
#include <functional>
#include <array>
#include <climits>
#include <cmath>

using namespace std;
using ll = long long;
const ll MOD = (ll)1e9 + 7;
const ll LL_MAX = 0x7fffffffffffffff;

int main()
{
    string s;
    cin >> s;
    int num = 0;
    int len = int(s.size());
    int c = s[0];
    int count = 1;
    for (int i = 1; i < len; i++)
    {
        if (c != s[i])
        {
            if (count > 1)
            {
                if (count & 1)
                {
                    num += count / 2;
                    c = s[i];
                }
                else
                {
                    num += count / 2 + 1;
                }
            }
            else
            {
                c = s[i];
            }
            count = 1;
        }
        else
        {
            count++;
        }
    }
    num += count / 2;
    cout << num;
    return 0;
}


Measured memory_bytes: 512
#他の方を参考したコード
#メモ用に提出
n = gets.chomp.to_i
 
a_b_arr = []
n.times do |i|
  a_b_arr << gets.chomp.split(" ").map(&:to_i)
end
 
c_d_arr = []
n.times do |i|
  c_d_arr << gets.chomp.split(" ").map(&:to_i)
end
 
a_b_arr.sort_by!{|(a, b)| -a }
c_d_arr.sort_by!{|(c, d)| d }
 
count = 0
a_b_arr.each do |(a, b)|
  index = -1
  c_d_arr.each_with_index do |(c, d), i|
    if a < c && b < d then
      index = i
      break
    end
  end
  if index != -1 then
    c_d_arr.delete_at(index)
    count += 1
  end
end
 
puts count

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


using namespace std;
typedef long long ll;
int main(){
    ll N; cin >> N;
    for(ll n = 1; n <= 3500; n++){
        for(ll h = 1; h<= 3500; h++){
            if(4 *h * n - N*h - N*n == 0) continue;
            if((N * h * n) % (4 *h * n - N*h - N*n) == 0){
                ll w = (N * h * n) / (4 *h * n - N*h - N*n);
                if(w < 0) continue;
                cout << h << " " << n << " " << w ;
                return 0;
            }

        }
    }


    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
A = []
for i in range(0,N):
	A.append(0)
for i in range(0,M):
	a, b = map(int, input().split())
	A[a-1] += 1
	A[b-1] += 1
for i in range(0,N):
	print(A[i])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define fast                                                                   \
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define ll long long
#define f(i, n) for (int i = 0; i < n; i++)
#define fo(i,a,n) for (i = a; i <= n; i++)
#define F first
#define S second
#define pii pair<int,int>
#define sz size()
#define all(v) v.begin(),v.end()
#define pb push_back
#define pf push_front    
#define PB pop_back
#define pll pair<long long, long long>
#define vi vector<int>
#define vl vector<int>
#define mp make_pair
#define mod 1000000007
typedef unsigned long long ull;
const int N = 200005;
const int MOD = 998244353 ;



void solve(){
    int n;
    cin>>n;
    set<string> s;
    map<string,int> m;
    f(i,n){
        string t;
        cin>>t;
        s.insert(t);
        m[t]++;
    }
    vector<pair<int,string> > v1;
    for(auto it = s.begin(); it != s.end(); it++){
        v1.pb(mp(m[*it],*it));
    }
    vector<string> ans;
    sort(all(v1));
    reverse(all(v1));
    f(i,v1.size()){
        if(v1[i].F == v1[0].F)ans.pb(v1[i].S);
        else break;
    }
    sort(all(ans));
    f(i,ans.size())cout<<ans[i]<<endl;
}

int32_t main() {
    fast
    int t;
    t = 1;
    //cin >> t;
    while(t--)solve();
    return 0;
}


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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rep1r(i, n) for (int i = ((int)(n)); i > 0; --i)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

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

    int n;
    cin >> n;
    ll a[n];
    for (int i = 0; i < n + 1; i++) {
        cin >> a[i];
    }
    ll b[n];
    rep(i, n) { cin >> b[i]; }

    ll sum = 0;
    for (int i = 0; i < n; i++) {
        ll temp = 0;
        if (b[i] > a[i]) {
            temp = b[i] - a[i];
            if (temp >= a[i + 1]) {
                sum += a[i] + a[i + 1];
                a[i + 1] = 0;
            } else {
                a[i + 1] -= temp;
                sum += a[i] + temp;
            }
        } else {
            sum += b[i];
        }
    }

    cout << sum << endl;

    return 0;
}


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

int main(){
  string S;
  cin>>S;
  int N=S.size();
  int res=0;
  
  for(int i=0;i<N-1;i++){
    if(S.at(i)!=S.at(i+1))
      res++;
  }
  
  cout<<res;
}

Measured memory_bytes: 512
import java.util.ArrayList;
import java.util.Scanner;

class Pair{
	int x;
	int y;
	public Pair(int x, int y) {
		super();
		this.x = x;
		this.y = y;
	}
	@Override
	public String toString() {
		return "Pair [x=" + x + ", y=" + y + "]";
	}
	public int getX() {
		return x;
	}
	public void setX(int x) {
		this.x = x;
	}
	public int getY() {
		return y;
	}
	public void setY(int y) {
		this.y = y;
	}
	
}

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		boolean flag=false;
		ArrayList<Pair> a=new ArrayList<Pair>();
		for(int i=0;i<n;i++) {
			a.add(new Pair(sc.nextInt(),sc.nextInt()));
		}
		boolean ans=false;
		for(int i=0;i<n-2;i++) {
			if(a.get(i).x==a.get(i).y) {
				if(a.get(i+1).x==a.get(i+1).y&&a.get(i+2).x==a.get(i+2).y) {
					ans=true;
					break;
				}
			}
		}
		
		if(ans==true) System.out.println("Yes");
		else System.out.println("No");
	}

}


Measured memory_bytes: 27304
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, W; cin >> N >> W;
	vector<int> v(N), w(N); rep(i, 0, N) { cin >> v[i] >> w[i]; }
	vector<int>dp(W + 1, 0);
	rep(i, 0, N)rep(j, w[i], W + 1)
		chmax(dp[j], dp[j - w[i]] + v[i]);
	cout << dp[W] << endl;
	return 0;
}

Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
int main() {
    // ifstream in("data.txt");
    // cin.rdbuf(in.rdbuf());
    int N;
    cin >> N;
    vector<int> v(N);
    int cnt = 0;
    for(int i = 0; i < N; ++i) {
        cin >> v.at(i);
        if(v.at(i) != i + 1) {
            cnt++;
        }
    }

    if(cnt == 2 || cnt == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
num= map(int, input().split())
A=list(num)
B=[]
for i in range(A[1]):
    snake=int(input())
    S= map(int, input().split())
    for n in S:
        B.append(n)
D=0
for x in range(1,A[0]+1):
    if x not in B:
        D =D+1
print(D)

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

const int N = 100000 + 5;

int n, s, t, d;
vector<int> g[N];

void dfs(int x, int fa, int dis, int &point) {
    if (dis > d) {
        d = dis;
        point = x;
    }
    for (int i = 0; i < g[x].size(); ++i) {
        int y = g[x][i];
        if (y == fa) continue;
        dfs(y, x, dis + 1, point);
    }
}

vector<int> path;
bool color[N];

bool find_path(int x, int fa) {
    path.push_back(x); color[x] = true;
    if (x == t) return true;
    for (int i = 0; i < g[x].size(); ++i) {
        int y = g[x][i];
        if (y == fa) continue;
        if (find_path(y, x)) return true;
    }
    path.pop_back(), color[x] = false;
    return false;
}

bool vis[N];
int cnt[N];
int ans1[N], ans2[N];

int main() {
    scanf("%d", &n);
    for (int i = 1, a, b; i < n; ++i) {
        scanf("%d%d", &a, &b);
        g[a].push_back(b), g[b].push_back(a);
    }
    dfs(1, 0, 0, s), d = 0, dfs(s, 0, 0, t);
    find_path(s, 0);
    for (int i = 0; i < path.size(); ++i) {
        int x = path[i];
        for (int j = 0; j < g[x].size(); ++j) {
            int y = g[x][j];
            vis[y] = true;
            if (!color[y]) ++cnt[i];
        }
    }
    for (int i = 1; i <= n; ++i) if (!vis[i]) { puts("-1"); return 0; }
    int pos = 1, id = 1;
    for (int i = 0; i < path.size(); ++i) {
        for (int j = 1; j <= cnt[i]; ++j)
            ans1[pos++] = id + j;
        ans1[pos++] = id;
        id += cnt[i] + 1;
    }
    pos = 1, id = 1;
    for (int i = path.size() - 1; i >= 0; --i) {
        for (int j = 1; j <= cnt[i]; ++j)
            ans2[pos++] = id + j;
        ans2[pos++] = id;
        id += cnt[i] + 1;
    }
    int t = 1;
    for (int i = 1; i <= n; ++i) if (ans1[i] < ans2[i]) { t = 1; break; } else if (ans1[i] > ans2[i]) { t = 2; break; }
    if (t == 1) for (int i = 1; i <= n; ++i) printf("%d%c", ans1[i], i == n ? '\n' : ' ');
    else for (int i = 1; i <= n; ++i) printf("%d%c", ans2[i], i == n ? '\n' : ' ');
    return 0;
}


Measured memory_bytes: 14072
/*
 * Author: .-O_O-.
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
//void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
													 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 1000000007;
const ll maxn = 2005;
const ll mm = 1e+18;
void solve()
{
	int n;
	cin>>n;
	int a[n+1];
	rep0(i,n+1) cin>>a[i];
	int x=0;
	int lo=a[n];
	int hi=a[n];
	vector<pair<int,int>>v(n+1);
	v[n]=make_pair(lo,hi);
	//v.pb({lo,hi});
	for(int i=n-1;i>=0;i--){
		lo=(lo+1)/2+a[i];
		hi=hi+a[i];
		v[i]=make_pair(lo,hi);
	}
	if(lo!=1){
		pr(-1);
		return;
	}
	int ans=0;
	int f=1;
	rep0(i,n+1){
		f=min(f,v[i].s);
		//deb(f,v[i]);
		ans+=f;
		f-=a[i];
		f*=2;
		//f=min(f,v[i].s);
	}
	//ans+=f;
	pr(ans);
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        //nx;
    }
    return 0;
}


Measured memory_bytes: 5556
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll int ara[100003],mark[100003];
int main() {
    ll int n,k,q,x,l=1,i;
    cin>>n>>k>>q;
    for(i=1; i<=n; i++)
        ara[i]=k;

  
      for(int i=1;i<=q;i++){
        cin>>x;
        mark[x]++;

    }

    for (int i=1; i<=n; i++) {

        x=q-mark[i];
        ara[i]=ara[i]-x;
        if(ara[i]>0)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }

    return 0;

}



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

using namespace std;

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

#define N 100010
#define M 200010
#define endl "\n"
#define mod 1000000007 

ll dp[N][2];
ll a[N], b[N];

int main(){
	
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(NULL);
	
	ll n;
	
	cin >> n;
	
	string ans = "";
	while(n){
		ll r = n % 26;
		
		if(r == 0){
			ans = "z" + ans;
			n--;
		}
		else{
			ans = (char)('a' + r - 1) + ans;
		}
		
		n /= 26;
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};

#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)

#define mp make_pair
#define fi first
#define se second

#define bit(n) (1LL<<(n))

i64 n,a;
char var;

i64 dp[5005][5005];


void Main()
{
  cin >> n;
  a = 0LL;
  while(cin>>var) a++;

  rep(i,n+1) rep(j,n+1) dp[i][j] = 0LL;
  dp[0][a] = 1LL;

  rep(i,n) rep(j,n+1){
    if(j==0){
      dp[i+1][j] += dp[i][0];
      dp[i+1][j] %= MOD;
    }
    if(0<j){
      dp[i+1][j] += dp[i][j-1]*2;
      dp[i+1][j] %= MOD;
    }
    if(j<n){
      dp[i+1][j] += dp[i][j+1];
      dp[i+1][j] %= MOD;
    }
  }

  cout << dp[n][0] << "\n";
}

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


Measured memory_bytes: 195840
N,M,V,P=map(int,input().split())
import numpy as np
A=np.array(sorted(map(int,input().split())))
ng,ok=-1,N-P+1
while ng+1<ok:
    t=(ng+ok)//2
    if A[t]+M<A[-P] or np.sum(np.minimum(M,A[t]+M-A[t+1:N-P+1]))<M*(V-P-t):
        ng=t
    else:
        ok=t
print(N-ok)

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

using namespace std;

const int N=55;

void maxi(int &a, int b) {
	a = max(a,b);
}

using ll = long long;
ll MOD = 1e9 +7;

ll add(ll x, ll y) {
	return ((x + y) % MOD);
}


int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);	
	vector<ll> X;
 	vector<ll> Y;
	int n, m; cin >> n >> m;
	for (int i=0; i < n; i++) {
		ll x; cin >> x;
		X.push_back(x);
	}
	for (int i=0; i < m; i++) {
		ll y; cin >> y;
		Y.push_back(y);
	}
	ll x_total = 0;
	for (int k=0; k <n; k++) {
		x_total += add(X[k]*k, -(n-k-1)*X[k]);	
		x_total %= MOD;
	}
	//ll x_check =0;
	//for (int i=0; i < n; i++) {
	//	for (int j=i+1; j < n; j++) {
	//		x_check += (X[j] - X[i]);
	//	}
	//}
	//assert(x_check == x_total);
	ll y_total = 0;
	for (int k=0; k < m; k++) {
		y_total += add(Y[k]*k, -(m-k-1)*Y[k]);	
		y_total %= MOD;
	}
	//ll y_check = 0;
	//for (int i=0; i < m; i++) {
	//	for (int j=i+1; j < m; j++) {
	//		y_check += (Y[j] - Y[i]);
	//	}
	//}
	//assert(y_check == y_total);
	ll total = (x_total*y_total) % MOD;
	if (total < 0) {
		total += MOD;
	}
	cout << total << endl;
}



Measured memory_bytes: 2548
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define ll long long
#define ld long double
#define oo 2e18
#define OS tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define file freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 1e2 + 5;
int n, k, a[N];

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> k;
    for (int i = 0; i < k; i++) {
        int j;
        cin >> j;
        while (j--) {
            int b;
            cin >> b;
            a[b]++;
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (a[i] == 0) {
            ans++;
        }
    }
    cout << ans << "\n";
    return 0;
}

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

const int maxn = 305, P = 1e9+7;
typedef long long ll;

int n, a[maxn<<1], b[maxn<<1], v[maxn<<1];
int f[maxn<<1][maxn][maxn];

int dp(int i, int j, int k) {
	if (j < 0 || j >= maxn || k < 0 || k >= maxn) return 0;
	if (i > 2*n) return (j == 0 && k == 0);
	if (v[i]) return dp(i+1,j,k);
	if (f[i][j][k] != -1) return f[i][j][k];
	if (b[i]) {
		f[i][j][k] = ((ll)dp(i+1,j,k+1)+dp(i+1,j-1,k))%P;
	} else {
		f[i][j][k] = ((ll)dp(i+1,j,k-1)+(ll)(j+1)*dp(i+1,j+1,k)+dp(i+1,j,k+1))%P;
	}
//	printf("f[%d][%d][%d] = %d\n", i, j, k, f[i][j][k]);
	return f[i][j][k];
}

int main() {
	scanf("%d", &n);
	for (int i = 0; i < 2*n; ++i) {
		scanf("%d", a+i);
		if (a[i] != -1) b[a[i]] = 1;
	}
	int cnt = 0;
	for (int i = 0; i < n; ++i) {
		if (a[2*i] != -1 && a[2*i+1] != -1) {
			v[a[2*i]] = v[a[2*i+1]] = 1;
		}
		if (a[2*i] == -1 && a[2*i+1] == -1) cnt++;
	}
	memset(f, -1, sizeof(f));
	int fact = 1;
	for (int i = 1; i <= cnt; ++i) fact = (ll)i*fact%P;
	cout << (ll)dp(1, 0, 0)*fact%P << endl;
}


Measured memory_bytes: 221952
L,R=map(int,input().split())

ans=2019
for i in range(L,min(R,L+2018)):
    for j in range(i+1,min(R+1,L+2019)):
        mod = (i*j) % 2019
#        print(str(i)+' '+str(j)+' '+str(mod))
        if mod == 0:
            ans = 0
            break
        if mod < ans:
            ans = mod
print(ans)


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

using namespace std;
//vector<long long> factors;
#define ll long long

#define pii pair<int,int>
#define pll pair<ll,ll>
#define _ <<'\n'
#define __ << ' '
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
int IT_MAX = 1 << 17;
int MOD = 998244353;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x0f3f3f3f3f3f3f3f;
const double PI = acos(-1);
const double ERR = 1e-10;
#define szz(x) (int)(x).size()
#define IOS ios_base::sync_with_stdio(false); cout.tie(0);cin.tie(0);
#define flush fflush(stdout)

ll mod(ll a, ll m) { return (a + (abs(a) / m) * m + m) % m; }

//****************************don't use int!!!!!!!****************************//
//***************************code starts here!!!!!****************************//


int main() {
    IOS

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

    for(auto& st : vs){
        sort(all(st));
    }

    sort(all(vs));

    ll ans = 0;

    for(int i = 0;i < n; ++i){
        ll cur_cnt = 0;
        int cur_i = i;
        while(cur_i < n && vs[i] == vs[cur_i]){
            ++cur_i;
            ++cur_cnt;
        }
        i = cur_i - 1;
        ans += (cur_cnt) * (cur_cnt - 1) / 2;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int (i)=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1000000007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }


int main(){
    int N;
    cin >> N;
    vector<int> S(1<<N);
    REP(i, (1<<N)) cin >> S[i];
    sort(S.begin(), S.end(), greater<int>());

    multiset<int> A, B;
    A.insert(S[0]);
    REP(i, 1, (1<<N)) B.insert(S[i]);
    while(!B.empty()){
        auto AA = A;
        for(auto itr=AA.rbegin(); itr!=AA.rend(); itr++){
            int a = *itr;
            auto itr2 = B.lower_bound(a);
            if(itr2==B.begin()){
                cout << "No" << endl;
                return 0;
            }
            itr2--;
            A.insert(*itr2);
            B.erase(itr2);
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 19712
#include <iostream>
#include <string>

#include <math.h>
#include <algorithm>
#include <set>
#include <vector>
using namespace std;


int sign(int i) {
	
	if (i == 0) {

		return 1;
	}
	else {

		return -1;
	}
}

char sign_c(int i) {
	
	if (i == 0) {

			return '+';
	}
	else {

		return '-';
	}

}


int main()
{
	//ソース300
	//Train Ticket
	//文字型と数値型は刻み幅が同じの相対座標なので
	//和か差で7になるように符号を入れ替える
	string str;
	int a[4];
	cin >> str;

	a[0] = str[0] - '0';
	a[1] = str[1] - '0';
	a[2] = str[2] - '0';
	a[3] = str[3] - '0';

	//2^3通りの全探索を行う
	int total = 0;
	//出力を記録する変数
	int p, q, r;

	//インデックスが偶数で足し算、奇数で引き算と決めて全組み合わせ
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < 2; j++) {
			for (int k = 0; k < 2; k++) {

				total = a[0] + sign(i)* a[1] + sign(j)*a[2] + sign(k) * a[3];
				
				if (total == 7) {
					//符号を記録
					p = i;
					q = j;
					r = k;
					break;
				}
			}
		}	
	}
	cout << a[0] << sign_c(p) << a[1] << sign_c(q) << a[2] << sign_c(r) << a[3] << "=7" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(void) {
	char s[4];
	scanf("%s",s);
	int i,frag[3]={};
	for(i=0;i<3;i++){
		frag[s[i]-'a']++;
	}
	for(i=0;i<3;i++){
		if(frag[i]!=1){
			printf("No\n");
			break;
		}
	}
	if(i==3){
		printf("Yes\n");
	}
	return EXIT_SUCCESS;
}


Measured memory_bytes: 128
#include<stdio.h>

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

  scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

  if(x+r > W || y+r > H || x-r < 0 || y-r < 0)
    printf("No\n");
  else
    printf("Yes\n");

  return 0;
}

Measured memory_bytes: 584
#include<bits/stdc++.h>
#define MAXN 200010
using namespace std;
int n,Q,ans[MAXN];
vector<int> G[MAXN];
void DFS(int x,int fa){
	ans[x]+=ans[fa];
	for(int i=0;i<G[x].size();i++){
		int t=G[x][i];
		if(t==fa)continue;
		DFS(t,x);
	}
}
int main(){
	scanf("%d %d",&n,&Q);
	for(int i=1;i<=n-1;i++){
		int x,y;
		scanf("%d %d",&x,&y);
		G[x].push_back(y);
	}
	for(int i=1;i<=Q;i++){
		int x,p;
		scanf("%d %d",&x,&p);
		ans[x]+=p;
	}
	DFS(1,0);
	for(int i=1;i<=n;i++)printf("%d ",ans[i]);
	return 0;
}

Measured memory_bytes: 23424