akhauriyash/Code-Regression huggingface dataset:
#include<cmath>
#include<cstdio>
#include<vector>
#include<complex>
#include<algorithm>

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

using namespace std;

typedef	complex<double>	Point;

enum {CCW=1,CW=-1,ON=0};
const double EPS=1e-9;

class Line:public vector<Point>{
public:
	Line(){}
	Line(const Point &a,const Point &b){
		pb(a),pb(b);
	}
};

class Segment:public Line{
public:
	Segment(){}
	Segment(const Point &a,const Point &b):Line(a,b){}
};

typedef	vector<Point>	Polygon;

namespace std{
	bool operator <(const Point &a,const Point &b){
		return (real(a)==real(b))?(imag(a)<imag(b)):(real(a)<real(b));
	}
	bool operator >(const Point &a,const Point &b){
		return b<a;
	}
}

double dot(const Point &a,const Point &b){
	return real(a)*real(b)+imag(a)*imag(b);
}

double cross(const Point &a,const Point &b){
	return real(a)*imag(b)-imag(a)*real(b);
}

int ccw(const Point &a,Point b,Point c){
	b-=a,c-=a;
	double rotdir=cross(b,c);
	if(rotdir>EPS)		return CCW;
	if(rotdir<-EPS)		return CW;
	return ON;
}

bool intersect(const Segment &s,const Segment &t){
	if(max(real(s[0]),real(s[1]))<min(real(t[0]),real(t[1]))
	|| max(real(t[0]),real(t[1]))<min(real(s[0]),real(s[1]))
	|| max(imag(s[0]),imag(s[1]))<min(imag(t[0]),imag(t[1]))
	|| max(imag(t[0]),imag(t[1]))<min(imag(s[0]),imag(s[1])))	return false;

	if(ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1])<=0
	&& ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1])<=0)	return true;
	return false;
}

bool contain(const Polygon &g,const Point &p){
	int n=g.size();
	int dir=ccw(g[n-1],g[0],p);
	if(dir==ON)	return dot(g[0]-p,g[n-1]-p)<EPS;
	rep(i,n-1){
		int a=ccw(g[i],g[i+1],p);
		if(a==ON)	return dot(g[i+1]-p,g[i]-p)<EPS;
		if(a!=dir)	return false;
	}
	return true;
}

bool contain(const Polygon &g1,const Polygon &g2){
	rep(i,g2.size()) if(contain(g1,g2[i])) return true;
	return false;
}

bool intersect(const Polygon &g1,const Polygon &g2){
	int n1=g1.size(),n2=g2.size();
	rep(i,n1)rep(j,n2){
		if(intersect(Segment(g1[i],g1[(i+1)%n1]),Segment(g2[j],g2[(j+1)%n2])))	return true;
	}
	return contain(g1,g2) || contain(g2,g1);
}

typedef	vector<int>	vi;

class UnionFind{
	vi a;
	int root(int x){ return ~a[x]?a[x]=root(a[x]):x; }
public:
	UnionFind(int n):a(n,-1){}
	bool find(int x,int y){ return root(x)==root(y); }
	bool unite(int x,int y){ return find(x,y)?0:(a[root(y)]=root(x),1); }
};

int main(){
	for(int n;scanf("%d",&n),n;){
		rep(k,n){
			int m;	scanf("%d",&m);
			Polygon g[100];
			rep(i,m){
				rep(j,4){
					int x,y;	scanf("%d%d",&x,&y);
					g[i].pb(Point(x,y));
				}
				reverse(g[i].begin(),g[i].end());
			}

			int cnt=m;
			UnionFind uf(m);
			rep(i,m)rep(j,i) if(intersect(g[i],g[j])) cnt-=uf.unite(i,j);
			printf("%d\n",cnt);
		}
	}

	return 0;
}

Measured memory_bytes: 824
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int h,i=0,r=2,j=0;
	cin>>h;
	while(h>1)
	{
		j++;
		h=h/2;
	}
	while(j--)
	{
		r=r*2;
	}
	cout<<r-1<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"

using namespace std;
const int MAXN = 1e5 + 5;

long long DP[MAXN];

