akhauriyash/Code-Regression huggingface dataset:
// #include {{{
#include <array>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iterator>
#include <tuple>
#include <utility>
#include <random>
#include <limits>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cstdint>
#include <cassert>
// }}}

using namespace std;

// macros {{{
template<typename T, size_t N>
constexpr size_t NELEMS(T (&)[N]) { return N; }

template<typename InputIt>
void PRINT_RANGE(InputIt first, InputIt last)
{
    for(; first != last; ++first)
        cout << *first << (first==last ? "" : " ");
    cout << "\n";
}

template<typename T>
void PRINT_MATRIX(T mat, size_t nr, size_t nc)
{
    for(size_t r = 0; r < nr; ++r) {
        for(size_t c = 0; c < nc; ++c) {
            cout << mat[r][c] << (c==nc-1 ? "" : " ");
        }
        cout << "\n";
    }
}

#define FOR(i, start, end) for(int i = (start); i < (end); ++i)
#define REP(i, n) FOR(i, 0, n)
// }}}

// types {{{
using ll  = long long;
using ull = unsigned long long;
// }}}

ll N, M, Q;
vector<vector<int>> S;

vector<vector<ll>> V;  // 頂点数
vector<vector<ll>> EH; // 水平な辺の数
vector<vector<ll>> EV; // 垂直な辺の数

void init()
{
    V.assign(N+1, vector<ll>(M+1, 0));

    FOR(y, 1, N+1) {
        FOR(x, 1, M+1) {
            V[y][x] = V[y-1][x] + V[y][x-1] - V[y-1][x-1] + S[y][x];
        }
    }

    EH.assign(N+1, vector<ll>(M+1, 0));
    EV.assign(N+1, vector<ll>(M+1, 0));
    FOR(y, 1, N+1) {
        FOR(x, 1, M+1) {
            EH[y][x] = EH[y-1][x] + EH[y][x-1] - EH[y-1][x-1];
            if(S[y][x] == 1 && S[y][x-1] == 1)
                ++EH[y][x];

            EV[y][x] = EV[y-1][x] + EV[y][x-1] - EV[y-1][x-1];
            if(S[y][x] == 1 && S[y-1][x] == 1)
                ++EV[y][x];
        }
    }

#if DEBUG
    PRINT_MATRIX(V,  N+1, M+1);
    PRINT_MATRIX(EH, N+1, M+1);
    PRINT_MATRIX(EV, N+1, M+1);
#endif
}

void solve()
{
    init();

    REP(_, Q) {
        int x1, y1;
        int x2, y2;
        cin >> y1 >> x1;
        cin >> y2 >> x2;

        ll v = V[y2][x2] - V[y2][x1-1] - V[y1-1][x2] + V[y1-1][x1-1];

        ll eh = EH[y2][x2] - EH[y2][x1] - EH[y1-1][x2] + EH[y1-1][x1];
        ll ev = EV[y2][x2] - EV[y2][x1-1] - EV[y1][x2] + EV[y1][x1-1];

        ll ans = v - eh - ev;
        cout << ans << "\n";
    }
}

int main()
{
    cin >> N >> M >> Q;
    S.assign(N+1, vector<int>(M+1, false));
    FOR(y, 1, N+1) {
        string s;
        cin >> s;
        transform(begin(s), end(s), begin(S[y])+1, [](char c) {
            return c == '1' ? 1 : 0;
        });
    }
    //PRINT_MATRIX(S, N+1, M+1);

    solve();

    return 0;
}


Measured memory_bytes: 112384
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define fore(x, c) for(auto &&x : c)
#define rep(i, a, n) for(int i = a, i##len = (int)(n); i < i##len; ++i)
#define rrep(i, a, n) for(int i = (int)(n - 1); i >= a; --i)
#define sz(c) ((int)c.size())
#define contains(c, x) (c.find(x) != end(c))
#define inseg(l, x, r) ((l) <= (x) && (x) < (r))
#define dump(...)
#define pb push_back
#define eb emplace_back
#define _ 0
const signed INF_ = 1001001001; const long long INF = 1001001001001001001LL;
const int DX[9] = {0,1,0,-1,1,1,-1,-1,0}, DY[9] = {-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is, vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
  is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a, const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a, const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap = priority_queue<T, deque<T>, greater<T>>;
struct before_main_function {
  before_main_function() {
      cin.tie(nullptr); ios::sync_with_stdio(false);
      cout << setprecision(15) << fixed;
  }
} before_main_function;
// clang-format on
//------------------8<------------------------------------8<--------------------

signed main() {
  int N;
  cin >> N;
  map<string, int> cnt;
  rep(i, 0, N) {
    string s;
    cin >> s;
    cnt[s]++;
  }
  vector<string> k = {"AC", "WA", "TLE", "RE"};
  for (auto &x : k) {
    cout << x << " x " << cnt[x] << endl;
  }
  return (0 ^ _ ^ 0);
}



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

#define N 200123
#define mod 1000000007

int main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    int n, m, sock = 1, strip = 0;
    cin >> n >> m;
    while(sock < m){
    	sock--;
    	sock += n;
    	strip++;
    }
    cout << strip << endl;
    return 0;
}

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

int main() {
  int64_t A, B, N;
  cin >> A >> B >> N;
  if (A >= N) {
    cout << A - N << ' ' << B << endl;
  } else if (B >= N - A) {
    cout << 0 << ' ' << B - N + A << endl;
  } else {
    cout << 0 << ' ' << 0 << endl;
  }
}

Measured memory_bytes: 3600
n = int(input())
if n== 1:
  print(1)
  exit()
