akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
#endif

	
	
		int n,k;
		cin>>n>>k;
		bool sn[n+1]={0};
		for(int i=0;i<k;i++)
		{
			int d;
			cin>>d;
			for(int j=0;j<d;j++)
			{
				int s;
				cin>>s;
				sn[s]=1;
			}
		}
		int count=0;
		for(int i=1;i<=n;i++)
		{

			if(sn[i]==0)
			{
				count++;
			}
		}
		cout<<count;

	return 0;
}


Measured memory_bytes: 3644
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
//ll n;
//ld ;
string s;
// char c;

int main() {
  cin >> s;
  bool ans = (s[0]!=s[1]) || (s[1]!=s[2]) || (s[1]!=s[2]);
  yorn(ans);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) x.begin() , x.end()
#define ll long long 
#define pb push_back
#define mp make_pair

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n ; cin>>n;
    vector<int>v(n);
    int mx = 0;
    for(int& i : v){
        cin>>i;
        mx = max(i , mx);
    }
    sort(all(v));
    int cnt = 0;
    for(int i = 1 ; i <= mx; ++i){
        int x = upper_bound(all(v) , i) - v.begin();
        if(2 * x == n)cnt++;
    }
    cout<<cnt<<endl;
    

}

Measured memory_bytes: 768
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define rep(i,n) for(int i=0;i<(n);i++)
#define tr(it,container) for(typeof(container.begin()) it = container.begin(); \
                                                  it != container.end(); ++it)
#define mp(a,b) make_pair((a),(b))
#define eq ==

typedef long long ll;
typedef complex<double> point;
typedef pair<int,int> pii;

// →↑←↓
const int dx[] = {1,0,-1,0};
const int dy[] = {0,-1,0,1};


const double EPS = 1e-9;

int main(){
    while(true){
        int n,S;

        cin >> n >> S;
        if(n == 0) break;
        vector<int> R(n);
        rep(i,n) cin >> R[i];
        sort(all(R));

        int allcnt = 0;
        for(int i=0;i<n;i++){
            int req = S+1 - R[i];

            int lower = (lower_bound(R.begin(),R.end(),req) - R.begin());
            //cerr << i << " " << lower << endl;
            int cnt = n-lower;
            if(lower <= i){
                // self contain.
                cnt--;
            }
            allcnt += cnt;
        }
        cout << allcnt/2 << endl;
    }
    return 0;
}

Measured memory_bytes: 1252
import numpy as np
    
n = int(input())
S = np.asarray([])
St = np.zeros(4) # None,B,A,BA
count = 0

for i in range(n):
    S=np.append(S,input())
    tmp = 0
    count += S[i].count("AB")
    if S[i][0] == "B":
        tmp += 1
    if S[i][-1] == "A":
        tmp += 2
    St[tmp]+=1

if (St[1] == 0)&(St[3]>0):
    St[1]+=1
    St[3]-=1

if (St[2] == 0)&(St[3]>0):
    St[2]+=1
    St[3]-=1

print(int(count+min(St[1],St[2])+St[3]))

Measured memory_bytes: 15040
// #include "bits/stdc++.h"
#include<iostream>
#include<algorithm>
#include<bitset>
#include<string>
#include<vector>
#include<string.h>

using namespace std;

#ifdef LOCAL
        #include "debug.h"
        #define input freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
        #else
        #define debug(...) 4
        #define input ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#endif

using ll = long long;
const int N = 2e5 + 5;
const int mod = 1e9 + 7;


int dp[19][1 << 18];

int main() {
    input;
    int n;
    cin >> n;
    int a[n], b[n];
    for(int i = 0; i < n; i++)
        cin >> a[i];

    for(int i = 0; i < n; i++) {
        cin >> b[i];

    }
    int ans = 1e9;
    for(int mask = 0; mask < (1 << n); mask++) {
        vector<pair<int, int>> v;
        vector<pair<int, int>> odd, even;
        // if present in mask, use b[j], else a[i]
        // b[j] and j will have different parity
        // a[j] and j will have same parity

        for(int j = 0; j < n; j++) {
            if((1 << j) & mask) {
                if(j % 2)
                    even.push_back({b[j], j});
                else
                    odd.push_back({b[j], j});

            }
            else {
                if(j % 2)
                    odd.push_back({a[j], j});
                else
                    even.push_back({a[j], j});
            }
        }
        if(odd.size() != (n / 2))
            continue;
        sort(odd.begin(), odd.end());
        sort(even.begin(), even.end());
        int inv = 0;
        for(int i = 0; i < n; i++) {
            if(i % 2)
                v.push_back(odd[i / 2]);
            else
                v.push_back(even[i / 2]);
            if(i > 0) {
                if(v.back().first < v[i - 1].first)
                    inv = 1e9;
            }
        }
        // sort odd and even and merge alternatively
        for(int i = 0; i < n; i++) {
            for(int j = i + 1; j < n; j++) {
                if(v[i].second > v[j].second)
                    inv++;
            }
        }
        // inversion count is the no of operations
        ans = min(ans, inv);
        
    }

    cout << (ans == 1e9 ? -1 : ans);

}   

Measured memory_bytes: 384
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val N = nextInt()
    val A = IntArray(N) { nextInt() }
    val max = A.max()!!
    val mmax = A.toList().minus(max).max()!!
    for (a in A) {
        println(if (a != max) max else mmax)
    }
}

Measured memory_bytes: 61952
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define ll long long int

ll t[100001],ar[100001],k;

