akhauriyash/Code-Regression huggingface dataset:
n, m, c = list(map(int, input().split()))

B = list(map(int, input().split()))

A = []
for i in range(n):
    A.append(list(map(int, input().split())))

score_list=[]
for a in A:
    score = 0
    for _a, _b in zip(a,B):
        score += _a * _b
    score += c
    score_list.append(score)

# print(A)
# print(score_list)

print(sum([1 if i>0 else 0 for i in score_list]))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  char a;
  cin >> a;
  char vo[] = {'a','i','u','e','o'};
  for(int i=0; i<5; i++){
    if(a==vo[i]){
      cout << "vowel" << endl;
      return 0;
    }
  }
  cout << "consonant" << endl;
  return 0;
}


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


int main()
{
  int N;
  int a[1000];

  while(cin >> N, N) {
    vector< int > nums;
    for(int i = 0; i < N; i++) {
      string S;
      cin >> S;
      if(S == "x") {
        a[i] = (1 << 30);
      } else {
        a[i] = stoi(S);
        for(int j = -2; j <= 2; j++) nums.push_back(a[i] + j);
      }
    }
    sort(nums.begin(), nums.end());
    nums.erase(unique(nums.begin(), nums.end()), nums.end());

    int ret = 0;
    vector< int > ans;
    for(int i = 0; i < nums.size(); i++) {
      int& x = nums[i];
      bool flag = true;
      for(int j = 1; j < N; j++) {
        int prevcur = (a[j - 1] == (1 << 30) ? x : a[j - 1]);
        int realcur = (a[j] == (1 << 30) ? x : a[j]);
        if(j & 1) flag &= prevcur < realcur;
        else flag &= prevcur > realcur;
      }
      ret += flag;
      if(flag) ans.push_back(nums[i]);
    }
    if(ret == 0) cout << "none" << endl;
    else if(ret == 1) cout << ans[0] << endl;
    else cout << "ambiguous" << endl;
  }
}

Measured memory_bytes: 3252
//#include "stdafx.h"
#include <iostream>

using namespace std;

void func139b() {
    int a, b;
    cin >> a;
    cin >> b;

    int count = 0;
    b--; //開始時にある1つの差し込み口をカウント
    while (b > 0) {
        if (b - a + 1<= 0) {
            ++count;
            break;
        }
        b -= a - 1;
        ++count;
    }

    cout << count;

}

int main() {
    func139b();

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll n,k,ans=0;
void Main(){
    cin>>n>>k;
    vector<ll> a(n),f(n);
    For(i,0,n)cin>>a.at(i);
    For(i,0,n)cin>>f.at(i);
    sort(ALL(a));
    sort(ALL(f));
    reverse(ALL(f));
    ll left=0,right=0;
    For(i,0,n){
        right=max(right,a.at(i)*f.at(i));
    }
    while(left!=right){
        ll center=(left+right)/2;
        ll kaisuu=0;
        For(i,0,n){
            if(a.at(i)*f.at(i)>center){
                kaisuu+=a.at(i)-center/f.at(i);
            }
        }
        if(kaisuu>k){
            if(right-left==1){
                left++;
            }
            else left=center;
        }
        else{
            if(right-left==1){
                right--;
            }
            else right=center;
        }
    }
    ans=right;
    cout<<ans<<endl;
}
int main(){
    Main();
    return 0;
}


Measured memory_bytes: 3328
#include <iostream>
using namespace std;
const int mod=1e9+7;
int main()
{
    int n,m,dp[1005][1005];
    char mat[1005][1005];
    cin >> n >> m;
    for (int i=1;i<=n;i++)
    {
        for (int j=1;j<=m;j++)
        {
            char c;
            cin >> c;
            mat[i][j]=c;
            if (c=='.') dp[i][j]=1;
            else if (c=='#') dp[i][j]=0;
        }
    }
    for (int i=2;i<=m;i++)
    {
        if (mat[1][i]!='#') dp[1][i]=dp[1][i-1];
    }
    for (int i=2;i<=n;i++)
    {
        if (mat[i][1]!='#') dp[i][1]=dp[i-1][1];
    }
    for (int i=2;i<=n;i++)
    {
        for (int j=2;j<=m;j++)
        {
            if (mat[i][j]=='.') dp[i][j]=(dp[i][j-1]+dp[i-1][j])%mod;
        }
    }
    cout << dp[n][m];
}

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


int main(){


  int x;

  cin>>x;


  // 整数どうしの割り算は小数点が切り捨てられます

  // x%60 で xを60で割ったあまりを計算できます

  int h = x / 3600;

  int m = (x / 60) % 60;

  int s = x % 60;

  cout<<h<<":"<<m<<":"<<s<<endl;


  return 0;
}



Measured memory_bytes: 3116
#include<stdio.h>
int main(void)
{
    int w,h,x,y,r,f;
    scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);

    f=0;
    if(x+r>w)f=1;
    if(y+r>h)f=1;
    if(r>x)f=1;
    if(r>y)f=1;

    if(f==0)printf("Yes\n");
    else printf("No\n");

    return 0;
}


Measured memory_bytes: 2104
#include "bits/stdc++.h"
using namespace std;

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

    int A = N / 1000;
    int B = N / 100 - A * 10;
    int C = N / 10 - A * 100 - B * 10;
    int D = N % 10;

    if (A + B + C + D == 7) {
        cout << A << "+" << B << "+" << C << "+" << D << "=7" << endl;
    }
    else if (A + B + C - D == 7) {
        cout << A << "+" << B << "+" << C << "-" << D << "=7" << endl;
    }
    else if (A + B - C + D == 7) {
        cout << A << "+" << B << "-" << C << "+" << D << "=7" << endl;
    }
    else if (A + B - C - D == 7) {
        cout << A << "+" << B << "-" << C << "-" << D << "=7" << endl;
    }
    else if (A - B + C + D == 7) {
        cout << A << "-" << B << "+" << C << "+" << D << "=7" << endl;
    }
    else if (A - B + C - D == 7) {
        cout << A << "-" << B << "+" << C << "-" << D << "=7" << endl;
    }
    else if (A - B - C + D == 7) {
        cout << A << "-" << B << "-" << C << "+" << D << "=7" << endl;
    }
    else if (A - B - C - D == 7) {
        cout << A << "-" << B << "-" << C << "-" << D << "=7" << endl;
    }
}

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

