akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

  int n;
  cin >> n;

  ll ans = 0;
  for (int i = 1; i <= n; ++i) if (i % 3 && i % 5) ans += i;

  cout << ans << '\n';
  
  return (0);
}


Measured memory_bytes: 3628
import math
n = int(raw_input())
degree = math.pi / 3
     
def print_point(point):
    print "%f %f" % (point[0], point[1])
     
def koch(depth, p1, p2):
    if depth == 0:
        return
    s = ((2 * p1[0] + p2[0]) / 3, (2 * p1[1] + p2[1]) / 3)
    t = ((p1[0] + 2 * p2[0]) / 3, (p1[1] + 2 * p2[1]) / 3)
    u = ((t[0] - s[0]) * math.cos(degree) - (t[1] - s[1]) * math.sin(degree) + s[0],
         (t[0] - s[0]) * math.sin(degree) + (t[1] - s[1]) * math.cos(degree) + s[1])
    depth -= 1
    koch(depth, p1, s)
    print_point(s)
    koch(depth, s, u)
    print_point(u)
    koch(depth, u, t)
    print_point(t)
    koch(depth, t, p2)
     
start = (0.0, 0.0)
end = (100.0, 0.0)
print_point(start)
koch(n, start, end)
print_point(end)

Measured memory_bytes: 6620
#include <bits/stdc++.h>
#ifdef BUG
    #include "debug.hpp"
#else
    #define DEBUG(var)
#endif

using namespace std;
template< class T1, class T2 > inline istream &
operator>>( istream & fin, pair< T1, T2 > & pr )
{ fin >> pr.first >> pr.second; return fin; }
template< class T0, class T1, class T2 > inline istream &
operator>>( istream & fin, tuple< T0, T1, T2 > & t )
{ fin >> get<0>(t) >> get<1>(t) >> get<2>(t); return fin; }
template< class T > inline istream &
operator>>( istream & fin, vector< T > & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class T, size_t n> inline istream &
operator>>( istream & fin, array<T, n> & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class FwdIter> inline auto
dump(FwdIter first, FwdIter last, const char * dlm = " ") -> void {
typedef typename iterator_traits<FwdIter>::value_type value_type;
copy(first, last, ostream_iterator<value_type>(cout, dlm)); }
template<typename T> vector<T> & operator--(vector<T> & a)
{ for(auto & i: a) --i; return a; }
/* @@@ ----------------------------------- */

const char *const
arc078_b()
{
  size_t n;
  cin >> n;
  vector<vector<size_t>> adj(n);
  for(size_t i = 0, u, v; i + 1 < n; ++i)
  {
    cin >> u >> v;
    -- u; -- v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }

  const size_t inf = numeric_limits<size_t>::max() >> 2;
  vector<size_t> path;
  {
    vector<size_t> dist(n, inf);
    queue<size_t> q;
    dist[0] = 0;
    for(q.push(0); !q.empty(); q.pop())
    {
      const auto u = q.front();
      for(const auto v: adj[u])
        if(dist[u] + 1 < dist[v])
        {
          dist[v] = dist[u] + 1;
          q.push(v);
        }
    }
    DEBUG(dist);
    path.push_back(n - 1);
    for(size_t u = n - 1; u != 0; )
    {
      for(const auto v: adj[u])
        if(dist[v] + 1 == dist[u])
        {
          u = v;
          break;
        }
      path.push_back(u);
    }
  }

  reverse(begin(path), end(path));
  DEBUG(path);
  const size_t nil = (size_t)-1;
  vector<size_t> col(n, nil);
  for(size_t i = 0, j = path.size() - 1; i < j + 1; ++i, --j)
  {
    col[path[i]] = 0;
    if(j != i) col[path[j]] = 1;
  }

  {
    queue<size_t> q;
    for(size_t i = 0; i < n; ++i)
      if(col[i] != nil) q.push(i);

    for(; !q.empty(); q.pop())
    {
      const auto u = q.front();
      for(const auto v: adj[u])
        if(col[v] == nil)
        {
          col[v] = col[u];
          q.push(v);
        }
    }
  }

  const size_t blk = count(begin(col), end(col), 0);
  const size_t wte = n - blk;
  return wte < blk ? "Fennec" : "Snuke";
}

int main(const int argc, char * argv [])
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cout << arc078_b();

  return EXIT_SUCCESS;
}


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

int main()
{
	int n,i,iv;
	cin>>n;
	int a[n+1];
	for(i=1; i<=n; i++)
		cin>>a[i];
	sort(a+1,a+n+1);
	for(i=1; i<=a[n]; i++)
	{
		int s=0;
		for(int j=1; j<=n; j++)
			s+=(a[j]-i)*(a[j]-i);
		if(i==1)
			iv=s;
		else
			if(s<iv)
				iv=s; 
	 } 
	cout<<iv;
	return 0;
}

Measured memory_bytes: 256
import itertools
import sys

n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

for i, j in itertools.product(range(n - m + 1), range(n - m + 1)):
	if a[i][j] == b[0][0]:
		for p, q in itertools.product(range(m), range(m)):
			if a[i + p][j + q] != b[p][q]:
				if i == n - m and j == n - m:
					print('No')
				break
			elif p == m - 1 and q == m - 1:
				print('Yes')
				sys.exit()
				
	elif i == n - m and j == n - m:
		print('No')

Measured memory_bytes: 3064
//gauravsingh :)
#include <bits/stdc++.h>
using namespace std;
 
//using int = long long int;
using ll = long long int;
using pii = pair < int, int >;

#define ff first
#define ss second
#define endl '\n'
#define pb push_back

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define rep(i, j, n)    for(int i = j; i < n; i++)
#define ren(i, j, n)    for(int i = n-1; i >= j; i--)

#define cerr cout
void _print() {cerr << "]\n";}
template <typename T, typename... V> void _print(T t, V... v) {
    cerr << t; if(sizeof...(v)) cerr << ", "; _print(v...);
}
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)

const int mod = 1000000007;

void io_set(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}

void solve(){
    int k;
    cin >> k;
    rep(i, 0, k){
        cout << "ACL";
    }
}