ll fun(ll l,ll r){
  if(l>=r) return 0;
  ll a=0,b=0;
  if(t[l]==-1){
    t[l]=fun(l+1,r)+abs(ar[l]-ar[l+1]);
    for(int i=2;i<=k;i++){
      if(l+i<=r){ 
       a=fun(l+i,r)+abs(ar[l]-ar[l+i]);
       t[l]=t[l]>=a?a:t[l];
      }
    }
  }
  return t[l];
}

  int main(){
    for(int i=0;i<100001;i++)
     t[i]=-1;
    ll n;
    scanf("%lld%lld",&n,&k);
    for(int i=0;i<n;i++)
      scanf("%lld",ar+i);
    printf("%lld\n",fun(0,n-1));
    return 0;
  }


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

bool stones(int arr[], int n, int k){

    vector<bool> dp(k+1);
    dp[0] = false;
    for(int i=1; i<=k; i++){
        dp[i] = false;
        for(int j=0; j<n; j++)
            if(i-arr[j] >= 0 and !dp[i-arr[j]]){
                dp[i] = true;
                break;
            }
    }
    return dp[k];
}

int main()
{
 int n, k;
 cin>>n>>k;
 int arr[n];
 for(int i=0; i<n; i++)
     cin>>arr[i];
 if(stones(arr, n, k))
    cout<<"First"<<endl;
 else
    cout<<"Second"<<endl;

 return 0;
}



Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)


int main(){
    ll x;
    cin >> x;

    cout << (2199 - x) / 200 << endl;

    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
using namespace std;
long long n,m,a[1000000],b[1000000],c[1000000],u,v,res,ress;
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    cin>>n>>m;
    for (int i=1;i<=n;i++)
        cin>>a[i];
    for (int i=1;i<=m;i++){
        cin>>u>>v;
        if (c[u]==0)ress++;
        if (c[v]==0)ress++;
        c[u]=1;
        c[v]=1;
        if (a[u]<=a[v]&&b[u]==0){b[u]=1;res++;}
        if (a[u]>=a[v]&&b[v]==0){b[v]=1;res++;}
    }
    cout<<n-res;
}


Measured memory_bytes: 5544
#include <iostream>
using namespace std;
#define rep(i,n) for (int i=0;i<n;i++)

int main() {
	int n;
	while (cin >> n && n) {
		int two_count = 0;
		int five_count = 0;
		int warukazu = 2;

		while(warukazu <= n) {
			two_count += n / warukazu;
			warukazu *= 2;
		}

		warukazu = 5;
		while (warukazu <= n) {
			five_count += n / warukazu;
			warukazu *= 5;
		}

		cout << (two_count > five_count ? five_count : two_count) << endl;
	}

}

Measured memory_bytes: 3072
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
using namespace std;

int main(){
    string S;cin>>S;
    long long K;cin>>K;
    int N=S.size();

    int i=0;
    long long c1=0;
    while(S[i]=='1'){
        c1++;
        i++;
        if(i==N){
            cout<<1<<endl;
            goto lol;
        }
    } 
    if(K<=c1)cout<<1<<endl;
    else cout<<S[i]<<endl;
    lol:
    return 0;
}

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

int main(){
	int x,y;
	cin >> x >> y;
	while(!(x==0&&y==0)){
		if(x<y) cout << x << " " << y << endl;
		else cout << y << " " << x << endl;
		cin >> x >> y;
	}
	return 0;
}


Measured memory_bytes: 2976
#include <stdio.h>
#include <iostream>
using namespace std;
int main(int argc, char **argv)
{
    long long N;
    long long M;

    cin >> N >> M;
    long long bins[N + 1];
    for (long long  i = 0; i < N + 1; i++)
    {
        bins[i] = 0;
    }
    long long right = 0;
    long long wrongnum = 0;
    long long Pi = -1;

    for (long long i = 0; i < M; i++)
    { //loop through each problem
        cin >> Pi;
        string Si;
        cin >> Si;
        if (bins[Pi] == -1)
        {
        }
        else if (Si.compare("AC") == 0)
        {
            right++;
            wrongnum+=bins[Pi];
            bins[Pi]=-1;

        }
        else
        {
            bins[Pi]++;
        }
    }
    cout << right << " " << wrongnum;
    return 0;
}

Measured memory_bytes: 1024
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author NikuKyabe
 */

#include "bits/stdc++.h"
using namespace std;


class AAlready2018 {
public:
	void solve(std::istream& in, std::ostream& out) {
    string s;
    in >> s;
    s[3] = '8';
    out << s;
	}
};


signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout << fixed;
	AAlready2018 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

using namespace std;

#define N 1200000

int n,a[N],sum;
char s[N];

int main(){
	scanf("%s",s+1); n=strlen(s+1);
	for (int i=1;i<=n;++i) a[i]=s[n-i+1]-'0';
	++n;
	for (int i=1,jw=0;i<=n;++i){
		a[i]=a[i]*9+jw;
		jw=a[i]/10;
		a[i]%=10;
	}
	for (int i=1;i<=n;++i) sum+=a[i];
	for (int i=0;;++i){
		if (sum<=i){
			printf("%d\n",(i+8)/9);
			return 0;
		}
		++a[1]; ++sum;
		for (int j=1;a[j]>9;++j){
			sum-=9;
			a[j]=0;
			++a[j+1];
		}
		if (a[n+1]) ++n;
	}
	
	return 0;
}
			

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;

#define ll long long
const long long llINF = 1LL << 60;
const int iINF = 1LL << 20;
template<class T> inline bool chmin(T& a, T b) {
    if (b < a) {
        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;
}

void execute();
int main() 
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);// cin と scanfの併用禁止
    cout << fixed << setprecision(15);
    execute();
    return 0;
}


