akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.math.BigInteger;
import java.io.BufferedReader;
import java.io.InputStream;

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

    static class B_Comparison {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            String a = in.next();
            String b = in.next();

            BigInteger A = new BigInteger(a);
            BigInteger B = new BigInteger(b);

            if (A.compareTo(B) > 0) out.printLine("GREATER");
            else if (A.compareTo(B) < 0) out.printLine("LESS");
            else out.printLine("EQUAL");
        }

    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer st;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            st = null;
        }

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

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void printLine(String s) {
            writer.println(s);
        }

        public void close() {
            writer.close();
        }

    }
}



Measured memory_bytes: 21460
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include<cstring>

using namespace std;

typedef long long ll;
char a[4];int x,y;
int main()
{

    cin>>a;
    for(int i=0;i<3;i++)
    {
        if(a[i]=='A')
        {
            x++;
        }
        if(a[i]=='B')
        {
            y++;
        }
    }
    if(x&&y)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
         cout<<"No"<<endl;
    }
    return 0;
}



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

long long k = 0, c[3] = {0};

vector<long long> cake[3], ans, lst;

void solve();
long long ch(long long now);

int main() {
  for(int i = 0; i < 3; ++i) cin >> c[i];
  cin >> k;
  for(int i = 0; i < 3; ++i) {
    cake[i].resize(c[i]);
    for(int j = 0; j < c[i]; ++j) cin >> cake[i][j];
    sort(cake[i].begin(), cake[i].end());
  }
  solve();
  for(int i = 0; i < k; ++i) cout << ans[i] << endl;
  return 0;
}

void solve() {
  long long maxnum = cake[0][c[0] - 1] + cake[1][c[1] - 1] +
                     cake[2][c[2] - 1],
            minnum =
                cake[0][0] + cake[1][0] + cake[2][0] - 1;
  for(int i = 0; i < c[1]; ++i)
    for(int j = 0; j < c[2]; ++j)
      lst.push_back(cake[1][i] + cake[2][j]);
  sort(lst.begin(), lst.end());
  for(int i = 0; i < k; ++i) {
    long long l = minnum, r = maxnum;
    while(r - l > 1) {
      long long now = (l + r) / 2, nowid = ch(now);
      if(nowid <= i)
        r = now;
      else {
        if(nowid >= k) minnum = now;
        l = now;
      }
    }
    maxnum = r;
    ans.push_back(r);
  }
}

long long ch(long long now) {
  long long cnt = 0;
  for(int i = 0; i < c[0]; ++i) {
    long long nowbound = now - cake[0][c[0] - 1 - i];
    auto it = upper_bound(lst.begin(), lst.end(), nowbound);
    if(it == lst.end()) break;
    cnt += lst.end() - it;
  }
  return cnt;
}

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

int main()
{
    int n, x, y, w, h, m, a, b;

    cin >> n;

    for( int i = 0; i < n; i++ )
    {
        cin >> x >> y >> w >> h;

        cin >> m;
        int cnt = 0;
        for( int j = 0; j < m; j++ )
        {
            cin >> a >> b;
            if( x <= a && a <= x + w && y <= b && b <= y + h )
                cnt++;
        }
        cout << cnt << endl;
    }
    return 0;
}


Measured memory_bytes: 3084
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll A, B;
    cin >> A >> B;
    cout << A * B << endl;
}


Measured memory_bytes: 3632
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

vector<vector<ll>> edge;

vector<ll> ret;
vector<bool> used;
pair<ll,ll> cy;
bool done=false;

void dfs(ll where,ll parent){
    //cout<<where<<endl;
    ll count=0;
    used[where]=true;
    ret.push_back(where);
    for(int i=0;i<edge[where].size() && !done;i++){
        ll to=edge[where][i];
        if(to==parent && count==0){count++; continue;}
        if(used[to]){cy={to,where}; done=true; break;}
        dfs(to,where);
    }
    if(!done){ret.pop_back();}
}


int main(){
    ll n;
    cin>>n;
    edge.resize(n);
    used.resize(n,false);
    for(int i=0;i<n;i++){
        ll u,v;
        cin>>u>>v;
        u--; v--;
        edge[u].push_back(v);
        edge[v].push_back(u);
    }
    dfs(0,-1);
    set<ll> s;
    bool in=false;
    for(int i=0;i<ret.size();i++){
        if(ret[i]==cy.F){in=true;}
        if(in){s.insert(ret[i]);}
        if(ret[i]==cy.S){in=false;}
    }
    ll q;
    cin>>q;
    while(q--){
        ll a,b;
        cin>>a>>b;
        a--; b--;
        if(s.find(a)!=s.end() && s.find(b)!=s.end()){cout<<2<<endl;}
        else{cout<<1<<endl;}
    }
    
    
    return 0;
}


Measured memory_bytes: 18560
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
#define INF2 1140000000
//const long long MOD = 1000000007;
const long long MOD = 998244353;

using namespace std;