signed main(int argc, char **argv){
    //io_set();
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int tt = 1;
    //cin >> tt;
    while(tt--){
        solve();
    }
    return 0;
}



Measured memory_bytes: 3608
import sys
input = sys.stdin.readline

N = int(input())
edge = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    edge[a].append(b)
    edge[b].append(a)


def dist(root):  # 根をnとしたときの各点の深さ
    res = [-1] * (N + 1)
    node = [root]
    res[root] = 0
    while node:
        s = node.pop()
        d = res[s]
        for t in edge[s]:
            if res[t] == -1:
                node.append(t)
                res[t] = d + 1
    return res[1:]


fenek = dist(1)
snuke = dist(N)
f, s = 0, 0
for i, j in zip(fenek, snuke):
    if i <= j:
        f += 1
    else:
        s += 1

ans = "Fennec" if f > s else "Snuke"
print(ans)


Measured memory_bytes: 29856
#include<cstdio>
using namespace std;

main(){
  int n,s;
  while(scanf("%d%d",&n,&s) && n){
    int r[101]={0};
    for(int i=0;i<n;i++){
      int tmp;scanf("%d",&tmp);r[tmp]++;
    }
    int ans = 0;
    for(int i=0;i<101;i++){
      if (i+i > s && r[i])ans += (r[i]*(r[i]-1))/2;
      for(int j=i+1;j<101;j++){
	if (i+j > s && r[i] && r[j])ans += r[i]*r[j];
      }
    }
    printf("%d\n",ans);
  }
}

Measured memory_bytes: 0
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(void) {
	int H;
	int A;
	char buf[128], *ch;

	fgets(buf, sizeof(buf), stdin);
	ch = strtok(buf, " ");
	H = atoi(ch);
	ch = strtok(NULL, " ");
	A = atoi(ch);

	if(H % A == 0) {
		printf("%d\n", H / A);
	} else {
		printf("%d\n", H / A + 1);
	}

	return 0;
}


Measured memory_bytes: 128
package main

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	a := nextInt(sc)
	b := nextInt(sc)

	d := a / b
	r := a % b
	f := float64(a) / float64(b)

	fmt.Printf("%d %d %f", d, r, f)
}


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