int main() {
  int n,k,r,s,p;
  int64_t ans=0;
  string t;
  cin >> n >> k >> r >> s >> p >> t;
  vector<bool> flg(n,false);
  for(int i=0;i<n;i++){
    if (i>=k && t[i] == t[i-k] && flg[i-k]) continue;
    if (t[i] == 'r') ans += p;
    if (t[i] == 's') ans += r;
    if (t[i] == 'p') ans += s;
    flg[i] = true;
  }
  cout << ans << endl;
}


Measured memory_bytes: 512
///https://atcoder.jp/contests/dp/tasks/dp_d

#include<bits/stdc++.h>
#define ll long long int  
using namespace std;

ll max(ll a, ll b) { return (a > b)? a : b; } 

void d_knapsack1(ll W,ll wt[],ll val[],ll n)
{
	ll dp[n+1][W+1]; 			
	for(int i=0;i<=n;i++)
	{
		for(int w=0;w<=W;w++)
		{
			if(i==0 || w==0)
			{
				dp[i][w]=0;
			}
			else if(wt[i-1]<=w)
			{
				dp[i][w]=max(val[i-1]+dp[i-1][w-wt[i-1]],dp[i-1][w]);
			}
			else
			{
				dp[i][w]=dp[i-1][w];
			}
		}
	}
	cout<<dp[n][W];
	return;
}

int main()
{
	ll n,w;
	cin>>n>>w;
	ll wt[n],val[n];
	ll wei,va;
	for(int i=0;i<n;i++)
	{
		cin>>wei>>va;
		wt[i]=wei;
		val[i]=va;
	}
	d_knapsack1(w,wt,val,n);
}

Measured memory_bytes: 79104
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())




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

	string s;
	cin>>s;

	cout << (s.find("AC")!=string::npos ? "Yes":"No")<<endl;

	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <istream>
#include <ostream>

#include <cstdlib>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define rep(i,n) for(ll i=0; i < (n); ++i)
#define rrep(i,n) for(ll i=((n)-1); i >= 0; --i)

#define OPLT(T) bool operator<(const T & lop_, const T & rop_)
#define OPEQ(T) bool operator==(const T & lop_, const T & rop_)

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

istream& operator>>(istream& istr, __float128& obj) { double d; istr >> d; obj = d; return istr; };
ostream& operator<<(ostream& ostr, __float128& obj) { ostr << static_cast<double>(obj); return ostr; };

int N;
vector<int> A;
vector<vector<int> > E;

int solve(int n, int p, bool & flg) {
	if(E[n].size() == 1)
		return A[n];
	ll s = 0;
	ll mx = 0;
	rep(i,E[n].size()) {
		if(E[n][i] == p) continue;
		ll tmp;
		tmp = solve(E[n][i], n, flg);
		s += tmp;
		mx = max(mx,tmp);
	}
	ll I, O;
	I = s - A[n];
	O = A[n] - I;
	if(I < 0 || O < 0 || (I > s-mx && mx*2 > s)) flg = false;
	return O;
}