void execute()
{
    int N;
    cin >> N;

    ll sum[100001][3];
    sum[0][0] = sum[0][1] = sum[0][2] = 0L;
  
    for(int i = 1; i <= N; i++){
    ll a[3];
    cin >> a[0] >> a[1] >> a[2];
      
    for(int j = 0; j < 3; j++){
      sum[i][j] = 0;
      for(int k = 0; k < 3; k++){
        if(j==k) continue;
        chmax(sum[i][j], sum[i-1][k] + a[j]);
      }
    }
  }

  ll v = 0;
  chmax(v, sum[N][0]);
  chmax(v, sum[N][1]);
  chmax(v, sum[N][2]);
  
  cout << v << endl; 
}


Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <set>
using namespace std;
int main(void){
    int a,b;
    cin>>a>>b;
    char c[200][200];
    for(int i=0;i<a+2;i++){
        for(int j=0;j<b+2;j++){
            if(i==0||i==a+1||j==0||j==b+1)c[i][j]='#';
            else cin>>c[i][j];
            cout<<c[i][j];
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
problems = [False] * (N+1)
penalty = [0]*(N+1)

for i in range(M):
    p, S = input().split()
    if S == 'AC':
        problems[int(p)] = True
    if S == 'WA' and problems[int(p)] is False:
        penalty[int(p)] += 1

ans_AC, ans_pena = 0, 0
for i in range(1, N+1):
    if problems[i] is True:
        ans_AC += 1
        ans_pena += penalty[i]


print(ans_AC, ans_pena)


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

int main()

{
    string s;

    cin >> s;
    int sum =0;
     int n = s.length();
     for(int i =0;i<n;i++)
     {
         sum += (s[i]-'0');
     }
     int k = stoi(s);
     if(k%sum ==0)
        cout << "Yes";
     else
        cout << "No";

}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

#define X_MAX ((int)pow(10, 9))

int main(){
	unsigned int x;
	cin >> x;
	unsigned int sum = 0;
	for(int i = 0; i < X_MAX; i++){
		sum += i;
		if(sum >= x){
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
import sys

def func(s, i):
    if i == 7:
        if eval(s) == 7:
            print(s + '=7')
            sys.exit()
        return
    s = s[:i] + '+' + s[i + 1:]
    func(s, i + 2)
    s = s[:i] + '-' + s[i + 1:]
    func(s, i + 2)

s = input()

a = s[0]
b = s[1]
c = s[2]
d = s[3]
s = a + '#' + b + '#' + c + '#' + d

func(s, 1)

Measured memory_bytes: 3064
#https://atcoder.jp/contests/dp/tasks/dp_a
n=int(input())
L=list(map(int,input().split()))
#L=[30 ,10 ,60 ,10 ,60 ,50]
dp=[9999999]*n
#upišem si za prva dva jer mi je lakše
dp[0]=0
dp[1]=abs(L[0]-L[1])
#krećemo od dva jer ga još nismo izračunali
for i in range(2,n):
       skok1=dp[i-1]+abs(L[i]-L[i-1])
       skok2=dp[i-2]+abs(L[i]-L[i-2])
       dp[i]=min(skok1, skok2)

print(dp[n-1])
       



Measured memory_bytes: 13924
#メモ化再帰
import sys
sys.setrecursionlimit(10**5+10)

n = int(input())
h = [int(i) for i in input().split()]

#dpの最小値を変更する関数
def chmin(a, b):
    if a > b:
        return b
    else:
        return a

f_inf = float('inf')

#DPテーブルの初期化
dp = [f_inf] * (10**5+10)

#メモ化再帰の関数
def rec(i):
    #dpの値が更新されている場合はその値を返す
    if dp[i] < f_inf:
        return dp[i]
    #再帰の終了条件
    if i == 0:
        return 0
    res =f_inf
    res = chmin(res, rec(i-1)+abs(h[i]-h[i-1]))
    if i >1:
        res = chmin(res, rec(i-2) + abs(h[i]-h[i-2]))
    #結果をメモ
    dp[i]= res
    return res

ans = rec(n-1)
print(ans)

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;

/*UnionFind--------------------------*/
class UnionFind {
    using i32 = int_fast32_t;
private:
    std::vector<i32> parent;
    std::vector<i32> siz;

public:
    UnionFind(i32 sz): parent(sz), siz(sz, 1) {
        for(i32 i = 0; i < sz; ++i) parent[i] = i;
    }
    void init(i32 sz) {
        for(i32 i = 0; i < sz; ++i) parent[i] = i;
    }
    /*Member Func------*/
    /*return root id*/
    i32 root(i32 x) {
        while(parent[x] != x) {
            x = parent[x] = parent[parent[x]];
        }
        return x;
    }
    /*merge two groups*/
    bool merge(i32 x, i32 y) {
        x = root(x);
        y = root(y);
        if(x == y) return false;
        //Merge Tech
        if (siz[x] < siz[y]) swap(x,y);
        siz[x] += siz[y];
        parent[y] = x;
        return true;
    }
    /*同じ集合にあるか*/
    bool issame(i32 x, i32 y) {
        return (root(x) == root(y));
    }
    /*xの属する集合の大きさ*/
    i32 size(i32 x) {
        return siz[root(x)];
    }
};

/*-----------------------------------*/
/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int _StartTime_ = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    int n,m,k; cin >> n >> m >> k;

    UnionFind uni(n);

    vec<PII> friends;
    vi ans(n, 0);
    rep(i,m) {
        int a,b;
        cin >> a >> b;
        --a;--b;
        uni.merge(a, b);
        --ans[a];
        --ans[b];
    }

    rep(i,n) ans[i] += uni.size(i);

    vec<PII> block(k);
    rep(i,k) {
        int c,d;
        cin >> c >> d;
        --c;--d;
        if(uni.issame(c,d)) {
            --ans[c];--ans[d];
        }
    }

    rep(i,n) cout << max(0,ans[i]-1) << (i==n-1 ? '\n' : ' ');

    // printf("ExcutionTime: %d /ms\n",1000*(int)((clock()-_StartTime_)/CLOCKS_PER_SEC));
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(LLI i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a, b) ((a < b) ? a : b)
#define _max(a, b) ((a < b) ? b : a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a) ? 1 : -1)
#define SORT(v) sort(v.begin(), v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

int main() {
    cout << fixed << setprecision(10);
    LLI W, H;
    cin >> H >> W;

    LLI ans = H * W;
    FOR(w, 1, W) {
        LLI a = H * w;
        LLI b = (H / 2) * (W - w);
        LLI c = (H - H / 2) * (W - w);

        LLI ma = max(max(a, b), c);
        LLI mi = min(min(a, b), c);

        chmin(ans, ma - mi);
    }
    FOR(h, 1, H) {
        LLI a = h * W;
        LLI b = (H - h) * (W / 2);
        LLI c = (H - h) * (W - W / 2);

        LLI ma = max(max(a, b), c);
        LLI mi = min(min(a, b), c);

        chmin(ans, ma - mi);
    }
    FOR(w, 1, W) {
        LLI a = H * w;
        LLI b = H * ((W - w) / 2);
        LLI c = H * ((W - w) - (W - w) / 2);

        LLI ma = max(max(a, b), c);
        LLI mi = min(min(a, b), c);

        chmin(ans, ma - mi);
    }
    FOR(h, 1, H) {
        LLI a = h * W;
        LLI b = ((H - h) / 2) * W;
        LLI c = ((H - h) - (H - h) / 2) * W;

        LLI ma = max(max(a, b), c);
        LLI mi = min(min(a, b), c);

        chmin(ans, ma - mi);
    }
    cout << ans;
    return 0;
}

/*

W*(h)
W*(H-h)/2

*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)




using namespace std;
using ll = long long;
using P = pair<int,int>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;
const ll Lmax=ll(1e18);
const ll Nmax=1e9;



int main(){
  ll n;
  cin>>n;
  vector<string> s(n);
  map<string,int> mp;
  ll ans=0;
  rep(i,n){
    cin>>s[i];
    sort(s[i].begin(),s[i].end());
    if(mp[s[i]]>0){
    	ans+= mp[s[i]];
    }
    mp[s[i]]+=1;
  }
  cout<<ans;


  return 0;





}


Measured memory_bytes: 14088
#include<iostream>
using namespace std;
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2 + 2], R[MAX/2 + 2];
int cnt;

void merge(int A[], int n, int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    for ( int i = 0; i < n1; i++) L[i] = A[left + i];
    for ( int i = 0; i < n2; i++) R[i] = A[mid + i];
    L[n1] = R[n2] = SENTINEL;
    int i = 0, j = 0;
    for ( int k = left; k < right; k++) {
        cnt++;
        if ( L[i] <= R[j] ) {
            A[k] = L[i++];
        }
        else {
            A[k] = R[j++];
        }
    }
}

void mergeSort(int A[], int n, int left, int right) {
    if ( left + 1 < right ) {
        int mid = (left + right ) / 2;
        mergeSort(A, n, left, mid);
        mergeSort(A, n, mid, right);
        merge(A, n, left, mid, right);
    }
}

int main() {
    int A[MAX], n, i;
    cnt = 0;
    cin >> n;
    for ( i = 0; i < n; i++) cin >> A[i];

    mergeSort(A, n, 0, n);
    for ( int i = 0; i < n; i++) {
        if ( i ) cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 6996
use proconio::{fastout, input};
use std::io::*;
use std::str::FromStr;

use std::cmp::{max, min};
use std::collections::{BinaryHeap, HashMap, HashSet, VecDeque};

fn main() {
    input! {
        n: usize,
        w: usize,
        wv: [(usize, usize); n],
    }
    let mut wmap = vec![vec![]; 4];
    let w1 = wv[0].0;

    for i in 0..wv.len() {
        let wvi = wv[i];
        let d = wvi.0 - w1;
        wmap[d].push(wvi.1);
    }

    for i in 0..wmap.len() {
        wmap[i].sort();
        wmap[i].reverse();
    }

    for i in 0..wmap.len() {
        let mut tmp = 0;
        for j in 0..wmap[i].len() {
            tmp += wmap[i][j];
            wmap[i][j] = tmp;
        }
    }
    let mut ans = 0;

    for a in 0..=n {
        for b in 0..=n - a {
            for c in 0..=n - b - a {
                for d in 0..=n - a - b - c {
                    if a > wmap[0].len()
                        || b > wmap[1].len()
                        || c > wmap[2].len()
                        || d > wmap[3].len()
                    {
                        continue;
                    }
                    // println!("a:{}, b:{}, c:{}, d:{}", a, b, c, d);
                    if a * w1 + b * (w1 + 1) + c * (w1 + 2) + d * (w1 + 3) > w {
                        continue;
                    }
                    let abcd = vec![a, b, c, d];
                    let mut s = 0;
                    for i in 0..4 {
                        if abcd[i] != 0 {
                            s += wmap[i][abcd[i] - 1];
                        }
                    }
                    ans = max(ans, s);
                }
            }
        }
    }

    // println!("wmap:{:?}", wmap);
    println!("{}", ans);
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
static const int MOD = 1000000007;
long long int memo_fact_mod[200001];
long long int memo_fact_inverse_mod[200001];
long long int mod_pow(long long int x, long long int n){
	if(n == 0) return 1;
	long long int res = mod_pow(x * x % MOD, n / 2);
	if(n % 2 == 1) res = res * x % MOD;
	return res;
}
long long int fact_mod(long long int n){
	long long int res = 1;
	for(long long int i = 1; i <= n; i++){
		res *= i;
		res %= MOD;
	}
	return res;
}
long long int fact_inverse_mod(long long int n){
	long long int res = mod_pow(fact_mod(n), MOD - 2);
	return res;
}
long long int combination(long long int n, long long int r){
	return (((fact_mod(n) * fact_inverse_mod(r)) % MOD) * fact_inverse_mod(n - r)) % MOD;
}
long long int combination_with_memo(long long int n, long long int r){
	if(r == 0 || r == n) return 1;
	else return (((memo_fact_mod[n] * memo_fact_inverse_mod[r]) % MOD) * memo_fact_inverse_mod[n - r]) % MOD;
}

int main(){
	memo_fact_mod[0] = 0; memo_fact_mod[1] = 1LL;
	for(int i = 2; i <= 200000; i++){
		memo_fact_mod[i] = (memo_fact_mod[i - 1] * i) % MOD;
	}
	for(int i = 0; i <= 200000; i++){
		memo_fact_inverse_mod[i] = mod_pow(memo_fact_mod[i], MOD - 2);
	}
	int H, W, A, B;
	scanf("%d %d %d %d", &H, &W, &A, &B);
	long long int ans = 0;
	for(int i = B + 1; i <= W; i++){
		ans += ((combination_with_memo(i + (H - A) - 2, i - 1) * combination_with_memo(W - i + A - 1, A - 1)) % MOD);
		ans %= MOD;
	}
	printf("%lld\n", ans);
	return 0;
}


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

int main() {
    int n;
    cin>>n;
    vector<int> t(n+1),x(n+1),y(n+1);
    t[0]=0;x[0]=0;y[0]=0;
    for(int i=1;i<=n;i++){
        cin>>t[i]>>x[i]>>y[i];
    }
    bool ok = true;
    rep(i,n){
        int dist = abs(x[i+1]-x[i])+abs(y[i+1]-y[i]);
        if((t[i+1]-t[i])<dist) ok = false;
        if((t[i+1]-t[i])%2 != dist%2) ok = false;
    }
    if(ok) cout<< "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int a[10];
for(int i=0;i<10;i++)cin>>a[i];
sort(a,a+10);
cout<<a[9]<<endl;
cout<<a[8]<<endl;
cout<<a[7]<<endl;
return 0;
}

Measured memory_bytes: 1176
using System;
using System.Collections.Generic;
class Program
{

    static void Main()
    {
       
        string[] AB = Console.ReadLine().Split(' ');
        decimal A = decimal.Parse(AB[0]);
        decimal B = decimal.Parse(AB[1]);
        decimal C = 0;

        C = A * B;

        C = Math.Floor(C);

        Console.WriteLine(C);

    }

}

Measured memory_bytes: 27632
import sys
from collections import OrderedDict
#from me.io import dup_file_stdin

#@dup_file_stdin
def solve():
    while True:
        n = int(sys.stdin.readline())
        if n==0 :
            break
        emps = OrderedDict()
        for i in range(n):
            no,price,amount = map(int,sys.stdin.readline().split(' '))
            emps[no]=emps.get(no,0)+price*amount
        results = [k for k,v in emps.items() if v>=1000000]
        if len(results) > 0:
            [print(emp) for emp in results]
        else:
            print("NA")
solve()
        

Measured memory_bytes: 8320
/* Author: Jason L.(int3xccATgmailDOTcom), Mon Sep  4 00:19:04 CST 2017 */
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using pll = pair<ll, ll>; using dd = long double;
//=========================================================================
namespace {
static bool constexpr dbg =
#ifdef INT3XCC_DEBUG
        1;
#else
        0;
#endif
#define Dprintf(fmt, ...) do{if(dbg) printf(fmt, ##__VA_ARGS__);}while(0)
#define REP0(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
//=========================================================================
ll constexpr N = 1.1e5;
ll n, cnt[N], res;
//=========================================================================
void init() {
    cin>>n;
    REP1(_, n) {
        ll t; cin>>t; ++cnt[t];
    }
}
void solve() {
    REP1(i, N-2) res = max(res, cnt[i-1] + cnt[i] + cnt[i+1]);
    cout<<res;
}}
//=========================================================================
int main() {
    if (!dbg) { std::ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
    cout<<fixed<<setprecision(20); init(); solve(); return 0;
}


Measured memory_bytes: 1024
# coding: utf-8
import sys
# from operator import itemgetter
sysread = sys.stdin.readline
read = sys.stdin.read
sys.setrecursionlimit(10 ** 7)
from heapq import heappop, heappush
#from collections import OrderedDict, defaultdict
#import math
#from itertools import product, accumulate, combinations, product
#import bisect# lower_bound etc
#import numpy as np
#from copy import deepcopy
#from collections import deque
#import numba

def sum_between(a, b):
    return (abs(b-a)+1) * (b+a) // 2

def run():
    N = int(input())
    n_dots = 0
    for i in range(1, N+1):
        n_dots += (1+i) * i // 2
    #print(n_dots)
    ans = (N-1) * (N+1) * N // 2
    #print(ans)
    lr = list(map(int, read().split()))
    l = lr[::2]
    r = lr[1::2]
    for l,r in zip(l, r):
        if l > r: l,r = r,l
        tmp = 0
        if l > 1: tmp += sum_between(r-1, r-l+1)
        tmp += r-l
        tmp += sum_between(N-l, 1)
        #print(tmp)
        ans -= tmp

    print(n_dots - ans)


    ans = (N-1) * N * N


if __name__ == "__main__":
    run()

Measured memory_bytes: 57184
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(obj) (obj).begin(),(obj).end()

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a[3][3];
  rep(i,3)rep(j,3)cin>>a[i][j];
  int n;cin>>n;
  rep(i,n){
    int tmp;
    cin>>tmp;
    rep(k,3)rep(j,3)if(a[k][j]==tmp)a[k][j]=-1;
  }
  bool s=0;
  if(a[0][0]==-1){
    if(a[0][1]==-1&&a[0][2]==-1)s=1;
    else if(a[1][0]==-1&&a[2][0]==-1)s=1;
    else if(a[1][1]==-1&&a[2][2]==-1)s=1;
  }
  if(a[0][1]==-1){
    if(a[1][1]==-1&&a[2][1]==-1)s=1;
  }
  if(a[0][2]==-1){
    if(a[1][2]==-1&&a[2][2]==-1)s=1;
    else if(a[1][1]==-1&&a[2][0]==-1)s=1;
  }
  if(a[1][0]==-1){
    if(a[1][1]==-1&&a[1][2]==-1)s=1;
  }
  if(a[2][0]==-1){
    if(a[2][1]==-1&&a[2][2]==-1)s=1;
  }
  
  if(s==1)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;

int main(){
    int a,b,d,r;
    double f;
    cin >> a >> b;
    d = a/b;
    r = a%b;
    f = 1.00000*a/b;
    printf("%d %d %.5lf\n", d, r ,f);
    return 0;
}


Measured memory_bytes: 3224
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    cout << ((a == b && b == c && c == a)? "Yes":"No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int f=1;
    string s,t;
    cin >> s;
    cin>>t;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]!=t[i])
        {
            f=0;
            break;
        }
    }
    if(t.length()!=s.length()+1)
    {
        f=0;
    }
    if(f)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 3632
*a, = map(int, list(input())[::-1])
n = len(a)

b = [[0]*k for k in range(n+1)]
for k in range(n+1):
    for i in range(k):
        b[k][i] = sum([10**j * a[i+j] for j in range(k-i)])
# b[k][i]は整数"a[k-1]a[k-2] ... a[i]"

dp = [0]*n
for k in range(n):
    dp[k] = sum([b[k+1][0]] + [b[k+1][i+1]*2**i + dp[i] for i in range(k)])

print(dp[n-1])


Measured memory_bytes: 3064
N = int(input())
liss = {}
for i in range(N):
  s = input()
  a = "".join(sorted(s))
  if a in liss:
    liss[a] += 1
  else:
    liss[a] = 1

ans = 0
for cc in liss:
  ans = ans + (liss[cc] * (liss[cc] - 1) / 2)
print(int(ans))


Measured memory_bytes: 17892
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define ocut cout
#define ouct cout
#define itn int
;
long long gcd(long long a, long long b){
   if (a%b == 0){
       return(b);
   }
   else{
       return(gcd(b, a%b));
   }
}

long long lcm(long long a, long long b){
   return a/gcd(a, b)*b;
}
int main(){
  long long n;
  cin >> n;
  long long t[n];
  rep(i,n){
    cin >> t[i];
  }
  long long to=t[0],m;
  rep(i,n-1){
    m=to;
    m=lcm(to,t[i+1]);
    to=m;
  }
  cout << to;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  ll H[N];
  for(int i=0;i<N;++i) cin>>H[i];
  int ans=0;
  int tmp=0;
  for(int i=0;i<N-1;++i) {
    if(H[i]>=H[i+1]) tmp++;
    else {
      ans = max(ans, tmp);
      tmp = 0;
    }
  }
  ans = max(ans, tmp);
  cout<<ans<<endl;
}



Measured memory_bytes: 4356
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int>P;
typedef tuple<int,int,int,int>T;
#define PI 3.14159265359
#define MOD 1000000007

const int MAX =210000;
int main(){
  int N;
  cin >>N;
  vector<int>A(N);
  rep(i,N){
  	cin >>A[i];
  }
  vector<int>a(N);
  a[0]=0;
  for(int i=0;i<=N-2;i++){
  	a[i+1]=A[i]-a[i];
  }
  ll sumA=0;
  ll suma=0;
  rep(i,N){
    sumA+=A[i];
  	suma=suma+(2*a[i]);
  }
  ll dif=(suma-sumA)/2;
  rep(i,N){
  	if(i%2==0){a[i]-=dif;}
    else{a[i]+=dif;}
  }
  rep(i,N){
  cout<<2*a[i]<<' ';
  }
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

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

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

	int c[3][3];

	rep(i, 3) rep(j, 3) cin >> c[i][j];

	if(c[1][0] - c[0][0] != c[1][1] - c[0][1]){
		cout << "No" << endl;
		return 0;
	}

	if(c[1][0] - c[0][0] != c[1][2] - c[0][2]){
		cout << "No" << endl;
		return 0;
	}

	if(c[2][0] - c[1][0] != c[2][1] - c[1][1]){
		cout << "No" << endl;
		return 0;
	}

	if(c[2][0] - c[1][0] != c[2][2] - c[1][2]){
		cout << "No" << endl;
		return 0;
	}

	if(c[0][1] - c[0][0] != c[1][1] - c[1][0]){
		cout << "No" << endl;
		return 0;
	}

	if(c[1][1] - c[1][0] != c[2][1] - c[2][0]){
		cout << "No" << endl;
		return 0;
	}

	if(c[0][2] - c[0][1] != c[1][2] - c[1][1]){
		cout << "No" << endl;
		return 0;
	}

	if(c[1][2] - c[1][1] != c[2][2] - c[2][1]){
		cout << "No" << endl;
		return 0;
	}

	cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)
ll INF = 1LL << 60;

//* check if a single integer n is a prime O(sqrt(N))
bool is_prime(ll n){
    for(ll i=2; i*i<=n; i++){
        if(n % i == 0)
            return false;
    }
    return n!= 1; //* n should not be 1.
}

//* enumerate divisors in O(sqrt(N))
vll divisor(ll n){
    vll res;
    for(ll i=1; i * i <= n; i++){
        if(n % i == 0){
            res.push_back(i);
            if(i != n/i)
                res.push_back(n/i);
        }
    }
    return res;
}

//* prime factorization in O(sqrt(n))
map<ll, ll> prime_factor(ll n){
    map<ll, ll> res;
    for(ll i=2; i*i <= n; i++){ //* n shrinks during the for-loop!
        while(n % i == 0){
            ++res[i];
            n /= i;
        }
    }
    if(n != 1) {
        ++res[n];
    }
    return res;
}

int main(){
    ll n; cin>> n;
    map<ll, ll> res = prime_factor(n);
    cout << n <<":";
    for(auto it = res.begin(); it != res.end(); ++ it){
        rep(i, it->second)
            cout << " "<< it->first;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3080
#include <iostream>

using namespace std;
int main() {
	int n;
	cin >> n;
	int k = n / 4;
	for(int i = 0; i <= k; i++) {
		if((n - 4 * i) % 7 == 0) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}


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

int n;

int f(long long s, int b) {
	if (s > n)
		return 0;
	return (b == 7) + f(s * 10 + 3, b | 4) + f(s * 10 + 5, b | 2)
			+ f(s * 10 + 7, b | 1);
}

int main() {
	cin >> n;
	cout << f(0, 0) << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String buffer;

		try {
			while ((buffer = reader.readLine())  != null) {
				String[] strings = buffer.split(" ");

				int n = Integer.valueOf(strings[0]);
				int x = Integer.valueOf(strings[1]);

				if (n == 0 && x == 0) return;

				int count = 0;
				for (int a = 1; a <= n - 2; a++) {
					for (int b = a + 1; b <= n - 1; b++) {
						for (int c = b + 1; c <= n; c++) {
							if (a + b + c == x) count++;
						}
					}
				}
				System.out.println(count);
			}
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}
}



Measured memory_bytes: 24816
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			int[] s = new int[n];
			Arrays.fill(s, 0);
			IntStream.range(1, n).forEach(i -> s[scanner.nextInt() - 1]++);
			Arrays.stream(s).forEach(System.out::println);
		}
	}
}


Measured memory_bytes: 62272
S = int(input())
YY = S // 100
MM = S % 100

if YY <= 12 and MM <= 12 and MM > 0 and YY > 0:
    print('AMBIGUOUS')
elif MM <= 12 and MM > 0:
    print('YYMM')
elif MM > 12 and YY <= 12:
    print('MMYY')
elif MM == 0 and YY <= 12 and YY > 0:
    print('MMYY')
else:
    print('NA')




Measured memory_bytes: 3060
s=int(input())
t=1 if s>=3 else 0
m=10**9+7
S=[1]+[0]*2000

for i in range(1,2000):
  S[i]=S[i-1]*i

for i in range(2,s//3+1):
  t=(t+S[s-2*i-1]//S[i-1]//S[s-3*i])%m

print(t)


Measured memory_bytes: 11552
<?php

fscanf(STDIN, '%s', $b);

switch ($b) {
    case 'A':
        $ans = 'T';
        break;
    case 'C':
        $ans = 'G';
        break;
    case 'G':
        $ans = 'C';
        break;
    case 'T':
        $ans = 'A';
        break;
}

echo $ans . PHP_EOL;

Measured memory_bytes: 4856
#include<bits/stdc++.h>
#define M 300005 
#define LL long long
using namespace std;
int A[M],B[M],C[M],sz[M],fa[M];
int P=1e9+7,n;
vector<int>edge[M];
LL F[M],dp[M],pre,Ft[M],T[M];
int fast(int x,int n){
	LL res=1,a=x;
	while(n){
		if(n&1)res=res*a%P;
		a=a*a%P;
		n>>=1;
	}
	return res;
}
void dfs(int x,int f){
	sz[x]=1;fa[x]=f;
	for(int i=0;i<edge[x].size();i++){
		int y=edge[x][i];
		if(y==f)continue;
		dfs(y,x);
		sz[x]+=sz[y];//儿子的数量  
	}
	dp[1]=dp[1]*T[sz[x]]%P;
} 
void rdfs(int x,int f,LL pre){ 
	 //pre记录x的祖先节点在把x变成根是的前缀积 
	for(int i=0;i<edge[x].size();i++){
		int y=edge[x][i];
		if(y==f)continue; 
		//y变成根之后，y在原树的所有祖先节点的 子树大小都发生变化 
		LL p=pre*sz[x]%P*T[n-sz[y]]%P; 
		LL tmp=p*sz[y]%P*T[n]%P; 
		dp[y]=dp[1]*tmp%P; 
		rdfs(y,x,p); 
	}
}
int main(){
	int a,b;
	cin>>n;
	dp[1]=1;
	for(int i=1;i<=n;i++)dp[1]=dp[1]*i%P;
	T[1]=T[0]=1;
	for(int i=2;i<=n;i++){
		//i*a+b=P
		/*
		  -i*a=b
		  -a=b*i^-1
		  -a*b^-1=i^-1
		*/
		a=P/i;b=P%i;
		T[i]=(P-a)*T[b]%P; 
	} 
	for(int i=1;i<n;i++){
		scanf("%d %d",&a,&b);
		edge[a].push_back(b);
		edge[b].push_back(a);
	} 
	dfs(1,0); 
	rdfs(1,0,1);
	for(int i=1;i<=n;i++)printf("%lld\n",dp[i]);
	return 0; 
} 

Measured memory_bytes: 25076
#include<string.h>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<stdio.h>
//2000001
int main(void){
    int i,k,x,a,b;
    scanf("%d%d",&k,&x);
    for(i=0;i<k;i++){
        a=x-i;
        if(x<-2000001) break;
    }
    for(i=0;i<k;i++){
        b=x+i;
        if(x>2000001) break;
    }
    for(i=a;i<b+1;i++){
    printf("%d ",i);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int n;cin>>n;
  int f[n][10];
  for(int i=0;i<n;i++){
    for(int j=0;j<10;j++) cin>>f[i][j];
  }
  int p[n][11];
  for(int i=0;i<n;i++){
    for(int j=0;j<11;j++) cin>>p[i][j];
  }
  ll m=-10000000000;
  for(int i=1;i<=1023;i++){
    int k=i;
    vector<int>v(10);
    for(int j=0;j<10;j++){
      v[j]=k%2;
      k/=2;
    }
    ll s=0;
    for(int j=0;j<n;j++){
      int c=0;
      for(int l=0;l<10;l++){
        if(v[l]==1&&f[j][l]==1) c++;
      }
      s+=p[j][c];
    }
    m=max(s,m);
  }
  cout<<m<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
/** Problem0062 : What is Bottommost? **/
int main()
{
	int array1[10], array2[10];
	char c;
	while (1) {
		for (int i=0; i<10; i++) {
			cin >> c;
			array1[i] = c - '0';
		}
		if (cin.eof()) break;
		
		for (int i=1; i<10; i++) {
			for (int j=i; j<10; j++) {
				if (i%2==1) {
					array2[j] = (array1[j-1]+array1[j])%10;
				} else {
					array1[j] = (array2[j-1]+array2[j])%10;
				}
			}
		}
		cout << array2[9] << endl;
	}
	return 0;
}

Measured memory_bytes: 1140
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#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()
#define rrng(a) a.rbegin(),a.rend()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define dup(x,y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
using ll = int64_t;
using ull = uint64_t;
using uint = uint32_t;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pil = pair<int,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,v.size())i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,v.size())s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(v.size())o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const double eps = 1e-6;
const ll LINF = 100200300400500600ll;
const int INF = 1001001001;
//--------------------------------------------------------
#define fastio cin.tie(nullptr); std::ios::sync_with_stdio(false);
#define myio ifstream iofi; if(argc>1){iofi.open(argv[1]); std::cin.rdbuf(iofi.rdbuf());}
#define myloopset int loop = 1; if(argc>2) loop =stoi(argv[2]); rep(i,loop)
//--------------------------------------------------------------
template <class T> T chmin(T &a,T b){if(a>b){a=b; return 1;}else return 0;}
template <class T> T chmax(T &a,T b){if(a<b){a=b; return 1;}else return 0;}
const int dx[4] = {0,1,0,-1};
const int dy[4] = {-1,0,1,0};
const int mod = 1000000007;

void Main(){
  int n;
  map<string,int> m;
  cin>>n;
  rep(i,n){
    string s;
    cin>>s;
    m[s]++;
  }
  int max = 0;
  for(auto i:m){
    if(i.se>max) max = i.se;
  }
  for(auto i:m){
    if(i.se==max) cout<<i.fi<<endl;
  }

} signed main(int argc,char** argv)
{fastio; myio; myloopset Main();}


Measured memory_bytes: 23808
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")

#include "bits/stdc++.h"
using namespace std;

#define pb push_back
#define F first
#define S second
#define f(i,a,b)  for(int i = a; i < b; i++)
//#define endl '\n'

using ll = long long;
using db = long double;
using ii = pair<int, int>;

const int N = 100 + 5, LG = 19, MOD = 998244353;
const int SQ =225;

int32_t main(){
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
  int k;
  cin >> k;
  cout << 360 / __gcd(360, k) << endl;

  return 0  ;
}


Measured memory_bytes: 3604
const int isDebugMode = 1;
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
struct edge{long long to,cost;};
const int inf = 1 << 27;
const long long INF = 1LL << 60;
const int COMBMAX = 1001001;
const long long MOD = 1000000007;
const long long dy[] = {-1, 0, 0, 1};
const long long dx[] = {0, -1, 1, 0};
string abc = "abcdefghijklmnopqrstuvwxyz";
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for (const auto &e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (long long)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (long long)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
long long mpow(long long a, long long n, long long mod = MOD){long long res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void pt(){cout << endl; return;}
template<class Head> void pt(Head&& head){cout << head; pt(); return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
void dpt(){if(!isDebugMode) return; cout << endl; return;}
template<class Head> void dpt(Head&& head){if(!isDebugMode) return; cout << head; pt(); return;}
template<class Head, class... Tail> void dpt(Head&& head, Tail&&... tail){if(!isDebugMode) return; cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){if(!isDebugMode) return; rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){if(!isDebugMode) return; rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}
template<class T1, class T2> long long gcd(T1 a, T2 b){return a % b ? gcd(b , a % b) : b;}
template<class T1, class T2> void reduce(T1 &a, T2 &b){ll g = gcd(a, b); a /= g; b /= g; return;}
bool valid(long long H, long long W, long long h, long long w) { return 0 <= h && h < H && 0 <= w && w < W; }

int D;
vector<int> c(26);
int ss[365][26];
vector<int> ans(0);

double powyabai = 1.2;
double cyabaipow = 1.2;
double uresisapow = 1.2;

double evaluate(int day, int kind){

    double yabasa = 0;
    int s = ans.size();
    int idx;
    for(idx = s - 1; 0 <= idx; idx--){
        if(ans[idx] == kind) break;
    }
    yabasa = pow(day - idx, powyabai) * pow(c[kind], cyabaipow);
    double uresisa = pow(ss[day][kind], uresisapow);
    return yabasa + uresisa;
}

int main(){
    cin >> D;
    rep(i, 26) cin >> c[i];
    rep(i, D)rep(j, 26) cin >> ss[i][j];
    rep(i, D){
        double max_eva = -inf;
        double choice = 0;
        rep(j, 26){
            if(chmax(max_eva, evaluate(i, j))) choice = j;
        }
        ans.push_back(choice);
    }
    rep(i, D) pt(ans[i] + 1);
}

Measured memory_bytes: 4144
object Main extends App {
	val Array(t1, t2) = scala.io.StdIn.readLine.split(" ")
	val n = t1.toInt
	val x = t2.toLong
	val a = scala.io.StdIn.readLine.split(" ").map(_.toLong).sorted

	var cnt = 0
	var ans = x

	while(ans > 0L && cnt < n){
		ans -= a(cnt)
		cnt += 1
	}

	if(ans == 0L){
		println(cnt)
	}else{
		println(cnt - 1)
	}
}

Measured memory_bytes: 25392