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

#define mod 1000000007
#define modd 998244353
#define PI 3.1415926
#define ll long long
#define ld long double
#define pb push_back
#define popb pop_back
#define beg begin()
#define en end()
#define sz(v) (int)((v).size())
#define all(v) (v).begin(),(v).end()
#define ub upper_bound
#define lb lower_bound
#define ff first
#define ss second
#define endl "\n"
#define forn(i,a,n) for(int i=a;i<int(n);++i)
#define forb(i,a,n) for(int i=int(n)-1;i>=a;--i)
#define cout(ans) cout<< ans << "\n"
#define couts(ans) cout<< ans <<" "
#define coutss(a,b) cout<< a <<" "<< b << "\n"
#define coutsm(a,b,c) cout<< a <<" "<< b <<" "<< c << "\n"
#define maxx *max_element
#define minn *min_element


void speed()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    cout.tie(NULL);
}





void solve()
{      
    string s;cin>>s;
    int ans=0,cnt=0;
    for(int i=0;i<3;++i)
    {
        if(s[i]=='R')
        {    cnt++;
            ans=max(cnt,ans);
        }
        else
            cnt=0;
    }
    cout(ans);

}


int main()
{   
    speed();
    int tc=1;
    // cin>>tc;
    while(tc--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <vector>
#include <cstdlib>
#define mem(i,a) memset(i,a,sizeof(i))
#define PI acos(-1.0)
#define DMAX 80000+5
#define eps 1e-8
#define mp make_pair
#define INF 1000000000+9
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
inline void read(ll &f){
    f=0;
    ll x=1;
    char ch=getchar();
    while(ch<48 || ch>57) {
        if(ch=='-') {
            x=-1;
        }
        ch=getchar();
    }
    while(ch<=57 && ch>=48) {
        f=f*10+ch-'0';
        ch=getchar();
    }
    f*=x;
}
ll n,a,b;
int main(){
    read(n),read(a),read(b);
    ll p=a+b;
    ll ans=n/p*a;
    n%=p;
    ans+=min(n,a);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <typeinfo>
//#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

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

Measured memory_bytes: 256
#include<iostream> 
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>
//#define _LIBCPP_DEBUG 0
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define all(a) (a).begin(),(a),end()
#define rep(i,n) for (ll i = 0; i < ll(n); ++i)	
//setprecision(16)

void outi(int x) { cout << x << endl; }
void outl(ll x) { cout << x << endl; }
void outs(string x) { cout << x << endl; }
ll max(ll a, ll b) {
	ll max;
	if (a > b) max = a;
	else max = b;
	return max;
}
ll min(ll a, ll b) {
	ll min;
	if (a < b) min = a;
	else min = b;
	return min;
}
//---------------------------------------------------------------

int main() {
	ll n;
	long long a[100005];

	cin >> n;
	rep(i, n) {
		cin >> a[i];
		if (a[i] == 0) {
			outi(0);
			return 0;
		}
	}
	ll ans = 1;
	rep(i, n) {
		if (a[i] <= 1000000000000000000 / ans) {
			ans *= a[i];
		}
		else {
			outi(-1);
			return 0;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 4332
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);

		int N = in.nextInt();
		int K = in.nextInt();
		
		ArrayList<Long> left = new ArrayList<Long>();
		ArrayList<Long> right = new ArrayList<Long>();
		
		for (int i = 0; i < N; i++) {
			long temp = in.nextLong();
			// Include 0 in left
			if (temp <= 0) {
				left.add(temp);
			} else {
				right.add(temp);
			}
		}
		
		long temp = 0;
		long answer = Long.MAX_VALUE;

		// go to left
		for (int i = left.size() - 1; i >= 0; i--) {
			int count = left.size() - i;
			temp = Math.abs(left.get(i));
			
			if (count < K && count + right.size() >= K) {
				int rightIndex = K - count - 1;
				temp *= 2;
				temp += right.get(rightIndex);
				answer = Math.min(answer, temp);
			} else if (count == K) {
				answer = Math.min(answer, temp);
			}
		}
		
		// go to right
		for (int i = 0; i < right.size(); i++) {
			int count = i + 1;
			temp = right.get(i);
			
			if (count < K && count + left.size() >= K) {
				int leftIndex = left.size() - (K - count);
				temp *= 2;
				temp += Math.abs(left.get(leftIndex));
				answer = Math.min(answer, temp);
			} else if (count == K) {
				answer = Math.min(answer, temp);
			}
		}
		
		System.out.println(answer);
    }
}

Measured memory_bytes: 61112
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
const int MX = 1000005;
int n, q, k, a[MX], b[MX];
string s;
int main(){
	cin >> n >> s >> q;
	rep(i,n){
		a[i+1] = a[i] + (s[i] == 'D');
		b[i+1] = b[i] + (s[i] == 'M');
	}
	rep(i,q){
		cin >> k;
		long long t = 0, ans = 0;
		rep(j,n){
			if(j-k >= 0 && s[j-k] == 'D') t -= b[j] - b[j-k];
			if(s[j] == 'M') t += a[j] - (j-k >= 0 ? a[j-k+1] : 0);
			else if(s[j] == 'C') ans += t;
		}
		cout << ans << '\n';
	}
}

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

int main() {
  int k, n,distance = 0;
  cin >> k >> n;
  vector<int> a(n + 100);
  for (int i = 0; i < n; i++) cin >> a.at(i);
  for (int i = 0; i < n - 1; i++)
  {
    if (a.at(i+1) - a.at(i) > distance) distance = a.at(i+1) - a.at(i);
  }
  if (a.at(0) + k - a.at(n-1) > distance) distance = a.at(0) +  k - a.at(n-1);

  cout << k - distance;
  return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>
#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 1LL << 61;
//const ll mod = 1000000007LL;
const ll mod = 998244353LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
ll dx[9] = { 0,1,0,-1,0,1,1,-1,-1 }, dy[9] = { 0,0,1,0,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222


ll cnt[33];
ll rmax[33][MAX];



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


  string t;
  cin >> s;
  cin >> t;

  rep(i, s.size()) {
    tmp = s[i] - 'a';
    cnt[tmp]++;
  }
  rep(i, t.size()) {
    tmp = t[i] - 'a';
    if (!cnt[tmp]) {
      cout << "-1" << endl;
      return 0;
    }
  }

  rep(i, 33) rmax[i][s.size()] = inf;
  rep(i, 33) rrep(j, s.size()) {
    tmp = s[j] - 'a';
    if (i == tmp) rmax[i][j] = j;
    else rmax[i][j] = rmax[i][j + 1];
  }

  ll cur = 0, tcur = 0;
  while (tcur < t.size()) {
    cur = 0;
    while (cur < s.size() && tcur < t.size()) {
      tmp = t[tcur] - 'a';
      if (rmax[tmp][cur] != inf) {
        tcur++;
        cur = rmax[tmp][cur] + 1;
      }
      else break;
    }
    if (tcur == t.size()) ans += cur;
    else ans += s.size();
  }
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 55760
from fractions import gcd

a, b, c, d = map(int, input().split())
a -= 1

def lcm(x, y):
    return (x * y) // gcd(x, y)

l = lcm(c, d)
divc = b // c - a // c
divd = b // d - a // d
divl = b // l - a // l

print(b - a - divc - divd + divl)

Measured memory_bytes: 5076
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#define FOR(i,a,b) for(i=a;i<=b;i++)

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long


int N, D, X, A[200], ans;


int main()
{
	cin >> N >> D >> X;
	for (int i = 1; i <= N; i++)
		cin >> A[i];
	ans += X;
	for (int i = 1; i <= N; i++) {
		ans += 1 + (D - 1) / A[i];
	}



	cout <<ans;


    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;    
int x[103],y[103],a[103];
int main(){
	fastIO;         
	int w,h,n;
	cin>>w>>h>>n;
	int lxp=w,lxn=0,lyp=h,lyn=0;
	for(int i=0;i<n;i++){
		cin>>x[i]>>y[i]>>a[i];
		if(a[i]==1){
			lxn=max(x[i],lxn);
		}
		else{
			if(a[i]==2){
				lxp=min(x[i],lxp);
			}
			else{
				if(a[i] == 3){
					lyn=max(y[i],lyn);
				}
				else{
					lyp=min(y[i],lyp);
				}
			}
		}
	}	
	cout<<max(0,lxp-lxn)*max(0,lyp-lyn)<<'\n';
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
public class Hello{
    public static void Main(){
        var list = new List<int>();
        
        while(true){
            var n = Console.ReadLine();
            if(n == null || n == "0"){
                break;
            }else{
                list.Add(int.Parse(n));
            }
        }
        
        for(var i = 0;i < list.Count();i++){
            Console.WriteLine($"Case {(i + 1)}: {list[i]}");
        }
    }
}



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

int main() {
    string s; cin >> s;
    // BBW -> WBB
    long long ans = 0, cnt_b = 0;
    for (char c: s) {
        if (c == 'B') cnt_b++;
        if (c == 'W') ans += cnt_b;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 644
#include<iostream>
#include<algorithm>
using namespace std;
const int BUF = 200005;
const int INF = 1 << 30;


int nVal;
int val[BUF];

void read() {
    cin >> nVal;
    for (int i = 0; i < nVal; ++i) {
        cin >> val[i];
    }
}


void work() {
    int minV = INF;
    int sum = 0;

    for (int i = 0; i < nVal; ++i) {
        if (minV > val[i]) {
            ++sum;
        }
        minV = min(minV, val[i]);
    }

    cout << sum << endl;
}


int main() {
    read();
    work();
    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
using namespace std;
const long long INF = 1000000000000000000;
int main() {
	int N;
	scanf("%d", &N);
	long long A[N], ans = 1;
	for (int i = 0; i < N; ++i) scanf("%lld", &A[i]);
	for (int i = 0; i < N; ++i) {
		if (A[i] == 0) {
			printf("0");
			return 0;
		}
	}
	for (int i = 0; i < N; ++i) {
		if (INF / ans < A[i]) {
			printf("-1");
			return 0;
		} else ans *= A[i];
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 2512
K = int(input())

from collections import deque

q = deque([i for i in range(1,10)])

for i in range(K):
    x = q.popleft()
    y = x % 10
    if y != 0:
        q.append(10*x+y-1)
    q.append(10*x+y)
    if y != 9:
        q.append(10*x+y+1)

print(x)


Measured memory_bytes: 18808
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use itertools::Itertools;
use proconio::*;
use text_io::*;

const U_INF: usize = 1 << 60;
const I_INF: isize = 1 << 60;

fn main() {
    let n: usize = read!();
    let top = n / 100;

    if n <= top * 100 + top * 10 + top {
        println!("{}", top * 100 + top * 10 + top);
    } else {
        let a = top + 1;
        println!("{}", a * 100 + a * 10 + a);
    }
}


Measured memory_bytes: 2100
import sys,math
from functools import reduce
input = sys.stdin.readline
n=int(input())
l=list(map(int,input().split()))

def lcm_base(x,y):
    return (x*y)//math.gcd(x,y)
def lcm(*N):
    return reduce(lcm_base,N,1)

print(lcm(*l))


Measured memory_bytes: 6340
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    cin>>s;
    while (1) {
        s.erase(s.size()-1);
        if (s.size()%2==0) {
            string front=s.substr(0,s.size()/2);
            string back=s.substr(s.size()/2,s.size()/2);
            if (front==back) {
                cout<<s.size()<<endl;
                break;
            }
        }
    }
}


Measured memory_bytes: 256
#                       _oo0oo_
#                      o8888888o
#                      88" . "88
#                      (| -_- |)
#                      0\  =  /0
#                    ___/`---'\___
#                  .' \\|     |// '.
#                 / \\|||  :  |||// \
#                / _||||| -:- |||||- \
#               |   | \\\  -  /// |   |
#               | \_|  ''\---/''  |_/ |
#               \  .-\__  '-'  ___/-. /
#             ___'. .'  /--.--\  `. .'___
#          ."" '<  `.___\_<|>_/___.' >' "".
#         | | :  `- \`.;`\ _ /`;.`/ - ` : | |
#         \  \ `_.   \_ __\ /__ _/   .-` /  /
#     =====`-.____`.___ \_____/___.-`___.-'=====
#                       `=---='
#
#
#     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
#               佛祖保佑         永无BUG

a = int(input())
print(a ** 3)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<string,int>;
const double PI = acos(-1);
int main() {
int a,b,h,m;
cin >> a >> b >> h >> m;
double ang1 = (double)(h*60 + m)/720*2*PI;
double ang2 = (double)m/60*2*PI;
double xa = a*cos(ang1);
double ya = a*sin(ang1);
double xb = b*cos(ang2);
double yb = b*sin(ang2);
double dx = xa - xb;
double dy = ya - yb;
double d = sqrt(dx*dx + dy*dy);
printf("%.10f\n",d);

}


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

int main() {

  ll x;
  cin >> x;
  bool ans = false;
  
  for(ll i = -200; i < 200; i++) {
    for(ll j= -200; j < 200; j++) {
      if((i*i*i*i*i) - (j*j*j*j*j) == x) {
        cout << i << " " << j << endl;
        ans = true;
        break;
      }
    }
    if(ans) break;
  }

}


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

int main()
{
    long long a;
    long long x = 100;
    int count = 0;
    cin >> a;
    while(x < a){
        x *= 1.01;
        count++;
    }
    cout << count << endl;
    return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<int> p(a), q(b), r(c);
  for (int i = 0; i < a; i++) cin >> p[i];
  for (int i = 0; i < b; i++) cin >> q[i];
  for (int i = 0; i < c; i++) cin >> r[i];
  sort(p.begin(), p.end(), greater<int>());
  sort(q.begin(), q.end(), greater<int>());
  for (int i = 0; i < x; i++) r.emplace_back(p[i]);
  for (int i = 0; i < y; i++) r.emplace_back(q[i]);
  sort(r.begin(), r.end(), greater<int>());
  long long ans = 0;
  for (int i = 0; i < x + y; i++) ans += r[i];
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 5568
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(std::unique(all(x)), x.end());
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=acos(-1);
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    string s;
    int x,y;
    cin>>s>>x>>y;
    int n=sz(s);
    s+='T';

    vector<int> dx,dy;
    int cnt=0;
    bool is_x=1;
    for(int i = 0; i < n+1; i++) {
        if(s[i]=='F') cnt++;
        else {
            (is_x ? dx : dy).push_back(cnt);
            is_x^=1;
            cnt=0;
        }
    }

    const int g=17000;

    int p=sz(dx);
    vector<vector<bool> > dpx(p+10,vector<bool>(34000));
    dpx[0][0+g]=true;
    dpx[1][dx[0]+g]=true;
    for(int i = 1; i < p; i++) {
        for(int j = -8000; j <= 8000; j++) {
            dpx[i+1][j+g]=(dpx[i][j-dx[i]+g] || dpx[i][j+dx[i]+g]);
        }
    }

    int q=sz(dy);
    vector<vector<bool> > dpy(p+10,vector<bool>(34000));
    dpy[0][0+g]=true;
    for(int i = 0; i < q; i++) {
        for(int j = -8000; j <= 8000; j++) {
            dpy[i+1][j+g]=(dpy[i][j-dy[i]+g] || dpy[i][j+dy[i]+g]);
        }
    }

    cout<<(dpx[p][x+g]&&dpy[q][y+g] ? "Yes" : "No")<<endl;

}



Measured memory_bytes: 33792
n, p = map(int, input().split())
ns = list(map(int, input().split()))
ns = [i % 2 for i in ns]
ans = [0, 0]
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result
c = ns.count(1)
ans[1] = sum(cmb(c, i) for i in range(1, c + 1, 2)) * 2 ** (n - c)
ans[0] = 2**n - ans[1]
print(ans[p])

Measured memory_bytes: 38256
#include <iostream>
#include <cstdio>
using namespace std;
int A[100],B[300],n;

bool search(int i, int key) {
	if (key == 0)return true;
	if (i >= n)return false;
	bool res = search(i + 1, key) || search(i + 1, key - A[i]);
	return res;
}

int main() {
	
	int q;
	scanf("%d", &n);
	for (int t = 0; t < n; t++) {
		scanf("%d", &A[t]);
	}
	scanf("%d", &q);

	
	for (int t = 0; t < q; t++) {
		scanf("%d", &B[t]);
		if (search(0, B[t])) {
			printf("yes\n");
		}
		else {
			printf("no\n");
		}
	}
	
	return 0;
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<ll>>;
#define F(i,s,e) for(ll i=s;i<e;++i)
#define IA(array,size) F(i,0,size) cin >> array[i];
#define PA(array,size) F(i,0,size) cout << array[i] << " "; cout << endl;
constexpr int32_t MOD = 1000000007;

int main(){
    ll n;
    cin >> n;
    ll a[n];
    IA(a,n);

    ll sum=abs(0-a[0])+abs(a[n-1]-0);
    F(i,0,n-1) sum+=abs(a[i+1]-a[i]);

    F(i,0,n){
        if(i==0) cout << sum-abs(a[0])-abs(a[1]-a[0])+abs(a[1]) << endl;
        else if(i==n-1) cout << sum-abs(a[n-1])-abs(a[n-1]-a[n-2])+abs(a[n-2]) << endl;
        else cout << sum-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1]) << endl;
    }

    return 0;
}

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

int main() {
    int H,W,ans,a,b,c,ans0,a1,b1,c1,ans1,a2,b2,c2,ans2,a3,b3,c3,ans3;
    cin>>H>>W;
    if(H%3==0||W%3==0) ans=0;
    else {
        a=(H/3)*W;
        b=(H-(H/3))*(W/2);
        c=(H-(H/3))*(W-(W/2));
        ans0=max(max(a,b),c)-min(min(a,b),c);
        a1=(H/3+1)*W;
        b1=(H-(H/3+1))*(W/2);
        c1=(H-(H/3+1))*(W-(W/2));
        ans1=max(max(a1,b1),c1)-min(min(a1,b1),c1);
        a2=(W/3)*H;
        b2=(W-(W/3))*(H/2);
        c2=(W-(W/3))*(H-(H/2));
        ans2=max(max(a2,b2),c2)-min(min(a2,b2),c2);
        a3=(W/3+1)*H;
        b3=(W-(W/3+1))*(H/2);
        c3=(W-(W/3+1))*(H-(H/2));
        ans3=max(max(a3,b3),c3)-min(min(a3,b3),c3);
        ans=min(min(min(ans0,ans1),min(ans2,ans3)),min(H,W));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
S = input()
keywords = ["dream", "dreamer", "erase", "eraser"]
while(True):
    if len(S) == 0:
        print("YES")
        break
    for key in keywords:
        if S.endswith(key):
            S = S[:-len(key)]
            break
    else:
        print("NO")
        break

Measured memory_bytes: 3188
from collections import Counter
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parent = [i for i in range(n)]
        self.rank = [0 for i in range(n)]

    def getParent(self):
        return [self.find(i) for i in range(N)]

    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    def unite(self, x, y):
        root_x = self.find(x)
        root_y = self.find(y)
        if (root_x == root_y):
            return
        elif self.rank[root_x] > self.rank[root_y]:
            self.parent[root_y] = root_x

        elif self.rank[root_y] > self.rank[root_x]:
            self.parent[root_x] = root_y

        else:
            self.parent[root_x] = root_y
            self.rank[root_y] += 1

    def isSame(self, x, y):
        return self.find(x) == self.find(y)

    def memsInGroup(self, x):
        """
        O(N)かかります
        """
        root = self.find(x)
        return [i for i in range(N) if root == self.find(i)]

    def sizeOfGroup(self, x):
        return len(self.memsInGroup(x))


N, M = map(int, input().split())

uf = UnionFind(N)
for i in range(M):
    a, b = map(int, input().split())
    uf.unite(a-1, b-1)

# print(uf.getParent())
groups = len(Counter(uf.getParent()).keys())
ans = groups - 1
print(ans)


Measured memory_bytes: 96936
import sys
sys.setrecursionlimit(4100000)

import math

import logging

logging.basicConfig(level=logging.DEBUG)

logger = logging.getLogger(__name__)


def resolve():
    c = [x for x in sys.stdin.readline().split()][0]  # 整数一つ
    # N, D = [int(x) for x in sys.stdin.readline().split()] # 整数 複数

    logger.debug('{}'.format([c]))

    print(str(chr(ord(c) + 1)))


if __name__ == "__main__":
    resolve()

# AtCoder Unit Test で自動生成できる, 最後のunittest.main は消す
# python -m unittest template/template.py で実行できる
# pypy3 -m unittest template/template.py で実行できる
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """a"""
        output = """b"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """y"""
        output = """z"""
        self.assertIO(input, output)


Measured memory_bytes: 5696
#include <stdio.h>

int main()
{
    int a, b, c, i, result;

    scanf("%d %d %d", &a, &b, &c);

    if(a==b && a==c)
    {
        result=0;
    }

    else
    {
        if( a==b || b==c || c==a)
            result=1;
        else
            result=0;
    }

    if(result==0)
        printf("No");
    else
        printf("Yes");
}


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

main(){
  int N;
  cin >> N;
  int dn=0;
  int count=0;
  for(int i=1; i<=N; i+=2){
    for(int j=1; j<=i; j++){
      if( i%j ==0)
        dn++;
    }
    if(dn ==8)
      count++;
    dn=0;
  }
  cout << count << endl;
  return 0;
}  

Measured memory_bytes: 256
main(i,j,m,n){
  for(;scanf("%d%d",&n,&m),n;){
    for(i=0;i<m;i++)a[i]=i+1;
    for(;n;n--)
      for(i=0;i<m;i++)
        scanf("%d",&j),a[i]+=j*10000;
    for(i=0;i<m-1;i++)
      for(j=0;j<m-1;j++)
        if(a[j]/10000<a[j+1]/10000)
          n=a[j],a[j]=a[j+1],a[j+1]=n;
    for(i=0;i<m;i++)
      printf("%d%c",a[i]%10000,i==m-1?'\n':' ');
  }
  return 0;
}

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

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

    int ans = n;
    int count = 1;
    int isFusion = 0;
    for(int i = 0; i < n - 1; i++) {
        if(s[i] == s[i + 1]) {
            count++; 
            isFusion = 1;
            continue;
        }
        if(s[i] != s[i + 1] && isFusion == 1) {
            ans = ans - count + 1;
            isFusion = 0;
            count = 1;
            continue;
        }
        if(s[i] != s[i + 1] && isFusion == 0) {
            count = 1;
            continue;
        }
    }

    if(isFusion) ans = ans - count + 1;

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 512
def ans():
	l = list(map(int, raw_input().split()))
	if l[0] == l[1] and l[1] == l[2]:
		print 1
		return 1
	elif l[0] == l[1] or l[1] == l[2] or l[2] == l[0]:
		print 2
		return 2
	else:
		print 3
		return 3

if __name__ == '__main__':
	ans = ans()

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

#ifndef DEBUG
#define endl '\n'
#define debugf(...)
#define debug(...)
#else
#define debugf(...) printf(__VA_ARGS__)
#define debug(...) __VA_ARGS__
#endif

const int N = 1e5 + 5;



int (((((main)))))() <%
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	int a, b, c;
	cin >> a >> b >> c;

	set<int> s;
	s.emplace(a);
	s.emplace(b);
	s.emplace(c);

	if (s.size() == 2)
		cout << "Yes\n";
	else cout << "No\n";
	
	return 0;
%>

Measured memory_bytes: 256
n = int(input().strip())
a = [int(input().strip()) for _ in range(n)]
visited = [False] * n
visited[0] = True
now = 0
ans = 0
while True:
    now = a[now] - 1
    ans += 1
    if now == 1:
        print(ans)
        exit()
    elif visited[now]:
        print(-1)
        exit()
    visited[now] = True


Measured memory_bytes: 50240
n,m = map(int,input().split())
h = [0]+list(map(int,input().split()))
t = [1]*(n+1)
for i in range(m):
    a,b = map(int,input().split())
    if(h[a] < h[b]):
        t[a] = 0
    elif(h[a] > h[b]):
        t[b] = 0
    else:
        t[a] = 0
        t[b] = 0
p = 0
for i in range(1,n+1):
    if(t[i] == 1):
        p += 1
print(p)

Measured memory_bytes: 20128
# import sys; input = sys.stdin.buffer.readline
# sys.setrecursionlimit(10**7)
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	X, K, D = getlist()
	if X - K * D >= 0:
		print(X - K * D)
	elif X + K * D <= 0:
		print(abs(X + K * D))

	else:
		X = abs(X)
		K -= X // D
		X = X % D

		if K % 2 == 0:
			print(X)
		else:
			print(D - X)



if __name__ == '__main__':
	main()

Measured memory_bytes: 9460
#include <bits/stdc++.h>
using  namespace  std;
using ll=long long;
int main(){
  char a,b;
  cin>>a>>b;
  if(a=='D'){
    if(b=='D')cout<<'H'<<endl;
    else cout<<'D'<<endl;
  }
  else cout<<b<<endl;
}

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

int sum(int x){
    int sum = 0;
    while(x>0){
        sum += x%10;
        x /= 10;
    }
    return sum;
};

int main(){
    int N;
    cin>>N;
    string s = "No";
    if(N%sum(N) == 0){
        s = "Yes";
    }
    cout<<s<<endl;
}


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

typedef long long ll;

int main () {

    int a[3];
    for (int i=0; i<3; ++i) {
	cin >> a[i];
    }
    sort(a,a+3);
    if(a[0] == 5 and a[1] == 5 and a[2] == 7)
	cout << "YES" << endl;
    else
	cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
typedef long long ll;
typedef pair<ll, ll> P;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll MOD = 1000000007;
int INF = 1001001001;

void solve()
{
	string s;cin >> s;
	set<char> a;
	rep(i, sz(s))a.insert(s[i]);
	if(sz(a)==1)cout << "No" << endl;
	else cout << "Yes" << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


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

int main(void){
	int N,K;
	cin >> N >> K;
	double ans = 0;
	if(N>(K-1)){
		ans += (double)((N-K)+1)/(double)N;
	}
	int range = N;
	if(N>=K)range = K-1;
	for(int i=1;i<=range;i++){
		double ret = 1.0;
		int tempi=i;
		while(tempi<K){
			ret *= 0.5;
			tempi*=2;
		}
		ans += ret/(double)N;
	}
	//cout << fixed << setprecision(10) << ans << endl;
	printf("%.10lf\n",ans);
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n,k = map(int,readline().split())
p = [int(input()) for i in range(n)]
p.sort()
ans = 10**9 
for i in range(n-k+1):
    if p[i+k-1]-p[i] < ans: ans =  p[i+k-1]-p[i]
print(ans)

Measured memory_bytes: 7496
import math

li =[]
li2 = []
for i in range(5):
	li.append(int(input()))
	a = li[i]%10
	if a == 0:
		a = 10
	li2.append(a)
    
#print(li)
#print(li2)

mi = li2.index(min(li2))
#print(li[mi])
result=0
for i in range(len(li)):
	if i==mi:
		result = result+li[i]
	else:
		result = result+math.ceil(li[i]/10)*10
print(result)

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

int main() {
  int a, b = 0, c = 100;
  vector<string> d(200);
  for (cin >> a; a; a--) cin >> d.at(b++);
  for (cin >> b; b--;) cin >> d.at(c++);
  for (;;) {
    b = 0;
    string e = "";
    for (c = 0; c < 200; c++) {
      if (e == "" && d.at(c) != "") e = d.at(c);
      if (e != "" && e == d.at(c)) {
        d.at(c) = "";
        if (c > 99) b--;
        else b++;
      }
    }
    if (e == "") break;
    if (b > a) a = b;
  }
  cout << a;
}

Measured memory_bytes: 3640
n, k = map(int,input().split())
h = list(map(int,input().split()))
INF = float('inf')
dp = [INF] * n 
dp[0] = 0 
dp[1] = abs(h[1] - h[0])




for i in range(2,n):
    for j in range(1, min(i, k) + 1):
        dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i  -j]))
        

print(dp[n - 1])

            
        
        
        
        


Measured memory_bytes: 85652
import java.util.*;
import java.math.BigDecimal;

class Main{
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		double x1 = stdIn.nextDouble();
		double y1 = stdIn.nextDouble();
		double x2 = stdIn.nextDouble();
		double y2 = stdIn.nextDouble();
		int q = stdIn.nextInt();
		for(int i=0;i<q;i++){
			double xp = stdIn.nextDouble();
			double yp = stdIn.nextDouble();
			Vector vec1 = new Vector(x1,y1,x2,y2);
			Vector vec2 = new Vector(x1,y1,xp,yp);
			vec1.projection(vec2);
			System.out.println((vec1.x+x1)+" "+(vec1.y+y1));
		}

	}	
}

class Vector{
	public final double EPS = Math.pow(10,-8);
	public double x,y;
	int cutoff = 9;

	Vector( double x1 , double y1 , double x2 , double y2 ){
		this.x = x2 - x1;
		this.y = y2 - y1;
	}

	double dot( Vector a ){	
		return cuttingOff(this.x * a.x + this.y * a.y);
	}
	double cross( Vector a ){	
		return cuttingOff(this.x * a.y - this.y * a.x);
	}

	void add( Vector a ){
		this.x = cuttingOff(this.x + a.x);
		this.y = cuttingOff(this.y + a.y);
	}
	void sub( Vector a ){
		this.x = cuttingOff(this.x - a.x);
		this.y = cuttingOff(this.y - a.y);
	}
	void mul( double z ){
		this.x = cuttingOff(this.x * z);
		this.y = cuttingOff(this.y * z);
	}
	void div( double z ){
		this.x = cuttingOff(this.x / z);
		this.y = cuttingOff(this.y / z);
	}

	double abs(){
		return Math.sqrt(norm());
	}
	double norm(){
		return cuttingOff(this.x * this.x + this.y * this.y);
	}

	void projection( Vector a ){
		if(judge(a.norm())){
			this.x = 0;
			this.y = 0;
		}
		else{
			double cos = dot(a)/(abs() * a.abs());
			double frac = a.abs() * cos/abs();
			mul(frac);
		}
	}
	Vector reflection( Vector a ){
		projection(a);
		return new Vector(a.x,a.y,this.x,this.y);
	}

	boolean judgeisOrthogonal( Vector a ){	
		return judge(dot(a)) ? true : false;
	}  
	boolean judgeisParallel( Vector a ){	
		return judge(cross(a)) ? true : false;
	}

	boolean judge( double a ){		
		return Math.abs(a)<EPS ? true : false;
	}
	double cuttingOff(double a){
		BigDecimal bi = new BigDecimal(String.valueOf(a));
		return bi.setScale(cutoff,BigDecimal.ROUND_DOWN).doubleValue();
	}
} 

Measured memory_bytes: 44752
#include<bits/stdc++.h>
using namespace std;
#define int long long
inline void read(int &x){
    char c = getchar();
    int p = 1;
    x = 0;
    while(!isdigit(c)){
        if(c == '-')p = -1;
        c = getchar();
    }
    while(isdigit(c)){
        x = (x << 1) + (x << 3) + (c ^ '0');
        c = getchar();
    }
    x *= p;
}
int t, a, b, c, d;
signed main(){
    //freopen(".in", "r", stdin);
    //freopen(".out", "w", stdout);
    read(t);
    while(t--){
        read(a), read(b), read(c), read(d);
        if(a < b){puts("No"); continue;}
        if(d < b){puts("No"); continue;}
        if(b <= c + 1){puts("Yes"); continue;}
        int gcd = __gcd(b, d);
        if(((a - c - 1ll) / gcd - (a - b) / gcd) > 0)puts("No");
        else puts("Yes");
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp> 
#include<ext/pb_ds/tree_policy.hpp> 
#define ll long long int
#define all(v) v.begin(),v.end() 
#define rev(v) v.rbegin(),v.rend()
#define ssd ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define ordered_set tree<ll, null_type, less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define trace(x) cerr<<#x<<" : "<<x<<endl;
#define inp 100005
#define en "\n"
using namespace std;
using namespace __gnu_pbds;

signed main() 
{
    ssd
    string s1,s2;
    cin>>s1>>s2;
    int i,j,k,n1 = s1.length(), n2 = s2.length();
    s1 = "0" + s1; 
    s2 = "0" + s2;
    vector<vector<int>> dp(n1+5,vector<int> (n2+5,0));

    for(i=1;i<=n1;i++)
    {
        for(j=1;j<=n2;j++)
        {
            if(s1[i]==s2[j])
            {
                dp[i][j] = 1 + dp[i-1][j-1];
            }   
            else
            {
                dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    deque<char> ans;
    i = n1, j = n2;
    while(i!=0 && j!=0)
    {
        if(s1[i]==s2[j])
        {
            ans.push_front(s1[i]);
            i = i-1;
            j = j-1;
        }
        else
        {
            if(dp[i-1][j] > dp[i][j-1]) i = i-1;
            else j = j-1;
        }
    }
    for(auto it:ans) cout<<it;
    return 0;           
}

Measured memory_bytes: 38516
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t;
    }
    return n*rep_jijo(n,x-1);
}

const ll M = pow(10,9)+7;

vector<ll> fac(1000001); //n!(mod M)
vector<ll> ifac(1000001); //k!^{M-2} (mod M)


ll mpow(ll x, ll n){ //x^n(mod M)
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b){ //aCb(mod M)
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}

ll perm(ll a, ll b){
    if(a < b) return 0;
    ll tmp = ifac[a-b] % M;
    return tmp * fac[a] % M;
}

ll dupc(ll a,ll b){
    if(a == 0 && b == 0)return 1;
    if(a < 0 || b == 0)return 0;
    ll tmp = ifac[a-1]* ifac[b] % M;
    return tmp * fac[a+b-1] % M;
}



int main(){
    ll s;
    cin >> s;
    ll ans = 1;
    ll r = s/3;

    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<1000000; i++){
        fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
        ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M)
    }

    if(s <=2){
        cout << 0 << endl;
        return 0;
    }


    for(int i = 2; i <= r; i++){
        ll n = s-3*i;
        ans += comb(n+i-1,n);
        ans %= mod;
    }

    cout << ans <<endl;



    return 0;
}

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

int main() {
  string s;
  cin >> s;
  string ans;
  for( int i=0;i<s.size();i++){
	if( i == 0 || i == s.size()-1 ){
      ans += s.at(i);
    }else if( i == 1 ){
      ans += to_string( s.substr(1,s.size()-2).size() );
    }
    
  }
  cout << ans << endl;
    
  return 0;
  
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	MOD := int(math.Pow10(9) + 7)

	var N int
	fmt.Scan(&N)

	DP := make([][]int, N+1)
	for i := 0; i <= N; i++ {
		DP[i] = make([]int, 64)
	}

	for i := 0; i < 64; i++ {
		DP[3][i] = 1
	}
	DP[3][6], DP[3][9], DP[3][18] = 0, 0, 0

	for i := 4; i <= N; i++ {
		for j := 0; j < 64; j++ {
			if j == 6 || j == 9 || j == 18 {
				continue
			}
			for k := 0; k < 64; k++ {
				if j%4 == 2 && k%16 == 1 {
					continue
				} else if j%4 == 1 && k%16 == 2 {
					continue
				} else if j%4 == 2 && k%16 == 4 {
					continue
				} else if j%4 == 2 && k>>2 == 1 {
					continue
				} else if j%4 == 2 && k>>4 == 0 && k%4 == 1 {
					continue
				} else if (j >> 2) == (k % 16) {
					DP[i][j] = (DP[i][j] + DP[i-1][k]) % MOD
				}
			}
		}
	}

	ans := 0
	for i := 0; i < 64; i++ {
		ans = (ans + DP[N][i]) % MOD
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
class SegTreeMin
    attr_reader :dat
    def initialize(n_input, top=Float::INFINITY)
        @n_input = n_input
        @n = 1 << @n_input.to_s(2).length
        @top = top
        @dat = Array.new(2 * @n - 1, @top)
    end

    def update(k, a)
        k += @n - 1
        @dat[k] = a
        while k > 0 do
            k = (k - 1) / 2
            if @dat[k] < a
                break
            else
                @dat[k] = a
            end
        end
    end

    # include a and b
    def min_between(a, b)
        query(a, b + 1, 0, 0, @n)
    end

    def query(a, b, k, l, r)
        return @top if r <= a || b <= l
        return @dat[k] if a <= l && r <= b
        vl = query(a, b, k * 2 + 1, l, (l + r) / 2)
        vr = query(a, b, k * 2 + 2, (l + r) / 2, r)
        #return [vl, vr].min
        return vl < vr ? vl : vr
    end
end

#t = Time.now
#N = 200000
#as = (1..N).to_a.shuffle
N = gets.to_i
NN = 1 << N.to_s(2).length
as = gets.split.map(&:to_i)
st = SegTreeMin.new(N, N+1)
rev = Array.new(N+1)
N.times do |i|
    rev[as[i]] = i
end
(1..N).each do |i|
    st.update(rev[i], i)
end

ans = 0
ls = [0]
rs = [N-1]
while ls.length > 0 do
    l = ls.pop
    r = rs.pop
    loop do
        if l == r
            ans += as[l]
            break
        end
        min = st.query(l, r + 1, 0, 0, NN)
        min_i = rev[min]
        if l == min_i
            ans += (r - min_i + 1) * min
            l += 1
        elsif r == min_i
            ans += (min_i - l + 1) * min
            r -= 1
        else
            ans += (r - min_i + 1) * (min_i - l + 1) * min
            ls.push(min_i + 1)
            rs.push(r)
            #ls.push(l)
            #rs.push(min_i - 1)
            r = min_i - 1
        end
    end
end

puts ans
#p Time.now - t

Measured memory_bytes: 23740
#include<stdio.h>
#include<algorithm>
using namespace std;
int n,m,h,a[17][17],i,j,l,w,b,c,flg;
int main(void)
{
	while(1){
		scanf("%d %d",&n,&m);
		if(n==0&&m==0) break;
		scanf("%d",&h);
		for(i=1;i<=m;i++){
			for(j=1;j<=n;j++){
				a[i][j]=0;
			}
		}
		for(i=0;i<h;i++){
			scanf("%d %d",&b,&c);
			a[c][b]=-1;
		}
		a[1][1]=1;
		for(i=1;i<=m;i++){
			for(j=1;j<=n;j++){
				if(i<m&&a[i][j]!=-1&&a[i][j+1]!=-1){
					a[i][j+1]+=a[i][j];
				}
				if(a[i+1][j]!=-1&&a[i][j]!=-1){
					a[i+1][j]+=a[i][j];
				}
			}
		}
/*		for(i=1;i<=m;i++){
			for(j=1;j<=n;j++){
				printf("%d ",a[i][j]);
			}
			printf("\n");
		}
*/		w=0;
		for(i=1;i<=n;i++){
			if(a[m][i]!=-1) w+=a[m][i];
			else w=0;
		}
		printf("%d\n",w);
	}
	return 0;
}

Measured memory_bytes: 2556
using System;
//using System.Collections.Generic;
using System.Linq;

namespace solution
{
  class Class1
  {
    static void Main()
    {
      int n = 0;
      while ((n = int.Parse(Console.ReadLine())) != 0)
      {
        var s = Console.ReadLine().Split().Select(int.Parse).ToArray();
        double m = s.Average();
        double sum = 0;
        foreach (var i in s)
        {
          sum += Math.Pow((i - m), 2) / n;
        }
        Console.WriteLine("{0:f8}", Math.Sqrt(sum));
      }
    }
  }
}


Measured memory_bytes: 9972
import sys
# input = sys.stdin.buffer.readline
def input(): return sys.stdin.readline().rstrip()
sys.setrecursionlimit(10 ** 7)

N = int(input())
ys = [[-1]*N for _ in range(N)]
for i in range(N):
    A = int(input())
    for j in range(A):
        x, y = map(int, input().split())
        ys[i][x-1] = y
# print(ys)

ans = 0
for b in range(1<<N):
    chk = [-1] * N      # 1: 正直 0:不親切
    flg = True
    for i in range(N):
        if b>>i&1:
            if chk[i] == 0:
                flg = False
                break
            chk[i] = 1
            for j in range(N):
                if ys[i][j] == -1: continue
                if chk[j] != -1 and chk[j] != ys[i][j]:
                    flg = False
                    break
                chk[j] = ys[i][j]
        else:
            if chk[i] == 1:
                flg = False
                break
            chk[i] = 0
    if flg:
        ans = max(ans, sum(chk))    # chk が 1の数
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ll> vi;
typedef unsigned long long ull;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

vector<int> fact;
vector<int> ifact;
vector<int> inv;
vector<int> pow2;
const int MOD = (1e9 + 7);
int add(int a, int b)
{
	a+=b;
	while(a>=MOD) a-=MOD;
	return a;
}
int mult(int a, int b)
{
	return (a*1LL*b)%MOD;
}
int modpow(int a, int b)
{
	int r=1;
	while(b)
	{
		if(b&1) r=mult(r,a);
		a=mult(a,a);
		b>>=1;
	}
	return r;
}
int choose(int a, int b)
{
	if(a<b) return 0;
	if(b==0) return 1;
	if(a==b) return 1;
	return mult(fact[a],mult(ifact[b],ifact[a-b]));
}
int inverse(int a)
{
	return modpow(a,MOD-2);
}
void init(int _n)
{
	fact.clear(); ifact.clear(); inv.clear(); pow2.clear();
	fact.resize(_n+1);
	ifact.resize(_n+1);
	inv.resize(_n+1);
	pow2.resize(_n+1);
	pow2[0]=1;
	ifact[0]=1;
	fact[0]=1;
	for(int i=1;i<=_n;i++)
	{
		pow2[i]=add(pow2[i-1],pow2[i-1]);
		fact[i]=mult(fact[i-1],i);
		//ifact[i]=mult(ifact[i-1],inv[i]);
	}
	ifact[_n] = inverse(fact[_n]);
	for(int i=_n-1;i>=1;i--)
	{
		ifact[i] = mult(ifact[i + 1], i + 1);
	}
	for(int i=1;i<=_n;i++)
	{
		inv[i] = mult(fact[i-1],ifact[i]);
	}
}
	
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); 
	init(555555);
	int n,a,b,c; cin>>n>>a>>b>>c;
	int p=mult(a,inv[a+b]); int q=mult(b,inv[a+b]); 
	int C = mult(100,inv[a+b]);
	int ans=0;
	for(int i=0;i<n;i++) //A wins
	{
		int coeff = choose(n+i-1,n-1);
		coeff=mult(coeff,mult(modpow(p,n),modpow(q,i)));
		coeff=mult(coeff,mult(n+i,C));
		ans=add(ans,coeff);
	}
	swap(p,q);
	for(int i=0;i<n;i++) //B wins
	{
		int coeff = choose(n+i-1,n-1);
		coeff=mult(coeff,mult(modpow(p,n),modpow(q,i)));
		coeff=mult(coeff,mult(n+i,C));
		ans=add(ans,coeff);
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 8960
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e16;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll n, a[500], dp[500][500][500];

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> n;
	a[0] = 0;
	for(ll i = 1; i <= n; i++){
		cin >> a[i];
		a[i] += a[i-1];
	}
	
	for(ll i = 2; i <= n; i++){
		for(ll j = 1; j+i-1 <= n; j++){
			dp[i][j][j+i-1] = INF;
		}
	}
	for(ll j = 1; j <= n; j++){
		dp[1][j][j] = 0;
	}
	
	for(ll i = 2; i <= n; i++){
		for(ll j = 1; j+i-1 <= n; j++){
			for(ll k = 1; k <= i-1; k++){
				dp[i][j][j+i-1] = min(dp[k][j][j+k-1]+dp[i-k][j+k][j+i-1]+a[j+i-1]-a[j-1], dp[i][j][j+i-1]);
			}
		}
	}
	print(dp[n][1][n])
	return 0;
}

Measured memory_bytes: 780672
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}*/


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

	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	rep(i, n) cin >> a[i];

	// dp[i][j]:= 石がi個あり、操作するのがjのとき、jが勝てるかどうか
	vector<vector<bool>> dp(k + 1, vector<bool>(2, false));

	rep(i, k + 1) {
		rep(j, 2) {
			rep(k, n) {
				if(i - a[k] >= 0)
					dp[i][j] = dp[i][j] || !dp[i - a[k]][(j + 1) % 2];
			}
		}
	}

	cout << (dp[k][0] ? "First" : "Second") << endl;

	return 0;
}


Measured memory_bytes: 7296