int main() {
	int root;
	cin >> N;
	A.resize(N); E.resize(N);
	rep(i,N) cin >> A[i];
	rep(i,N-1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		E[a].push_back(b);
		E[b].push_back(a);
	}
	for(root = 0; root < N; root++) {
		if(E[root].size() > 1)
			break;
	}
	bool flg = true;
	int res;
	if(N > 2)
		res = solve(root,-1,flg);
	else
		res = A[0] != A[1];
	if(flg && !res)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 12800
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <string.h>

using namespace std;
typedef pair<int, int> P;


long long calc(long long X)
{
	if (X % 4 == 0)
	{
		return(X);
	}
	else if (X % 4 == 1)
	{
		return(1);
	}
	else if (X % 4 == 2)
	{
		return(X + 1);
	}
	return(0);
}

void solve()
{
	long long int A, B;
	cin >> A >> B;
	long long A1 = calc(A - 1);
	long long B1 = calc(B);
	long long ans = B1 ^ A1;
	cout << ans << endl;
}

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

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
using namespace std;
int main() {
    long long x;
    cin >> x;
    long long i = 100;
    int ans=0;
    while(i < x){
        i += i/100;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int d,n;
    scanf("%d%d",&d,&n);
    if(d==0)
    {
        if(n!=100) printf("%d\n",n);
        else printf("101\n");
    }
    else if(d==1)
    {
        if(n!=100) printf("%d\n",100*n);
        else printf("%d\n",101*100);
    }
    else
    {
        if(n!=100) printf("%d\n",n*10000);
        else printf("%d\n",101*10000);
    }
}


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

const int MAX_N = 1010;

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

    int n;
    while(cin >> n && n){

        for(int i = 0; i < n; ++i){
            int x1, y1, z1, w1;
            int x2, y2, z2, w2;
            cin >> x1 >> y1 >> z1 >> w1;
            cin >> x2 >> y2 >> z2 >> w2;

            int x3 = x1 * x2 - y1 * y2 - z1 * z2 - w1 * w2;
            int y3 = x1 * y2 + y1 * x2 + z1 * w2 - w1 * z2;
            int z3 = x1 * z2 + z1 * x2 - y1 * w2 + w1 * y2;
            int w3 = x1 * w2 + w1 * x2 + y1 * z2 - z1 * y2;

            cout << x3 << " " << y3 << " " << z3 << " " << w3 << endl;
        }
    }

   return 0;
}

/*
(x1+y1+z1+w1)*(x2+y2+z2+w2)=
x1*x2 + x1*y2 + x1*z2 + x1*w2 +
y1*x2 + y1*y2 + y1*z2 + y1*w2 +
z1*x2 + z1*y2 + z1*z2 + z1*w2 +
w1*x2 + w1*y2 + w1*z2 + w1*w2
*/

Measured memory_bytes: 1196
#include <iostream>
#include <stdlib.h>
#include <math.h>

int main() {
    
    int seconds = 0;
    int h,m,s;
    div_t result;
    
    std::cin >> seconds;
    result = div(seconds, 3600);
    h = result.quot;
    
    result = div(result.rem, 60);
    m = result.quot;
    
    s = result.rem;
    
    std::cout << h << ":" << m << ":" << s << "\n";
    return 0;
}



Measured memory_bytes: 3108
/**
 *    Creator :  bizarre
 *    Date : 5/2020
 *    Problem Number : 536
**/
#include <bits/stdc++.h>
using namespace std;
#define bizarre  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define ll long long
#define ld long double
/*
vector<int> prime_Numbers;
bool primes[1000005];
void prime(int n)
{
    primes[1]=primes[0]=0;
    for(int i=2; i<=n; i++)
        primes[i]=true;
    for(int i=2; i<=n; i++)
    {
        if(primes[i]==true)
        {
            prime_Numbers.push_back(i);
            for(int j=i+i; j<=n; j+=i)
                primes[j]=false;
        }
    }
}
void move1step(long long& a, long long& b, long long q)
{
    long long c= a-q*b;
    a=b;
    b=c;
}
long long egcd(long long r0,long long r1,long long& x0,long long& y0)
{
    long long x1=0,y1=1;
    x0=1;
    y0=0;
    while(r1)
    {
        long long q=r0/r1;
        move1step(r0,r1,q);
        move1step(x0,x1,q);
        move1step(y0,y1,q);
    }
    return r0;
}
bool  solve (long long a, long long b, long long c,long long&x, long long& y)
{
    long long g=egcd(a,b,x,y);
    int m=c/g;
    x*=m;
    y*=m;
    return c%g==0;
}
int gcd(int a, int b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}
void PrimeFactorization(int n)
{
    for(int i=2; i*i<=n; i++)
    {
        int c=0;
        if(n%i==0)
        {
            while(n%i==0)
            {
                n/=i;
            }

        }
    }

}
long long ncrtane(long long n, long long r)
{
    long long ans=1,cntr=1;
    for(int i=n; i>n-r; i--)
    {
        ans*=i;
        ans/=cntr;
        cntr++;
    }
    return ans;
}
const int N = 1e6 + 5, inf = 2e9, mod = 1e9 + 7;
long long fp(long long base, long long exp)
{
    if (exp == 0)
        return 1;
    long long ans = fp(base, exp / 2);
    ans = (ans * ans) % mod;
    if (exp % 2 != 0)
        ans = (ans * (base % mod)) % mod;
    return ans;
}
long long fact[N], inv[N];
void pre(long long n)
{
    fact[0] = 1;
    inv[0] = 1;
    for (long long i = 1; i <= n; i++)
    {
        fact[i] = (i * fact[i - 1]) % mod;
        inv[i] = fp(fact[i], mod - 2);
    }
}
int ncr(long long n, long long r)
{
    return (((fact[n] * inv[n - r]) % mod) * inv[r]) % mod;
}

int npr(long long n, long long r)
{
    return (fact[n] * inv[n - r]) % mod;
}
*/
int main()
{

    bizarre
     ll a,b,c,k;
     cin >> a >> b >> c >> k;
     ll ans=min(k,a);
     k-=min(k,a);
     k-=min(k,b);
     ans-=min(k,c);
     k-=min(k,c);
     cout << ans;
    return 0;
}


Measured memory_bytes: 3640
N,M=map(int,input().split())
s,c=[],[]
for i in range(M):
    x=list(map(int,input().split()))
    s.append(x[0])
    c.append(x[1])
    
if N==3:
    down=100
    up=1000
elif N==2:
    down=10
    up=100
else:
    down=0
    up=10
ans=-1

for i in range(down,up):
    num=list(str(i))
    x=True
    for j in range(M):
        if num[(s[j]-1)]!=str(c[j]):
            x=False
    if x:
        ans=i
    if ans!=-1:
        break
print(ans)

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

int main(){
	

	int n;
	cin >> n;
	std::vector<int> v(n);
	for(int i = 0; i < n; ++i){
		cin >> v[i];
	}
	ll sum = 0;
	std::vector<ll> pre(n);
	pre[0] = v[0];
	for(int i = 1; i < n; ++i){
		pre[i] = (pre[i-1]%mod+v[i]%mod)%mod;
	}
	// cout << pre[0]<< pre[1] << pre[2];
	for(int i = 0; i < n; ++i){
		sum = (sum % mod + (((pre[n-1]-pre[i] + mod)%mod ) * v[i]%mod))%mod;
	}
	cout << sum ;
	return 0;
}

Measured memory_bytes: 5632
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define inf  1000000000
#define mod  1e9+1
#pragma GCC optimization ("O3")
using namespace std;
const long long int N = 6999999;
#define all(x) begin(x),end(x)
int main()
{
 
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n;
  cin >> n;
  vector<int>A(n),B(n),C(n-1);
  for (int i = 0; i < n; ++i)
  {
    cin >> A[i];
    A[i]--;
  }
  int ans =0;
  for (int i = 0; i < n; ++i)
  {
    cin >> B[i];
    ans += B[i];
  }
  for (int i = 0; i < n-1; ++i)
  {
    cin >> C[i];
  }
  for (int i = 0; i < n; ++i)
  {
    if (i > 0 && A[i] == A[i-1]+1)
    {
      ans += C[A[i-1]];
    }
  }
  cout << ans << endl;
	return 0;
}	

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <climits>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define si(x) int x = scanInt();
#define sll(x) LL x = scanLong();
#define sci(x) int x; scanf("%d", &x);
#define scll(x) LL x; scanf("%lld", &x);
#define pi(x) printf("%d ", x)
#define pll(x) printf("%lld ", x)
#define nl printf("\n")
#define clr(a) memset(a, 0, sizeof(a))
#define PB push_back
#define MP make_pair
using namespace std;
typedef unsigned int UI; // 32 bit integer
typedef long int LI; // 32 bit integer
typedef unsigned long int ULI; // 32 bit unsigned integer
typedef long long int LL; // 64 bit integer
typedef unsigned long long int ULL; // 64 bit unsigned integer
typedef long double LD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef deque<int> DI;
typedef deque<LL> DLL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const LL MOD = 1e9+7;

/* Fast I/O */
inline int scanInt() {
	int n = 0;
	char ch = getchar();
	int sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(int)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

inline LL scanLong() {
	LL n = 0;
	char ch = getchar();
	LL sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(LL)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

int main() {
	sll(n);
	LL A[n], B[n-1];
	rep(i, 0, n-1)	B[i] = scanLong();
	rep(i, 0, n)	A[i] = min((i > 0 ? B[i-1] : LONG_MAX), (i < n-1 ? B[i] : LONG_MAX));
	LL ans = accumulate(A, A+n, 0ll);
	pll(ans); nl;
}


Measured memory_bytes: 256
object Main {
  def main(args:Array[String]) = {
   // val seq = readLine.split("")
    val input=io.Source.stdin.getLines().mkString("\n")
    println(solve(input).toString.trim())
  }


def solve(aaa:String): Int={
  val seq = aaa.split(" ").map(_ .toInt)
  val n = seq(0)
  val l = seq(1)
  val rag= (0 until n).toList.map(_ +l)
  var mins = if (rag.contains(0)){
  	0
  } else if(rag.min > 0 ){
  	rag.min
  }else{
    rag.max
  }
  rag.sum - mins
}
}

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

using namespace std;

int C[110];
int memo[110][100010];
const int M = 1e9 + 7;
int N;

// int solve(int index, int k) {
//     if (index == N) return k == 0;
//     int& res = memo[index][k];
//     if (res != -1) return res;
//     res = 0;
//     for (int i = 0; i <= min(k, C[index]); i++) {
//         res += solve(index + 1, k - i);
//         res %= M;
//     }
//     return res;
// }

void add_self(int& a, int b) {
    a += b;
    if (a >= M) {
        a -= M;
    }
}

void sub_self(int& a, int b) {
    a -= b;
    if (a < 0) {
        a += M;
    }
}

int main(int argc, char *argv[])
{
    int K;
    cin >> N >> K;
    // for (int i = 0; i < N; i++) {
    //     cin >> C[i];
    // }
    // memset(memo, -1, sizeof memo);
    // cout << solve(0, K) << endl;
    vector<int> dp(K + 1);
    dp[0] = 1;
    for (int child = 0; child < N; child++) {
        int up_to;
        cin >> up_to;
        vector<int> fake(K + 1);
        for (int used = K; used >= 0; used--) {
            int tmp = dp[used];
            int L = used + 1;
            int R = used + min(up_to, K - used);
            if (L <= R) add_self(fake[L], tmp);
            if (R + 1 <= K) sub_self(fake[R + 1], tmp);
        }
        int prefix = 0;
        for (int k = 0; k <= K; k++) {
            add_self(prefix, fake[k]);
            add_self(dp[k], prefix);
        }
    }
    cout << dp[K] << endl;
    return 0;
}


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

using namespace std;

const int N = 2e5 + 10;

struct SegTree {
  int mx[N << 2];
  
  void pushup(int x) { mx[x] = max(mx[x<<1], mx[x<<1|1]); }

  void mdf(int x, int l, int r, int p, int v) {
    if (l == r) {
      mx[x] = v;
      return;
    }
    int mid = (l + r) >> 1;
    if (p <= mid) mdf(x<<1, l, mid, p, v);
    else mdf(x<<1|1, mid + 1, r, p, v);
    pushup(x);
  }
  
  int qry(int x, int l, int r, int ql, int qr) {
    if (ql > qr) return 0;
    if (ql <= l && r <= qr) return mx[x];
    int mid = (l + r) >> 1, ans = 0;
    if (ql <= mid) ans = max(ans, qry(x<<1, l, mid, ql, qr));
    if (mid < qr) ans = max(ans, qry(x<<1|1, mid + 1, r, ql, qr));
    return ans;
  }
  
  void build(int x, int l, int r) {
    mx[x] = 0;
    if (l == r) return;
    int mid = (l+r) >> 1;
    build(x<<1, l, mid);
    build(x<<1|1, mid + 1, r);
  }
} T;

int a[N], val[N], tot, n;
vector<int> e[N];

int ans[N];

void dfs(int u, int ff) {
  ans[u] = T.qry(1, 1, tot, 1, a[u]-1) + 1;
  int lst = T.qry(1, 1, tot, a[u], a[u]);
  if (ans[u] > lst) T.mdf(1, 1, tot, a[u], ans[u]);
  ans[u] = max(ans[u], ans[ff]);
  for (auto v : e[u]) if (v != ff) dfs(v, u);
  T.mdf(1, 1, tot, a[u], lst);
}

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), val[++tot] = a[i];
  for (int i = 1; i < n; i++) {
    int u, v; scanf("%d%d", &u, &v);
    e[u].push_back(v);
    e[v].push_back(u);
  }
  sort(val + 1, val + n + 1);
  tot = unique(val + 1, val + n + 1) - val - 1;
//  cerr << tot << endl;
  for (int i = 1; i <= n; i++) a[i] = lower_bound(val + 1, val + tot + 1, a[i]) - val;
  T.build(1, 0, tot), dfs(1, 0);
  for (int i = 1; i <= n; i++) printf("%d\n", ans[i]);
  return 0;
} 


Measured memory_bytes: 31284
import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
from functools import lru_cache
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7 

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


def main():
    N, M = read_values()
    S = read_list()
    T = read_list()

    dp = [[0 for _ in range(M + 1)] for _ in range(N + 1)]

    for i in range(N + 1):
        dp[i][0] = 1
    
    for j in range(M + 1):
        dp[0][j] = 1

    for i in range(N):
        for j in range(M):
            dp[i + 1][j + 1] = (dp[i][j + 1] + dp[i + 1][j] - (dp[i][j] if S[i] != T[j] else 0)) % mod
    
    print(dp[N][M])


if __name__ == "__main__":
    main()



Measured memory_bytes: 108780
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String ss[] = new String[4];
    for(int i = 0;i<4;i++){
      ss[i] = s.substring(i,i+1);
    }
    for(int i = 0;i<3;i++){
      if(ss[i].equals(ss[i+1])){
        System.out.println("Bad");
        return ;
      }
    }
    System.out.println("Good");
  }
}