void solve()
{
    int n, x, y;
    scanf("%d%d%d", &n, &x, &y);

    vector<int> a(n);
    int m = n-(y - x - 1);
    int i;
    for (i = 1; i <= m - 1; i++) {
        a[i] += (m - i)*2;
    }
    a[1]-=2;
    
    int mm = y - x + 1;
    for (i = 1; i <= mm - 1; i++) {
        int d = MIN(i, mm - i);
        a[d] += mm;
    }
    int j;
    for (i = 1; i <= mm - 2; i++) {
        int i2 = MIN(i, mm - i);
        for (j = 1; j <= n - y; j++) {
            a[i2 + j]+=2;
        }
        for (j = 1; j <= x - 1; j++) {
            a[i2 + j]+=2;
        }
    }

    for (i = 1; i < n; i++) {
        printf("%d\n", a[i]/2);    
    }

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T; scanf("%d", &T);
    while(T--) {
        solve();
    }
#endif
    return 0;
}

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

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int W=in.nextInt();
		int H=in.nextInt();
		int N=in.nextInt();
		int newH=0;
		int newW=0;
		int temp1=0;
		int temp2=W;
		int temp3=0;
		int temp4=H;
		int area=0;
		for (int i = 0; i < N; i++) {
			int x=in.nextInt();
			int y=in.nextInt();
			int a=in.nextInt();
			if(a==1)
				temp1=Math.max(temp1,x);
			if(a==2)
				temp2=Math.min(temp2,x);
			
			newW=(W-temp1)-(W-temp2);
			
			if(a==3)
				temp3=Math.max(temp3,y);
			if(a==4)
				temp4=Math.min(temp4,y);
			
			newH=(H-temp3)-(H-temp4);

		}
		area=newH*newW;
		if(area<0)
			area=0;
		if(newW<0 && newH<0)
			area=0;
		System.out.println(area);
	}
}

Measured memory_bytes: 27668
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define double long double
#define EPS 1e-9
//#define PI 3.14159265358979

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < A[i].size(); j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> N;
	vector< int > A(N);
	rep(i, N) cin >> A[i];
	sort(A.begin(), A.end());
	int ans = 1;
	double ans2 = 1.0;
	rep(i, N) {
		/*if (A[i] != 0 && ans > 3e18 / A[i]) {
			ans = -1;
			break;
		}*/
		//cout << ans << endl;
		ans *= A[i];
		ans2 *= A[i];
		if (ans2 > 1e18) {
			ans = -1;
			break;
		}
	}
	if (ans > 1e18)
		ans = -1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4052
use std::io::Read;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let mut dp = vec![std::i32::MIN + 3; n + 1];
    dp[0] = 0;
    for s in it {
        let a: usize = s.parse().unwrap();
        dp[a] = dp[a - 1] + 1;
    }
    let v = dp.into_iter().max().unwrap();
    if v <= 0 {
        println!("-1");
    } else {
        let ans = n as i32 - v;
        println!("{}", ans);
    }
}

fn main() {
    run();
}

Measured memory_bytes: 6396
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>
#include <bitset>
#include <memory>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <iomanip>
using namespace std;

int find(int n, unordered_map<int, int>& um) {
	if (um[n] >= 0) {
		um[n] = find(um[n], um);
		return um[n];
	}
	else {
		return n;
	}
}

void myunion(int a, int b, unordered_map<int, int>& um) {
	int fa = find(a, um);
	int fb = find(b, um);
	if (fa != fb) {
		um[fb] += um[fa];
		um[fa] = fb;
	}
}

int main(int argc, char *argv[]) {
	int n, m, k;
	cin >> n >> m >> k;
	vector<pair<int, int>> fs, bs;
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		fs.push_back(make_pair(a, b));
	}
	for (int i = 0; i < k; i++) {
		int a, b;
		cin >> a >> b;
		bs.push_back(make_pair(a, b));
	}

	unordered_map<int, int> um;
	for (int i = 1; i <= n; i++) {
		um[i] = -1;
	}
	for (auto p : fs) {
		myunion(p.first, p.second, um);
	}

	vector<int> res (n + 1, 0);
	for (int i = 1; i <= n; i++) {
		int fi = find(i, um);
		res[i] = -um[fi];
	}
	for (auto p : fs) {
		int a = p.first, b = p.second;
		if (find(a, um) == find(b, um)) {
			res[a]--;
			res[b]--;
		}
	}
	for (auto p : bs) {
		int a = p.first, b = p.second;
		if (find(a, um) == find(b, um)) {
			res[a]--;
			res[b]--;
		}
	}
	for (int i = 1; i <= n; i++) {
		cout << res[i] - 1 << " ";
	}
	cout << endl;
}









Measured memory_bytes: 8692
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0;i<n;i++)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (b>a) { 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; }
const long long INF = 2LL << 60;
using ll = long long;
using P = pair<ll, ll>;

int main(int argc, char const *argv[]){
    int n;
    string s, t;
    cin >> n >> s >> t;
    rep(i,n){
        cout << s[i] << t[i];
    }
    cout << endl;

    return 0;
}


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