pos = []
diff = []
for _ in range(n):
  x,y = map(int,input().split())
  for px,py in pos:
    diff.append((x-px, y-py))
    diff.append((px-x, py-y))
  pos.append((x,y))
from collections import Counter
diff = Counter(diff).most_common()
x,y = diff[0][0]
count = diff[0][1]
if x== y == 0:
  x,y = diff[1][0]
  count = diff[1][1]
print(n-count)



Measured memory_bytes: 3956
import java.util.*;

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

            //int ans = Integer.valueOf(sc.next());
            String input = sc.next();
            String input1 = input.substring(0, 1);
            String input2 = input.substring(1, 2);
            String input3 = input.substring(2, 3);

            if(input1.equals(input2) && input1.equals(input3)){
                System.out.println("No");
            }else{
                System.out.println("Yes");
            }


        }catch(Exception e){
            e.printStackTrace();
        }        
    }
}

Measured memory_bytes: 25172
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
typedef long long ll;

int main()
{
	int N;
	int m_bef, m_aft;

	cin >> N;
	vector<int> X(N), copy(N);
	rep(i, N) {
		cin >> X[i];
		copy[i] = X[i];
	}

	sort(copy.begin(), copy.end());
	m_bef = copy[N / 2 - 1];
	m_aft = copy[N / 2];

	rep(i, N) {
		if (X[i] <= m_bef) cout << m_aft << endl;
		else cout << m_bef << endl;
	}

	return 0;
}


Measured memory_bytes: 3712
#include <iostream>
using namespace std;
int main(void)
{
    string s;
    getline(cin,s);
    for(int i = 0; i < s.size();i++){
        char c = s[i];
        if('A' <= c && c <= 'Z'){
            c = c + 32;
        }
        else if('a' <= c && c <= 'z'){
            c = c - 32;
        }
        cout << c;
    }
    cout << endl;
}


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

#define F first
#define S second
#define ll long long
#define pb push_back
#define endl '\n'

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    if ( a > b * c) cout << "No\n";
    else cout << "Yes\n";
}


Measured memory_bytes: 3608
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;

/*

*/

// vector<ll> Coordinate_compression(vector<ll> a){
// 	vector<ll> b,ans(a.size());
// 	rep(i,a.size())b.push_back(make_pair(a[i],i));
// 	sort(b.begin(),b.end());
// 	rep(i,a.size())ans[b[i].second]=i;
// 	return ans;
// }

int main(void){
	bool ok=true;
	ll n,a[100010],b[100010];
	a[0]=0;
	b[0]=0;
	vector<ll> x,y;
	vector<mp> x1,y1;
	cin>>n;
	reg(i,1,n){
		cin>>a[i];
		a[0]=a[0]^a[i];//全体のxorを求める．
	}
	reg(i,1,n){
		cin>>b[i];
		b[0]=b[0]^b[i];//全体のxorを求める．
	}
	x.push_back(a[0]);
	y.push_back(b[0]);
	//同じ場所は無視できるので除く
	reg(i,1,n){
		if(a[i]!=b[i]){
			x.push_back(a[i]);
			y.push_back(b[i]);
		}
	}
	// rep(i,x.size())printf("%lld ",x[i]);
	// printf("\n");
	// rep(i,y.size())printf("%lld ",y[i]);
	// printf("\n⬇座標圧縮後\n");
	//集合として同じか比較
	//x1：sorted
	rep(i,x.size())x1.push_back(make_pair(x[i],i));
	rep(i,y.size())y1.push_back(make_pair(y[i],i));
	sort(x1.begin(),x1.end());
	sort(y1.begin(),y1.end());
	rep(i,x1.size())if(x1[i].first!=y1[i].first)ok=false;
	if(ok){//集合として同じなら
		//座標圧縮
		ll x2[100010],y2[100010],visit[100010],inv[100010];
		rep(i,100010)visit[i]=-1;
		vector<ll> v[100010];//辺を張る
		rep(i,x1.size())x2[x1[i].second]=i;
		rep(i,y1.size())y2[y1[i].second]=i;
		// rep(i,x1.size())printf("%lld ",x2[i]);
		// printf("\n");
		// rep(i,y1.size())printf("%lld ",y2[i]);
		// printf("\n");
		//y2[i]になるid
		rep(i,x1.size())inv[y2[i]]=i;
		rep(i,x1.size())v[i].push_back(inv[x2[i]]);
		//同じ数字に辺を張る
		reg(i,1,x1.size()-1){
			if(x1[i].first==x1[i-1].first){
				v[x1[i].second].push_back(x1[i-1].second);
				v[x1[i-1].second].push_back(x1[i].second);
			}
		}
		// rep(i,x1.size()){
		// 	printf("%d:",i);
		// 	rep(j,v[i].size()){
		// 		printf("%lld ",v[i][j]);
		// 	}
		// 	printf("\n");
		// }
		//連結成分の数を見ていく
		ll c=0;
		rep(i,x1.size()){
			if(visit[i]==-1){
				visit[i]=i;
				queue<ll> Q;
				Q.push(i);
				while(!Q.empty()){
					ll p=Q.front();Q.pop();
					rep(j,v[p].size()){
						ll q=v[p][j];
						if(visit[q]==-1){
							visit[q]=i;
							Q.push(q);
						}
					}
				}
				c++;
			}
		}
		cout<<x1.size()-1+c-1<<endl;
	}else{
		cout<<-1<<endl;
	}
	return 0;
}

Measured memory_bytes: 17640
n = int(input())
taro=0
hanako=0
for i in range(n):
	A=list(map(str,input().split()))
	if A[0]==A[1]:
		taro +=1
		hanako +=1
	else:
		B=sorted(A)#A???????????????????????????
		if A == B:#hanako??????????°???????
			hanako+=3
		else:
			taro+=3
