akhauriyash/Code-Regression huggingface dataset:
function main(input) {
    const args = input.split(" ");
    const a = parseInt(args[0], 10);
    const b = parseInt(args[1], 10);

    if ((a * b) % 2 === 0) {
        console.log("Even");
    } else {
        console.log("Odd");
    }
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{   
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s,t;cin>>s>>t;
    ll n=s.length(),m=t.length();
    ll dp[n+1][m+1];
    for(int i=0;i<=n;++i)
    {
        dp[i][0]=0;
    }
    for(int i=0;i<=m;++i)
    {
        dp[0][i]=0;
    }
    for(int i=0;i<=n;++i)
    {
        for(int j=0;j<=m;++j)
        {
            dp[i][j]=0;
        }
    }
    for(int i=1;i<=n;++i)
    {
        for(int j=1;j<=m;++j)
        {
            if(s[i-1]!=t[j-1])
            {
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
            else
            {
                dp[i][j]=dp[i-1][j-1]+1;
            }
        }
    }
    //cout<<dp[n][m]<<endl;
    if(dp[n][m]==0)
    {
        cout<<"\n";
        return 0;
    }
    string ans="";
    int ti=n,tj=m;
    while(ti>0 && tj>0)
    {
        
        if(dp[ti][tj-1]==dp[ti][tj])
        {
            tj--;
        }
        else if(dp[ti][tj]==dp[ti-1][tj])
        {
            ti--;
        }
        else if(dp[ti][tj]==dp[ti-1][tj-1]+1)
        {
            ans+=s[ti-1];
            ti--;tj--;
        }
        
        
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 70656
#include<stdio.h>
int main()
{
	int a[105]={0},i,n,m,x,t,s1=0,s2=0;
	scanf("%d %d %d",&n,&m,&x);
	for(i=0;i<m;i++){
		scanf("%d",&t);
		a[t]=1;
	}
	for(i=x-1;i>=0;i--)
		s1+=a[i];
	for(i=x+1;i<=n;i++)
	    s2+=a[i];
	if(s1<=s2)
	    printf("%d",s1);
	else
	    printf("%d",s2);
}


Measured memory_bytes: 128
#include<cstdio> 
#include<cstring>
using namespace std;
const int N=200004;
const int T=100001;
int a[N];
int main()
{
	int t;
	memset(a,0,sizeof(a));
	scanf("%d",&t);
	for(int i=0;i<t;i++)
	{
		int x;
		scanf("%d",&x);
		a[T+x-1]++;a[T+x]++;a[T+x+1]++;
	}
	int max=0;
	for(int i=0;i<N;i++)
	{
		if(a[i]>max) max=a[i];
	}
	printf("%d\n",max);
}

Measured memory_bytes: 3868
#include <iostream>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for (int i = s; i < t; i++)
#define rng(a) a.begin(),a.end()
using ll = long long;

using namespace std;



int main() {
    int n;
    cin>>n;
    if(n<10) {
        cout<<n<<endl;
        return 0;
    }
    int a = n;
    int b = 0;
    while(a) {
        a /= 10;
        b++;
    }
    int mul = 1;
    int ans = 0;
    rrep(i,b) {
        if(i%2){
            if(i!=b) ans += 9*mul;
            else ans += n-mul+1;
        }
        mul *= 10;
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3624
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <string>
#include <utility>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstring>
#include <complex>
#include <queue>
#include <stack>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}


void run(){
  int n,k;
  cin>>n>>k;
  string s;
  cin>>s;
  s[k-1]+='a'-'A';
  cout<<s<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <queue>
typedef long long ll;
#define rep(i,n) for(int i = 0;i<n;++i)
#define repc(bit,k,n) for (int bit = (1<<k)-1;bit < (1<<n); bit = next_combination(bit))
#define repi(itr,vec) for(auto itr = vec.begin();itr!=vec.end();++itr)
using namespace std;
using Graph = vector<vector<int> >;

/* next combination
 * usage:repc(bit,k,n)
 * */
inline int next_combination(int sub) {
  int x = sub & -sub, y = sub + x;
  return (((sub & ~y) / x) >> 1) | y;
}

/* uniq
 * usage:uniq(vec)
 * */
void uniq(vector<int> &vec){
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return;
}
/* DP
 * usage: chmin(dp[i],dp[i-1]+v);
 * */
const ll INF = 1LL << 60;
ll dp[10001];
bool checked[10001];

template<class T> inline bool chmin(T& a, T b) {
      if (a > b) {
                a = b;
                        return true;
                            }
          return false;
}
template<class T> inline bool chmax(T& a, T b) {
      if (a < b) {
                a = b;
                        return true;
                            }
          return false;
}

int count16bit(unsigned short v) {
  unsigned short count = (v & 0x5555) + ((v >> 1) & 0x5555);
  count = (count & 0x3333) + ((count >> 2) & 0x3333);
  count = (count & 0x0f0f) + ((count >> 4) & 0x0f0f);
  return (count & 0x00ff) + ((count >> 8) & 0x00ff);
}

ll solve(ll Hp, const vector<vector<ll> >&magic){
  if(checked[Hp])return dp[Hp];
  ll mini = INF;
  repi(itr,magic){
    ll left = Hp - (*itr)[1];
    left = left>=0?left:0;
    chmin(mini, solve(left, magic)+(*itr)[0]);
  }
  checked[Hp] = true;
  return dp[Hp] = mini;
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int H,n; cin >> H>>n;
  fill((ll*)dp, (ll*)dp+sizeof(dp)/sizeof(ll), 0);
  vector<vector<ll> > magic(n);
  rep(i,n){
    ll a,b;cin>>a>>b;
    magic[i] = {b,a};
  }
  sort(magic.begin(),magic.end(), [](const vector<ll> &a, const vector<ll> &b){return a[0]<=b[0];});
  rep(i, int(magic[0][1])){
    checked[i+1] = true;
    dp[i+1] = magic[0][0];
  }
  checked[0]=true; dp[0] = 0;
  cout<< solve(H,magic)<<endl;


  return 0;
}

Measured memory_bytes: 4252
#include<bits/stdc++.h>
#define lld long long int
#define vec vector<lld>
#define pll pair<lld,lld>
#define pb push_back
#define ss second
#define ff first
#define mp make_pair
#define mod 1000000007
#define answer(x) cout<<endl<<"answer : "<<x<<endl<<endl;
#define op(x) cout<<x<<endl;
#define maxn 500005
#define lld_max 5000000000000000000
#define messi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
lld poww(lld a, lld b){
    lld cnt=1;
    lld i;
    for(i=0;i<b;i++)
        cnt=(cnt%mod * a%mod)%mod;
    return cnt;
}
int main() {messi lld t=1;//cin>>t;
    while(t--)
    {
        lld n=0,m=0,k=0,i=0,j=0,p=0,q=0,x=0,y=0,z=0,ans=0,cnt=0,l=0,r=0,mid=0,lo=0,hi=0;string s;bool flag=false;
        cin>>n;
        ans = poww(10,n);
        ans -= (2*poww(9,n))%mod;
        if(ans<0) ans+=mod;
        ans = (ans + poww(8,n))%mod;
        op(ans);
    }
	return 0;
}
/*  CODED BY:-
 ________________________________________
|            __        __                |
|  /\   /\  |__)  /\  |  \ |__| \ /  /\  |
| /~~\ /~~\ |  \ /~~\ |__/ |  |  |  /~~\ |
|________________________________________|

*/


Measured memory_bytes: 3672
#include<bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define mp make_pair
#define fi fisrt
#define se second

using namespace std;
const int N=1e5+5;
const int mod=1e9+7;
const int inf=0x3f3f3f3f3f3f3f;

int ksm(int xx,int yy,int zz)
{
	int ret;
	while (yy)
	{
		if (yy&1) ret=(ret*xx) % zz;
		xx=(xx*xx)%zz;
		yy>>=1;
	}
	return ret;
}

signed main()
{
	int N,X,T;
	cin>>N>>X>>T;
	cout<<((N+X-1)/X)*T<<endl; 
}


Measured memory_bytes: 3620
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define rep(i, n, s) for (int i = s; i < (int)(n); i++)

ll calcNumOfCombination(ll n, ll r) {
    ll num = 1;
    for (ll i = 1; i <= r; i++) {
        num = num * (n - i + 1) / i;
    }
    return num;
}

int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }

int findSumDigits(int s) {
    int num = 0;
    int temp = 0;
    while (s) {
        temp = s % 10;
        num += temp;
        s = s / 10;
    }
    return num;
}

int countDivisorNum(int n) {
    int count = 0;
    for (int i = 1; i <= n; i++) {
        if (n % i == 0) {
            count++;
        }
    }
    return count;
}


int main() {
    string s;
    cin >> s;

    if (s == "ABC") {
        cout << "ARC" << endl;
    } else {
        cout << "ABC" << endl;
    }
    return 0;
}

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

ll days(ll y,ll m,ll d){
  if(m<3)y--,m+=12;
  return 365*y+y/4-y/100+y/400+(153*m+8)/5+d;
}
void ymd(ll day,ll &y,ll &m,ll &d){
  ll lo=-1,hi=1000000000,mid;
  while(lo+1<hi){
    mid=(lo+hi)/2;
    if(days(mid,12,31)<day)lo=mid;
    else hi=mid;
  }
  y=hi;
  for(m=1;m<12;m++)if(days(y,m+1,1)>day)break;
  d=day-days(y,m,0);
}

int main() {
  string s;
  ll y=days(2012,12,21);
  while(cin >> s && s!="#") {
    s+='.';
    ll n=s.size(),x=0;
    vector<ll> a;
    for(int i=0; i<n; i++) {
      if(s[i]=='.') {
        a.push_back(x);
        x=0;
      } else {
        x*=10;
        x+=s[i]-'0';
      }
    }
    if(a.size()==3) {
      x=days(a[0],a[1],a[2]);
      x=(x+1872000-y)%1872000;
      ll b[5],c=20*20*18*20;
      b[0]=x/c;x%=c;c/=20;
      b[1]=x/c;x%=c;c/=20;
      b[2]=x/c;x%=c;c/=18;
      b[3]=x/c;x%=c;c/=20;
      b[4]=x;
      for(int i=0;i<5;i++) {
        if(i) cout << '.';
        cout << b[i];
      }
      cout << endl;
    } else {
      x=a[0]*20*20*18*20+a[1]*20*18*20+a[2]*18*20+a[3]*20+a[4];
      x=x+y;
      ymd(x,a[0],a[1],a[2]);
      cout << a[0] << "." << a[1] << "." << a[2] << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
const int N = 2e5 + 5;
 
int32_t main()
{
	IOS;
	
	ll n;cin>>n;
	ll a[n+1];
	
	for(ll i=0;i<n;i++) 
	cin>>a[i];
	
	ll ans = INT_MAX;
	
	for(ll i=1;i<=100;i++){
	    ll s=0;
	    for(ll j=0;j<n;j++){
	        ll x = a[j]-i;
	        x = x*x;
	        s +=x;
	    }
	    
	    ans = min(ans,s);
	}
	
	
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>
#include <stack>
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iterator>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <time.h>
#include <complex>
#include <cmath>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n;i>0;i--)
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define SORT(v) sort((v).begin(),(v).end())
#define TEMP(type,x,y) do {temp temp=x,x=y,y=temp}while(0)
const ll INF = (1LL << 50);
typedef pair<ll, ll> P;

bool cmp(const P &a, const P &b) {
	return a.second < b.second;
}

int main() {

	int n;
	cin >> n;

	vector<P>work(n);

	REP(i, n){
		cin >> work[i].first >> work[i].second;
	}

	sort(work.begin(), work.end(), cmp);

	ll time = 0;
	bool is_possible = 1;
	REP(i, n) {
		time += work[i].first;
		if (time > work[i].second) {
			is_possible = 0;
			break;
		}
	}

	if (is_possible) cout << "Yes" << endl;
	else cout << "No" << endl;



	return 0;
	
}

Measured memory_bytes: 3328
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll mod = 1e9+7;
ll inf=1e18;

//WA

ll digit_sum(ll n){
	ll ans=0;
	while(n>0){
		ans+=n%10;
		n/=10;
	}
	return ans;
}

ll f(ll shita,ll top){
	ll ans=0;
	ll a = (ll)pow(10,shita);
	ans += a*top;
	reg(i,0,shita-1){
		a = (ll)pow(10,i);
		ans += a*9;
	}
	return ans;
}


int main(void){
	ll K;
	cin>>K;
	ll cnt=1;
	reg(shita,0,16){
		if(K<=0)break;
		while(K>0){
			if((double)f(shita,cnt)/digit_sum(f(shita,cnt)) > (double)f(shita,cnt+1)/digit_sum(f(shita,cnt+1))){
				if(log10(cnt)>1){
					cnt=(cnt+1)/10;
				}else{
					cnt=1;
				}
				break;
			}
			cout<<f(shita,cnt)<<endl;
			K--;
			cnt++;
		}
	}
	// cout<<log10(10)<<endl;
	// ll a=2099;
	// ll b=2199;
	// cout<<(double)a/digit_sum(a)<<endl;
	// cout<<(double)b/digit_sum(b)<<endl;
	return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC140
{
    class B
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int[] B = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int[] C = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            int ans = B.Sum();
            for (int i = 0; i < N - 1; i++)
            {
                if (A[i + 1] - A[i] == 1)
                {
                    ans = ans + C[A[i]-1];
                }
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13396
n,x=gets.split.map(&:to_i)
a=gets.split.map(&:to_i).sort
s=a.inject(&:+)
if s == x
  puts n
  exit(0)
elsif s < x
  puts n-1
  exit(0)
end

puts a.count{|a|x-=a; x>=0}

Measured memory_bytes: 1788
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>

using namespace std;


int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(b / a > c){
    cout << c << endl;
  } else {
    cout << b / a << endl;
  }
}


Measured memory_bytes: 256
#include<queue>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i,j;
  int a[52][52],b[52][52],sx,sy,tx,ty,w,h;
  char s;
  bool d[52][52][52][52];
  queue<pair<pair<int,int>,pair<int,int> > > c;
  while(cin>>w>>h&&w+h){
    memset(a,-1,sizeof(a));
    memset(b,-1,sizeof(b));
    for(i=1;i<h+1;i++){
      for(j=1;j<w+1;j++){
	cin>>s;
	if(0){
	}else if(s=='#'){
	}else if(s=='%'){
	  a[j][i]=1;
	}else{
	  a[j][i]=0;
	  if(s=='L'){
	    sx=j;
	    sy=i;
	  }
	}
      }
      for(j=w;j>0;j--){
	cin>>s;
	if(0){
	}else if(s=='#'){
	}else if(s=='%'){
	  b[j][i]=1;
	}else{
	  b[j][i]=0;
	  if(s=='R'){
	    tx=j;
	    ty=i;
	  }
	}
      }
    }
    memset(d,0,52*52*52*52);
    while(c.empty()==0)
      c.pop();
    c.push(make_pair(make_pair(sx,sy),make_pair(tx,ty)));
    while(c.empty()==0){
      sx=c.front().first.first;
      sy=c.front().first.second;
      tx=c.front().second.first;
      ty=c.front().second.second;
      if(a[sx][sy]==1&&b[tx][ty]==1)
	break;
      c.pop();
      if(a[sx][sy]==0&&b[tx][ty]==0&&d[sx][sy][tx][ty]==0){
	d[sx][sy][tx][ty]=1;
	c.push(make_pair(make_pair(sx-(a[sx-1][sy]==-1?0:1),sy),make_pair(tx-(b[tx-1][ty]==-1?0:1),ty)));
	c.push(make_pair(make_pair(sx+(a[sx+1][sy]==-1?0:1),sy),make_pair(tx+(b[tx+1][ty]==-1?0:1),ty)));
	c.push(make_pair(make_pair(sx,sy-(a[sx][sy-1]==-1?0:1)),make_pair(tx,ty-(b[tx][ty-1]==-1?0:1))));
	c.push(make_pair(make_pair(sx,sy+(a[sx][sy+1]==-1?0:1)),make_pair(tx,ty+(b[tx][ty+1]==-1?0:1))));
      }
    }
    if(c.empty())
      cout<<"No"<<endl;
    else
      cout<<"Yes"<<endl;
  }
  return 0;
}

Measured memory_bytes: 11000
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include<math.h>
using namespace std;

int main() {
	int n, i = 0, counter = 0; cin >> n;
	int a[n];
	for (int j = 0; j < n; j++)cin >> a[j];
	bool flag = 1;
	while (flag) {
		flag = 0;
		for (int j = n - 1; j > i; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				counter++;
			}
		}
		i++;
	}
	for (int j = 0; j < n-1; j++)cout << a[j] << ' ';
	cout << a[n - 1] << endl << counter << endl;
}


Measured memory_bytes: 3112
A = [list(map(int, input().split())) for i in range(3)]
N = int(input())
b = []
for i in range(N):
	b.append(int(input()))
	
yoko = A
tate = [[], [], []]
for row in A:
	for i in range(3):
		tate[i].append(row[i])
naname = [[A[0][0], A[1][1], A[2][2]], [A[0][2], A[1][1], A[2][0]]]

all = yoko + tate + naname

y = 0
chk = 0
for kumi in all:
	for k in kumi:
		if k in b:
			chk += 1
		else:
			continue
	if chk == 3:
		print("Yes")
		y = 1
		break
	else:
		chk = 0
		
if y == 0:
	print("No")

Measured memory_bytes: 3064
import numpy as np
 
def luka(n):
    a,b=1,2
    if n==1:
        pass
    elif n>=1:
        for _ in range(n-1):
            a,b=a+b,a
    
    print(a)
    
 
def main():
    N=int(input())
 
    luka(N)
 
if __name__=="__main__":
    main()

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

namespace ABC125
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] a = Console.ReadLine().Split(' ');
            int[] an = a.Select(x => int.Parse(x)).ToArray();

            long result = 0;

            foreach (int x in an)
            {
                result += Math.Abs(x);
            }

            if (an.Count(x => x < 0) % 2 == 0)
            {
                Console.WriteLine(result);
            }
            else
            {
                int min = Math.Abs(an[0]);
                for (int i = 0; i < an.Length; i++)
                {
                    if (Math.Abs(an[i]) < min) min = Math.Abs(an[i]);
                }
                result -= min * 2;
                Console.WriteLine(result);
            }
        }
    }
}


Measured memory_bytes: 31964
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/
const int MOD = 1000000007;

vector<long long> inv_init(int num) {
  vector<long long> inv(num + 1, 0);
  inv[1] = 1;
  FOR(i, 2, num + 1) inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
  return inv;
}

pair<long long, long long> ext_gcd(long long a, long long b) {
  if (b == 0) return {1, 0};
  pair<long long, long long> pr = ext_gcd(b, a % b);
  return {pr.second, pr.first - a / b * pr.second};
}

long long mod_inv(long long a) {
  if (__gcd(a, (long long)MOD) != 1) return 0;
  pair<long long, long long> pr = ext_gcd(a, MOD);
  return (pr.first + MOD) % MOD;
}

const int MAX = 10000000;
long long fact[MAX + 1], fact_inv[MAX + 1];
void nCk_init(int num = MAX) {
  fact[0] = 1;
  FOR(i, 1, MAX + 1) fact[i] = fact[i - 1] * i % MOD;
  fact_inv[MAX] = mod_inv(fact[MAX]);
  for (int i = MAX; i > 0; --i) fact_inv[i - 1] = fact_inv[i] * i % MOD;
}

inline long long nCk(int n, int k) {
  if (n < 0 || n < k || k < 0) return 0;
  return fact[n] * (fact_inv[k] * fact_inv[n - k] % MOD) % MOD;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, a, b, c, d; cin >> n >> a >> b >> c >> d;
  nCk_init(n);
  vector<long long> inv = inv_init(d);
  // dp[i][j] = 既に i 人グループに含まれており,
  //            各グループの最大人数が j 人
  vector<vector<long long> > dp(n+1, vector<long long>(b+1, 0));
  dp[0][a-1] = 1; // 高々 j 人なので1人もグループ分けされていなくてもよい
  REP(i, n+1) FOR(j, a-1, b) {
    // 既に i 人グループに含まれており, 各グループの最大人数が j 人のとき
    // j+1 人のグループを k (k = 0, c,...,d) グループ作る場合
    // 残りの人々の選び方の総数は
    // C(n-i, j+1) * C(n-i-(j+1), j+1) * ... * C(n-i-(k-1)*(j+1), j+1) / k!
    (dp[i][j+1] += dp[i][j]) %= MOD; // k = 0
    long long tmp = dp[i][j];
    FOR(k, 1, d+1) {
      if (i+k*(j+1) > n) break;
      (tmp *= nCk(n-i-(k-1)*(j+1), j+1) * inv[k] % MOD) %= MOD;
      if (k >= c) (dp[i+k*(j+1)][j+1] += tmp) %= MOD;
    }
  }
  cout << dp[n][b] << '\n';
  return 0;
}


Measured memory_bytes: 164352
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
typedef long long ll;
using namespace std;
void BinomialCoefficients() {
	int n;
	cin >> n;
	int t[100001];
	for (size_t i = 0; i < n; i++)
	{
		cin >> t[i];
	}
	sort(t, t + n);
	int med = 0;
	int minv = 1000000001;
	int lg = t[n - 1];
	int half = lg / 2 + (lg % 2);
	for (size_t i = 0; i < n - 1; i++)
	{
		int ab = abs(half - t[i]);
		if (ab < minv) {
			minv = ab;
			med = t[i];
		}
	}
	cout << t[n - 1] << " " << med << endl;
}
int main() {
	BinomialCoefficients();
	return 0;
}

Measured memory_bytes: 640
package main
 
import (
	"fmt"
)
 
func main() {
	var s string
	fmt.Scan(&s)
	s1 := s[:(len(s)-1)/2]
	s2 := s[(len(s)+3-1)/2:]
   
	f := equal(s1, s2)
	if f {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}
 
func equal(s1, s2 string) bool {
	if len(s1) == 1 {
		return true
	} else if len(s1) == 2 {
		if s1[0] == s2[0] && s1[1] == s2[1] {
			return true
		} else {
			return false
		}
	} else {
		for i := 0; i < len(s1); i++ {
			if s1[i] != s2[i] {
				return false
			}
		}
        for i, j :=0,len(s2)-1;; i, j = i+1, j-1 {
          if len(s1)%2 == 1 && i == j {
            break
          } else if len(s1)%2 == 0 && i > j {
            break
          }
          if s1[i] != s1[j] || s2[i] != s2[j] {
            return false
          }
      }
	}
 
	return true
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;

int main(){
    ll n,ans=1,NUM = 1e9+7;
    cin >> n;
    vector<ll> a(n);
    for(ll i=0;i<n;i++) cin >> a[i];
    sort(a.begin(),a.end());
    if(n%2==1){
        if(a[0]==0){
            for(int i=1;i<a.size();i+=2){
                if(a[i]!=a[i+1]){
                    cout << 0 << endl;
                    return 0;
                }
            }
        }
        else{
            cout << 0 << endl;
            return 0;
        }
    }
    else{
        for(int i=0;i<a.size();i+=2){
            if(a[i]!=a[i+1]){
                cout << 0 << endl;
                return 0;
            }
        }
    }
    for(ll i=1;i<=n/2;i++){
            ans*=2;
            ans=ans%ll(NUM);
    }
    cout << ans << endl;
    return 0;
}

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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (ll)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) {
        ll d = euclid(b, a % b, y, x);
        return y -= a / b * x, d;
    }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1)
            ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1);
        return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e)
            return Mod(1);
        Mod r = *this ^ (e / 2);
        r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int isprime(int n) {
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0 && (i % 7 == 1 || i % 7 == 6) && (n / i % 7 == 1 || n / i % 7 == 6)) {
            return false;
        }
    }
    return true;
}

int toint(string s) {
    string b;
    copy_if(all(s), back_inserter(b), [](char c) { return c != ':'; });
    return stoi(b);
}

struct P { ll p, a, b, c, d, e, f, s, m; string nm; };

int main() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin.exceptions(cin.failbit);

    const int dir[4][2] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}};

    for (;;) {
        int n; cin >> n;
        if (!n) break;

        vector<P> v(n);

        rep(i, 0, n) {
            P &p = v[i];
            cin >> p.nm >> p.p >> p.a >> p.b >> p.c >> p.d >> p.e >> p.f >> p.s >> p.m;
            // cout << p.nm << ": " << 1.0 * (p.m * p.f * p.s - p.p) / (p.a * p.b * p.c + p.m * (p.d + p.e)) << endl;
        }

        sort(all(v), [](const P&a, const P& b) {
            ll na = a.m * a.f * a.s - a.p, da = a.a + a.b + a.c + a.m * (a.d + a.e);
            ll nb = b.m * b.f * b.s - b.p, db = b.a + b.b + b.c + b.m * (b.d + b.e);

            // na/nb > da/db
            if (na * db != da * nb) {
                return na * db > da * nb;
            } else {
                return a.nm < b.nm;
            }
        });

        rep(i, 0, n) cout << v[i].nm << endl;
        cout << "#" << endl;
    }
}



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