int main(){
    int N,K;
    std::cin >> N >> K;
    std::vector<int> a(N);
    for (int i=0;i<N;i++){
        std::cin >> a.at(i);
    }

    for (int i=K+1;i<=N;i++){
        if(a.at(i-1) > a.at(i-K-1)){
            std::cout << "Yes" << std::endl;
        }
        else{
            std::cout << "No" << std::endl;
        }

    }
    return 0;
    
}


Measured memory_bytes: 3984
#include <set>
#include <cstring>
#include <iostream>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

template<class T> T getAs(){ T v; std::cin >> v; return v; }
inline int getInt(){ return getAs<int>(); }

using namespace std;

const int MAX = 21 - 6 + 1;
long long memo[1 << MAX];
int l[100];
int mask[100];

int main(){
  while(int n = getInt()){
    long long ans = 0;

    memset(memo, 0, sizeof(memo));

    REP(i,n){
      int m = getInt();
      l[i] = getInt();
      mask[i] = 0;

      REP(k,m){
        int s = getInt();
        int e = getInt();

        for(int j = s; j < e; j++){
          mask[i] |= (1 << (j - 6));
        }
      }
    }

    REP(i, (1 << MAX)){
      ans = max(ans, memo[i]);
      REP(j, n) if((i & mask[j]) == 0){
        memo[ i | mask[j] ] = max( memo[ i | mask[j] ], memo[i] + l[j] );
      }
    }

    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 0
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			final int a = sc.nextInt();
			final int b = sc.nextInt();
			final int c = sc.nextInt();
			final int d = sc.nextInt();
			final int e = sc.nextInt();
			
			if(a == 0 && b == 0 && c == 0 && d == 0 && e == 0){
				break;
			}
			
			final int na = sc.nextInt();
			final int nb = sc.nextInt();
			final int nc = sc.nextInt();
			
			final int sum = na + nb + nc;
			
			final int full = na * a + nb * b + nc * c;
			//System.out.println(full);
			int min = full;
			
			for(int inc = 1; inc <= sum; inc++){
				int rest = inc;
				
				int cur = full;
				
				
				
				// c
				final int c_c = Math.min(nc, rest);
				cur -= c_c * c;
					
				if(inc < d){
					cur += d * e;
				}else{
					cur += c_c * e;
				}
				rest = Math.max(0, rest - c_c);
				
				// b
				final int b_c = Math.min(nb, rest);
				cur -= b_c * b;
				if(inc >= d){
					cur += b_c * e;
				}
				
				rest = Math.max(0, rest - b_c);
				
				// a
				final int a_c = Math.min(na, rest);
				cur -= a_c * a;
				if(inc >= d){
					cur += a_c * e;
				}
				
				rest = Math.max(0, rest - a_c);
				
				//System.out.println(inc + " " + cur);
				
				min = Math.min(min, cur);
			}
			
			System.out.println(min);
		}
	}

}