print(taro,hanako)

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

queue<pair<int, int> > ans_que;

#define int long long

int n;
int a[100010];

signed main(){
    cin >> n;

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

    sort(a, a+n);

    int ans = 0;
    if(a[n-1] <= 0){
        ans = a[n-1];
        for(int i = 0;i < n-1;i++){
            ans_que.push(make_pair(ans, a[i]));
            ans = ans-a[i];
        }
    }else{
        queue<int> que;
        int tmp = a[0];
        for(int i = 1;i < n-1;i++){
            if(a[i] <= 0){
                que.push(a[i]);
            }else{
                ans_que.push(make_pair(tmp, a[i]));
                tmp = tmp-a[i];
            }
        }
        que.push(tmp);
        ans = a[n-1];
        while(!que.empty()){
            ans_que.push(make_pair(ans, que.front()));
            ans = ans-que.front();
            que.pop();
        }
    }

    cout << ans << endl;
    while(!ans_que.empty()){
        cout << ans_que.front().first << " " << ans_que.front().second << endl;
        ans_que.pop();
    }

    return 0;
}

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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Graph;
const int MOD = 1e9 + 7;
const ll INF = 1e9;
const int MAX_V = 1e5 + 5;
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

long long fac[MAX_N], finv[MAX_N], inv[MAX_N];
// テーブルを作る前処理 from: https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX_N; 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(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

struct mint {
    // Preparation: MOD is already defined.
    ll x;

    mint(ll x = 0) : x((x % MOD + MOD) % MOD) {}

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    mint pow(mint m) const {
        return pow(m.x);
    }