int main(){
    int N;
    // vector<int> vp;
    // int vp[105];
    int64_t res;
    int64_t lucas[90];

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

    lucas[0] = 2ll;
    lucas[1] = 1ll;
    for (int i=2; i<=N; i++) {
        lucas[i] = lucas[i-1] + lucas[i-2];
    }

    res = lucas[N];

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS                     \
    ios::sync_with_stdio(false);\
    cin.tie(0)

// *start on @date: 2020-05-31 19:57 

int main() 
{
    IOS;
    ll a,b;
    cin>>a>>b;
    cout<<a*b<<endl;
    return 0;
}

Measured memory_bytes: 3648
#include<stdio.h>
int main(void){
  char a[4];
  
  scanf("%s",a);
  
  if(a[0]=='A'){
     puts("T");
  }
  if(a[0]=='T'){
     puts("A");
  }
  if(a[0]=='C'){
     puts("G");
  }
  if(a[0]=='G'){
     puts("C");
  }
  
  return 0;
}

Measured memory_bytes: 128
S = gets.strip
i=0
S.chars do |s|
    if i%2==0
        if s=="R" || s=="U" || s=="D"

        else
            puts 'No'
            exit
        end
    else
        if s=="L" || s=="U" || s=="D"

        else
            puts 'No'
            exit
        end

    end
    i+=1
end

puts 'Yes'


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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n-1;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define INF 999999999

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef unordered_map<ll, ll> ump;

const ll mod = 1e9+7;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a, b;
	ll ans = 0;
	cin >> a >> b;
	FOR(i, a, b+1){
		if((i/10000==i%10) && (i%10000/1000==i%100/10)){
			ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(n) n.begin(),n.end()
#define yn(x) cout << (x ? "Yes":"No") << endl;

int main() {
  ll n;
  cin >> n;
  ll ans;
  for(ll i=sqrt(n);i>0;i--){
    if(n%i==0){
      ans = i+n/i-2;
      break;
    }
  }
  cout << ans << endl;
}


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

#define int long long
#define fi first
#define se second
#define pb push_back
#define ins insert
#define er erase

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;

const int oo = 1e18 + 7, mod = 1e9 + 7;

int n, m, dp[105][105];
char board[105][105];

signed main(){
	ios_base::sync_with_stdio(0);
	cin >> n >> m;
	for(int i = 1; i <= n; i++){
	    for(int j = 1; j <= m; j++) cin >> board[i][j];
	}
	dp[1][1] = (board[1][1] == '#');
	for(int i = 2; i <= n; i++){
	    dp[i][1] = dp[i - 1][1];
	    if(board[i][1] == '#' && board[i - 1][1] == '.') dp[i][1]++;
	}
	for(int i = 2; i <= m; i++){
	    dp[1][i] = dp[1][i - 1];
	    if(board[1][i] == '#' && board[1][i - 1] == '.') dp[1][i]++;
	}
	for(int i = 2; i <= n; i++){
	    for(int j = 2; j <= m; j++){
	        if(board[i][j] == '.') dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]);
	        else{
	            int tmp1 = dp[i - 1][j] + (board[i - 1][j] == '.'), tmp2 = dp[i][j - 1] + (board[i][j - 1] == '.');
	            dp[i][j] = min(tmp1, tmp2);
	        }
	    }
	}
	cout << dp[n][m];
}

/*
TEST HERE
INPUT #1

OUTPUT #1


INPUT #2

OUTPUT #2


INPUT #3

OUTPUT #3

*/


Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
#define MAX 100005
#define INFTY -1

int n, m, st[MAX];
vector<vector<int> > G, C;

void bfs(int s) {
	if (st[s] != 0) return;
	vector<int> ve;
	queue<int> Q;
	Q.push(s);
	st[s] = 1;
	ve.push_back(s);
	while (!Q.empty()) {
		int u = Q.front();
		Q.pop();
		for (int i = 0; i < G[u].size(); i++) {
			int v = G[u][i];
			if (st[v] != 0) continue;
			Q.push(v);
			st[v] = 1;
			ve.push_back(v);
		}
	}
	C.push_back(ve);
}

void solution() {
	int i;
	for (i = 0; i < n; i++) {
		bfs(i);
	}
	for (i = 0; i < C.size(); i++) {
		sort(C[i].begin(), C[i].end());
	}
}

int main(void) {
	int i, j, a, b, q;
	for (i = 0; i < MAX; i++) {
		st[i] = 0;
	}
	cin >> n >> m;
	G.resize(n);
	for (i = 0; i < m; i++) {
		cin >> a >> b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	solution();
	cin >> q;
	while (q--) {
		bool flag = false;
		cin >> a >> b;
		for (i = 0; i < C.size(); i++) {
			if (*(lower_bound(C[i].begin(), C[i].end(), a)) != a) continue;
			if (*(lower_bound(C[i].begin(), C[i].end(), b)) != b) continue;
			flag = true;
		}
		if (flag)
			cout << "yes\n";
		else
			cout << "no\n";
	}
}


Measured memory_bytes: 10372
class Node
  attr_accessor :parent, :size, :rank

  def initialize(n)
    @parent = n
    @size = 1
    @rank = 1
  end
end

class UnionFindTree
  def initialize(n)
    @nodes = (0..n).to_a.map { |i| Node.new(i) }
  end

  def root(x)
    return x if @nodes[x].parent == x

    @nodes[x].parent = root(@nodes[x].parent)
  end

  def size(x)
    @nodes[root(x)].size
  end

  def unite(a, b)
    a = root(a)
    b = root(b)
    return if a == b

    if @nodes[a].rank > @nodes[b].rank
      @nodes[b].parent = a
      @nodes[a].size += @nodes[b].size
    else
      @nodes[a].parent = b
      @nodes[b].size += @nodes[a].size
      @nodes[b].rank += 1 if @nodes[a].rank == @nodes[b].rank
    end
  end

  def same?(a, b)
    root(a) == root(b)
  end
end

n, m = gets.split.map(&:to_i)

tree = UnionFindTree.new(n)
ans = [ n * (n - 1) / 2 ]

x = []

m.times do |i|
  x << gets.split.map(&:to_i)
end

x.reverse.each do |a, b|
  if ans[-1] == 0
    ans << 0
  elsif !tree.same?(a, b)
    ans << ans[-1] - tree.size(a) * tree.size(b)
    tree.unite(a, b)
  else
      ans << ans[-1]
  end
end

puts ans[0...-1].reverse


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

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define all(x) x.begin(), v.end()
#define rall(x) x.rbegin(), x.rend()
#define PB push_back
#define F first
#define S second

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

const ll MOD = 1000000007;

#define MAX 10000007

ll fat[MAX];

ll binPow(ll a, ll p){
	ll ans = 1;
	while(p){
		if(p&1)
			ans = ans * a % MOD;
		a = a * a % MOD;
		p>>=1;
	}
	return ans;
}

ll calculateBIN(int m, int k){
	ll ans = fat[m] * binPow(fat[k], MOD-2) % MOD;
	ans = ans * binPow(fat[m-k], MOD-2) % MOD;
	return ans;
}

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

	fat[0] = 1;
	for(int i = 1; i < MAX; i++){
		fat[i] = fat[i-1] * i % MOD;
	}

	int r1, c1, r2, c2;
	cin >> r1 >> c1 >> r2 >> c2;

	ll ans = 0;
	for(int i = r1; i <= r2; i++){
		ll add = calculateBIN(i+c2+1, i+1);
		ll sub = calculateBIN(i+c1, i+1);
		add = (add - sub + MOD) % MOD;
		ans = (ans + add) % MOD; 
	} 

	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 78336
using System;

namespace Csharp_ITP1 {
    class ITP1_2_B {
        static void Main() {
            string[] s = Console.ReadLine().Split();
            int a = int.Parse(s[0]); int b = int.Parse(s[1]); int c = int.Parse(s[2]);
            Console.WriteLine((a < b && b < c ? "Yes" : "No"));
        }
    }
}


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

int main() {
	int *l;
	int n;
	cin >> n;
	l = new int[n];
	int ml = 0,sum = 0;
	for(int i = 0;i < n;i++) {
		cin >> l[i];
		sum += l[i];
		if(ml < l[i]) ml = l[i];
	}
	if(sum - ml > ml) cout << "Yes";
	else cout << "No";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> inline bool chmin(T&x,T y){if(x>y){x=y;return true;}return false;}
template<class T> inline bool chmax(T&x,T y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    int n;
    in>>n;
    vector<ll> a(n);
    for(auto&i:a) in>>i;
    if(n&1){
        if(n==3) return cout<<max({a[0],a[1],a[2]})<<endl,0;
        auto c=vector(3,vector(n,-(1ll<<60)));
        c[0][0]=a[0];
        c[1][1]=a[1];
        c[0][2]=a[0]+a[2];
        c[2][2]=a[2];
        c[1][3]=max(a[0]+a[3],a[1]+a[3]);
        for(int i=4;i<n;++i){
            chmax(c[0][i],c[0][i-2]+a[i]);
            chmax(c[1][i],max(c[1][i-2]+a[i],c[0][i-3]+a[i]));
            chmax(c[2][i],max({c[2][i-2],c[1][i-3],c[0][i-4]})+a[i]);
        }
        cout<<max({c[2][n-1],c[1][n-2],c[0][n-3]})<<endl;
    }
    else{
        if(n==2) return cout<<max({a[0],a[1]})<<endl,0;
        auto c=vector(2,vector(n,-(1ll<<60)));
        c[0][0]=a[0];
        c[1][1]=a[1];
        c[0][2]=a[0]+a[2];
        for(int i=3;i<n;++i){
            chmax(c[0][i],c[0][i-2]+a[i]);
            chmax(c[1][i],max(c[1][i-2],c[0][i-3])+a[i]);
        }
        cout<<max({c[1][n-1],c[0][n-2]})<<endl;
    }
}

Measured memory_bytes: 11120
#include <stdio.h>

using namespace std;

int main(){
	int r,c,sum,total_sum = 0;
	scanf("%d %d",&r,&c);
	int table[r+1][c+1];

	for(int i = 0; i < r+1; i++){
		for(int j = 0; j < c+1; j++){
			table[i][j] = 0;
		}
	}

	for(int i = 0; i < r; i++){
		sum = 0;
		for(int j = 0; j < c; j++){
			scanf("%d",&table[i][j]);
			sum += table[i][j];
			table[r][j] += table[i][j];
		}
		table[i][c] = sum;
		total_sum += sum;
	}
	table[r][c] = total_sum;

	for(int i = 0; i < r+1; i++){
		for(int j = 0; j < c; j++){
			printf("%d ",table[i][j]);
		}
		printf("%d\n",table[i][c]);
	}
}

Measured memory_bytes: 1064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  long a[n];
  int i;
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  long long s[n];
  s[0] = a[0];
  for(i=1;i<n;i++){
    s[i] = a[i] + s[i-1];
  }
  long long minn = abs(s[n-1]-2*s[0]);
  long long tmp;
  for(i=1;i<n-1;i++){
    tmp = abs(s[n-1]-2*s[i]);
    if(tmp<minn)minn=tmp;
  }
  cout << minn;
}


Measured memory_bytes: 3328
object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def getDivCount(x: Int): Int = {
    var tmp = x
    var count = 0
    while (tmp % 2 == 0) {
      count += 1
      tmp = tmp / 2
    }
    count
  }


  def getDivCount2(x: Int, c: Int = 0): Int = {
    if (x % 2 != 0) c
    else getDivCount2(x / 2) + 1
  }


  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    val a = new Array[Int](n)
    for (i <- 0 until n) {
      a(i) = sc.nextInt
    }

    val loopCount =
      a.map(v =>
        if (v % 2 == 0) getDivCount2(v)
        else 0
      ).sum
    println(loopCount)
  }
}


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