Measured memory_bytes: 20912
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
const int INF = 1 << 30;
const ll INFll = 1ll << 60;

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  for (int i = 0; i < n; i++) cin >> s[i];

  int m;
  cin >> m;
  vector<string> t(m);
  for (int i = 0; i < m; i++) cin >> t[i];

  auto calc = [&](string str) {
    int buf = 0;
    for (string S : s) {
      if (S == str) buf++;
    }
    for (string S : t) {
      if (S == str) buf--;
    }
    return buf;
  };

  int ans = 0;
  for (string S : s) {
    ans = max(ans, calc(S));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int A=0, B=0;
  int n,a[101]={0},i,j,max;

  scanf("%d", &n);

  for(i=0;i<n;i++)
  scanf("%d", &a[i]);

  max=0;

  while(1){
    for(i=0;i<n;i++){
      if(max<a[i]){
      max=a[i];
      j=i;
    }
    }
      if(max==0){
      break;
    }
    A=A+max;
    max=0;
    a[j]=0;

    for(i=0;i<n;i++){
      if(max<a[i]){
      max=a[i];
      j=i;
    }
    }
      if(max==0){
      break;
    }
    B=B+max;
    max=0;
    a[j]=0;
  }

  printf("%d", A-B);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int hAB[5000], hCD[5000], A, B, C, D, E, F;

void prepare() {
    for(int i = 0; i * A * 100 <= F; i++)
        for(int j = 0; i * A * 100 + j * B * 100 <= F; j++)
            hAB[i * A * 100 + j * B * 100] = 1;
    for(int i = 0; i * C <= F; i++)
        for(int j = 0; i * C + j * D <= F; j++)
            hCD[i * C + j * D] = 1;
}

int main() {
    cin >> A >> B >> C >> D >> E >> F;
    prepare();
    int g = 100 * A, s = 0;
    for(int i = 0; i <= F; i++)
        for(int j = 0; j + i <= F; j++) {
            if (!hAB[i] || !hCD[j]) continue;
            if (j * 100 > i * E) continue;
            if (j * g > s * (i + j)) s = j, g = i + j;
        }
    cout << g << " " << s << endl;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	MyScanner sc = new MyScanner();
	Scanner sc2 = new Scanner(System.in);
	int mod = 1000000007;
	int[] dx = { 1, 0, 0, -1 };
	int[] dy = { 0, 1, -1, 0 };

	void run() {
		int D = sc.nextInt();
		boolean first = true;
		while (D-- > 0) {
			if (!first) {
				System.out.println();
			}
			first = false;
			int n = sc.nextInt();
			char[][] field = new char[n][n];
			for (int i = 0; i < n; i++) {
				Arrays.fill(field[i], ' ');
			}
			for (int i = 0; i < n; i++) {
				field[i][0] = '#';
				field[0][i] = '#';
			}
			if (n < 3) {
				debug2(field);
			} else if (n == 3) {
				for (int i = 0; i < n; i++) {
					field[i][n - 1] = '#';
				}
				debug2(field);
			} else {
				for (int i = 0; i < n; i++) {
					field[i][n - 1] = '#';
				}
				int nowX = n - 1;
				int nowY = n - 1;
				boolean go = true;
				while (go) {
					go = false;
					while (nowX - 2 >= 0 && field[nowY - 1][nowX - 1] != '#'
							&& field[nowY][nowX - 2] != '#'
							&& field[nowY][nowX - 1] != '#') {
						field[nowY][--nowX] = '#';
						go = true;
					}
					while (nowY - 2 >= 0 && field[nowY - 1][nowX + 1] != '#'
							&& field[nowY - 2][nowX] != '#'
							&& field[nowY - 1][nowX] != '#') {
						field[--nowY][nowX] = '#';
						go = true;
					}
					while (nowX + 2 < n && field[nowY + 1][nowX + 1] != '#'
							&& field[nowY][nowX + 2] != '#'
							&& field[nowY][nowX + 1] != '#') {
						field[nowY][++nowX] = '#';
						go = true;
					}
					while (nowY + 2 < n && field[nowY + 1][nowX - 1] != '#'
							&& field[nowY + 2][nowX] != '#'
							&& field[nowY + 1][nowX] != '#') {
						field[++nowY][nowX] = '#';
						go = true;
					}
				}
				debug2(field);
			}
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	void debug2(char[][] array) {
		for (int i = 0; i < array.length; i++) {
			System.out.println(new String(array[i]));
		}
	}

	class MyScanner {
		int nextInt() {
			try {
				int c = System.in.read();
				while (c != '-' && (c < '0' || '9' < c))
					c = System.in.read();
				if (c == '-')
					return -nextInt();
				int res = 0;
				do {
					res *= 10;
					res += c - '0';
					c = System.in.read();
				} while ('0' <= c && c <= '9');
				return res;
			} catch (Exception e) {
				return -1;
			}
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String next() {
			try {
				StringBuilder res = new StringBuilder("");
				int c = System.in.read();
				while (Character.isWhitespace(c))
					c = System.in.read();
				do {
					res.append((char) c);
				} while (!Character.isWhitespace(c = System.in.read()));
				return res.toString();
			} catch (Exception e) {
				return null;
			}
		}
	}
}

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

if 7%K == 0:
    print(1)
    exit()
if K%2 == 0 or K%5 == 0:
    print(-1)
    exit()
if K == 3:
    print(3)
    exit()

repunit = 7
for i in range(2, 10**9-1):
    repunit = (repunit*10 + 7)%K
    if repunit == 0:
        print(i)
        exit()
print(-1)


Measured memory_bytes: 62992
#include <iostream>
#include <cstdio>
#include <map>
using namespace std;
typedef long long ll;

ll n, k, t, ans, a[200005];
map<ll, ll> mp;
int main() {
	cin >> n >> k;
	mp[0] = 1;
	for(ll i=1; i<=n; i++) {
		if(i>=k) mp[a[i-k]]--;
		scanf("%lld", &t);
		a[i] = (a[i-1] + t-1) % k;
		ans += mp[a[i]];
		mp[a[i]]++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 14336
using System;

namespace AtCoder.ABC094
{
    public class A
    {
        public static void Solve()
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
            int c = int.Parse(input[2]);

            if (c >= a && c <= a + b)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }    
    }
}

namespace AtCoder {
    class Program
    {
        static void Main(string[] args)
        {
            ABC094.A.Solve();
        }
    }
}


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

int main() {
    int N, M; cin >> N >> M;
    int students[N][2];
    int distance[N];
    int ans[N];
    int checkpoints[M][2];
    for (int i = 0; i < N; i++) {
        cin >> students[i][0];
        cin >> students[i][1];
        distance[i] = 400000000;
    }
    for (int i = 0; i < M; i++) {
        cin >> checkpoints[i][0];
        cin >> checkpoints[i][1];
    }
    for (int i = 0; i < N; i++) {
        int a = students[i][0];
        int b = students[i][1];
        for (int j = 0; j < M; j++) {
            int c = checkpoints[j][0];
            int d = checkpoints[j][1];
            int distance_temp = abs(a - c) + abs(b - d);
            if (distance[i] > distance_temp) {
                distance[i] = distance_temp;
                ans[i] = j + 1;
            }
        }
    }
    for (int i = 0; i < N; i++) {
        cout << ans[i] << endl;
    }
}



Measured memory_bytes: 3544
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007 
#define all(n)      (n).begin(), (n).end()
#define ll long long 
#define PI 3.14159265358979323846



int main (){
	#ifndef ONLINE_JUDGE
		freopen ("input.txt","r",stdin);
		freopen ("output.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	//Write from here.
	int r; cin >> r; 
	
	
	cout << setprecision(21) << (2 * PI * r) << endl;
	
	
		
	
	return 0;
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
#define all(x) (x).begin(),(x).end()
#define dlog(x) cerr<<#x<<'='<<x<<endl
#define f first
#define s second
#define endl '\n'
#define sq(x) (x)*(x)*1ll
//typedef tree<int,null_type,less_equal<int>,rb_tree_tag,
//      tree_order_statistics_node_update> indexed_multiset;
//typedef tree<int,null_type,less<int>,rb_tree_tag,
//      tree_order_statistics_node_update> indexed_set;
typedef long long ll;
typedef pair<int,int> pii;


int main () {
        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//        freopen("test_input.txt", "r", stdin);
        string str; cin >> str;
        int q; cin >> q;
        vector<char> f,b;
        int rev = 0;
        while (q--) {
                int a; cin >> a;
                if (a == 1) {
                        rev ^= 1;
                } else {
                        int x; cin >> x;
                        char c; cin >> c;
                        if (rev) x = 3 - x;
                        if (x == 1) f.emplace_back(c);
                        else b.emplace_back(c);
                }
        }

        reverse(all(f));
        string ans;
        for (const auto w: f) ans += w;
        ans += str;
        for (const auto w: b) ans += w;
        if (rev)
                reverse(all(ans));

        cout << ans;
        return 0;
}

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

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a.begin(), a.end() );
    double ans=1.0*(a[0]+a[1])/2.0;
    for(int i=2;i<n;i++){
        ans = (ans+1.0*a[i])/2.0;
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 256
(defun Sum-of-gcd-of-Tuples (n)
    (let ((ans 0))
        (progn  
            (loop
                :for i :from 1 :to n
                :do (loop
                        :for j :from 1 :to n
                        :do (loop
                                :for k :from 1 :to n
                                :do (incf ans (gcd (gcd i j) (gcd i k))))))
            ans)))

(princ (Sum-of-gcd-of-Tuples (read)))

Measured memory_bytes: 24384
import math

n = int(input())
s = list(input())
mod = 10**9+7

cnt_w = 0
cnt_ans = 1

for i in range(0,n*2):
    if i%2 == 0:
        if s[i] == "B":
            s[i] = "W"
        else:
            s[i] = "B"
    if s[i] == "W":
        cnt_w += 1
        continue
    if s[i] == "B":
        cnt_ans *= cnt_w
        cnt_w -= 1
        cnt_ans %= mod

if s.count("B") != s.count("W"):
    print(0)
    exit()
    
print((cnt_ans*math.factorial(n))%mod)


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

typedef long long LL;
const int INF = int(1e9);
const int MAX = 1000020;
LL N;
LL a[MAX],b[MAX],c[MAX];
 
void Cin(LL a[]){
    for(int i = 1;i<=N;i++)
        scanf("%lld",&a[i]);
}
 
int main(){
    cin>>N;
    Cin(a),Cin(b),Cin(c);
    sort(a+1,a+1+N),sort(b+1,b+1+N),sort(c+1,c+1+N);
    LL sum = 0;
    LL ai = 0,ci = 0;
    for(int i = 1;i<=N;i++){
        while(a[ai+1]<b[i]&&ai+1<=N)
            ai++;
        while(c[ci+1]<=b[i]&&ci+1<=N)
            ci++;
        sum += ai*(N-ci);
    }
    cout<<sum<<endl;
    return 0;
}

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

#define FO(i,a,b) for (int i = (a); i < (b); i++)
#define sz(v) int(v.size())

using namespace std;

int a[100005];
int n;

int main() {
    scanf("%d", &n);
    FO(i,1,n+1) scanf("%d", &a[i]);
    int r = 0;
    FO(i,1,n+1) r += a[a[i]] == i;
    printf("%d\n", r/2);
}


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

int main(){
    int a,b;
    cin>>a>>b;
    if(a == 1){
        if(b ==2) cout<<3<<endl;
        else cout<<2<<endl;
    }
    else if (a==2){
        if(b == 3) cout<<1<<endl;
        else cout<<3<<endl;
    }
    else{
        if(b == 2) cout<<1<<endl;
        else cout<<2<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INF = 10000000;

int dx[2][6] = {
  {0,1,1,0,-1,-1},
  {0,1,1,0,-1,-1}
};
int dy[2][6] = {
  {1,0,-1,-1,-1,0},
  {1,1,0,-1,0,1}
};

struct Edge{
  int to, cost;

  Edge(int t, int c): to(t), cost(c)
  {}
  bool operator>(const Edge& rhs) const{
	return cost > rhs.cost;
  }
};
typedef vector< vector<Edge> > Graph;


int idx(int y, int x, int t){
  return ((y+100)*210 + (x+100))*6 + t;
}

void Dijkstra(const Graph& edges, vector<int>& d, int s){
  priority_queue<PII, vector<PII>, greater<PII> > pq;
  fill(d.begin(), d.end(), INF);
  d[s] = 0;
  pq.push(MP(0,s));

  while(!pq.empty()){
	PII pii = pq.top(); pq.pop();
	int v = pii.second;
	if(d[v] < pii.first) continue;
	for(int i=0;i<edges[v].size();++i){
	  const Edge& e = edges[v][i];
	  if(d[e.to] > d[v] + e.cost){
		d[e.to] = d[v] + e.cost;
		pq.push(MP(d[e.to], e.to));
	  }
	}
  }
}


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

  int sx, sy, gx, gy, n, lx, ly;
  cin >> sx >> sy >> gx >> gy >> n;

  bool ok[201][201];
  fill((bool*)ok, (bool*)ok+201*201, true);
  REP(i,n){
	int x, y; cin >> x >> y;
	ok[y+100][x+100] = false;
  }
  cin >> lx >> ly;

  Graph G(210*210*10);
  for(int y=-ly;y<=ly;++y)
	for(int x=-lx;x<=lx;++x)
	  for(int t=0;t<6;++t){
		int dir = abs(x*y*t)%6;
		REP(i,6){
		  int tx = x + dx[abs(x)%2][i];
		  int ty = y + dy[abs(x)%2][i];
		  if(abs(tx) > lx || abs(ty) > ly || !ok[ty+100][tx+100]) continue;
		  G[idx(y,x,t)].PB(Edge(idx(ty,tx,(t+1)%6), i!=dir));
		}
		G[idx(y,x,t)].PB(Edge(idx(y,x,(t+1)%6), 1));		
	  }
  VI dist(210*210*10);
  Dijkstra(G, dist, idx(sy,sx,0));
  int ans = INF;
  REP(i,6)
	ans = min(ans, dist[idx(gy,gx,i)]);

  cout << (ans>=INF? -1: ans) << endl;
  
  return 0;
}

Measured memory_bytes: 32140
import java.io.*
import java.util.*

var pw = PrintWriter(System.out)
fun solve(r: Long){
    println(3L*r*r)
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val r = sc.next().toLong()
    solve(r)
}



Measured memory_bytes: 31392
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;

#define REP(i,n) for(int i=0;(i)<(n);(i)++)

int main() {
	int x, y;
	cin >> x >> y;
	
	int gx, gy;

	if (x == 2) gx = 3;
	else if (x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12) gx = 2;
	else gx = 1;

	if (y == 2) gy = 3;
	else if (y == 4 || y == 6 || y == 9 || y == 11) gy = 1;
	else gy = 2;

	if (gx == gy) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

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

namespace ABC113_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var NM = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var N = NM[0];
            var M = NM[1];

            var P = new long[M];
            var Y = new long[M];
            var data = new List<Data>();
            
            for (int i = 0; i < M; i++)
            {
                var PY = Console.ReadLine().Split().Select(long.Parse).ToArray();
                var d = new Data()
                {
                    Id = i,
                    P = PY[0],
                    Y = PY[1]
                };

                data.Add(d);
            }

            data = (from d in data
                    orderby d.P, d.Y
                    select d).ToList();

            long tmpP = 0;
            var tmpcnt = 1;
            for (int i = 0; i < M; i++)
            {
                if (tmpP == data[i].P)
                {
                    tmpcnt++;
                }
                else
                {
                    tmpP = data[i].P;
                    tmpcnt = 1;
                }
                data[i].newY = tmpcnt;
            }

            data = data.OrderBy(x => x.Id).ToList();

            for (int i = 0; i < M; i++)
            {
                Console.WriteLine(data[i].P.ToString("000000") + data[i].newY.ToString("000000"));
            }
        }

        public class Data
        {
            public int Id { get; set; }
            public long P { get; set; }
            public long Y { get; set; }
            public int newY { get; set; }
        }
    }
}


Measured memory_bytes: 35764
// #pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define N 1000000007
#define N2 998244353
#define Nmax 1000005
#define INF (ll)1e18
#define pll pair<ll,ll>
#define mp make_pair
#define fi first
#define se second
#define vv vector
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(ll i=m;i<(n);i++)
#define repr(i,n) repr2(i,n,0)
#define repr2(i,m,n) for(ll i=m;i>=(n);i--)
#define get(n) ll (n); scanf("%lld",&(n));
#define get2(n,k) ll (n),(k); scanf("%lld%lld",&(n),&(k));
#define get3(n,m,k) ll (n),(m),(k); scanf("%lld%lld%lld",&(n),&(m),&(k));
#define gets(s) string (s); cin >> (s);
#define ALL(c) (c).begin(),(c).end()
#define fill_nums(A,n) vector<ll> A((n)); for(ll i=0;i<n;i++) scanf("%lld",&A[i]);
#define fill_edges(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1); adj[b-1].pb(a-1);}
#define fill_direct(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1);}
#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); //cout.tie(0);
#define pi 3.1415926535897
#define db double
#define noop
#define flu fflush(stdout)
#define imp {cout<<"NO\n"; return 0;}
#define debug_vec(vec,n) {rep(idxi,n) cout<<vec[idxi]<<" "; cout<<"\n";}
#define debug_pvec(vec,n) {rep(idxi,n) cout<<vec[idxi].fi<<"-"<<vec[idxi].se<<"  "; cout<<"\n";}
#define debug_set(seta) {cout<<seta.size()<<"\n"; for(auto idxi:seta) cout<<idxi<<" "; cout<<"\n";}
#define debug_map(mappa) {cout<<mappa.size()<<"\n";for(auto idxi:mappa) cout<<idxi.fi<<"-"<<idxi.se<<"  "; cout<<"\n";}

int main() {

    get2(n,m);
    string a(m,n+'0'), b(n,m+'0');
    if(a<b) cout<<a<<endl;
    else cout<<b<<endl;

    return 0;  
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define li long long int
void city(long long int* C,long long int* A,long long int* B,int i,int j){
  if(A[i]>=B[j]){
    C[i]+=B[j];
    A[i]-=B[j];
       B[j]=0;
  }else{
    C[i]+=A[i];
    B[j]-=A[i];
    A[i]=0;

  }


}

int main (){
  int N;
  cin >>N;
  long long int A[N+1],B[N],C[N+1]={0};
  for(int i=0;i<N+1;i++)
    cin >>A[i];
  rep(i,N)
    cin >>B[i];
  for(int i=N;i>0;i--){
    city(C,A,B,i,i-1);
    city(C,A,B,i-1,i-1);
  }
  long long int count=0;
  for(int i=0;i<N+1;i++){
    count+=C[i];
  
  }

  cout << count;






  return 0;
}


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

bool hantei(string s) {
	string t = s;
	reverse(t.begin(), t.end());
	return t == s;
}

int main() {
	string s;
	cin >> s;
	if (!hantei(s)) {
		puts("No");
		return 0;
	}
	string t = s.substr(0, (s.size() - 1) / 2);

	if (!hantei(t)) {
		puts("No");
		return 0;
	}
	puts("Yes");
	return 0;
}

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

int main() {
  int X,a,b; cin >> X;bool fin = false;
  for(int i=0;i<120;i++){
    a=i;
    for(int j=-120; j<120;j++){
      b=j;
      if(a*a*a*a*a - b*b*b*b*b ==X){
        cout << a <<" "<< b <<endl;
        fin= true;
      }
      if(fin)break;
    }
    if(fin)break;
  }
}
        


Measured memory_bytes: 3584
/*input
3 10
*/
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#include <bits/stdc++.h>
typedef long double ld;
typedef long long ll;
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	ll N, K;
	cin >> N >> K;
	ld ret = 0;
	for (ll k = 1; k <= N; k++)
	{
		ll x = k;
		ld p = 1.0 / N;
		while (x < K)
		{
			p /= 2;
			x *= 2;
		}
		ret += p;
	}
	cout << fixed << setprecision(20) << ret << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef pair<int,ii> iii;
typedef pair<int, iii> iiii;
typedef pair<double, ii> dii;
typedef long long ll;
typedef pair<ll, ii> lii;
const int INF = 1000000000;
const double EPS = 1e-9;
#define LSOne(S) (S & (-S))
int mods(int a, int b) { return (b + (a%b)) % b; }


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int L, R, n, ans = INF;
    bitset<2025> visited;

    cin >> L >> R;

    int mx = -INF;
    for (int i = L; i <= R; i++) {
        n = i % 2019;
        if (visited[n]) break;
        else visited[n] = 1;
        mx = max(mx, n);
    }


    for (int i = 0; i <= mx; i++) {
        if (!visited[i]) continue;
        for (int j = i+1; j <= mx; j++) {
            if (!visited[j]) continue;
            ans = min(ans, (i*j) % 2019);
        }
    }
    
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int q = in.nextInt();

		// 子をキーにして親を記録 → 木なので根以外は必ず単一の親を持つ
		HashMap<Integer, Integer> map = new HashMap<>();
		for ( int i = 1; i < n; i++ ) {
			int a = in.nextInt();
			int b = in.nextInt();
			map.put(b, a);
		}

		long[] cnt = new long[n + 1];
		for ( int i = 1; i <= q; i++ ) {
			int p = in.nextInt();
			int x = in.nextInt();
			cnt[p] += x;
		}

		for ( int i = 2; i <= n; i++ ) {
			// 子に親から降りてきたカウントを加算	
			cnt[i] += cnt[map.get(i)];
		}
		for ( int i = 1; i <= n; i++ ) {
			// 表示			
			System.out.println( cnt[i] );
		}
		in.close();
	}
}


Measured memory_bytes: 187800
/**
 * Copyright (c) 2017, xehoth
 * All rights reserved.
 * 「ARC 058D」いろはちゃんとマス目 / Iroha and a Grid 05-08-2017
 * 组合数学
 * @author xehoth
 */
#include <bits/stdc++.h>

#define long long long

const int MOD = 1e9 + 7;
const int MAXN = 200000;

inline int modPow(int a, int b, int c) {
    register int ret = 1;
    for (; b; b >>= 1, a = (long)a * a % c)
        (b & 1) ? ret = (long)ret * a % c : 0;
    return ret;
}

int fac[MAXN + 1] = {1}, inv[MAXN + 1];

inline void init(const int n) {
    for (register int i = 1; i <= n; i++) fac[i] = (long)fac[i - 1] * i % MOD;
    inv[n] = modPow(fac[n], MOD - 2, MOD);
    for (register int i = n - 1; i >= 0; i--)
        inv[i] = (long)inv[i + 1] * (i + 1) % MOD;
}

inline int nCr(int n, int r) {
    return (long)fac[n] * inv[r] % MOD * inv[n - r] % MOD;
}

int main() {
    std::ios::sync_with_stdio(false), std::cin.tie(NULL), std::cout.tie(NULL);
    init(MAXN);
    register int H, W, A, B;
    std::cin >> H >> W >> A >> B;
    register int ans = 0, tmp;
    for (register int i = B + 1, h, w; i <= W; i++) {
        h = H - A - 1, w = i - 1, tmp = nCr(h + w, h);
        h = A - 1, w = W - i, ans = (ans + (long)nCr(h + w, w) * tmp) % MOD;
    }
    std::cout << ans;
    return 0;
}

#undef long

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
vector<int> i;
vector<int> u;
vector<int> o;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a=0,b,c,d=0,e=0,f=0,g;
  string s;
  cin >>a>>b>>c>>d;
  cout <<(a-c)*(b-d)<<'\n';
  return (0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
void pr(){ln;}
template<Z A,Z...B>void pr(const A &a,const B&...b){cout<<a<<' ';pr(b...);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;


ll n,m,k;
ll a[55],b[55],c[55],d[55],ans;

void dfs(vector<int> v) {
  if(v.size()==n) {
    ll sum=0;
    rep(i,k) {
      if(v[b[i]-1]-v[a[i]-1]==c[i]) sum+=d[i];
    }
    ans=max(ans,sum);
    return;
  }
  int M=1;
  if(v.size()) M=v.back();
  REP(i,M,m+1) {
    vector<int> g=v;
    g.pb(i);
    dfs(g);
  }
}

void Main() {
  cin >> n >> m >> k;
  rep(i,k) cin >> a[i] >> b[i] >> c[i] >> d[i];
  dfs(vector<int>());
  pr(ans);
}

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


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int N=305,inf=1e9+10;
int a[N][N],d[N][N];
bool mark[N];
int n;
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  cin>>n;
  rep(i,1,n+1)
    rep(j,1,n+1) cin>>a[i][j],d[i][j]=a[i][j];
  rep(k,1,n+1)
    rep(i,1,n+1) rep(j,1,n+1) d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
  bool ok=true;
  rep(i,1,n+1) rep(j,1,n+1) ok&=(a[i][j]==d[i][j]);
  if(!ok)
    {
      cout<<-1<<endl;
      return 0;
    }
  ll ans=0;
  rep(i,1,n+1)
    rep(j,i+1,n+1)
    {
      bool ok=true;
      rep(k,1,n+1)
	if(a[i][k]+a[k][j]==a[i][j] && k!=i && k!=j)
	  ok=false;
      if(ok) ans+=a[i][j];
    }
  cout<<ans<<endl;
  return 0 ;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll n,k;
  cin >> n >> k;
  ll ans=0;
  for(ll i=k;i<=n+1;i++) {
    ll tmp1=(2*n-i+1)*i/2;
    ll tmp2=i*(i-1)/2;
    (ans+=(tmp1-tmp2+1)%mod)%=mod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3620
class MatrixLikeComputation
  def execute
    n=gets.to_i
    str=calculate_matrix_total(n)
    puts str
  end

  def calculate_matrix_total(n)
    return "" if n==0
    ans_matrix=""
    rows = n.times.map{gets.chomp.split.map(&:to_i)}
    rows.each do |row|    # 行ごとに数字の配列を格納
      ans_matrix += (row << row.sum.to_s).map{|i| "%5d" % i}.join + "\n"
    end
    column_sums = n.times.map{|i| rows.inject(0){|column_sum,row| column_sum+row[i]}}   # 列ごとの合計を格納する用の配列
    ans_matrix += (column_sums << column_sums.sum.to_s).map{|i| "%5d" % i}.join + "\n" + calculate_matrix_total(gets.to_i)
  end
end

mlc = MatrixLikeComputation.new
mlc.execute


Measured memory_bytes: 7072