Measured memory_bytes: 21844
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, cos, radians, pi, sin
from operator import mul
from functools import reduce
from operator import mul


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]


n = I()
P = LI()
L = [[min(x, y, n - x - 1, n - y - 1) for x in range(n)] for y in range(n)]
flg = [[1] * n for _ in range(n)]
ans = 0
for i in P:
    xi = (i - 1) % n
    yi = (i - 1) // n
    ans += L[yi][xi]
    flg[yi][xi] = 0
    q = [((i - 1) // n,  (i - 1) % n)]
    while q:
        a, b = q.pop()
        val = L[a][b] + flg[a][b]
        if a >= 1 and L[a - 1][b] > val:
            L[a - 1][b] = val
            q += [(a - 1, b)]
        if b >= 1 and L[a][b - 1] > val:
            L[a][b - 1] = val
            q += [(a, b - 1)]
        if a < n - 1 and L[a + 1][b] > val:
            L[a + 1][b] = val
            q += [(a + 1, b)]
        if b < n - 1 and L[a][b + 1] > val:
            L[a][b + 1] = val
            q += [(a, b + 1)]

print(ans)






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

string org;
string S;

int main()
{
	cin>>org;
	for(int i=0;i<org.size();i++)
	{
		if(org[i]=='T')
		{
			if(!S.empty() && S.back()=='S') S.pop_back();
			else S.push_back('T');
		}
		else S.push_back('S');
	}
	cout<<S.size()<<endl;
	return 0;
}


Measured memory_bytes: 776
#include <iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<cmath>
#include<queue>
#include<string>
#include<set>
#include<map>
#include<bitset>
#define UP(i,l,h) for(int i=l;i<h;i++)
#define DOWN(i,h,l) for(int i=h-1;i>=l;i--)
#define W(a) while(a)
#define INF 0x3f3f3f3f
#define LL long long
#define MAXN 8200
#define EPS 1e-10
#define MOD 100000000

using namespace std;

int main(){
    int n;
    scanf("%d",&n);
    printf("ABC%d\n",n);
}


Measured memory_bytes: 256
#include <stdio.h>
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define N 100

void dfs(void);
void visit(int);
int color[N],d[N],f[N],t,i,j,M[N][N],n;

int main(){
  int u,k,v;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++) M[i][j]=0;
  }
  
  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }

  dfs();

  return 0;
}