int main(){
long long S;
  cin>>S;
  
  int ans=999;
  while(S>=100){
   int X=S%1000;
   ans=min(ans, abs(X-753)); 
    S/=10;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
/*input
1 0.01
*/

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

int main() {
  ll a, b = 0;
  cin >> a;
  rep(i, 4) {
    char c;
    cin >> c;
    if (i == 1) continue;
    b = b*10+(c-'0');
  }
  ll ans = a*b/100;
  cout << ans << endl;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define int long long int
int h[105];
int ans,n;
int32_t main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>h[i];
		if(h[i]>h[i-1]){
			ans += h[i]-h[i-1];
		}
	}
	cout<<ans;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int MAX = 50000;

void eratosthenes(bool* p)
{
	for (int i=0; i<=MAX; i++) p[i] = true;
	p[1] = false;
	for (int i=2; i<=MAX; i++) {
		if (!p[i]) continue;
		for (int d=2; i*d<=MAX; d++) p[i*d] = false;
	}
}

int main()
{
	int n;
	
	bool *is_prime = new bool[MAX+1];
	if (is_prime == NULL) return 1;
	eratosthenes(is_prime);
	
	while (true) {
		cin >> n;
		if (n==0) break;
		
		int count = 0;
		for (int i=2; i<=n/2; i++) {
			if (is_prime[i] && is_prime[n-i]) count++;
		}
		
		cout << count << endl;
	}
	
	delete[] is_prime;
	
	return 0;
}

Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
#define ll            long long
#define nl            "\n"
#define PB            push_back
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
int maxn=1e5+10;
int main()
{
    _SAD()
    int n,x;
    cin>>n>>x;
    int a[n],j=0;
    for(int i=0;i<n;i++)
    {
        int y,z;
        cin>>y>>z;
        if(z<=x)
        {
            a[j]=y;
            j++;
        }
    }
    if(j==0)
    {
        cout<<"TLE"<<nl;
        return 0;
    }
    SRT(a,j);
    cout<<a[0]<<nl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
#define REP(i, s, n) for(int i = s; i < n; ++i)
#define rep(i, n)        REP(i, 0, n)
#define SORT(c)          sort((c).begin(), (c).end())
#define IINF    INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
  
typedef long long               ll;
typedef pair <int, int> ii;
 
int main() {
     
    int a, l;
    while(cin >> a >> l, a, l){
        vector<int> as;
         
        rep(loop, 50){
            bool endflag = false;
            rep(i, as.size()){
                if(as[i] == a){
                    cout << i << " " << a << " " << loop - i << endl;
                    endflag = true;
                    break;
                }
            }
            if(endflag) break;
            as.push_back(a);
            vector<int> tmp(l);
            int i = 0;
            while(a != 0){
                tmp[i] = a % 10;
                a /= 10;
                i++;
            }
             
            SORT(tmp);

            int maxi = 0, mini = 0;
            int dex = 1;
            rep(i, l){
                mini += (dex * tmp[l-1-i]);
                maxi += (dex * tmp[i]);
                dex *= 10;
            }
            a = maxi - mini;
        }
    }
     
    return 0;
}

Measured memory_bytes: 3112
#include <iostream>

using namespace std;

int main(){
    int n;
    long ans=0,count=0;
    cin>>n;

    for(int a=1; a<=n; a++){
        for(int b=1; b<=n; b++){
            if(n-a*b>0) ans++;
            else break;
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
const int P=1e9 + 7;
int dp[113][100013];
int DD(const int a, const int b){return (a+b>=P?a+b-P:a+b);}
int T[113];

int main()
{
    ios_base::sync_with_stdio(0);
    int n,k;
    dp[0][0]=1;
    cin>>n>>k;
    for(int i=1;i<=n;i++)   cin>>T[i];
    for(int i=1;i<=n;i++)
    {
        dp[i][0]=1;
        for(int j=0;j<k;j++)
        {
            if(j+1>T[i])
            {
                dp[i][j+1]=dp[i-1][j+1]+dp[i][j]-dp[i-1][j-T[i]];
                dp[i][j+1]%=P;
                if(dp[i][j+1]<0)    dp[i][j+1]+=P;
            }
            else
            {
                dp[i][j+1]=DD(dp[i-1][j+1],dp[i][j]);
            }
        }
    }
    cout<<dp[n][k];
    return 0;
}


Measured memory_bytes: 40832
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
import re
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    s = S()
    ANS = "keyence"
    for i in range(len(s) + 1):
        for j in range(i, len(s)):
            a = s[:i] + s[j:]
            if a == ANS:
                print("YES")
                return
            
            
    print("NO")

    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 39792
#include<bits/stdc++.h>
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

vector<int>v;
void dfs(int p, int rest) {
	if (!rest) {
		rep(i, v.size()) {
			if (i)printf(" "); printf("%d", v[i]);
		}
		printf("\n");
		return;
	}
	for (int i = min(p, rest); i >= 1; i--) {
		v.push_back(i);
		dfs(i, rest - i);
		v.pop_back();
	}
}
int main() {
	int d;
	while (scanf("%d", &d), d) {
		dfs(d, d);
	}
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1000000007;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

ll dp[3010][3010][4];

int main(){
    ll R,C,K;
    cin >> R >> C >> K;
    vector<ll> r(K), c(K), v(K);
    vector<vector<ll>> T(R, vector<ll>(C));//, dp(R+1, vector<ll>(C+1));;
    rep(i,K){
        cin >> r[i] >> c[i] >> v[i];
        r[i]--;c[i]--;
        T[r[i]][c[i]] = v[i];
    }
    //rep(i,R+1)rep(j,C+1)rep(k,4)dp[i][j][k] = -1e18;
    //dp[0][0][0] = 0;
    rep(i,R){
        rep(j,C){
            for(ll k=2;k>=0;k--){
                cmax(dp[i][j][k+1], dp[i][j][k] + T[i][j]);
            }
            rep(k,4){
                if(i+1 < R){
                    cmax(dp[i+1][j][0], dp[i][j][k]);
                }
                if(j+1 < C){
                    cmax(dp[i][j+1][k], dp[i][j][k]);
                }
            }
        }
    }
    ll ans = 0;
    rep(k,4){
        cmax(ans, dp[R-1][C-1][k]);
    }
    cout << ans << endl;
    /*
    rep(i,R){
        multiset<ll> que;
        /*if(i<R-1){
            dp[i+2][1] = dp[i+1][1];
        }*/
        /*
        rep(j,C){
            if(T[i][j] == 0){
                dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
            }else{
                if(que.size() <= 2){
                    dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]) + T[i][j];
                    que.insert(T[i][j]);
                }else{
                    ll tmp = *que.begin();
                    if(tmp < T[i][j]){
                        que.erase(que.begin());
                        que.insert(T[i][j]);
                        if(dp[i+1][j]-tmp+T[i][j] <= dp[i][j+1]+T[i][j]){
                            dp[i+1][j+1] = dp[i][j+1]+T[i][j];
                        }else{
                            dp[i+1][j+1] = dp[i+1][j]-tmp+T[i][j];
                        }
                    }else{
                        if(dp[i+1][j] <= dp[i][j+1]+T[i][j]){
                            que.clear();
                            que.insert(T[i][j]);
                            dp[i+1][j+1] = dp[i][j+1]+T[i][j];
                        }else{
                            dp[i+1][j+1] = dp[i+1][j];
                        }
                    }
                }
            }
        }
        
    }
    cout << dp[R][C] << endl;*/
}

Measured memory_bytes: 360552
import sys

input = sys.stdin.readline

n = int(input())

ans = "No"
count = 0
for _ in range(n):
    a, b = map(int, input().split())
    if a == b:
        count += 1
        if count == 3:
            ans = "Yes"
    else:
        count = 0

print(ans)


Measured memory_bytes: 61840
import math

def main():
    Q = int(input())
    cnt = [0 for _ in range(10**5+1)]
    num = [False for _ in range(10**5+1)]
    
    
    for i in range(2, 10**5+1):
        for j in range(2, int(math.sqrt(i))+1):
            if(i%j==0):
                cnt[i] = cnt[i-1]
                break
        else:
            num[i] = True
            if(num[(i+1)//2]):
                cnt[i] = cnt[i-1]+1
            else:
                cnt[i] = cnt[i-1]

    for i in range(Q):
        l, r = map(int, input().split())
        print(cnt[r]-cnt[l-1])

main()

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

int main() {
	int N;
	cin >> N;
	unordered_map<int, bool> IsExist;
	bool ans = true;
	for (int i = 0; i < N; i++) {
		int A;
		cin >> A;
		if (IsExist[A]) ans = false;
		else IsExist[A] = true;
	}
	cout << (ans ? "YES" : "NO") << endl;
}

Measured memory_bytes: 8520
import heapq

N, M = [int(i) for i in input().split()]
heaps = [[] for _ in range(N + 1)]
cities = [None] * (M+1)
for m in range(M):
    p, y = [int(i) for i in input().split()]
    heapq.heappush(heaps[p], (y, p, m))

for heap in heaps:
    id = 0
    while len(heap) > 0:
        id += 1
        y, p, m = heapq.heappop(heap)
        cities[m] = "{:06d}{:06d}".format(p, id)

for i in range(M):
    print(cities[i])


Measured memory_bytes: 39144
# 数値の取得
thp,tat,ahp,aat = map(int,input().split())

# 勝敗が決まるまでターンをループ
twin = ""
while twin == "":
    # 高橋君のターン
    ahp -= tat
    if ahp <= 0:
        twin = "Yes"
        break
    # 青木君のターン
    thp -= aat
    if thp <= 0:
        twin = "No"
        break
# 結果を出力
print(twin)

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

int main() {
  char c;
  cin >> c;
  
  if (c == 'a' || c == 'e' || c == 'o' || c == 'u' || c == 'i') {
    cout << "vowel" << endl;
  }
  
  else {
    cout << "consonant" << endl;
  }

}


Measured memory_bytes: 256
<?php

$input = explode( ' ', trim( fgets( STDIN ) ) );

$x = $input[0];
$y = $input[1];
$z = $input[2];

$tmp = $x;
$x = $y;
$y = $tmp;

$tmp = $z;
$z = $x;
$x = $tmp;

echo $x . ' ' . $y .  ' ' . $z;


?>

Measured memory_bytes: 4728
//pragma
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define YOU using
#define DONT namespace
#define SAY std

YOU DONT SAY;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define REPP(i,a,b,d) for(int i=a;i<=b;i+=d)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,d) for(int i=a;i>=b;i-=d)
#define REV(i,a,b) REVV(i,a,b,1)

#define FOR(i,a) for(int i=0; i<a; i++)
#define FORD(i,a) for(int i=(int)a-1; i>=0; i--)

#define pb push_back
#define F first
#define S second

const int OO = 1e9;
const ll INF = 1e18;

const int irand(int lo,int hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

const ll lrand(ll lo,ll hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

#define getc getchar
template<typename T>
T getnum(){
	int sign = 1;
	T ret = 0;
	char c;

	do{
		c = getc();
	}while(c == ' ' || c == '\n');
	if(c == '-')sign = -1;
	else ret = c-'0';
	while(1){
		c = getc();
		if(c < '0' || c > '9')break;
		ret = 10*ret + c-'0';
	}
	return sign * ret;
}

inline void ini(int& x){
	x = getnum<int>();
}

inline void scani(int& x){
	scanf("%d",&x);
}

//end of macro

const ll MOD = 1e9 + 7;
inline ll addmod(ll a, ll b){
	if(a+b<MOD)return a+b;
	return a+b-MOD;
}
inline ll mulmod(ll a, ll b){
	return (a*b)%MOD;
}
inline ll expmod(ll a, ll e){
	ll ret = 1;
	while(e){
		if(e&1)ret = mulmod(ret, a);
		a = mulmod(a, a);
		e >>= 1;
	}
	return ret;
}
inline ll divmod(ll a, ll b){
	return mulmod(a, expmod(b, MOD-2));
}

const int N = 2e5 + 5;

int fac[N];

int n;
vi lst[N];

int ways[N];
int sz[N];
void idfs(int now, int par){
	sz[now] = 1;

	ways[now] = 1;
	int div = 1;

	FOR(i,lst[now].size()){
		int to = lst[now][i];
		if(to == par)continue;
		idfs(to, now);
		sz[now] += sz[to];

		ways[now] = mulmod(ways[now], ways[to]);
		div = mulmod(div, fac[sz[to]]);
	}

	ways[now] = divmod(mulmod(ways[now], fac[sz[now]-1]), div);
}

int ans[N];
void dfs(int now, int par, int waystop){
	int sztop = n - sz[now];
	int mul = divmod(fac[n-1], mulmod(fac[sztop], fac[sz[now]-1]));
	ans[now] = mulmod(mul, mulmod(ways[now], waystop));

	// printf("ways %d = %d\n",now,ways[now]);
	// printf("waystop = %d\n",waystop);

	int tv = mulmod(waystop, divmod(ways[now], fac[sz[now]-1]));
	int ssz = sz[now]-1;
	tv = divmod(tv, fac[sztop]);
	ssz += sztop;
	FOR(i,lst[now].size()){
		int to = lst[now][i];
		if(to == par)continue;
		dfs(to, now, divmod(mulmod(tv, mulmod(fac[ssz-sz[to]], fac[sz[to]])), ways[to]));
	}
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #define endl '\n'
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(10);

    // prec fac
    fac[0] = 1;
    REP(i,1,N-1)fac[i] = mulmod(fac[i-1], i);

    cin>>n;
    REP(i,2,n){
    	int a,b;
    	cin>>a>>b;
    	lst[a].pb(b);
    	lst[b].pb(a);
    }

    idfs(1, -1);

    dfs(1, -1, 1);

    REP(i,1,n){
    	cout << ans[i] << endl;
    }

    return 0;
}


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

int main(void){
    int line_num, i;
    vector<int> arr;
    arr.resize(3);
    cin >> line_num;
    for(i = 0; i < line_num; i++){
        cin >> arr[0] >> arr[1] >> arr[2];
        sort(arr.begin(), arr.end());
        if(arr[0]*arr[0]+arr[1]*arr[1] == arr[2]*arr[2]){
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
}

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

#pragma GCC diagnostic warning "-std=c++11"

/* Raiyan Noory Rady,CSE'17,RUET
Email:raiyannooryrady@gmail.com
Smile->Desire->Unity->Effort->Struggle->Success->Again smile :)
*/

#define ll long long int
#define pf push_front
#define mod  1000000007
#define inf  1000000000000000000
#define pi  acos(-1.0)
#define maxn  1000009
#define sorted(s)  sort(s.begin(),s.end())
#define sortarr(a) sort(a,a+n)
#define slc(n) scanf("%I64d", &n)
#define sl(n)  scanf("%lld", &n)
#define sf(n)  scanf("%lf", &n)
#define si(n)  scanf("%d", &n)
#define sch(n)  scanf(" %c", &n)
#define ss(n)  scanf("%s", n)
#define prf printf
#define pb  push_back
#define fr first
#define sc second
#define all(a)  a.begin(),a.end()
#define forl(n) for(i=0;i<n;i++)
/*STL library functions

sort(first_iterator, last_iterator) – To sort the given vector.

reverse(first_iterator, last_iterator) – To reverse a vector.

*max_element (first_iterator, last_iterator) – To find the maximum element of a vector.

*min_element (first_iterator, last_iterator) – To find the minimum element of a vector.

accumulate(first_iterator, last_iterator, initial value of sum) – Does the summation of vector elements

count(first_iterator, last_iterator,x) – To count the occurrences of x in vector.

find(first_iterator, last_iterator, x) – Points to last address of vector ((name_of_vector).end())
 if element is not present in vector.

binary_search(first_iterator, last_iterator, x) – Tests whether x exists in sorted vector or not.

lower_bound(first_iterator, last_iterator, x) – returns an iterator pointing to the first element in the range [first,last)
which has a value not less than ‘x’.

upper_bound(first_iterator, last_iterator, x) – returns an iterator pointing to the first element in the range [first,last)
 which has a value greater than ‘x’.

arr.erase(position to be deleted) – This erases selected element in vector and shifts and resizes the vector elements accordingly.

arr.erase(unique(arr.begin(),arr.end()),arr.end()) – This erases the duplicate occurrences in sorted vector in a single line.

distance(first_iterator,desired_position) – It returns the distance of desired position from the first iterator.
This function is very useful while finding the index.

next_permutation(first_iterator, last_iterator) – This modified the vector to its next permutation.

prev_permutation(first_iterator, last_iterator) – This modified the vector to its previous permutation.
*/

using namespace std;

int main()
{

    string s,t;
    cin>>s>>t;
    ll c=0,i;
    ll sz=s.size();
    for(i=0;i<sz;i++)
    {
        if(s[i]==t[i])
            c++;
    }
    cout<<c<<endl;


    return 0;
}






Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  int n;
  cin >> n;
  if(n==1){
    cout << "Hello World" << endl;
  }else{
    int a, b;
    cin >> a >> b;
    cout << a+b << endl;
    }  
  return 0;  
}


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

int main() {
int a,b,c;
cin>>a>>b>>c;
int ans=0;
ans=max(10*a+b+c,ans);
ans=max(10*b+a+c,ans);
ans=max(10*c+a+b,ans);
cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

#define debug(x) cout << #x << "==" << x << endl;

typedef long long ll;

#define MAX_V 10000
vector<int> G[MAX_V];


void dfs(int v, vector<int> visited, int &res) {


  if( visited[v] ) return;
  visited[v] = true;

  bool all_visited = true;
  for( bool b : visited ) { all_visited = b && all_visited; }
  if( all_visited ) { res++; }

  for(int w : G[v]) {
    dfs(w, visited, res);
  }

}


int main() {
  ios::sync_with_stdio(false);

  int V, E;
  cin >> V >> E;

  for(int i = 0; i < E; i++) {
    int v, w;
    cin >> v >> w;
    v--; w--;
    G[v].push_back(w);
    G[w].push_back(v);
  }

  vector<int> visited(V, false);
  int res = 0;
  dfs(0, visited, res);

  cout << res << "\n";

  return 0;
}


Measured memory_bytes: 512
fun main(args:Array<String>?): Unit {
    while(true){
        val n = readLine()!!.trim().toInt()
        if (n == 0) return
        val goods = readLine()!!.trim().split(' ').map(String::toInt)
        if (goods.count{it > 1} == 0) println("NA")
        else println(goods.count{it > 0} + 1)
    }
}


Measured memory_bytes: 74008