    mint inv() const {
        ll a = x, b = MOD, u = 1, v = 0;
        while (b) {
            ll t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        u %= MOD;
        return u;
    }

    mint &operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint &operator-=(const mint a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint &operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

int main() {
    int n, k;
    cin >> n >> k;
    vector<ll> a(n);
    COMinit();
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end(), greater<ll>());
    mint sum = 0;
    rep(i, n - k + 1) {
        mint diff = COM(n - 1 - i, k - 1);
        mint ma = (diff * a[i]);
        mint mi = (diff * a[n - i - 1]);
        sum += ma;
        sum -= mi;
    }
    out(sum.x);
    return 0;
}


Measured memory_bytes: 3456
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>

using namespace std;

int main() {
	int n;
	long long k;
	cin >> n >> k;
	map<int, long long> mp;
	for (int i = 0; i < n; i++) {
		int a;
		long long b;
		cin >> a >> b;
		mp[a] += b;
	}
	long long c = 0;
	for (auto it = mp.begin(); it != mp.end(); it++) {
		if (c + it->second >= k) {
			cout << it->first;
		//	cin >> n;
			return 0;
		}
		c += it->second;
	}
	return 0;
}

Measured memory_bytes: 4224
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <map>
#include <utility>
#include <set>
#include <climits>

using namespace std;

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

int v[55];

int main() {
    int N;
    scanf("%d", &N);
    for (int i = 0; i < N; ++i) {
        scanf("%d", &v[i]);
    }

    sort(v, v + N);
    long long base = 2;
    double result = 0;
    for (int i = N - 1; i >= 0; --i) {
        result += 1.0 * v[i] / base;
        if (i > 1) {
            base *= 2;
        }
    }
    printf("%lf\n", result);
    return 0;
}



Measured memory_bytes: 256
#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;


class comb{
private:
    ll mod;
    ll mx;
    vector<ll> F;
    
public:
    comb(ll mod=1000000007,ll mx=1000000):mod(mod),mx(mx){
        mk_F();
    }
    
    ll mod_pow(ll a,ll x){
        a%=mod;
        ll ans=1;
        for(int i=0;i<63;i++){
            if(x>>i&1){ans*=a; ans%=mod;}
            a*=a;
            a%=mod;
        }
        return ans;
    }
    
    pll Ex_gcd(ll a,ll b){
        if(b==0){return {1,0};}
        pll ret=Ex_gcd(b,a%b);
        ret.F-=a/b*ret.S;
        return {ret.S,ret.F};
    }
    
    ll prime_R(ll a){
        return mod_pow(a,mod-2);
    }
    
    ll R(ll a){
        ll ret=Ex_gcd(a,mod).F;
        ret%=mod;
        if(ret<0){ret+=mod;}
        return ret;
    }
    
    void mk_F(){
        F={1};
        ll a=1;
        for(ll i=1;i<=mx;i++){
            a*=i;
            a%=mod;
            F.push_back(a);
        }
    }
    
    ll c(ll n,ll k){
        if(n<k){return 0;}
        if(n==k || k==0){return 1;}
        return F[n]*R(F[n-k])%mod*R(F[k])%mod;
    }
    
    //mod must be prime
    ll Lucas_C(ll n,ll m){
        ll ret=1;
        while(n>0 || m>0){
            ret*=c(n%mod,m%mod);
            ret%=mod;
            n/=mod; m/=mod;
        }
        return ret;
    }
    
    ll Stirling(ll n,ll k){
        ll ret=0;
        for(ll i=1;i<=k;i++){
            if((k-i)%2){ret-=c(k,i)*mod_pow(i,n)%mod;}
            else{ret+=c(k,i)*mod_pow(i,n)%mod;}
            ret%=mod;
        }
        ret*=R(F[k]);
        ret%=mod;
        if(ret<0){ret+=mod;}
        return ret;
    }
    
    ll Bell(ll n,ll k){
        ll ret=0;
        for(ll i=1;i<=k;i++){ret+=Stirling(n,i); ret%=mod;}
        return ret;
    }
};



int main(){
    comb C;
    ll h,w;
    cin>>h>>w;
    ll a,b;
    cin>>a>>b;
    if(b>=w || a>=h){cout<<0<<endl; return 0;}
    ll ans=0;
    a=h-a-1;
    while(a>=0 && b<w){
        ans+=C.c(a+b,b)*C.c(h+w-2-a-b,h-a-1)%MOD;
        ans%=MOD;
        a--; b++;
    }
    cout<<ans%MOD<<endl;
    
    
    return 0;
}



Measured memory_bytes: 10604
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;

ll mod = 1000000007;

ll exp(ll a, ll n) {
  if (n == 1) return a;

  if (n % 2 == 0) return exp(a, n/2) * exp(a, n/2) % mod;
  else return exp(a, n/2) * exp(a,n/2) % mod * a % mod;
}

ll com(ll n, ll r) {
  ll ans = 1;
  for(int i = 0;i < r; i++){
    ans *= n - i;
    ans %= mod;
  }
  for(int i= 0;i<r;i++){
    ans *= exp(i+1,mod-2);
    ans %= mod;
  }

  return ans;
}

int main(){
  ll n,a,b;
  cin >> n >> a >> b;

  ll ans = (exp(2,n) - 1 - com(n,a) -com(n,b)) % mod;
  if (ans < 0) cout << ans + mod << endl;
  else cout << ans << endl;

  return 0;
}




Measured memory_bytes: 504
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    long long mod=1e9+7;
    cin>>n>>m;
    vector<bool> forbidden(n+1,false);
    for(int i=0;i<m;i++){
        int a;
        cin>>a;
        forbidden[a]=true;
    }
    vector<long long int> dp(n+1);
    dp[0]=1;
    for(int now=0;now<n;now++){
        for(int next=now+1;next<=min(n,now+2);next++){
            if(forbidden[next])continue;
            dp[next]+=dp[now];
            dp[next]%=mod;
        }
    }
    cout<<dp[n]<<endl;
    return 0;
}


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

int main(void)
{
    int K, S;
    int x, y, z;
    cin >> K >> S;
    int c = 0;
    for (x=0; x<K+1; x++) {
        for (y=0; y<x+1; y++) {
            for (z=0; z<y+1; z++) {
                if (x + y + z == S) {
                    if (x!=y & x!=z & y!=z) c += 6;
                    else if (x==y & x==z & y==z) c += 1;
                    else c += 3;
                }
            }
        }
    }
    cout << c << endl;
}

Measured memory_bytes: 256
import sys
from fractions import gcd
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

def main():
    n = int(sys.stdin.readline())
    a_s = LI()
    # a_s = [2*i for i in a_s]
    sum_last = 0
    ans = [0 for i in range(n)]
    for i in range(n):
        if i % 2 == 1:
            sum_last += a_s[i]
    ans[0] = sum(a_s) - 2 * sum_last
    for i in range(1, n):
        ans[i] = 2 * a_s[i-1] - ans[i - 1]
    print(*ans)






if __name__ == "__main__":
    main()

Measured memory_bytes: 86368
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;

class Node {
  public:
    int cur = -1;
    long sum = 0;
}

class Edge {
  public:
    int a;
    int b;
    int opCmp (const Edge e) const {
		  return (a < e.a) ? -1 : (a > e.a) ? 1 : (b < e.b) ? -1 : (b > e.b) ? 1 : 0;
	  }
}

void main()
{
  int n, q;
  readf("%d %d\n", &n, &q);

  auto nodes = new Node[](n);
  foreach (i; 0..n) {
    nodes[i] = new Node();
  }
  
  auto edges = new int[][](n);
  
  foreach (i; 0..n-1) {
    int a, b;
    readf("%d %d\n", &a, &b);
    
    a--;
    b--;
    edges[a] ~= b;
    edges[b] ~= a;
  }

  auto que = BinaryHeap!(Edge[], "a > b")(new Edge[400000], 0);

  foreach (e; edges[0]) {
    auto edge = new Edge();
    edge.a = 0;
    edge.b = e;
    que.insert(edge);
  }

  nodes[0].cur = -2;
  while (!que.empty) {
    auto e = que.front;
    que.removeFront;
    if (nodes[e.b].cur != -1) {
      continue;
    }
    nodes[e.b].cur = e.a;

    foreach (ee; edges[e.b]) {
      auto edge = new Edge();
      edge.a = e.b;
      edge.b = ee;
      que.insert(edge);
    }
  }

  foreach (i; 0..q) {
    int p, x;
    readf("%d %d\n", &p, &x);
    p--;
    nodes[p].sum += x;
  }

  auto f = new long[](n);
  f[] = -1;

  long solve(int index) {
    if (f[index] != -1) {
      return f[index];
    }

    long res;
    res += nodes[index].sum;

    if (nodes[index].cur != -2) {
      res += solve(nodes[index].cur);
    }
    f[index] = res;
    return res;
  }

  foreach (i; 0..n) {
    solve(i);
  }

  writefln("%(%d %)", f);
}


Measured memory_bytes: 36732
// Problem : D - Water Bottle
// Contest : AtCoder - AtCoder Beginner Contest 144
// URL : https://atcoder.jp/contests/abc144/tasks/abc144_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣠⣶⡾⠏⠉⠙⠳⢦⡀⠀⠀⠀
⠀⠀⠀⣴⠿⠏⠀⠀⠀⠀⠀⠀⢳⡀⠀
⠀⠀⢠⣟⣋⡀⢀⣀⣀⡀⠀⣀⡀⣧⠀
⠀⠀⢸⣯⡭⠁⠸⣛⣟⠆⡴⣻⡲⣿⠀
⠀⠀⣟⣿⡭⠀⠀⠀⠀⠀⢱⠀⠀⣿⠀
⠀⠀⠙⢿⣯⠄⠀⠀⠀⢀⡀⠀⠀⡿⠀⠀
⠀⠀⠀⠀⠹⣶⠆⠀⠀⠀⠀⠀⡴⠃⠀⠀
⠀⠀⠀⠀⠀⢸⣷⡦⢤⡤⢤⣞⣁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⢀⣤⣴⣿⣏⠁⠀⠀⠸⣏⢯⣷⣖⣦⡀⠀⠀⠀⠀⠀⠀
⢀⣾⣽⣿⣿⣿⣿⠛⢲⣶⣾⢉⡷⣿⣿⠵⣿⠀⠀⠀⠀⠀⠀
⣼⣿⠍⠉⣿⡭⠉⠙⢺⣇⣼⡏⠀⠀⠀⣄⢸⠀⠀⠀⠀⠀⠀
⣿⣿⣧⣀⣿.........⣀⣰⣏⣘⣆⣀⠀
*/
#include <bits/stdc++.h> 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define l00p(i, a, b) for (int i=a; i<(b); i++)
#define loop(i, a) for (int i=0; i<(a); i++)
#define rep1(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rep(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
#define imax INT_MAX
#define imin INT_MIN
//#define MOD 998244353
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

int main() {
	 
	ios_base::sync_with_stdio(0); cin.tie(0); 
	int t=1;
	while(t--)
	{
		ld a,b,x;
		cin>>a>>b>>x;
		ld left=a*a*b-x;
		cout<<fixed<<setprecision(10);
		if(a*b*a/2<=x)
			cout<<atan(2*(left)/(a*a*a))*180/pii;
		else
			cout<<90-atan(2*x/(a*b*b))*180/pii;
		
	}
	return 0;
}
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3716
#include <stdio.h>
 
int calc(int,int,int);
 
int main(){
  int N,Y,M,D;
  scanf("%d",&N);
  while(N--){
    scanf("%d%d%d",&Y,&M,&D);
    printf("%d\n",calc(Y,M,D));
  }
  return 0;
}
 
int calc(int Y,int M,int D){
  int cnt = 0;
  int y = 1000,m = 1,d = 1;
  while(1){
    if(Y == y && M == m && D == d){
      break;
    }
    D++; cnt++;
    if((Y%3 == 0 || M%2) && D == 21){
      D = 1; M++;
    }else if(Y % 3 != 0 && M%2 == 0 && D == 20){
      D = 1; M++;
    }
    if(M == 11){ M = 1; Y++; }
  }
  return cnt;
}

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

using namespace std;

using ll = long long;

#define MOD_NUMBER 1000000007

template <class T> void vector_print(vector<T> vec) {
  for (unsigned int i = 0; i < vec.size(); i++) {
    cout << vec.at(i);
    if (i < vec.size()-1) {
      cout << " ";
    } else if (i == vec.size()-1) {
      cout << endl;
    }
  }
}

int main() {
  double L;
  cin >> L;
  printf("%f", L*L*L/27);
  return 0;
}


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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define REPR(i,a,b) for(ll i=b;i>=a;i--)
#define repr(i,n) REPR(i,0,n)
#define all(v) (v).begin(), (v).end()
#define pb push_back

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