void dfs(){
  for(i=0;i<n;i++) color[i]=WHITE;
  t=0;
  for(i=0;i<n;i++){
    if(color[i]==WHITE) visit(i);
  }
  for(i=0;i<n;i++) printf("%d %d %d\n",i+1,d[i],f[i]);
}

void visit(int u){
  int v;
  color[u]=GRAY;
  d[u]=++t;
  for(v=0;v<n;v++){
    if(M[u][v]==0) continue;
    if(color[v]==WHITE) visit(v);
  }
  color[u]=BLACK;
  f[u]=++t;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
#define ll long long
#define pb push_back
//#define mp make_pair
#define fr first
#define sc second
#define MAX ((ll)(1e17+100))
#define MX ((ll)(1e5+100))
#define ARRS ((ll)(1e6+100))
#define ARS ((ll)(1e3+100))
#define HS ((ll)(233))
#define MOD ((ll)(1e9+7))
#define EP ((double)(1e-9))
#define LG 21
#define mul(a,b) a=((a)*(b))%MOD
using namespace std;

ll n;
pair<ll,ll> a[ARRS];

int main(){
	ll n,m;
	cin>>n>>m;
	cout<<(n-1+m-2)/(m-1);
}


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

int main()
{
  int n;
  cin >> n;
  int sum = 0;
  vector<int> begin(n), end(n);
  for(int i = 0; i < n; i++){
    cin >> begin[i] >> end[i];
    sum = sum + end[i] - begin[i] + 1;
  }
  cout << sum << endl;
}

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

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


    long long a[n],max_1[n],sum =0 ;

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

    for(int i=0 ; i<n;i++ )
    {
        if(a[i] <  max_1[i])
        {
            sum += max_1[i] - a[i];

        }
    }
    cout<<sum; 

}

Measured memory_bytes: 6732
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    n = int(input())
    h = [int(hi) for hi in input().split()]

    m = 0

    c = 0
    prev = -1
    for i in h:
        if i <= prev:
            c += 1
        else:
            c = 0
        m = max(m, c)
        prev = i

    print(m)


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 45420
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>