int main() {
  int n;
  cin >> n;
  vector<long long> L(n + 1);
  for (int i = 0; i < n + 1; i++){
      if (i == 0)L[i] = 2;
      else if (i == 1)L[i] = 1;
      else{
          L[i] = L[i - 1] + L[i - 2];
      }
  }
  cout << L[n] << endl;
}


Measured memory_bytes: 3632
import java.io.*;
import java.util.*;
public class Main {

	public static void main(String[] args) throws Exception{
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer tok = new StringTokenizer(in.readLine());
		int N = Integer.parseInt(tok.nextToken());
		int M = Integer.parseInt(tok.nextToken());
		int size[] = new int[N]; Arrays.fill(size, 1);
		boolean rojos[] = new boolean[N];
		rojos[0] = true;
		for (int i = 0; i < M; i++) {
			tok = new StringTokenizer(in.readLine());
			int f = Integer.parseInt(tok.nextToken()) - 1;
			int t = Integer.parseInt(tok.nextToken()) -1;
			size[f] -= 1;
			size[t] += 1;
			if(rojos[f]) rojos[t] = true;
			if(size[f] == 0) rojos[f] = false;
		}
		
		int c = 0;
		for (int i = 0; i < rojos.length; i++) if(rojos[i])c++;
		System.out.println(c);
	}
}


Measured memory_bytes: 42356
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
    int n,i,j,k;
    int a[100005][5];
    scanf("%d",&n);
    for(i = 1;i <= n;i++)
    scanf("%d %d %d",&a[i][1],&a[i][2],&a[i][3]);
    int dp[100005][5];
    memset(dp,0,sizeof(dp));
    dp[1][1] = a[1][1];
    dp[1][2] = a[1][2];
    dp[1][3] = a[1][3];
    for(i = 2;i <= n;i++)
    {
        for(j = 1;j < 4;j++)
        {
            for(k = 1;k < 4;k++)
            {
                if(k != j)
                {
                    if(dp[i][j] < dp[i - 1][k] + a[i][j])
                    dp[i][j] = dp[i - 1][k] + a[i][j];
                }
            }
        }
    }
    printf("%d\n",max(dp[n][1],max(dp[n][2],dp[n][3])));
    return 0;
}

Measured memory_bytes: 4096
import java.util.Scanner;

class Main {
    private static void solve() {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextInt()) {
            int n = scanner.nextInt();
            int result = 2;
            for (int i = 1; i < n; i++) {
                result += i + 1;
            }
            System.out.println(result);
        }
    }

    public static void main(String... args) {
        solve();
    }
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if ( ((a + b) - (c + d)) > 0) {
    cout << "Left" << endl;
  } else if ((a + b) == (c + d)) {
    cout << "Balanced" << endl;
  } else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
N=int(input())

xp=yp=0
xn=yn=10**9
zs=[0]*N
ws=[0]*N
for i in range(N):
    xi,yi=map(int,input().split())
    zs[i]=xi+yi
    ws[i]=xi-yi
zs.sort()
ws.sort()
ans=max(zs[-1]-zs[0],ws[-1]-ws[0])
print(ans)

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

#define int long long
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define Rep(i, n) for( int i = 0; i < (n); i++ )
#define Rrep(i, a, n) for( int i = (a); i < (n); i++ )
#define All(v) v.begin(), v.end()

typedef pair<int, int> Pii;
typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;
int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};

int r = 0;
vector<int> xx;
vector<int> yy;
string s;
int x, y;
bool flag = false;

int dp1[2][25001] = {{0}};
int dp2[2][25001] = {{0}};