    ll n,k,a[100001],ans;
    cin >> n >> k;
    rep(i,n) cin >> a[i];
    if((n-1)%(k-1)==0) ans = (n-1) / (k-1);
    else ans = (n-1) / (k-1) + 1;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#define MOD 1000000007

using namespace std;
typedef long long ll;

vector<vector<long long> > v(2000 + 1,vector<long long>(2000 + 1, 0));

void comb(int n, int r) {
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j = 1; j < v.size(); j++) {
    for (int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]) % MOD;
    }
  }
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int s;
  cin >> s;
  ll sho, ama;
  sho = s/3; ama = s%3;
  ll ans = 0L;

  comb(ama+sho-1, sho-1);

  for(ll i = sho; i > 0; --i){
    ans = (ans + v[ama+i-1][i-1]) % MOD;
    ama += 3;
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 34416
#include<iostream>
#include<string>
using namespace std;
int main() {
  int H, W;
  cin >> H >> W;
  for(int i = 0; i < H; i++) {
    string line;
    cin >> line;
    cout << line << "\n";
    cout << line << "\n";
  }
  return 0;
}

Measured memory_bytes: 256
package main

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

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func main() {
	sc := NewScanner()
	sc.nextInt()
	S := sc.nextStr()
	ans := 0
	for i := 0; i < 1000; i++ {
		key := strconv.Itoa(i)
		if len(key) != 3 {
			if len(key) == 2 {
				key = "0" + key
			} else {
				key = "00" + key
			}
		}
		flag1 := false
		flag2 := false
		for _, r := range S {
			if !flag1 && r == rune(key[0]) {
				flag1 = true
			} else if !flag2 && flag1 && r == rune(key[1]) {
				flag2 = true
			} else if flag2 && r == rune(key[2]) {
				ans++
				break
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int main(){
  long n,t;
  cin >> n >> t;
  vector<long> w(n);
  vector<long> v(n);
  vector<pll> data(n);
  rep(i,n) cin >> data.at(i).first >> data.at(i).second;
  sort(data.begin(),data.end());
  rep(i,n){
    w.at(i) = data.at(i).first;
    v.at(i) = data.at(i).second;
  }
  vector<vector<long>> dp(n+1,vector<long>(7000,-1e15));
  rep(i,7000) dp.at(0).at(i) = 0;
  rep(i,n){
    rep(j,7000){
      if(j - w.at(i) >= 0 && j - w.at(i) < t) dp.at(i+1).at(j) = max(dp.at(i).at(j),dp.at(i).at(j-w.at(i))+v.at(i));
      else dp.at(i+1).at(j) = dp.at(i).at(j);
    }
  }
  long ans = 0;
  rep(i,7000){
    ans = max(ans,dp.at(n).at(i));
  }
  cout << ans << endl;
  /*rep(i,n+1){
    rep(j,20) cout << dp[i][j] << " ";
    cout << endl;
  }*/
}


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 2019;
const int inf = 1e9 + 5;

struct mint {
  ll x;
  mint(ll x=0) : x(x%mod) {}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x -= a.x) < 0) x += mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) {
    mint res(*this);
    return res*=a;
  }
};

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

  string s; std::cin >> s;
  reverse(rng(s));
  int n = s.size();
  mint base = 1;
  vector<mint> a(n); rep(i, n) a[i] = mint(s[i]-'0') * base, base *= 10;
  vector<mint> tot(n+1);
  rep(i, n) tot[i+1] = tot[i] + a[i];
  int ans = 0;
  map<ll, int> cnt;
  rep(i, n+1) {
    if (cnt.count(tot[i].x)) ans += cnt[tot[i].x];
    cnt[tot[i].x]++;
  }
  std::cout << ans << "\n";
}


Measured memory_bytes: 6796
def solve(n, m, x, y):
    x = list(map(lambda _:_-1, x))
    y = list(map(lambda _:_-1, y))
    p = [0] * n
    p[0] = 1
    c = [1] * n
    for i in range(m):
        if c[x[i]] > 1:
            if p[x[i]] == 1:
                p[y[i]] = 1
        else:
            if p[x[i]] == 1:
                p[y[i]] = 1
            p[x[i]] = 0
        c[x[i]] -= 1
        c[y[i]] += 1
    return sum(p)

n, m = map(int, input().split())
x = [0] * m
y = [0] * m
for i in range(m):
    x[i], y[i] = map(int, input().split())
print(solve(n, m, x, y))

Measured memory_bytes: 26140
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n, m, X, Y; cin >> n >> m >> X >> Y;
	vector<int> x(n + 1), y(m + 1);
	x[0] = X; y[0] = Y;
	rep(i, 1, n)
	{
		cin >> x[i];
	}
	rep(i, 1, m)
	{
		cin >> y[i];
	}
	sort(all(x));
	sort(all(y));
	if (x[n] < y[0])cout << "No War" << endl;
	else cout << "War" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <cmath>

using namespace std;

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

int main() {
    int N, A, B; // 20, 100, 2000
    scanf("%d %d %d", &N, &A, &B);

    printf("%d\n", min(B, N * A));

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int A[100010];
    A[0] = 0;
    rep(i, N) cin >> A[i + 1];
    A[N + 1] = 0;
    int sum = 0;
    rep(i, N + 1) {
        sum += abs(A[i + 1] - A[i]);
    }
    rep(i, N) {
        int cut1 = abs(A[i + 1] - A[i]);
        int cut2 = abs(A[i + 2] - A[i + 1]);
        int add = abs(A[i + 2] - A[i]);
        cout << sum - cut1 - cut2 + add << endl;
    }

    return 0;
}


Measured memory_bytes: 4028
#include<bits/stdc++.h>
using namespace std;
 
ostream& operator<<(ostream &out, string str) {
	for(char c : str) out << c;
	return out;
}
 
template<class L, class R> ostream& operator<<(ostream &out, pair<L, R> p) {
	return out << "(" << p.first << ", " << p.second << ")";
}
 
template<class T> auto operator<<(ostream &out, T a) -> decltype(a.begin(), out) {
	out << "{";
	for(auto it = a.begin(); it != a.end(); it = next(it))
		out << (it != a.begin() ? ", " : "") << *it;
	return out << "}";
}
 
void dump() { cerr << "\n"; }
template<class T, class... Ts> void dump(T a, Ts... x) {
	cerr << a << ", ";
	dump(x...);
}

#ifdef DEBUG
#  define debug(...) cerr << "[" #__VA_ARGS__ "]: ", dump(__VA_ARGS__)
#else
#  define debug(...) false
#endif
 
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define ST first
#define ND second
 
template<class T> int size(T && a) { return a.size(); }
 
using LL = long long;
using PII = pair<int, int>;

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

	int n, x, y, z;
	cin >> n >> x >> y >> z;

	int f = x + y + z;
	auto haiku = [&](int mask) {
		for(int i = f - 1; i < 30; i++) {
			if(mask & (1 << i)) {
				bool a = mask & (1 << (i - x));
				bool b = mask & (1 << (i - x - y));
				bool c = (i == f - 1) || (mask & (1 << (i - f)));
				if(a && b && c)
					return true;
			}
		}
		return false;
	};

	int mod = 1e9 + 7;
	auto add = [&](int &a, int b) {
		a += b;
		if(a >= mod) a -= mod;
	};

	vector<int> dp(1 << f);
	dp[0] = 1;
	FOR(i, 1, n) {
		vector<int> nt(1 << f);
		REP(j, (1 << f)) {
			if(dp[j] == 0) continue;
			FOR(k, 1, 10) {
				int mask = (j << k) + (1 << (k - 1));
				if(haiku(mask)) continue;
				mask &= (1 << f) - 1;
				add(nt[mask], dp[j]);
			}
		}
		swap(dp, nt);
	}

	int ans = 1;
	REP(i, n) ans = (LL) ans * 10 % mod;
	REP(i, (1 << f))
		add(ans, mod - dp[i]);

	cout << ans << "\n";
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define ll long long
#define INF INT_MAX 
#define mod 1000000007
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> t(N+1),x(N+1),y(N+1);
    t[0] = 0; x[0] = 0; y[0] = 0;
    for(int i=1;i<=N;i++) cin >> t[i] >> x[i] >> y[i];
    int T,X,Y;
    for(int i=1;i<=N;i++){
        T = t[i] - t[i-1];
        X = abs(x[i] - x[i-1]);
        Y = abs(y[i] - y[i-1]);
        if(T < X+Y){
            cout << "No" << endl;
            return 0;
        }else{
            if(T%2!=(X+Y)%2){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 1408
#include <iostream>
using namespace std;
int main ()
{
	long long n, pas=0, i=0;
	cin>>n;
	if(n%2==1){
		cout<<"0";
		return 0;
	}
	for(i=1; i<=n; i*=5)
	pas+=n/(5*i)/2;
	cout<<pas;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
using namespace std;
#define reps(i,b,n) for(int i = b ; i < n ; ++i )
#define rep(i,n) reps(i,0,n)
#define INF (1 << 30)
int n,table[10000];
int solve(int l){
  int r = l + 1 , cnt = n;
  while(true){
    int color = table[l] , dis = 0;
    while(table[l] == color && l >= 0 && ++dis) l--;
    while(table[r] == color && r < n && ++dis) r++;
    if(dis < 4) return cnt;
    else cnt -= dis;
  }
}
int main(){
  while(cin >> n , n){
    int ans = INF;
    rep(i,n) cin >> table[i];
    rep(i,n) reps(j,1,4) swap(j,table[i]) , ans = min(ans,solve(i)) , swap(j,table[i]);
    cout << ans << endl;
  }
}

Measured memory_bytes: 1200
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using int64 = long long int;

int64 dp[110][100010];
const int64 MOD = 1000000007;
int main() {
    int N, K; cin >> N >> K;
    vector<int> d;
    for(int i=1; i*i<=N; i++) {
        d.push_back(i);
        d.push_back(N/i);
    }
    sort(d.begin(), d.end());
    d.erase(unique(d.begin(), d.end()), d.end());

    vector<int> rng; rng.push_back(1);
    for(size_t i=1; i<d.size(); i++) rng.push_back(d[i] - d[i-1]);

    int M = rng.size();
    dp[0][0] = 1;
    for(int i=0; i<K; i++) {
        for(int j=0; j<M; j++) {
            (dp[i][j+1] += dp[i][j]) %= MOD;
        }
        for(int j=0; j<M; j++) {
            (dp[i+1][j] += dp[i][M-1-j] * rng[j]) %= MOD;
        }
    }

    int64 ans = 0;
    for(int i=0; i<M; i++) (ans += dp[K][i]) %= MOD;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 80124
#include<stdio.h>
#define MAX 2000000
int N;
int left(int);
int right(int);
int parent(int);
void maxHeapify(int *,int);
void buildMaxHeap(int *);
int main(){
  scanf("%d",&N);
  int A[MAX+1],i;
  for(i=1;i<=N;i++){
    scanf("%d",&A[i]);
  }
  buildMaxHeap(A);
  for(i=1;i<=N;i++) printf(" %d",A[i]);
  printf("\n");
  return 0;
  
}
int left(int n){
  return 2*n; 
}
int right(int n){
  return (2*n)+1;
}
int parent(int n){
  return n/2;
}
void maxHeapify(int A[],int i){
  int l=left(i);
  int r=right(i);
  int lst,temp;
  
  if(l<=N&&A[l]>A[i]){
    lst=l;
  }else{
    lst=i;
  }
  if(r<=N&&A[r]>A[lst]){
    lst=r;
  }
  if(lst!=i){
    temp=A[i];
    A[i]=A[lst];
    A[lst]=temp;
  maxHeapify(A,lst);
  }
}
void buildMaxHeap(int A[]){
  int i;
  for(i=N/2;i>=1;i--){
    maxHeapify(A,i);
  }
}



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

int main(){

  int a,b;

  while(scanf("%d %d",&a,&b)!=EOF){ 
    a+=b;
    int c=0;
    while(a){
      c++;
      a/=10;
    }
    printf("%d\n",c);
  }

  return 0;
}

Measured memory_bytes: 1188
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 200000
 
int main(void){
  char input[N];
  char stack[N];
  scanf("%s",input);
  
  int eraseCnt = 0;
  stack[0] = input[0];
  int sCnt,iCnt;
  for(sCnt = 0, iCnt = 1; input[iCnt] != '\0';){
    //printf("%c %c\n",stack[sCnt],input [iCnt]);
    if(stack[sCnt] != input [iCnt]){ //erase
      eraseCnt++;
      if(sCnt == 0){ // stack becomes empty
        stack[sCnt] = input[iCnt+1];
        sCnt = 0;
        iCnt = iCnt + 2;
      }else{ // stack still not empty
        sCnt = sCnt - 1;
        iCnt = iCnt + 1;
      }
    }
    else{ // dont erase
      stack[sCnt+1] = input[iCnt];
      sCnt++;
      iCnt++;
    }
  }
  printf("%d",eraseCnt*2);
  return 0;
}

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

int main() {
	int n;
	std::cin >> n;
	std::vector<int> a(n);
	for(int i = 0; i < n; ++i) 
		std::cin >> a[i];

	int sum = 0;
	for(auto v : a) 
		sum += v;
	int mi = 1e9;
	for(auto v : a)
		mi = std::min(std::abs(v * n - sum), mi);
	for(int i = 0; i < (int)a.size(); ++i)
		if(std::abs(a[i] * n - sum) == mi) {
			std::cout << i << '\n';
			return 0;
		}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, x, y) for (ll i = x; i <= y; i++)
#define BIT(t) (1ll << t)
#define PER(i, y, x) for (ll i = y; i >= x; i--)
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define pll pair<ll, ll>
#define SIZE(v) ll(v.size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
//        ios::sync_with_stdio(false);
//        cin.tie(nullptr);

struct store
{
       ll a; ll b;
       bool operator<(const store& rhs) const {
               return rhs.a * (b + 1) < a * (rhs.b + 1);
       }
};

int main(){
        ll n;
        ll t;
        cin >> n >> t;
        vector<store> v;
        vll itu;
        REP(i,0,n-1){
                ll a,b;
                cin >> a >> b;
                if(a == 0){
                        itu.push_back(b);
                }else{
                        v.push_back({a,b});
                }
        }
        ll iso = v.size();
        
        sort(v.begin(), v.end());
        
        vvll dp(v.size() + 3, vll(100, t+1));
        dp[0][0] = 0;
        REP(i,1,iso){
                REP(k,0,min(i, 99ll)){
                        if(k == 0){
                                dp[i][k] = 0;
                                continue;
                        }
                        ll tmp = dp[i-1][k-1] + 1 + v[i-1].a * (dp[i-1][k-1] + 1) + v[i-1].b;
                        dp[i][k] = min({t+1, dp[i-1][k], tmp});
                }
        }
        sort(itu.begin(), itu.end());
        REP(i,0,SIZE(itu)-1){
                itu[i]++;
        }
        REP(i,1,SIZE(itu)-1){
                itu[i] += itu[i-1];
        }
        ll ans = 0;
        REP(i,0,99){
                if(dp[iso][i] > t){
                        break;
                }
                ll q = upper_bound(itu.begin(), itu.end(), t - dp[iso][i]) - itu.begin();
                ll tmp = i + q;
                ans = max(tmp, ans);
                //cout << i << " " << q << " " << dp[iso][i] << endl;
        }
        cout << ans << endl;
        // REP(i,0,v.size()-1){
        //         cout << v[i].a << " " << v[i].b << endl;
        // }
        //  REP(i,0,6){
        //          REP(j,0,6){
        //                  cout << dp[i][j] << " ";
        //          }
        //          cout << endl;
        //  }

}



Measured memory_bytes: 167404
using System;
using System.Collections.Generic;

namespace Tenka1B
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string S = Console.ReadLine();
            int K = int.Parse(Console.ReadLine());

            List<char> answer = new List<char> { };
            foreach(char c in S)
            {
                if (S[K - 1] == c)
                {
                    answer.Add(S[K - 1]);
                }
                else
                {
                    answer.Add('*');
                }
            }
            string result = string.Join("", answer);
            Console.WriteLine(result);
            //Console.WriteLine(S);
        }
    }
}


Measured memory_bytes: 13268
# -*- coding: utf-8 -*-
from collections import Counter 
import sys

N = int(input())
D = list(map(int, input().split()))
if D[0] != 0:
    print(0)
    sys.exit()
    
mod = 998244353
D.sort()
d = list(Counter(D).items()) 

if d[-1][0] != len(d) - 1:
    print(0)
    sys.exit()
if d[0][1] != 1:
    print(0)
    sys.exit()
ans = 1   
for i in range(1,len(d)):
    for _ in range(d[i][1]):
        ans = ((ans * d[i-1][1]) % mod)
    
print(ans)
    

Measured memory_bytes: 21468
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793


int main(){
    int n; cin >> n;
    vector<int> v(n);
    int ma = 0;
    for(int i = 0; i < n; i++){
        cin >> v[i];
        ma = max(ma, v[i]);
    }
    int ma_cnt = 0;
    int nxt_ma = 0;
    for(auto i: v){
        if(i == ma) ma_cnt++;
        if(i != ma && i > nxt_ma) nxt_ma = i;
    }

    for(int i = 0; i < n; i++){
        if(ma != v[i] || ma_cnt >= 2)
            cout << ma << endl;
        else
            cout << nxt_ma << endl;
    }
}


Measured memory_bytes: 2432
while(1)
n,x=gets.chomp.split(" ").map(&:to_i)
if(n==0&&x==0)
 break
end
####n以下の異なる自然数3つで、合計がxであるものを求める
i3=3
count=0
while(i3<=n)
 i2=2
 while(i2<i3)
  i1=1
  while(i1<i2)
   if(i1+i2+i3==x)
    count=count+1
   end
   i1=i1+1
  end
  i2=i2+1
 end
 i3=i3+1
end
print("#{count}\n")
end


Measured memory_bytes: 6868
#coding:utf-8
def seki(a, b):
    c = []
    gou = 0
    d = []
    for i in range(len(a)):
        for j in range(len(b[0])):
            for k in range(len(b)):
                gou += a[i][k] * b[k][j]

            d.append(gou)
            gou = 0

        c.append(d)
        d=[]
    return c

n, m, l = [int(i) for i in input().rstrip().split()]

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

c = seki(a,b)

for i in c:
    print(" ".join(list(map(str,i))))

Measured memory_bytes: 8892
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	int n, h, w;
	cin >> n >> h >> w;
	int co = 0;
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		if (a >= h && b >= w) {
			co++;
		}
	}
	cout << co << endl;
	return 0;
}

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

int main() {
  string s;
  int cnt = 0, ans = 0;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'R') {
      cnt++;
    } else {
      ans = max(ans, cnt);
      cnt = 0;
    }
    if (i == s.size() - 1) ans = max(ans, cnt);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3628