int main(int argc, char* argv[]){
	int N, W, w, v;
	long long answer = 0;
	scanf("%d%d", &N, &W);
	
	for (int i=0; i < N; i++) {
		scanf("%d%d", &w, &v);

		for (int j = W; 0 <= j; j--)
			if ((DP[j] or j == 0) and j + w <= W) {
				DP[j + w] = max(DP[j + w], DP[j] + v);	
				answer = max(answer, DP[j + w]);
			}
	}

	printf("%lld\n", answer);
	return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <map>
const int MAXN = 1e5+5;
std::map<int,int> cnt;
int H[MAXN];
int N;

bool solve() {
  for (int i = 1; i < N; ++i) {
    if (!--cnt[H[i]]) {
      cnt.erase(H[i]);
    }
    int val = cnt.begin()->first;
    if (H[i]-1 > val) {
      return false;
    }
  }
  return true;
}

int main() {
  scanf("%d", &N);
  cnt.clear();
  for (int i = 1; i <= N; ++i) {
    scanf("%d", &H[i]);
    ++cnt[H[i]];
  }
  puts(solve() ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 5376
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	list := getStdinIntArr()
	A := list[0]
	B := list[1]
	C := list[2]
	K := list[3]

	A_N := A - K
	if A_N < 0 {
		K = K - A
		A_N = A
	} else {
		K = 0
		A_N = A - A_N
	}

	B_N := B - K
	if B_N < 0 {
		K = K - B
		B_N = B
	} else {
		K = 0
		B_N = B - B_N
	}

	C_N := C - K
	if C_N < 0 {
		K = K - C
		C_N = C
	} else {
		K = 0
		C_N = C - C_N
	}

	fmt.Printf("%d\n", A_N+(-1)*C_N)
	//fmt.Println(A_N)
	//fmt.Println(B_N)
	//fmt.Println(C_N)
}

func getStdin() string {
	sc.Scan()
	return sc.Text()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}


Measured memory_bytes: 1724
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int sx=stdIn.nextInt();
		int sy=stdIn.nextInt();
		int tx=stdIn.nextInt();
		int ty=stdIn.nextInt();
		int z=0;
		System.out.print("D");
		while((tx-sx)+1>z){
			System.out.print("R");
			z++;
		}z=0;
		while((ty-sy)+1>z){
			System.out.print("U");
			z++;
		}z=0;
		while((tx-sx)+1>z){
			System.out.print("L");
			z++;
		}z=0;
		while(ty-sy>z){
			System.out.print("D");
			z++;
		}z=0;
		System.out.print("L");
		while((ty-sy)+1>z){
			System.out.print("U");
			z++;
		}z=0;
		while((tx-sx)+1>z){
			System.out.print("R");
			z++;
		}z=0;
		while((ty-sy)+1>z){
			System.out.print("D");
			z++;
		}z=0;
		while(tx-sx>z){
			System.out.print("L");
			z++;
		}
	}
}

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

using namespace std;

void Solve(){
    string s;
    cin>>s;
    if(s[2] == s[3] && s[4] == s[5]) cout<<"Yes\n";
    else cout<<"No\n";

}
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int q = 1;
    //cin>>q;
    while(q--){
        Solve();
    }
}

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

namespace abc113
{
    class Program
    {
        static void Main(string[] args)
        {
            var buf = Console.ReadLine().Split().ToList().ConvertAll(int.Parse);
            var A = buf[0]; var B = buf[1];
            var fare = A + B / 2;
            Console.WriteLine(fare);
        }
    }
}


Measured memory_bytes: 11220
#![allow(unused)]

use cmp::Ordering::{Equal, Greater, Less};
use collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque};
use io::{Read, Write};
use std::{cmp, collections, fmt, io, iter, ops, str};

#[cfg(feature = "debug")]
macro_rules! debug {
    ($fmt: expr) => { eprintln!($fmt) };
    ($fmt: expr, $($args: tt)*) => { eprintln!($fmt, $($args)*) };
}

#[cfg(not(feature = "debug"))]
macro_rules! debug {
    ($fmt:expr) => {};
    ($fmt:expr, $($args:tt)*) => {};
}

macro_rules! vmax {
    ($x: expr, $y: expr) => { cmp::max($x, $y) };
    ($x: expr, $($args: expr),*) => { cmp::max($x, vmax!($($args),*)) };
}

macro_rules! vmin {
    ($x: expr, $y: expr) => { cmp::min($x, $y) };
    ($x: expr, $($args: expr),*) => { cmp::min($x, vmin!($($args),*)) };
}