signed main() {

    cin >> s;
    cin >> x >> y;

    int cnt = 0;
    int eo = -1;
    Rep(i, s.size()) {
        if ( s[i] == 'F' ) {
            cnt++;
        } else {
            if ( eo == -1 ) {
                r = cnt;
                cnt = 0;
                eo = 0;
            } else if ( eo == 0 ) {
                if ( cnt ) yy.pb(cnt);
                cnt = 0;
                eo = 1;
            } else {
                if ( cnt ) xx.pb(cnt);
                cnt = 0;
                eo = 0;
            }
        }
    }
    if ( eo == -1 ) {
        r = cnt;
        cnt = 0;
        eo = 0;
    } else if ( eo == 0 ) {
        if ( cnt ) yy.pb(cnt);
        cnt = 0;
        eo = 1;
    } else {
        if ( cnt ) xx.pb(cnt);
        cnt = 0;
        eo = 0;
    }
    //cout << yy[0] << endl;

    x += 10000;
    y += 10000;
    dp1[0][10000] = 1;
    dp2[0][10000+r] = 1;

    bool now = true;
    if ( yy.size() ) {
        for ( int i = 1; i <= yy.size(); i++ ) {
            Rep(j, 25001) dp1[now][j] = 0;
            Rep(j, 25001) {
                if ( !dp1[now^1][j] ) continue;
                dp1[now][j-yy[i-1]] = dp1[now][j+yy[i-1]] = 1;
            }
            now ^= 1;
        }
    }

    if ( !dp1[now^1][y] ) {
        cout << "No" << endl;
        return 0;
    }
    //cout << xx[0] << endl;
    now = true;
    if ( xx.size() ) {
        for ( int i = 1; i <= xx.size(); i++ ) {
            Rep(j, 25001) dp2[now][j] = 0;
            Rep(j, 25001) {
                if ( !dp2[now^1][j] ) continue;
                dp2[now][j-xx[i-1]] = dp2[now][j+xx[i-1]] = 1;
            }
            now ^= 1;
        }
    }

    if ( !dp2[now^1][x] ) {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;

}


Measured memory_bytes: 1024
#include<stdio.h>
int main(void){
	int a,b,c,k,i;
	scanf("%d %d %d",&a,&b,&c);
	scanf("%d",&k);
	for(i=0;i<k;i++){
		if((a>b)&&(a>c))a=a*2;
		else if((b>a)&&(b>c))b=b*2;
		else if((c>a)&&(c>b))c=c*2;
		else a=a*2;
	}
	printf("%d",a+b+c);

}

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

int main(){
	int a;
	cin>>a;
	
	int cnt=0,cnt1=0,ans=0,num;

	if(a==1){
		cout<<1<<endl;
		return 0;
	}

	for (int i = 1; i <= a; i++){
		cnt=0;
		num=i;
		while(num%2==0){
			num/=2;
			cnt++;
		}
		if(cnt>cnt1){
			cnt1=cnt;
			ans=i;
		}
		
	}

	cout<<ans<<endl;
}


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

int N, M;

int main() {
    cin >> N;
    map<int, int> D;
    int d;
    for (int i = 0; i < N; i++) {
        cin >> d;
        D[d]++;
    }
    cin >> M;
    vector<int> T(M);
    for (int i = 0; i < M; i++) {
        cin >> d;
        D[d]--;
        if (D[d] < 0) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 10368
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

s = input()
cnt = 0
ans = 0
size = len(s)
flag = False
for i in range(size):
    if cnt >= size - i:
        flag = True
    if s[i] == 'p':
        cnt -= 1
    if s[i] == 'g':
        if flag:
            ans += 1
        else:
            cnt += 1
if flag:
    print(ans)
else:
    print(min(cnt, 0))


Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int n;
	long long int a[100000];
	long long int b[100000];
	long long int c[100000];
	long long int dp[100001];
	cin >> n;
	for(int i=0;i < n;i++){
		cin >> a[i];
	}
	for(int i=0;i < n;i++){
		cin >> b[i];
	}
	for(int i=0;i < n;i++){
		cin >> c[i];
		dp[i] = 0;
	}
	sort(a, a + n);
	sort(b, b + n);
	sort(c, c + n);
	int z = n - 1;
	dp[n] = 0;
	for(int i = n - 1; i >= 0;i--){
		while(z >= 0 && b[i] < c[z]){
			z--;
		}
		z++;
		if(z == n){
			z--;
		}else{
			dp[i] = dp[i + 1] + (n - z);
		}
	}
	int x=0,y=0;
	z = 0;
	long long int ans = 0;
	while(x < n){
		while(y < n && a[x] >= b[y]){
			y++;
		}
		if(y == n){
			break;
		}
		ans += dp[y];
		x++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
#define int long long 
string mat[105];
int dp[105][105],m,n;


int32_t main(){
    cin>>n>>m;
    for(int i=0;i<105;i++){
        for(int j=0;j<105;j++){
            dp[i][j] = INT_MAX;
        }
    }
    for(int i=0;i<n;i++){
        cin>>mat[i];
    }
    dp[0][0] = (mat[0][0]=='#');
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            bool H=0,W=0;
            if(i==0 && j==0){continue;}
            if(i==0){
                H = (mat[i][j-1]=='.' && mat[i][j]=='#');
                dp[i][j] = H + dp[i][j-1];
                continue;
            }
            if(j==0){
                W = (mat[i-1][j]=='.' && mat[i][j]=='#');
                dp[i][j] = W + dp[i-1][j];
                continue;
            }
            
             H = (mat[i-1][j]=='.' && mat[i][j]=='#');
             W = (mat[i][j-1]=='.' && mat[i][j]=='#');
            dp[i][j] = min(H+dp[i-1][j],W+dp[i][j-1]); 
            
            
        }
       
    }
    cout<<dp[n-1][m-1];
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n, i;
	string xd;
	cin>>n>>xd;
	int ans = 1;
	for(i=1; i<xd.length(); i++){
		if(xd[i] != xd[i-1]){
			ans++;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 512
// Author: wlzhouzhuan
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rint register int
#define rep(i, l, r) for (rint i = l; i <= r; i++)
#define per(i, l, r) for (rint i = l; i >= r; i--)
#define mset(s, _) memset(s, _, sizeof(s))
#define pb push_back
#define pii pair <int, int>
#define mp(a, b) make_pair(a, b)
#define all(x) x.begin(), x.end()

inline int read() {
  int x = 0, neg = 1; char op = getchar();
  while (!isdigit(op)) { if (op == '-') neg = -1; op = getchar(); }
  while (isdigit(op)) { x = 10 * x + op - '0'; op = getchar(); }
  return neg * x;
}
inline void print(int x) {
  if (x < 0) { putchar('-'); x = -x; }
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}

inline void ckmin(int &a, int b) {
  if (a > b) a = b;
}
inline void ckmax(int &a, int b) {
  if (a < b) a = b;
}

string x;

int main() {
  cin >> x;
  x = ' ' + x;
  if (x[5] == x[6] && x[3] == x[4]) puts("Yes");
  else puts("No");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    vector<int>x(1,a[0]);
    for(int i=1;i<n;i++){
        if(x.back()>=a[i])x.push_back(a[i]);
        else x[upper_bound(x.begin(),x.end(),a[i],greater<int>())-x.begin()]=a[i];
    }
    cout<<x.size()<<endl;
    return 0;
}

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

int main(){
	int S,h,m,s;
	std::cin>> S;
	h = S / 3600;
	S = S - (h * 3600);
	m = S / 60;
	S = S - (m * 60);
	s = S;
	std::cout<< h << ":" << m << ":" << s << endl;
	return 0;
}

Measured memory_bytes: 3064
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AUOIAUAI solver = new AUOIAUAI();
        solver.solve(1, in, out);
        out.close();
    }

    static class AUOIAUAI {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String c = in.next();

            out.println("aeiou".contains(c) ? "vowel" : "consonant");
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }
}



Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
long long int n;
long long int dfs(long long int s){
  if(s>n) return 0;
  long long int t=s,a[3]={},c[3]={3,5,7},res=0;
  bool b=true;
  while(t && b){
    b=true;
    if(t%10==3) a[0]++;
    if(t%10==5) a[1]++;
    if(t%10==7) a[2]++;
    if(a[0]>0 && a[1]>0 && a[2]>0){
      res++;
      b=false;
    }
    t/=10;
  }
  for(int i=0;i<3;i++)
    res+=dfs(10*s+c[i]);
  return res;
}
  
  

int main() {
  cin>>n;
  if(n>=10)
  cout<<dfs(3)+dfs(7)+dfs(5);
  else cout<<0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int lim = 1010;

string s[lim];

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

    for(int i=0; i<n; i++){
        int dot_count = 0;
        for(int j=0; j<s[i].size(); j++){
            if(s[i][j] == '.'){
                dot_count++;
                s[i][j] = ' ';
            }
        }
        if(dot_count == 0) continue;
        s[i][--dot_count] = '+';

        int nec = i-1;
        while(nec >= 0 && dot_count < s[nec].size() && s[nec][dot_count] == ' '){
            s[nec][dot_count] = '|';
            nec--;
        }
    }

    return;
}

int main(){
    int n;
    while(true){
        cin >> n;
        if(n == 0) break;
        solve(n);
        for(int i=0; i<n; i++) cout << s[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3804
INF = 10 ** 9 + 7

N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
dp = [0] * (N + 1)
for i in range(M):
    dp[a[i]] = -1

dp[0] = 1
for i in range(1, N + 1):
    if dp[i] == -1: continue
    tmp = 0
    if dp[i - 1] != -1:
        tmp += dp[i - 1]
    if dp[i - 2] != -1 and i > 1:
        tmp += dp[i - 2]
    dp[i] = tmp % INF

print(dp[N])

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

int main() {
  int n,m;
  int max=0;
  
  cin >> n;
  vector<string> s(n);
  for(int i=0; i<n; i++) cin >> s.at(i);
  cin >> m;
  vector<string> t(m);
  for(int i=0; i<m; i++) cin >> t.at(i);
  
  for(int i=0; i<n; i++){
    int sum=0;
    for(int j=0; j<m; j++){
		if(s.at(i)==t.at(j)) sum--;
    }
    for(int j=0; j<n; j++){
      	if(s.at(i)==s.at(j)) sum++;
    }
    if(sum>max) max=sum;
  }
  cout << max << endl;
  
}




Measured memory_bytes: 256
from math import sqrt
n,d=map(int,input().split())
l=[list(map(float,input().split())) for i in range(n)]
nums=[i for i in range(n-1)]
fa=[i for i in range(d)]
cnt=0
ans=0
t=[]
for i in nums:
  for j in l[i+1:]:
    cnt=0
    for k in fa:
      cnt+=(l[i][k]-j[k])**2
    cnt=sqrt(cnt)
    t.append(cnt)
for v in t:
  if(v.is_integer()):
    ans+=1
print(ans)
    

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define reps(i,x) for(int i=1;i<=(int)(x);++i)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define pb push_back

string s, alpha = "abcdefghijklmnopqrstuvwxyz";
ll k;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> s >> k;
	int idx;
	rep(i, s.size()) {
		if (k == 0) break;
		if (k > 25) {
            rep(j, 26) if (alpha[j] == s[i]) idx = j;
            int last = s.size() - 1;
            if (i != last) {
                if (s[i] == 'a') continue;
                s[i] = 'a';
                k -= 26 - idx;
            } else {
                s[i] = alpha[(idx + k)%26];
                k = 0;
            }
		}
		else {
			rep(j, 26) if (alpha[j] == s[i]) idx = j;
			if (26 - idx <= k) {
				s[i] = 'a';
				k -= 26 - idx;
			}
			else {
				int last = s.size() - 1;
				if (i != last) continue;
				rep(j, 26) if (alpha[j] == s[i]) idx = j;
				s[last] = alpha[idx + k];
				k = 0;
			}
		}
	}
	cout << s << '\n';
	return 0;
}


Measured memory_bytes: 592
//const ll MOD = 998244353;
//const int N = 2e6+5;
//void _(){
//    Factorial f(N);
//    ll n,m;
//    cin >> n >> m;
//    ll ans = 0;
//    for(int i = m%2; i <= min(m,n); i += 2){
//        int singles = i;
//        ll cur = f.comb(n,singles);
//        ll rem = m*3-singles;
//        assert(rem%2 == 0);
//        rem /= 2;
//        ll tmp = 0;
//        rep(over,0,3){
//            ll sign = over%2 ? -1 : 1;
//            ll bound = m-1;
//            if(rem-over*(bound+1) >= 0){
//                tmp += cur*sign*f.comb(n-1+rem-over*(bound+1),n-1)%MOD*f.comb(n,over)%MOD;
//            }
//        }
//        ans = (ans+tmp)%MOD;
//    }
//    ans += n*f.comb(n-2+m,m);
//    ans %= MOD;
//    if(ans < 0)
//        ans += MOD;
//    print(ans);
//}
//
#include <iomanip>
#include <algorithm>
#include <cassert>
#include <vector>
#include <utility>
#include <iostream>
#include <string>
#define REP_INT(i,l,r) for(int i = l; i <= r; ++i)
#define GET_REP_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define rep(...) GET_REP_MACRO(__VA_ARGS__,REP_ANY,REP_INT)(__VA_ARGS__)
#define all(v) (v).begin(), (v).end()
#define sz(v) ll(v.size())
#define T1 template<typename T> static
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
const ll MOD = 998244353;
T1 ostream& operator<<(ostream& stream, const vector<T>& t);
T1 istream& read(T, T, istream& = cin);
T1 void print(T x, string end = "\n"){
    cout << x << end;
}
T1 T ext_euclid(T a, T b, T c, T d){
    if(c == T(0))
        return b;
    return ext_euclid(c, d, a % c, b - a / c * d);
}
T1 T mod_inverse(T x, T mod = T(MOD)){
    return (ext_euclid(mod, T(0), x, T(1)) + mod) % mod;
}
ll mod_inverse(int x, ll mod = MOD){
    return mod_inverse<ll>(x,mod);
}
struct Factorial{
    vl fact,ifact;
    ll comb(ll n, ll m){
        assert(n >= m);
        assert(n < sz(fact));
        return fact[n]*ifact[m]%MOD*ifact[n-m]%MOD;
    }
    Factorial(int n){
        fact.resize(n+1);
        ifact.resize(n+1);
        fact[0] = 1;
        for(int i = 1; i <= n; ++i)
            fact[i] = fact[i-1]*i%MOD;
        ifact[n] = mod_inverse(fact[n]);
        for(int i = n-1; i >= 0; --i)
            ifact[i] = (i+1)*ifact[i+1]%MOD;
    }
};
const int N = 2e6+5;
void _(){
    Factorial f(N);
    ll n,m;
    cin >> n >> m;
    ll ans = 0;
    for(int i = m%2; i <= min(m,n); i += 2){
        int singles = i;
        ll cur = f.comb(n,singles);
        ll rem = m*3-singles;
        assert(rem%2 == 0);
        rem /= 2;
        ll tmp = 0;
        rep(over,0,3){
            ll sign = over%2 ? -1 : 1;
            ll bound = m-1;
            if(rem-over*(bound+1) >= 0){
                tmp += cur*sign*f.comb(n-1+rem-over*(bound+1),n-1)%MOD*f.comb(n,over)%MOD;
            }
        }
        ans = (ans+tmp)%MOD;
    }
    ans += n*f.comb(n-2+m,m);
    ans %= MOD;
    if(ans < 0)
        ans += MOD;
    print(ans);
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
        _();
}


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

#define pb push_back
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define digits(x) floor(log10(x) + 1)
#define countbits(x) ((int)log2(x)+1)
#define forn(i, n) for (int i = 0; i < (int)(n); i++)
#define init(arr,value) memset(arr,value,sizeof(arr))
#define deb(x) cout << #x << "=" << x << endl;
#define test unsigned int tet;cin >> tet;while(tet--)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout.precision(10);cout << fixed;
#define int long long

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

const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 9;
const ll N   = 500500;

signed main(void)
{
    	fastio
        int x[5];
        for(int i=0; i<5; i++) cin >> x[i];

        for(int i=0; i<5; i++){
            if(x[i] == 0){
                cout << i+1 << endl;
                return 0;
            }
        }

    	return 0;
}



Measured memory_bytes: 3596
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::iter::FromIterator;

fn main() {
    let cin = stdin();
    let mut scan = Scanner::new(cin.lock());
    let comb = Comb::new(200_001);
    let h = scan.read::<usize>();
    let w = scan.read::<usize>();
    let a = scan.read::<usize>();
    let b = scan.read::<usize>();
    let mut ret = 0;
    for p in 0..h - a {
        let left = comb.of(b-1+p, b-1);
        let right = comb.of(h-p-1+w-1-b, h-p-1);
        ret += (left * right) % M;
        ret %= M;
    }
    println!("{}", ret);
}

#[allow(dead_code)]
const M: i64 = 1_000_000_007;

#[allow(dead_code)]
struct Comb {
    fac: Vec<i64>,
    finv: Vec<i64>,
    inv: Vec<i64>
}

#[allow(dead_code)]
impl Comb {
    fn new(n: usize) -> Self {
        let mut fac = vec![0;n];
        let mut finv = vec![0;n];
        let mut inv = vec![0;n];
        fac[0] = 1;
        fac[1] = 1;
        finv[0] = 1;
        finv[1] = 1;
        inv[1] = 1;
        for i in 2..n {
            let i_i64 = i as i64;
            fac[i] = fac[i-1] * i_i64 % M;
            inv[i] = M - inv[(M%i_i64) as usize] * (M / i_i64) % M;
            finv[i] = finv[i-1] * inv[i] % M;
        }
        Comb {
            fac: fac, finv: finv, inv: inv
        }
    }
    fn of(&self, n: usize, k: usize) -> i64 {
        if n < k {0}
        else {self.fac[n] * (self.finv[k] * self.finv[n - k] % M) % M}
    }
    /// combination with repetition
    fn rep(&self, n: usize, k: usize) -> i64 {
        self.of(n + k - 1, k)
    }
    fn perm(&self, n: usize, k: usize) -> i64 {
        if n < k {0}
        else {self.fac[n] * self.finv[n-k] % M}
    }
}

// region template
#[allow(dead_code)]
fn iu(i: isize) -> usize { i as usize }

#[allow(dead_code)]
fn ui(i: usize) -> isize { i as isize }

#[allow(dead_code, deprecated)]
fn join<T: std::fmt::Display>(slice: &[T], sep: &str) -> String {
    let strings = slice.iter().map(|t| format!("{}", t)).collect::<Vec<_>>();
    strings.connect(sep)
}

#[allow(dead_code)]
fn arr<'a, S, T>(n: usize, mut f: S) -> Vec<T> where S: FnMut(usize) -> T + 'a {
    (0..n).map(|i| f(i)).collect::<Vec<T>>()
}

#[allow(dead_code)]
fn alt<S, T>(v: Vec<S>) -> T where T: FromIterator<S> {
    v.into_iter().collect::<T>()
}

#[allow(dead_code)]
fn dup<S, T>(v: &[S]) -> T where T: FromIterator<S>, S: Clone {
    v.iter().cloned().collect::<T>()
}

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }

    fn readn<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect()
    }

    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
// endregion

Measured memory_bytes: 10492
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.nextLine());
        int[] H = new int[N];
        for (int i = 0; i < N; i++) {
            H[i] = Integer.parseInt(sc.next());
        }

        int[] higher = new int[N];
        for (int i = 0; i < N - 1; i++) {
            if (H[i + 1] <= H[i]) {
                higher[i]++;
            }
        }

        int ans = 0;
        int tmp = 0;
        for (int i = 0; i < N; i++) {
            if (higher[i] == 0) {
                ans = Math.max(ans, tmp);
                tmp = 0;
            } else {
                tmp++;
            }
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 48456
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#define INF 1000000000
#define rep(i,n) for(int i =0;i<n;i++)
using namespace std;
typedef long long int ll;

int main(){
    for(;;){
        int n;
        cin >> n;
        if(!n)break;
        int g[500][500];
        for (int i=0; i<500; i++) {
            for (int j=0; j<500; j++) {
                g[i][j]=0;
            }
        }
        vector<pair<int,int> > memo(250);
        for (int i=0; i<250; i++) {
            memo[i].first=0;
            memo[i].second=0;
        }
        g[250][250]=1;
        memo[0].first=250;
        memo[0].second=250;
        for (int i=1; i<n; i++) {
            int n,d;
            cin >> n >> d;
            int s=0,t=0;
            if (d==0) s=-1;
            if (d==1) t=-1;
            if (d==2) s=1;
            if (d==3) t=1;
            int ii=memo[n].first+s;
            int jj=memo[n].second+t;
            g[ii][jj]=1;
            memo[i].first=ii;
            memo[i].second=jj;
        }
        int u=0,m=0,h=0,s=0;
        for (int i=0; i<500; i++) {
            int ch=0;
            for (int j=0; j<500; j++) {
                if(g[i][j]!=0){
                    u=i;
                    ch++;
                    break;
                }
            }
            if(ch==1) break;
        }
        for (int i=499; i>=0; i--) {
            int ch=0;
            for (int j=0; j<500; j++) {
                if(g[i][j]!=0){
                    s=i;
                    ch++;
                    break;
                }
            }
            if(ch==1) break;
        }
        for (int i=0; i<500; i++) {
            int ch=0;
            for (int j=0; j<500; j++) {
                if(g[j][i]!=0){
                    h=i;
                    ch++;
                    break;
                }
            }
            if(ch==1) break;
        }
        for (int i=499; i>=0; i--) {
            int ch=0;
            for (int j=0; j<500; j++) {
                if(g[j][i]!=0){
                    m=i;
                    ch++;
                    break;
                }
            }
            if(ch==1) break;
        }
        cout << s-u+1<<" "<< m-h+1<<endl;
    }
}

Measured memory_bytes: 2172
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N; cin>>N;
    vint c(N),s(N),f(N);
    REP(i,N-1) cin>>c[i]>>s[i]>>f[i];

    for(int i=0;i<N;i++){
        int t=0;
        for(int j=i;j<N-1;j++){
            if(t<=s[j]) t=s[j]+c[j];
            else{ 
                t=(t+f[j]-1)/f[j]*f[j];
                t+=c[j];
            }
        }
        cout<<t<<endl;
    }
}


Measured memory_bytes: 256
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

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

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(1, 1E8); \
                 auto rnd = bind(__dis, __gen)

const int INF = 1E18;
const int mod = 1E9 + 7;

int32_t main() {
    fastIO();
    
    int sz;
    string s;
    cin >> s, sz = s.size();
    
    vector<int> pow_of_three(1, 1);
    for (int i = 1; i < sz; ++i) pow_of_three.eb(pow_of_three.back() * 3 % mod);
    
    vector<int> pre(sz, 0), suf(sz, 0), q_pre(sz, 0), q_suf(sz, 0);
    for (int i = 0; i < sz; ++i) {
          pre[i] = (i ?   pre[i-1] : 0LL) + (s[i] == 'A');
        q_pre[i] = (i ? q_pre[i-1] : 0LL) + (s[i] == '?');
    }
    for (int i = sz-1; i >= 0; --i) {
          suf[i] = (i != sz-1 ?   suf[i+1] : 0LL) + (s[i] == 'C');
        q_suf[i] = (i != sz-1 ? q_suf[i+1] : 0LL) + (s[i] == '?');
    }
    
    int ans = 0;
    for (int i = 1; i < sz-1; ++i) {
        if (s[i] == 'B' or s[i] == '?') {
            int a = pre[i-1], c = suf[i+1], ql = q_pre[i-1], qr = q_suf[i+1], pl, pr;
            cerr << a << " " << c << " " << ql << " " << qr << "\n";
            if (ql) pl = (a * 3 + ql) * pow_of_three[ql - 1] % mod;
            else pl = a;
            if (qr) pr = (c * 3 + qr) * pow_of_three[qr - 1] % mod;
            else pr = c;
            ans = (ans + pl * pr) % mod;
        }
    }
    
    cout << ans << "\n";
    
    return 0;
}

Measured memory_bytes: 4420