#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;

int A, B;

char m[101][101];

signed main()
{
	cin >> A >> B;

	cout << "100 100" << endl;

	for (int x = 0; x < 50; x++)
	{
		for (int y = 0; y < 100; y++)
		{
			m[x][y] = '.';
		}
	}
	for (int x = 50; x < 100; x++)
	{
		for (int y = 0; y < 100; y++)
		{
			m[x][y] = '#';
		}
	}

	for (int i = 0; i < B - 1; i ++)
	{
		int x = i % 25;
		int y = i / 25;
		m[x * 2][y * 2] = '#';
	}

	for (int i = 0; i < A - 1; i++)
	{
		int x = i % 25;
		int y = i / 25;
		m[x * 2 + 50 + 1][y * 2] = '.';
	}

	for (int y = 0; y < 100; y++)
	{
		for (int x = 0; x < 100; x++)
		{
			cout << m[x][y];
		}
		cout << endl;
	}

}







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

int GCD(int a,int b) {
    return a%b ==0 ? b : GCD(b, a % b);
}


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

    vector<int> left(N - 1 , 0);
    vector<int> right(N - 1 , 0);

    left[0] = A[0];
    right[0] = A[N-1];
    for(int i = 0;i < N-2;i++){
        left[i+1] = GCD(A[i+1],left[i]);
        right[i+1] = GCD(A[N-i-2],right[i]);
    }

    int k,MaxGCD = max(left[N-2],right[N-2]);
    for(int i = 0;i < N-2;i++){
        k = GCD(left[i],right[N-i-3]);
        MaxGCD = max(MaxGCD,k);
    }
    cout << MaxGCD << endl;

    return 0;
}

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