fn main() {
    let (a, b, c, d) = {
        let v = parse_vec::<i32>();
        (v[0], v[1], v[2], v[3])
    };

    if dist(a, c) <= d || (dist(a, b) <= d && dist(b, c) <= d) {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn dist(x: i32, y: i32) -> i32 {
    (x - y).abs()
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test() {
        //
    }
}

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().to_owned()
}

fn read_word() -> String {
    const CAPACITY: usize = 16;

    let mut stdin = io::stdin();
    let mut byte: [u8; 1] = [0];

    loop {
        let mut buf = Vec::with_capacity(CAPACITY);

        loop {
            let res = stdin.read(&mut byte);

            if res.unwrap_or(0) == 0 || byte[0] <= b' ' {
                break;
            } else {
                buf.push(byte[0]);
            }
        }

        if buf.len() > 0 {
            return String::from_utf8(buf).unwrap();
        }
    }
}

fn parse_line<T: str::FromStr>() -> T {
    read_line().parse().ok().unwrap()
}

fn parse_word<T: str::FromStr>() -> T {
    read_word().parse().ok().unwrap()
}

fn parse_vec<T: str::FromStr>() -> Vec<T> {
    read_line()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn flush() {
    io::stdout().flush();
}

fn next_prime(x: i32) -> i32 {
    for i in (x + 1).. {
        if is_prime(i) {
            return i;
        }
    }

    panic!("attempt to add with overflow");
}

fn is_prime(x: i32) -> bool {
    let ceil = (x as f64).sqrt().ceil() as i32;
    x == 2 || (2..(ceil + 1)).all(|i| x % i != 0)
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval>newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!
int getnum(string s){
  return 10*(s[0]-'0') + (s[1]-'0');
}

// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  string S; cin >> S;
  string s1 = S.substr(0,2);
  string s2 = S.substr(2,2);
  int n1 = getnum(s1); int n2 = getnum(s2);
  bool b1 = (1<=n1 &&n1<=12);
  bool b2 = (1<=n2 &&n2<=12);
  if(b1 && b2) cout << "AMBIGUOUS" << endl;
  else if (b1 && !b2) cout << "MMYY" << endl;
  else if ((!b1) && b2) cout << "YYMM" << endl;
  else cout << "NA" << endl;
  dump(S,n1,n2);
  return 0;
}


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

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

    int a[21][21] = {0};

    int state = pow(2, 21);
    vector<vector<int>> dp(21, vector<int>(state, 0));

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

    for (int i = 0; i < N; ++i)
    {
        if(a[0][i]) dp.at(0).at(1<<i) = 1;
    }

    for (int i = 1; i < N; ++i)
    {
        for (int j = 0; j < N; ++j)
        {
            if(a[i][j])
            {
                for (int k = 0; k < (1<<N); ++k)
                {
                    if((k >>j)%2 == 0)
                    {
                        dp[i][k+(1<<j)] = (dp[i][k+(1<<j)] + dp[i-1][k])%1000000007;
                        //dp.at(i).at(k+(1<<j)) += dp.at(i-1).at(k);
                        //dp.at(i).at(k+(1<<j)) %= 1000000007;
                    }
                }
            }
        }
    }

//    cout << (1<<N) << endl;
    cout << dp.at(N-1).at((1<<N)-1) << endl;

    return 0;
}



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

int main()
{
  long long N, M;
  
  cin >> N >> M;
  
  long long ans = 0;
  
  if (N > 1 && M > 1) {
    ans = (N - 2) * (M - 2);
  }
  else if (N > 1 && M == 1) {
    ans = N - 2;
  }
  else if (N == 1 && M > 1) {
    ans = M - 2;
  }
  else {
    ans = 1;
  }
  
  cout << ans << endl;
    
  return 0;
}


Measured memory_bytes: 256
package main

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

type bufReader struct {
	r   *bufio.Reader
	buf []byte
	i   int
}

var reader = &bufReader{
	bufio.NewReader(os.Stdin),
	make([]byte, 0),
	0,
}

func (r *bufReader) readLine() {
	if r.i < len(r.buf) {
		return
	}
	r.buf = make([]byte, 0)
	r.i = 0
	for {
		line, isPrefix, err := r.r.ReadLine()
		if err != nil {
			panic(err)
		}
		r.buf = append(r.buf, line...)
		if !isPrefix {
			break
		}
	}
}

func (r *bufReader) next() string {
	r.readLine()
	from := r.i
	for ; r.i < len(r.buf); r.i++ {
		if r.buf[r.i] == ' ' {
			break
		}
	}
	s := string(r.buf[from:r.i])
	r.i++
	return s
}

func (r *bufReader) nextLine() string {
	r.readLine()
	s := string(r.buf[r.i:])
	r.i = len(r.buf)
	return s
}

var writer = bufio.NewWriter(os.Stdout)

func next() string {
	return reader.next()
}

func nextInt64() int64 {
	i, err := strconv.ParseInt(reader.next(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func nextInt() int {
	return int(nextInt64())
}

func nextLine() string {
	return reader.nextLine()
}

func out(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

func max64(x, y int64) int64 {
	if x > y {
		return x
	}
	return y
}

func max(x, y int) int {
	return int(max64(int64(x), int64(y)))
}

func min64(x, y int64) int64 {
	if x < y {
		return x
	}
	return y
}

func min(x, y int) int {
	return int(min64(int64(x), int64(y)))
}

func abs64(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}

func abs(x int) int {
	return int(abs64(int64(x)))
}

func joinInt64s(a []int64, sep string) string {
	b := make([]string, len(a))
	for i, v := range a {
		b[i] = strconv.FormatInt(v, 10)
	}
	return strings.Join(b, sep)
}

func joinInts(a []int, sep string) string {
	b := make([]string, len(a))
	for i, v := range a {
		b[i] = strconv.Itoa(v)
	}
	return strings.Join(b, sep)
}

func divUp64(x, y int64) int64 {
	return (x + y - 1) / y
}

func divUp(x, y int) int {
	return int(divUp64(int64(x), int64(y)))
}

func gcd64(x, y int64) int64 {
	if x < y {
		x, y = y, x
	}
	for y != 0 {
		x, y = y, x%y
	}
	return x
}

func gcd(x, y int) int {
	return int(gcd64(int64(x), int64(y)))
}

func lcm64(x, y int64) int64 {
	return x * y / gcd64(x, y)
}

func lcm(x, y int) int {
	return int(lcm64(int64(x), int64(y)))
}

func pow64(x, y int64) int64 {
	return int64(math.Pow(float64(x), float64(y)))
}

func pow(x, y int) int {
	return int(pow64(int64(x), int64(y)))
}

func main() {
	solve()
	writer.Flush()
}

func solve() {
	o, e := next(), next()
	for i := 0; i < len(o); i++ {
		fmt.Print(string(o[i]))
		if i < len(e) {
			fmt.Print(string(e[i]))
		}
	}
}


Measured memory_bytes: 640
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math;

void main()
{
    auto s = readln.chomp.to!(dchar[]);
    sort(s);
    s = s.uniq.array;
    if (s[0] != 'a') {
        writeln("a");
        return;
    }
    foreach (i, c; s[0..$-1]) {
        if (s[i+1] - c != 1) {
            writeln((c + 1).to!char);
            return;
        }
    }
    if (s[$-1] != 'z') {
        writeln("z");
        return;
    }
    writeln("None");
}

Measured memory_bytes: 2712
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
typedef long long ll;

using namespace std;


int main() {
	ll n;
	string s;
	cin >> n >> s;
	char c2 = 'Z';
	rep(i, s.size()) {
		char c = s[i];
		c = c + n;

		while (c > c2) {
			c -= 26;
		}
		cout << c;
	}
	cout << endl;
}

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

int main()
{
  int a,b;
  cin >> a >> b;
  int ans = max(a,b);
  if(a == ans) a--;
  else b--;
  ans += max(a,b);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3604
using System;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        string O = sc.Next();
        string E = sc.Next();

        char[] ans = new char[O.Length + E.Length];
        for (int i = 0; i < O.Length; i++)
        {
            ans[i * 2] = O[i];
        }

        for (int i = 0; i < E.Length; i++)
        {
            ans[1 + i * 2] = E[i];
        }
        Console.WriteLine(new string(ans));
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define M 1500*1000

int h_pos[M+1];
int w_pos[M+1];

int main(){
	int n,m;
	while(cin >> n >> m , n | m ){
		vector<int> h(n) , w(m);
		memset(h_pos , 0 , sizeof(h_pos));
		memset(w_pos , 0 , sizeof(w_pos));
		for(int i=0;i<n;++i){
			cin >> h[i];
		}
		for(int i=0;i<m;++i){
			cin >> w[i];
		}
		
		
		for(int i=0;i<n;++i){
			int sum=0;
			for(int j=i;j<n;++j){
				sum+=h[j];
				h_pos[sum]++;
			}
		}
		for(int i=0;i<m;++i){
			int sum=0;
			for(int j=i;j<m;++j){
				sum+=w[j];
				w_pos[sum]++;
			}
		}
		int cnt=0;
		for(int i=0;i<=M;++i){
			cnt+=h_pos[i]*w_pos[i];
		}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 12932
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll MOD = 1000000007;
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  printf(a + b >= c ? "Yes\n" : "No\n");
}

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

const int N = 1e2 + 5, mod = 1e9 + 7;

int main()
{
    //ios::sync_with_stdio(false);cin.tie(nullptr);ios_base::sync_with_stdio(false);
    string s;
    cin >> s;
    int ans1 = 0, ans2 = 0;
    for (int i = 0; i < s.size(); i++)
    {
        ans1 += s[i] != '0' + i % 2;
        ans2 += s[i] == '0' + i % 2;
    }
    cout << min(ans1, ans2);
    return 0;
}

Measured memory_bytes: 3728
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  long long N;
  scanf("%lld", &N);
  long long K;
  scanf("%lld", &K);
  std::string S;
  std::cin >> S;
  vector<pair<char, int>> v;
  char c = S[0];
  int sum = 1;
  int l = 0, r = 0;
  for (int i = 1; i < N; ++i)
  {
    if (c == S[i])
    {
      sum++;
    }
    else
    {
      v.emplace_back(c, sum);
      if (c == 'L')
        l++;
      else
        r++;
      c = S[i], sum = 1;
    }
  }
  v.emplace_back(c, sum);
  if (c == 'L')
    l++;
  else
    r++;
  if (l <= r)
    c = 'L';
  else
    c = 'R';
  for (int i = 1; i < v.size() - 1; ++i)
  {
    if (K == 0)
      break;
    if (c == v[i].first)
    {
      K--;
      v[i].first = (c == 'L') ? 'R' : 'L';
    }
  }
  if (K > 0)
  {
    if (v[0].first == c)
    {
      K--;
      v[0].first = (c == 'L') ? 'R' : 'L';
    }
  }
  if (K > 0)
  {
    if (v[v.size() - 1].first == c)
    {
      K--;
      v[v.size() - 1].first = (c == 'L') ? 'R' : 'L';
    }
  }
  int ans = 0;
  for (int i = 0; i < v.size(); ++i)
  {
    ans += v[i].second;
    if (v[i].first == 'L' && (i == 0 || v[i].first != v[i - 1].first))
    {
      ans--;
    }
    if (v[i].first == 'R' && (i == v.size() - 1 || v[i].first != v[i + 1].first))
    {
      ans--;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1528
N,M,C=map(int,input().split())
B=list(map(int,input().split()))
A=[list(map(int,input().split())) for i in range(N)]

ok=0
for i in range(N):
    ev=0
    for j in range(M):
        ev+=A[i][j]*B[j]
    ev+=C
    if ev >0:
        ok+=1
        
print(ok)

Measured memory_bytes: 38256
N = int(input())
A = [int(input()) for _ in range(N)]
A.sort(reverse=True)

if N % 2 == 0:
    res = 0
    for i in range(N // 2 - 1):
       res += A[i] * 2
    res += A[N // 2 - 1]
    res -= A[N // 2]
    for i in range(N // 2 + 1, N):
        res -= A[i] * 2
    print(res)
else:
    res1 = 0
    for i in range(N // 2 - 1):
        res1 += A[i] * 2
    res1 += A[N // 2 - 1] + A[N // 2]
    for i in range(N // 2 + 1, N):
        res1 -= A[i] * 2

    res2 = 0
    for i in range(N // 2):
        res2 += A[i] * 2
    res2 -= A[N // 2] + A[N // 2 + 1]
    for i in range(N // 2 + 2, N):
        res2 -= A[i] * 2
    print(max(res1, res2))


Measured memory_bytes: 7516
#include <iostream>
#include <math.h>       /* pow */

using namespace std;
long long help(string s,long long cur){

    if(s.length()==0)
        return cur;
    long long curChar=s[0]-'0', newLen=s.length()-1,mod=pow(2,newLen);
    string sub=s.substr(1,newLen);

    return cur*mod+help(sub,0) +help(sub,cur*10+curChar);
}
int main(){
string s;
cin>>s;



cout<<help(s,0)<<endl;

return 0;
}



Measured memory_bytes: 256
// https://atcoder.jp/contests/abc136/tasks/abc136_b
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define EPS (1e-9)
#define INF (1e9)
#define INFL (1e18)
#define MOD (1000000007)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define LEN(x) (sizeof(x) / sizeof(*(x)))
// ll gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// ll lcm(long a, long b) { return a * b / gcd(a, b); }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, ans = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        if (to_string(i).length() % 2 != 0) {
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

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

    ll N; cin >> N;
    vector<ll> A(N), B(N);
    rep(i, 0, N) {
        cin >> A[i];
        B[i] = A[i]-(i+1);
    }

    sort(B.begin(), B.end());

    ll b = B[N/2];
    ll res = 0;
    rep(i, 0, N) res += abs(A[i]-b-(i+1));

    cout << res << "\n";
}

Measured memory_bytes: 3328
import java.util.*;

public class Main {
    public static void main(String args[]) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int prev = 0;
        while(n-- > 0) {
        	int num = sc.nextInt();
        	if(num > prev) {
        		prev = num - 1;
        	} else if(num < prev) {
        		System.out.println("No");
        		return;
        	}
        }
        System.out.println("Yes");
    }
}


Measured memory_bytes: 48272
package main

import (
	"fmt"
	"math"
)

func factorial(a int) int{
	res := 1
	for a > 0 {
		res = res*a
		a--
	}
	return res
}

func dictionary(a []int) int{
	res := 1
	b := make([]int,len(a)+1)
	for i,s := range a {
		c := make([]int,len(a))
		for ii := i; ii < len(a); ii++ {
			d := 0
			for k := 1; k <= s; k++ {
				if b[k] == 0 {
					d++
				}
			}
			c[ii] = d
		}
		res += factorial(len(a)-(i+1))*(c[i]-1)
		b[s] = 1
	}
	return res
}

func main() {
	var n int
	fmt.Scan(&n)
	p := make([]int,n)
	q := make([]int,n)
	for i := 0; i < n; i++ {
		fmt.Scan(&p[i])
	}
	for i := 0; i < n; i++ {
		fmt.Scan(&q[i])
	}

	pdic := dictionary(p)
	qdic := dictionary(q)
	fmt.Println(math.Abs(float64(pdic-qdic)))
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
long long res,l,i;
int main()
{
  string s;
  cin>>s;
  l=s.size();
  for(;i<l;i++)res+=((9*pow(10,l-1-i)-pow(2,l-1-i))/8)*pow(2,i)*(s[i]-'0');
  cout<<res<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define int ll
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<vi> vvi;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a*b/gcd(a,b);
}

signed main(void) {
    int n, m, k;
    cin >> n >> m >> k;
    vi d(m);
    rep(i,m) cin >> d[i], d[i]--;
    vi rev(n,-1);
    rep(i,m)rev[d[i]] = i;
    vvi v(n,vi(k));
    rep(i,n)rep(j,k)cin >> v[i][j], v[i][j]--;
    vi dp(1<<m,(ll)INF*INF);
    dp[(1<<m)-1] = 0;
    queue<int> q;
    q.push((1<<m)-1);
    while(q.size()){
        int bit = q.front();
        q.pop();
        if(bit == 0)continue;
        rep(i,k){
            int nbit = 0;
            rep(j,m)if(bit&(1<<j)){
                int nr = v[d[j]][i];
                rep(x,m)if(d[x] == nr) nbit |= (1<<x);
            }
            if(dp[nbit] > dp[bit]+1){
                q.push(nbit);
                dp[nbit] = dp[bit]+1;
            }
        }
    }
    cout << dp[0] << endl;
}



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

#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define endl "\n"
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define rev(a) (a).rbegin(),(a).rend()
#define pll pair<ll,ll>
#define rep(i,a,b) for(long long i = (a); i <= (b); i++)

const int mod = 1e9+7;
const int N = 1e5+5; 

int main(){
	fast;
	ll t = 1; 
// 	cin >> t;
	while(t--){
        ll r; cin >> r;
        double ans = 2 * M_PI * r;
        cout << ans << endl;
	}
}

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

class Program
{
    static void Main()
    {
        Console.WriteLine(Solve());
        //Solve();
        return;
    }

    public static string Solve()
    {
        string N = Read();
        for (int i = 0; i < N.Length; i++)
        {
            if (N[i] == '7')
            {
                return "Yes";
            }
        }

        return "No";
    }

    private static string Read() { return Console.ReadLine(); }
    private static int ReadInt() { return int.Parse(Read()); }
    private static long ReadLong() { return long.Parse(Read()); }
    private static double ReadDouble() { return double.Parse(Read()); }
    private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
    private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
    private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
}


Measured memory_bytes: 17344
#include <cassert>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
#include "limits.h"
 
#define rep(i, a, b) for (long long (i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;
  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0)) {
    return 0;
  }
  long long x = 1;
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P=std::pair<long long,long long>;

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

  ll n,k;
  std::cin>>n>>k;

  std::vector<ll> h(n);
  rep(i,0,n)std::cin>>h[i];

  std::sort(all(h));

  ll sum=0;
  rep(i,0,n-k)sum+=h[i];

  std::cout<<sum<<"\n";

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int n,m,i=0,j,a,min=1000000,ans=0;
    string s;
    cin >> n;
    pair<int,int>p[200020];
    for(i=0;i<n;i++)
    {
        cin >> a;
        p[i]=make_pair(a,i);
    }
    sort(p,p+n);
    for(i=0;i<n;i++)
    {
        if(i!=n-1)
        {
            cout << p[i].second+1 << " ";
        }
        else
        {
            cout << p[i].second+1;
        }
    }
    return 0;
}


Measured memory_bytes: 5156
import java.util.Scanner;

public class Main {
	
	static boolean isRight(int a, int b, int c) {
		if (a * a + b * b == c * c || a * a + c * c == b * b
				|| b * b + c * c == a * a) {
			return true;
		} else
			return false;
	}

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int a,b,c;
		for(int i=0;i<n;i++){
			a=scan.nextInt();
			b=scan.nextInt();
			c=scan.nextInt();
			if(isRight(a,b,c)==true)	System.out.println("YES");
			else System.out.println("NO");
		}
	}

}

Measured memory_bytes: 12000
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <set>
#include <utility>
#include <bitset>
using namespace std;
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
int c[4110][4110];
int n,k;
int get(int x1,int y1,int x2,int y2)
{
    return c[x2][y2]+c[x1-1][y1-1]-c[x1-1][y2]-c[x2][y1-1];
}
int query(int x,int y)
{
    return get(x,y,x+k-1,y+k-1)+get(x+k,y+k,x+2*k-1,y+2*k-1);
}
int main()
{
    scanf("%d%d",&n,&k);
    int kk=2*k;
    for(int i=1;i<=n;i++)
    {
        int x,y; char s[5];
        scanf("%d%d%s",&x,&y,s);
        if(s[0]=='B')y-=k;
        x=(x%kk+kk)%kk;
        y=(y%kk+kk)%kk;
        c[x+1][y+1]++;
        c[x+1+2*k][y+1]++;
        c[x+1][y+1+2*k]++;
        c[x+1+2*k][y+1+2*k]++;
    }
    for(int i=1;i<=4*k;i++)
        for(int j=1;j<=4*k;j++)
            c[i][j]+=c[i-1][j]+c[i][j-1]-c[i-1][j-1];
    int ans=0;
    for(int i=1;i<=2*k;i++)
        for(int j=1;j<=2*k;j++)
            ans=max(ans,query(i,j));
    printf("%d\n",ans);
}

Measured memory_bytes: 65792
#include<cstdio>
#include<cstring>
#include<list>
#include<algorithm>
using namespace std;

int main() {
	list<int> L;
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		char s[15];
		int  x;
		scanf("%s", s);
		if (s[0] == 'i') {
			scanf("%d", &x);
			L.push_front(x);
		}
		else {
			if (s[6] == 'F') L.pop_front();
			else if (s[6] == 'L') L.pop_back();
			else if (s[0] == 'd') {
				scanf("%d", &x);
				for (list<int> ::iterator it = L.begin(); it != L.end(); it++) {
					if (*it == x) {
						L.erase(it);
						break;
					}
				}
			}
		}
	}
	int i = 0;
	for (list<int>::iterator it = L.begin(); it != L.end(); it++) {
		if (i++) printf(" ");
		printf("%d", *it);
	}
	puts("");
}



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

#O(ElogV)
import heapq
def dijkstra_heap(s):
    #始点sから各頂点への最短距離
    d = [float("inf")] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for e in edge[s]:
        heapq.heappush(edgelist,e)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,[e[0]+d[v],e[1]])
    return d

################################
n = int(input()) #n:頂点数　w:辺の数
w = n - 1

edge = [[] for i in range(n)]
#edge[i] : iから出る道の[重み,行先]の配列
for i in range(w):
    x,y = map(int,input().split())
    x -= 1
    y -= 1
    z = 1
    edge[x].append([z,y])
    edge[y].append([z,x]) 

dis_from_f = dijkstra_heap(0)
dis_from_s = dijkstra_heap(n - 1)

cnt = 0
for i, j in zip(dis_from_f, dis_from_s):
    if i <= j:
        cnt += 1
if cnt > n - cnt:
    print("Fennec")
else:
    print("Snuke")

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

int main() {
	string s;
	cin >> s;
	if(s=="Sunny"){
		cout << "Cloudy" << endl;
	}
	if(s=="Cloudy"){
		cout << "Rainy" << endl;
	}
	if(s=="Rainy"){
		cout << "Sunny" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define deb(a) cout << a << ": "
using namespace std;
const int inf = 1e18 + 7;
const int N = 1e6 + 7;
const int md = 1e9 + 7;
void sliczny() {
  string s, t;
  cin >> s >> t;
  int ans = 0;
  for(int i=0; i<s.length(); i++) {
      if(s[i] != t[i]) {
          ans++;
      }
  }
  cout << ans << '\n';
}

int32_t main() 
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int T = 1;
  //cin >> T; 
  for(int t = 1; t <= T; t++) {
    //cout << "Case #" << t << ": ";
    sliczny();
  }
  return 0;
}


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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pop pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



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

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000],c;

	int ara[n_size],ara2[n_size];

	cin>>s;

	vi vec(400,0);

	//cout<<vec[0]<<endl;

    int len=strlen(s);

    f(i,0,len-1){
        vec[s[i]]++;
    }

    f(i,'a','z'){
        if(vec[i]==0){
            c=i;
            cout<<c<<endl,exit(0);
        }
    }
    cout<<"None"<<endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-3;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
//x,yがax+by=gcd(a,b)の解になる
ll extgcd(ll a, ll b, ll& x, ll& y) {
	ll d = a;
	if (b != 0) {
		d = extgcd(b, a%b, y, x);
		y -= (a / b)*x;
	}
	else {
		x = 1; y = 0;
	}
	return d;
}
//aのmod mでの逆元を求める
ll mod_inverse(ll a, ll m) {
	ll x, y;
	extgcd(a, m, x, y);
	return (m + x % m) % m;
}
const int N_MAX = 1 << 18;
ll p[N_MAX];
ll invp[N_MAX];
void init() {
	p[0] = 1;
	rep1(i, N_MAX - 1) {
		p[i] = p[i - 1] * i%mod;
	}
	rep(i, N_MAX) {
		invp[i] = mod_inverse(p[i],mod);
	}
}
//xCyを求める
ll comb(ll x, ll y, ll m) {
	if (x < y)return 0;
	ll res = p[x];
	(res *= invp[y]) %= mod;
	(res *= invp[x-y]) %= mod;
	return res;
}
int h, w,n;
ll dp[3001];
P loc[3001];
int main() {
	init(); cin >> h >> w >> n;
	rep(i, n) {
		int x, y; cin >> x >> y; loc[i] = { x,y };
	}
	loc[n] = { h,w };
	sort(loc, loc + n+1);
	rep(i, n+1) {
		int x = loc[i].first, y = loc[i].second;
		dp[i] = comb(x + y - 2, x - 1,mod);
		rep(j, i) {
			if (loc[j].second <= loc[i].second) {
				int dx = loc[i].first - loc[j].first;
				int dy = loc[i].second - loc[j].second;
				dp[i] = (dp[i] - dp[j] * comb(dx + dy, dx,mod) % mod + mod) % mod;
			}
		}
	}
	cout << dp[n] << endl;
	//stop
	return 0;
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
 ll n;
 cin>>n;
 ll a[n];
 for(ll i=0;i<n;i++) cin>>a[i];
 ll sum[n+1];
 sum[0]=0;
 for(ll i=1;i<=n;i++) sum[i]=sum[i-1]+a[i-1];
 ll dp[n][n];
 for(ll i=0;i<n;i++) dp[i][i]=a[i];
 for(ll i=n-1;i>=0;i--){
  for(ll j=i+1;j<n;j++){
   ll ans1=a[j]+sum[j]-sum[i]-dp[i][j-1];
   ll ans2=a[i]+sum[j+1]-sum[i+1]-dp[i+1][j];
   dp[i][j]=max(ans1,ans2);
  }
 }
 ll ans1=dp[0][n-1];
 ll ans2=sum[n]-sum[0]-ans1;
 cout<<ans1-ans2<<endl;
 return 0;
}

Measured memory_bytes: 70400
#include "bits/stdc++.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define repr(i,a,n) for(ll i = n-1;i >= a;i--)
#define LINF (ll)1e17
#define INF (int)1e9
#define MOD (ll)1e9+7
#define sMOD 1e5
#define fs first
#define sc second

ll gcd(ll a,ll b){
	if(!b) return a;
	return gcd(b,a%b);
	
}

signed main(){
	ll a,b,c;
	cin >> a >> b >> c;
	if(a+b+c >= 22) cout << "bust" << endl;
	else cout << "win" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<map>
using namespace std;
typedef long long LL;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if(a + b >= c) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 764
// C - Otoshidama
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)
#define irp(i,s,e) for(int i=(s);i>(e);--i)
#define irpz(i,s) irp(i,s,-1)

int main(){
	int N,Y; cin>>N>>Y;
	Y /= 1000;
	rpz(y10, N+1){
		irpz(y5, N-y10){
			if(y10 + y5 > N) continue;
			int y1 = N - y10 - y5;
			if(y10*10 + y5*5 + y1 != Y) continue;
			printf("%d %d %d\n", y10, y5, y1);
			return 0;
		}
	}
	puts("-1 -1 -1");
}

Measured memory_bytes: 256
x1, y1, x2, y2 = map(int, input().split())
x3 = x2 - (y2 - y1)
y3 = y2 + (x2 - x1)
x4 = x1 - (y2 - y1)
y4 = y1 + (x2 - x1)
print(x3, y3, x4, y4)

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}
struct edge {
  ll to, cost;
};

const int MAX = 510000;
const int MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// a^n mod を計算する
// 繰り返し二乗法を使っているので高速！ O(logk)
long long modpow(long long a, long long n, long long mod) {
  if(n == 0) {
    return 1;
  } else if(n % 2 == 1) {
    return modpow(a, n - 1, mod) * a % mod;
  } else {
    ll t = modpow(a, n / 2, mod);
    return t * t % mod;
  }
}

int main() {
  int N, K; cin >> N >> K;
  COMinit();
  for(int i = 0; i < K; ++i) {
    ll ans = 0;
    ans = COM(N - K + 1, i + 1) % MOD;
    ll a = COM(K - 1, i) % MOD;
    ans *= a % MOD;
    ans %= MOD;
    cout << ans << endl;
  }
}

Measured memory_bytes: 15548
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int H=in(),W=in();

	vector<vector<int>> S(H+1,vector<int>(W+1,0));
	REP(i,H){
		auto V=vecin(W);
		REP(j,W){
			if(V[j]==1) S[i+1][j+1] = 1;
		}
	}
	REP(i,H+1){
		REP(j,W){
			S[i][j+1] += S[i][j];
		}
	}
	REP(j,W+1){
		REP(i,H){
			S[i+1][j] += S[i][j];
		}
	}
	int OK=0,NG=min(H,W)+1;

	while(abs(NG-OK)>1){
		ll mid = (OK+NG)/2LL;

		bool exist = false;
		for(int i=0;i<H-mid+1;i++){
			for(int j=0;j<W-mid+1;j++){
				if(S[i][j]+S[i+mid][j+mid]-S[i+mid][j]-S[i][j+mid]==0){
					exist = true;
					break;
				}
			}
		}
		if(exist){
			OK = mid;
		}
		else{
			NG = mid;
		}
	}
	out(OK*OK);

	return 0;
}


Measured memory_bytes: 10532
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}
void readA(T)(size_t n,ref T t){t=new T(n);auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(ElementType!T);r.popFront;}}
void readM(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=readln.splitter;foreach(ref v;t){v[i]=r.front.to!(ElementType!(typeof(v)));r.popFront;}}}
void readS(T)(size_t n,ref T t){t=new T(n);foreach(ref v;t){auto r=readln.splitter;foreach(ref j;v.tupleof){j=r.front.to!(typeof(j));r.popFront;}}}

void main()
{
  int a, b, c; readV(a, b, c);
  writeln(a+b >= c ? "Yes" : "No");
}


Measured memory_bytes: 256
n,k = list(map(int, input().split()))
s =  [[int(_) for _ in input().split()] for __ in range(2*k)]

import itertools
d = s[0::2]
a = s[1::2]
a = list(set(list(itertools.chain.from_iterable(a))))

res = []
for i in range(1, n+1):
        if i not in a:
            res.append(i)

print(len(res))

Measured memory_bytes: 9204
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
int main()
{
	ll n;
	cin>>n;
	priority_queue<pair<ll,ll> > pq;
	for(int i=0;i<n;i++)
	{
		ll x,y;
		cin>>x>>y;
		pq.push({-1*y,x});
	}
	ll time =0;
	while(!pq.empty()){
		pair<ll,ll > temp = pq.top();
		ll end = -1*temp.first;
		ll amt = temp.second;
		if(time+amt>end){
			cout<<"No\n";
			return 0;
		}
		time+=amt;
		pq.pop();
	}
	cout<<"Yes\n";
	return 0;
}

Measured memory_bytes: 6512