int64_t gcd(int64_t a, int64_t b) {
	return b == 0 ? a : gcd(b, a % b);
}
int main() {
	int64_t N, X;
	cin >> N >> X;
	cout << 3 * (N - gcd(N, X));
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

解説の方法天才かよ
*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define inf 1e9+1
using namespace std;
void c_p_c(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
ll knapsack2(vector<pair<ll,ll> >v,int n,int w){
	int maxVal = n*1000;
	ll dp[n][maxVal+1];
	for(int val=0;val<=maxVal;val++)
		dp[0][val] = inf;
	dp[0][0] = 0;
	dp[0][v[0].second] = v[0].first;
	for(int i=1;i<n;i++){
		for(int j=0;j<=maxVal;j++){
			dp[i][j] = dp[i-1][j];
			if(v[i].second > j)
				continue;
			dp[i][j] = min(dp[i][j], v[i].first + dp[i-1][j-v[i].second]);
		}
	}
	ll ans = 0;
	for(int i=0;i<=maxVal;i++){
		if(dp[n-1][i] <= w)
			ans = i;
	}
	return ans;
}
int main()
{
	c_p_c();
	int n,w;
	cin>>n>>w;
	vector<pair<ll,ll> >v;
	for(int i=0;i<n;i++){
		int wt,val;
		cin>>wt>>val;
		v.push_back({wt,val});
	}
	cout<<knapsack2(v,n,w);
}

Measured memory_bytes: 78336
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
#include<map>
#include<set>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
int main() {
	int a, b;
	cin >> a >> b;
	if (a % 2 && b % 2)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		var di = new Dictionary<int,int>[2];
		for(int i=0;i<2;i++) di[i] = new Dictionary<int,int>();
		for(int i=0;i<N;i++){
			if(!di[i % 2].ContainsKey(A[i])) di[i % 2].Add(A[i], 0);
			di[i % 2][A[i]]++;
		}
		
		var l0 = di[0].Keys.ToList();
		var l1 = di[1].Keys.ToList();
		
		l0.Sort((a, b) => - (di[0][a].CompareTo(di[0][b])));
		l1.Sort((a, b) => - (di[1][a].CompareTo(di[1][b])));
		
		
		if(l0.Count == 1 && l1.Count == 1){
			if(l0[0] == l1[0]){
				Console.WriteLine(N / 2);
			} else {
				Console.WriteLine(0);
			}
			return;
		}
		
		int min = (int) 1e9;
		for(int i=0;i<Math.Min(2, l0.Count);i++){
			for(int j=0;j<Math.Min(2, l1.Count); j++){
				if(l0[i] == l1[j]) continue;
				int c0 = N / 2 - di[0][l0[i]];
				int c1 = N / 2 - di[1][l1[j]];
				min = Math.Min(min, c0 + c1);
			}
		}
		
		Console.WriteLine(min);
	}
	int N;
	int[] A;
	public Sol(){
		N = ri();
		A = ria();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 29664
/** MIT License Copyright (c) 2018-2019 Vasilev Daniil **/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
//#pragma GCC optimize("Ofast")
template<typename T> using v = vector<T>;
typedef long long ll;
//#define int ll
typedef long double ld;
typedef string str;
typedef vector<int> vint;
#define rep(a, l, r) for(int a = (l); a < (r); a++)
#define pb push_back
#define fs first
#define sc second
#define sz(a) ((int) a.size())
const long long inf = 4611686018427387903; //2^62 - 1
const long double EPS = 1e-12;
#if 0  //FileIO
const string fileName = "";
ifstream fin ((fileName == "" ? "input.txt"  : fileName + ".in" ));
ofstream fout((fileName == "" ? "output.txt" : fileName + ".out"));
#define get fin >>
#define put fout <<
#else
#define get cin >>
#define put cout <<
#endif
#define eol put endl
void read() {} template<typename Arg,typename... Args> void read (Arg& arg,Args&... args){get (arg)     ;read(args...) ;}
void print(){} template<typename Arg,typename... Args> void print(Arg  arg,Args...  args){put (arg)<<" ";print(args...);}
int getInt(){int a; get a; return a;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//code starts here

void run() {
	int n, q;
	str s;
	read(n, q, s);
	int p[n];
	p[n - 1] = 0;
	rep(i, 0, n - 1)
		p[i] = (s[i] == 'A' && s[i + 1] == 'C');
	
	int pr[n];
	rep(i, 0, n)
		pr[i] = (i ? pr[i - 1] : 0) + p[i];
	
	for (; q; q--) {
		int l, r;
		read(l, r);
		l--; r--;
		put pr[r] - p[r] - (l ? pr[l - 1] : 0);
		eol;
	}
}

signed main() {ios::sync_with_stdio(0); cin.tie(0); put fixed << setprecision(12); run();}



Measured memory_bytes: 1872
#include<iostream>
#include<math.h>
#include<string>

using namespace std;

int main()
{
    int a,b;

    cin>>a>>b;

    if(a<b)
    {
        cout<<"a"<<" < "<<"b";
    }

    else if(a>b)
    {
        cout<<"a"<<" > "<<"b";
    }

    else if(a==b)
    {
        cout<<"a"<<" == "<<"b";
    }

    cout<<endl;
}


Measured memory_bytes: 3096
def is_acgt(c)
  c == 'A' || c == 'C' || c == 'G' || c == 'T'
end

def main(argv)
  s = gets.chomp
  m = 0
  s.size.times do |left|
    (left...s.size).each do |right|
      ret = s[left..right].split('').find{|c| not is_acgt(c)}
      if ret == nil then
        m = [m, right - left + 1].max
      end
    end
  end
  puts m.to_s
end

if self.to_s == 'main' then
  main(ARGV)
end

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

typedef long long int int64;
static const int64 mod = 1000000007LL;
std::vector<int> mul(const std::vector<int> &a,const std::vector<int> &b)
{
	int na = a.size()-1, nb = b.size()-1;
	std::vector<int> ans(na+nb+1, 0);
	for(int k = 0;k <= na+nb;++k) {
		int64 val = 0;
		for(int i = std::max(0,k-nb);i <= na && i <= k;++i) {
			val += (int64)a[i] * b[k-i] % mod;
		}
		ans[k] = val % mod;
	}
	return ans;
}
struct vertex {
	int estart;
	bool vis;
} v[5003];
struct edge {
	int enext,to;
} e[10003];int en;
int fac[5003];
int sum(const std::vector<int> &val)
{
	int64 s = 0;
	for(int a = 1;a < val.size();++a) s += (int64)fac[a] * val[a] % mod;
	return s % mod;
}
std::vector<int> dfs(int i)
{
	v[i].vis = true;
	std::vector<int> ans(1, 1);
	for(int j = v[i].estart;j != -1;j = e[j].enext) {
		int to = e[j].to;
		if(!v[to].vis) {
			std::vector<int> val = dfs(to);
			int s = sum(val);
			s = mod-s;if(s >= mod) s -= mod;
			val[0] = s;
			ans = mul(ans, val);
		}
	}
	ans.insert(ans.begin(), 0);
	v[i].vis = false;
	return ans;
}
int n;
int main()
{
	fac[2] = 1;
	for(int i = 4;i <= 5000;i += 2) fac[i] = ((int64)fac[i-2] * (i-1)) % mod;
	scanf("%d",&n);
	for(int i = 0;i < n;++i) {
		v[i].estart = -1;
	}
	for(int i = 0;i < n-1;++i) {
		int a,b;
		scanf("%d%d",&a,&b);--a,--b;
		e[en].enext = v[a].estart;e[en].to = b;v[a].estart = en++;
		e[en].enext = v[b].estart;e[en].to = a;v[b].estart = en++;
	}
	printf("%d\n", sum(dfs(0)));
}


Measured memory_bytes: 896
#include <iostream>
#include <stdio.h>

using namespace std;
int main() {
	int t;
	cin >> t;
	if (t >= 30) cout << "Yes";
	else cout << "No";
}





/*#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

int main() {
	
	string s1 = "nakahashi";
	s1 += "tomoro";
	cout << s1 << 1 << "\n";
	printf("文字列サイズ = %d\n", s1.size());
	return 0;
}*/

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

int main() {
  int k, x;
  cin >> k >> x;
  for(int i = -k + 1; i < k; i++){
    cout << x + i;
    if(i != k - 1) cout << " ";
  }
  cout << endl;
}

Measured memory_bytes: 256
package main

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

func main() {
	sc := NewScanner()

	a := sc.ReadInt()
	b := sc.ReadInt()
	c := sc.ReadInt()
	d := sc.ReadInt()

	if Ceil(a, d) >= Ceil(c, b) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

// util
// *   math/simple

func Abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func Min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow(base int, exponent uint) int {
	answer := 1
	for i := uint(0); i < exponent; i++ {
		answer *= base
	}
	return answer
}

func Ceil(dividend int, divisor int) int {
	quo := dividend / divisor
	rem := dividend % divisor
	if rem > 0 {
		return quo + 1
	} else {
		return quo
	}
}

// *   io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}


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

void solve(){
    int n;
    cin>>n;
    vector<int> dp(3),mat(3);
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            cin>>mat[j];
        }
        int a=mat[0]+max(dp[1],dp[2]);
        int b=mat[1]+max(dp[0],dp[2]);
        int c=mat[2]+max(dp[0],dp[1]);
        dp={a,b,c};
    }
    cout<<max({dp[0],dp[1],dp[2]});
}

int main() {
	// your code goes here
	//freopen("inptmp0.txt","r",stdin);
	int T;
	
	//cin>>T;
	T=1;
	while(T--){
	    solve();
	}
	return 0;
}


Measured memory_bytes: 3588
#include <cstdio>

typedef struct Node {
    int id;
    int d;
    int f;
    int count;
} Node;


int count(int id, int now, Node *node, int a[101][100]){
    if(node[id].d == 0) node[id].d = now;
    else return now - 1;
    if(node[id].f != 0) return now - 1;
    for(int i = 0; i < node[id].count; ++i){
        int nextId = a[id][i];
        now = count(nextId, now + 1, node, a);
    }
    node[id].f = now + 1;
    return node[id].f;
}

int main(){
    int n;
    std::scanf("%d", &n);
    Node node[101];
    int a[101][100];
    for(int i = 1; i <= n; ++i){
        int id;
        std::scanf("%d", &id);
        node[id].id = id;
        std::scanf("%d", &node[id].count);
        for(int j = 0; j < node[id].count; ++j){
            std::scanf("%d", &a[id][j]);
        }
    }
    int now = 0;
    for(int i = 1; i <= n; ++i){
        now = count(i, now + 1, node, a);
    }
    for(int i = 1; i <= n; ++i){
        std::printf("%d %d %d\n", node[i].id, node[i].d, node[i].f);
    }

    return 0;
}



Measured memory_bytes: 2740
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=100000000000000000;

ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}

int main(){
    ll n,m;cin>>n>>m;
    ll p[m],y[m];
    vector<vector<pair<ll,ll>>> aa(n+1); //県iの市の＜年、市の番号＞を入れる
    for(ll i=0;i<m;i++){
        cin>>p[i]>>y[i];
        aa[p[i]].push_back(make_pair(y[i],i));
    }
    string ans[m];
    for(ll i=1;i<=n;i++){
        sort(aa[i].begin(),aa[i].end());
        for(ll j=0;j<aa[i].size();j++){
            ans[aa[i][j].second]=to_string(j+1);
            while(ans[aa[i][j].second].size()<6){
                ans[aa[i][j].second]='0'+ans[aa[i][j].second];
            }
            ans[aa[i][j].second]=to_string(i)+ans[aa[i][j].second];
            while(ans[aa[i][j].second].size()<12){
                ans[aa[i][j].second]='0'+ans[aa[i][j].second];
            }
        }
    }
    for(ll i=0;i<m;i++){
        cout<<ans[i]<<endl;
    }
    
    return 0;
}



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

#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define rep(i, n) REP (i, 0, n)
#define mset(a, n) memset(a, n, sizeof(a))

using namespace std;

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

bool isPrime(int x) {
	if (x < 2) return false;
	else if (x == 2) return true;
	if (x % 2 == 0) return false;
	for (int i = 3; i * i <= x; i += 2) {
		if (x % i == 0) return false;
	}
	return true;
}

int main() {
	int n; cin >> n;
	int ans = 0;
	while (n--) {
		int x; cin >> x;
		bool check = isPrime(x);
		if (check) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1164
#include<algorithm>
#include<cstdio>
using namespace std;
int n,p,t,a[100005];
bool bz;
bool cmp(int a,int b){return a>b;}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1,cmp);
	for (;a[p+1]>=p+1;p++);
	for (;a[p+t]>=p;t++); 
	if ((a[p]-p+1)&1 && t&1) bz=1;
	printf(bz?"Second":"First");
	return 0;
}


Measured memory_bytes: 512
#include <array>
#include <iostream>

constexpr std::size_t MaxDigits = 11;
std::array<char, MaxDigits> Buffer;

int
main()
{
    long long n = 0;
    std::cin >> n;

    std::string alphabets = "abcdefghijklmnopqrstuvwxyz";
    std::size_t digit = 0;

    while (true)
    {
        auto remain = (n-1) % 26;
        Buffer[MaxDigits-digit-1] = alphabets[remain];
        ++digit;
        n = (n-remain)/26;
        if (n<=0) break;
    }

    std::cout << std::next(Buffer.begin(), MaxDigits-digit) << "\n";
}


Measured memory_bytes: 3608
#include <iostream>
#include <math.h>
#include <algorithm>
#include <set>
#include <map>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)
#define repe_r(i,s,n)for(ll i=s;i<=n;i++)
static const ll MOD = 1e9 + 7;
//static const ll MOD = 1;
static const ll MAX_L = (ll)1 << 62;

static const ll FACT_SIZE = 1000000;
ll fact[FACT_SIZE] = {};

ll Pow(ll n, ll p) {
	if (p == 0)return 1;
	if (p == 1)return n;
	ll t = Pow(n, p / 2);
	if (p & 1) return (t * t % MOD) * n % MOD;
	//if (p & 1) return t * t * n;
	else return t * t % MOD;
	//else return t * t;
}
void factorial(ll f) {
	fact[0] = fact[1] = 1;
	rep(i, 1, FACT_SIZE) fact[i] = fact[i - 1] * i % MOD;
	//rep(i, 1, FACT_SIZE) fact[i] = fact[i - 1] * i;
}

ll nCr(ll n, ll r) {
	if (fact[0] == 0)	factorial(1000000);
	return ((fact[n] * (Pow(fact[r], MOD - 2) % MOD)) % MOD * Pow(fact[n - r], MOD - 2)) % MOD;
	//return fact[n] / (fact[r] * fact[n - r]);
}

ll a[50] = {};
int main() {
	ll n, p; cin >> n >> p;
	ll o = 0, e = 0;
	rep(i, 0, n) {
		cin >> a[i];
		if (a[i] & 1) o++;
		else e++;
	}
	if (o == 0) {
		if (p == 1) cout << 0 << endl;
		else {
			ll ans = 1;
			rep(i, 0, e) {
				ans *= 2;
			}
			cout << ans << endl;
			//cout << Pow(2, e) << endl;
		}
		return 0;
	}
	else {
		ll ans = 1;
		rep(i, 0, o + e - 1) {
			ans *= 2;
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 256