akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<int, int, ll> T;

int N;
vector<int> x(101, 0);
vector<int> y(101, 0);
vector<ll> h(101, 0);

int main(void){
    
	scanf("%d", &N);
	for(int i = 0; i < N; ++i) scanf("%d %d %lld", &x[i], &y[i], &h[i]);
	
	int xmx = *max_element(x.begin(), x.begin() + N), xmn = *min_element(x.begin(), x.begin() + N);
	int ymx = *max_element(y.begin(), y.begin() + N), ymn = *min_element(y.begin(), y.begin() + N);
	
	vector<T> v;
	for(int i = xmn; i <= xmx; ++i){
	    for(int j = ymn; j <= ymx; ++j){
	        for(int k = 0; k < N; ++k){
	            v.push_back(make_tuple(i, j, h[k] + abs(i - x[k]) + abs(j - y[k])));
	        }
	    }
	}
	
	for(int i = 0; i < v.size(); ++i){
	    int a, b; ll c; tie(a, b, c) = v[i];
	    int cnt = 0;
	    for(int j = 0; j < N; ++j){
	        
	        if(h[j] == max(c - abs(x[j] - a) - abs(y[j] - b), (ll)0)) ++cnt;
	    }
	    if(cnt == N) { printf("%d %d %lld\n", a, b, c); return 0; }
	}
	
    return 0;
}


Measured memory_bytes: 18668
// Create your own template by modifying this file!
#include <string>
#include <vector>
#include <climits>
#include <cstring>
#include <map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cassert>
#include <deque>
#include <stack>
#include <functional>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB emplace_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x;  }
void _R(int &x) { scanf("%d", &x);  }
void _R(int64_t &x) { scanf("%lld", &x);  }
void _R(double &x) { scanf("%lf", &x);  }
void _R(char &x) { scanf(" %c", &x);  }
void _R(char *x) { scanf("%s", x);  }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...);  }
template<class T> void _W(const T &x) { cout << x;  }
void _W(const int &x) { printf("%d", x);  }
void _W(const int64_t &x) { printf("%lld", x);  }
void _W(const double &x) { printf("%.16f", x);  }
void _W(const char &x) { putchar(x);  }
void _W(const char *x) { printf("%s", x);  }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' ');  }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...);  }
#ifdef DEBUG
 #define debug(...) {printf("[DEBUG] ");W(__VA_ARGS__);}
#else
 #define debug(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1<<20;
template<class T> void MIN(T& a, const T& b) { a = min(a, b); }
template<class T> void MAX(T& a, const T& b) { a = max(a, b); }

#include <atcoder/all>

using namespace atcoder;

void solve() {
    int N, M;
    R(N, M);
    VI a(N), b(M);
    REP(i, N) {
        R(a[i]);
    }
    REP(j, M) {
        R(b[j]);
    }
    W(convolution(a, b));
}

int main() {
#if MULTITEST    
    CASET{
        solve();
    }
#else
    solve();
#endif
    return 0;
}


Measured memory_bytes: 19020
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
using namespace std;
#define INF 1000000007
#define LINF 8000000000000000007
#define MOD 1000000007
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout << #X << ": " << X << " ";
#define ARDEB(i, X) cout << #X << "[" << i << "]: " << X[i] << " ";
#define END cout << endl;
#else
#define DEB(X) \
    {          \
    }
#define ARDEB(i, X) \
    {               \
    }
#define END \
    {       \
    }
#endif
typedef pair<int, int> P;
struct edge{int to,cost;};

typedef long long ll;

using namespace std;


int ans,ans2;
int n,a[111111],b[111111];

signed main(){

	cin>>n;
	rep(i,n+1)cin>>a[i];
	rep(i,n)cin>>b[i];
	rep(i,n){
		if(b[i]>a[i]){
			ans+=a[i];
			b[i]-=a[i];
			a[i]=0;
			if(b[i]>a[i+1]){
				ans+=a[i+1];
				b[i]-=a[i+1];
				a[i+1]=0;
			}
			else{
				ans+=b[i];
				a[i+1]-=b[i];
				b[i]=0;
			}
		}
		else{
			ans+=b[i];
			b[i]=0;
		}
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 1792
MOD = (10**9) + 7
ONE = '1'.freeze

def nCk(n, k)
  (fact(k + 1, n) * inv(fact(1, n - k) % MOD)) % MOD
end

def fact(s, e)
  (s..e).reduce(1) { |r, i| (r * i) % MOD }
end

def inv(x)
  res = 1
  beki = x
  (MOD - 2).to_s(2).reverse.chars do |digest|
    res = (beki * res) % MOD if digest == ONE
    beki = (beki * beki) % MOD
  end
  res
end

x, y = gets.chomp.split.map(&:to_i)

min, max = [x, y].sort

# min,maxのdiff回多く片方の遷移をしている。
diff = max - min
d_min = min - diff
if !(d_min >= 0 && d_min == max - 2 * diff && (d_min % 3).zero?)
  puts 0
else
  a = b = d_min / 3
  a += diff
  puts nCk(a + b, b)
end


Measured memory_bytes: 3836
//////////////////////////
//////////////////////////
////Please give me AC!////
////Please give me AC!////
//////////////////////////
//////////////////////////
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
const int MOD=1e9+7;
const long double Pi=acos(-1);
using  P=pair<ll,ll>;
ll gcd(ll a,ll b){//aとbの最大公約数を返す
  if(a%b==0){return b;}
  else{return gcd(b,a%b);}
}
ll lcm(ll a,ll b){//aとbの最小公倍数を返す
  return a*b/gcd(a,b);
}
ll pow(ll x,ll y){//x^yを返す
  ll tmp=x,res=1;
  while(y){
    if(y%2){res=res*tmp%MOD;}
    y>>=1;
    tmp=tmp*tmp%MOD;
  }
  return res;
}
ll nature(ll a){//絶対値を返す
  if(a>=0){return(a);}
  else{return(-1*a);}
}
ll prime(ll a){//素数なら1を返す
  if(a==2){return 1;}
  else if(a%2==0 || a==1){return 0;}
  for(ll i=3;i*i<=a;i+=2){if(a%i==0){return 0;}}
  return 1;
}
int main(){
  ll N;
  cin>>N;
  if(N==1){cout<<1<<endl;return 0;}
  unordered_map<ll,ll> mp;
  vector<ll> A(N);
  ll maxa=0;
  ll c=0;
  ll ans=0;
  vector<map<ll,ll>> vec(N);
  for(ll i=0;i<N;i++){
    cin>>A.at(i);
    mp[A.at(i)]++;
    if(i>0 && A.at(i)==A.at(i-1)){c++;}
    if(maxa<A.at(i)){maxa=A.at(i);}
  }
  if(c==N-1){cout<<0<<endl;return 0;}
  //cout<<mp[11]<<endl;
  //cout<<maxa<<endl;
  //cout<<mp[4]<<" "<<mp[5]<<endl;
  if(mp[1]==1){cout<<1<<endl;return 0;}
  if(mp[1]>1){cout<<0<<endl;return 0;}
  sort(A.begin(),A.end());
  for(ll i=0;i<N;i++){
    ll a=A.at(i);
    if(mp[A.at(i)]>1){mp[A.at(i)]=0;}
    for(ll j=2;j*a<=maxa;j++){
      if(mp[j*a]>0){mp[j*a]=0;}
    }
  }
  for(ll i=2;i<=maxa;i++){
    if(mp[i]>0){ans++;}
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 53548
#include "bits/stdc++.h"
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
#define int long long 
int F[2100010];

int Mul(int a, int b) {
	return ((a % mod) * (b % mod)) % mod;
}

int fact(void) {
	F[0] = 1;
	F[1] = 1;
	for (int i = 2; i <= 2100000; i++) {
		F[i] = Mul(i, F[i - 1]);
	}
}
int square(int x) {
	return (x * x) % mod;
}

int power(int x, int y) {
	if (y == 0) return 1;
	else if (y == 1) return x % mod;
	else if (y % 2 == 0) return square(power(x, y / 2)) % mod;
	else return square(power(x, y / 2)) * x % mod;
}

int Div(int a, int b) {
	return Mul(a, power(b, mod - 2));
}
int P(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	return Div(F[n], F[n - r]);
}

int C(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	int ret;
	ret = Div(F[n], Mul(F[n - r], F[r]));
	return ret;
}
int H(int n, int r) {
	if (n == 0 && r == 0) return 1;
	return C(n + r - 1, r);
}
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    fact();
    int N, M; cin >> N >> M;
    vector<int> v;
    REP(i, 2, 40000) {
        int tmp = 0;
        while (M % i == 0) {
            tmp++;
            M /= i;
        }
        if (tmp != 0) {
            v.push_back(tmp);
        }
    }
    if (M != 1) v.push_back(1);
    int ans = 1;
    rep(i, v.size()) {
        ans *= H(N, v[i]);
        ans %= mod;
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 16640
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int h, w;

void solve(){
    int a[h][w];
    rep(i, h)rep(j, w) scanf("%d", &a[i][j]);
    int ans = 0;
    rep(u, h)For(d, u + 2, h)rep(l, w)For(r, l + 2, w){
        int min_h = mod;
        For(i, u, d + 1){
            chmin(min_h, a[i][l]);
            chmin(min_h, a[i][r]);
        }
        For(j, l, r + 1){
            chmin(min_h, a[u][j]);
            chmin(min_h, a[d][j]);
        }

        int tmp = 0;
        For(x, u + 1, d){
            For(y, l + 1, r){
                if(a[x][y] >= min_h){
                    tmp = -1;
                    break;
                }
                tmp += min_h - a[x][y];
            }
            if(tmp < 0) break;
        }
        chmax(ans, tmp);
    }
    printf("%d\n", ans);
}

int main(){
    while(scanf("%d%d", &h, &w) && h){
        solve();
    }
}


Measured memory_bytes: 3212
#include <iostream>
#include <cstdio>

using namespace std;
typedef long long LL;
const int MAXN = 1e6 + 8;


int main()
{
    #ifdef LOCAL
    freopen("a.txt", "r", stdin);
    //freopen("a.out", "w", stdout);
    int T = 4;
    while(T--){
    #endif // LOCAL
    ios::sync_with_stdio(false); cin.tie(0);

    LL x, y, i;
    cin >> x >> y;
    if(x % y == 0) cout << -1 << endl;
    else cout << x << endl;



    #ifdef LOCAL
    cout << endl;
    }
    #endif // LOCAL
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

int main()
{
	int H,W;
	char S[2010][2010]={};

	cin >> H >> W;
	for(int i=1;i<=H;i++)
		for(int j=1;j<=W;j++)
			cin >> S[i][j];
	
	int up[2010][2010]={};
	int down[2010][2010]={};
	int left[2010][2010]={};
	int right[2010][2010]={};

	for(int i=1;i<=H;i++)
	{
		for(int j=1;j<=W;j++)
		{
			if(S[i][j]=='#')
				left[i][j]=0;
			else
				left[i][j]=left[i][j-1]+1;
		}
	}
	for(int i=1;i<=H;i++)
	{
		for(int j=W;j>=1;j--)
		{
			if(S[i][j]=='#')
				right[i][j]=0;
			else
				right[i][j]=right[i][j+1]+1;
		}
	}
	for(int i=1;i<=H;i++)
	{
		for(int j=1;j<=W;j++)
		{
			if(S[i][j]=='#')
				up[i][j]=0;
			else
				up[i][j]=up[i-1][j]+1;
		}
	}
	for(int i=H;i>=1;i--)
	{
		for(int j=1;j<=W;j++)
		{
			if(S[i][j]=='#')
				down[i][j]=0;
			else
				down[i][j]=down[i+1][j]+1;
		}
	}

	int ans=0;
	for(int i=1;i<=H;i++)
		for(int j=1;j<=W;j++)
			ans=max(ans,up[i][j]+down[i][j]+left[i][j]+right[i][j]-3);

	cout << ans << endl;
	return 0;
}



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

int main() {
   string s;
   cin >> s;
   int n = s.size() - 1;

   ll sum = 0;
   for(int bit = 0; bit < (1<<n); bit++) {
      ll t = s[0] - '0';
      rep(i, n) {
         if ((bit >> i) & 1) {
            sum += t;
            t = s[i+1] - '0';
         } else {
            t *= 10;
            t += s[i+1] - '0';
         }
      }
      sum += t;
   }

   cout << sum << endl;

   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize(3,"Ofast","inline")
using namespace std;
int n,dp[2003][2003],a[6003],ans,tg,MX[2003],cur;
int A[100004],B[100004],C[100004],t;
void init(){t=0;}
void add(int x,int y,int z){A[t]=x,B[t]=y,C[t++]=z;}
int main(){
	cin>>n;
	for(int i=1;i<=3*n;i++)cin>>a[i]; 
	dp[a[1]][a[2]]=dp[a[2]][a[1]]=MX[a[1]]=MX[a[2]]=cur=1;
	for(int i=3;i<3*n;i+=3){
		if(a[i]==a[i+1]&&a[i]==a[i+2]){tg++;continue;}
		init();
		if(a[i]>a[i+1])swap(a[i],a[i+1]);
		if(a[i+1]>a[i+2])swap(a[i+1],a[i+2]);
		if(a[i]>a[i+1])swap(a[i],a[i+1]);
		for(int j=1;j<=n;j++){
		if(a[i]==a[i+1])if(dp[j][a[i]]>0)add(j,a[i+2],dp[j][a[i]]+1);
		if(a[i+1]==a[i+2])if(dp[j][a[i+1]]>0)add(j,a[i],dp[j][a[i+1]]+1);
		}
		if(dp[a[i]][a[i]]>0)add(a[i+1],a[i+2],dp[a[i]][a[i]]+1);
		if(dp[a[i+1]][a[i+1]]>0)add(a[i],a[i+2],dp[a[i+1]][a[i+1]]+1);
		if(dp[a[i+2]][a[i+2]]>0)add(a[i],a[i+1],dp[a[i+2]][a[i+2]]+1);
		add(a[i],a[i+1],cur),add(a[i+1],a[i+2],cur),add(a[i],a[i+2],cur);
		for(int j=i;j<i+3;j++)for(int k=1;k<=n;k++)if(MX[k]>0)add(a[j],k,MX[k]);
		for(int j=0;j<t;j++)if(dp[A[j]][B[j]]<C[j])
			dp[A[j]][B[j]]=dp[B[j]][A[j]]=C[j],MX[A[j]]=max(MX[A[j]],C[j]),MX[B[j]]=max(MX[B[j]],C[j]),cur=max(cur,C[j]);
	}
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++)if(dp[i][j]>0)ans=max(ans,dp[i][j]-1);
		if(dp[i][i]>0)if(i==a[3*n])ans=max(ans,dp[i][i]);
	}
	printf("%d",ans+tg);
}


Measured memory_bytes: 19008
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);cout.precision(20);}} fast;

/* define */
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) (upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X))
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int,int>;
using pl = pair<long long,long long>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1,0,-1,0};
const long long dy[] = {0,1,0,-1};
const long long dx8[] = {1,1,0,-1,-1,-1,0,1};
const long long dy8[] = {0,1,1,1,0,-1,-1,-1};
const long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};
const long long dy9[] = {0,1,1,1,0,-1,-1,-1,0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
long long max(long long x,int y){return max(x,(long long)y);}
long long max(int x,long long y){return max((long long)x,y);}
long long min(long long x,int y){return min(x,(long long)y);}
long long min(int x,long long y){return min((long long)x,y);}

/* liblary */



/* main */

signed main(){
	string A;
	cin >> A;
	//DP[i][j] = A.substr(i)の文字j+'a'からはじめたときの最短の文字数
	int DP[A.size()][26];
	int tmp[26];
	FOR(i,0,26)tmp[i] = 1;
	REP(i,0,A.size()){
		FOR(j,0,26){
			if(A[i]-'a' == j){
				DP[i][j] = 1 + *min_element(tmp,tmp+26);
			}
			else{
				DP[i][j] = tmp[j];
			}
		}
		FOR(j,0,26)tmp[j] = DP[i][j];
	}
	int ans = *min_element(DP[0],DP[0]+26);
	int idx = 0;
	while(ans && idx < A.size()){
		int MIN = *min_element(DP[idx],DP[idx]+26);
		char tmp;
		FOR(i,0,26){
			if(DP[idx][i] == MIN){
				tmp = i + 'a';
				break;
			}
		}
		cout << tmp;
		while(tmp != A[idx] && idx < A.size())idx++;
		idx++;
		ans--;
	}
	cout << endl;
}

Measured memory_bytes: 20884
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def solve(inp):
    S = inp.readline().strip()

    for i in range(0, len(S), 2):
        if S[i:i + 2] != "hi":
            return "No"
    return "Yes"


def main():
    import sys
    result = solve(sys.stdin)
    if result is not None and result != '':
        print(result)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
typedef   long long int ll;
typedef unsigned long long int sll;
typedef  double ld;
#define A 1000000007ll
#define B 998244353ll
#define C 1000000000000000000ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI 3.1415926535

ll dp[3005][3005];

int main() 
{
    FAST;
    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    if(n%2==0)
        for(int i=0;i<n;i++)
            dp[i][i]=-a[i];
    else
        for(int i=0;i<n;i++)
            dp[i][i]=a[i];
    for(int i=1;i<n;i++)
    {
        if((i+1+n)%2==0)
            for(int j=0,k=i;j<n && k<n;j++,k++)
                dp[j][k]=max(dp[j+1][k]+a[j],dp[j][k-1]+a[k]);
        else
            for(int j=0,k=i;j<n && k<n;j++,k++)
                dp[j][k]=min(dp[j+1][k]-a[j],dp[j][k-1]-a[k]);
    }
    cout<<dp[0][n-1];
    return 0;
}

Measured memory_bytes: 70016
a = []
a = input().split()
N = int(a[0])
K = int(a[1])
Q = int(a[2])

A = []
for i in range(Q) :
  A.append(int(input()))

point = [K-Q for i in range(N)]

for i in range(Q) :
  point[A[i]-1] = point[A[i]-1] + 1

for i in range(N) :
  if point[i] > 0 :
    print('Yes')
  else :
    print('No')


Measured memory_bytes: 11840
#include <bits/stdc++.h>
using namespace std;
vector<string> state(string b,string a){
    vector<string> vs;
    string br,ar;
    br=b;
    reverse(br.begin(),br.end());
    ar=a;
    reverse(ar.begin(),ar.end());
    vs.push_back(b+a);
    vs.push_back(br+a);
    vs.push_back(b+ar);
    vs.push_back(br+ar);
    vs.push_back(a+b);
    vs.push_back(ar+b);
    vs.push_back(a+br);
    vs.push_back(ar+br);
    return vs;
}

void solve(string s){
    set<string> ss;
    vector<string> vs;
    string b,a;
    for(int i=1;i<s.size();i++){
        b=s.substr(0,i);
        a=s.substr(i,s.size());
        vs=state(b,a);
        for(string x:vs){
            ss.insert(x);
        }
    }
    cout<<ss.size()<<endl;
}


int main(void){
    int n;
    string s;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s;
        solve(s);
    }
}



Measured memory_bytes: 3148
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    h1,m1,h2,m2,k = LI()
    m1 += h1 * 60
    m2 += h2 * 60

    return m2 - m1 - k

print(main())





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

#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define MOD 1000000007

#define trace1(x)                    cout <<#x<<": "<<x<< endl;
#define trace2(x, y)                 cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)              cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)           cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;

typedef long long ll;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    ll i,j,n,m;
    cin>>n;
    vector<pair<ll,ll> > v;
    for(i=0;i<n;i++)
    {
        ll x,y;
        cin>>x>>y;
        v.pb(mp(y,x));
    }
    sort(all(v));
    ll pos=1;
    ll tot=0;
    for(i=0;i<n;i++)
    {
        tot+=v[i].Y;
        if(tot>v[i].X)
        pos=0;
    }
    if(pos)
    cout<<"Yes";
    else
    cout<<"No";
    return 0;
}

Measured memory_bytes: 6512
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::str::*;
#[allow(unused_imports)]
use std::mem::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::HashMap;
#[allow(unused_imports)]
use std::collections::VecDeque;
#[allow(unused_imports)]
use std::usize;

#[allow(unused_macros)]
macro_rules! read_cols {
    ($($t:ty),+) => {{
        let mut line = String::new();
        stdin().read_line(&mut line).unwrap();

        let mut it = line.trim()
            .split_whitespace();
        
        ($(
            it.next().unwrap().parse::<$t>().ok().unwrap()
        ),+)
    }}
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let mut line = String::new();
    stdin().read_line(&mut line).unwrap();
    line.trim().to_string().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: FromStr>() -> Vec<T> {
    let mut line = String::new();
    stdin().read_line(&mut line).unwrap();

    line.trim()
        .split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}

fn main() {
    let n = read::<usize>();
    let pos = read_vec::<i64>();

    assert_eq!(pos.len(), n);

    let travel_pos = {
        let mut travel_pos = vec![0];
        travel_pos.append(&mut pos.clone());
        travel_pos.push(0 as i64);
        travel_pos
    };

    let total_cost = travel_pos.iter().skip(1).scan(0, |current, &x| {
        let cost = (*current - x).abs();
        *current = x;
        Some(cost)
    }).sum::<i64>();

    for i in 0 .. n {
        let prev = travel_pos[i];
        let p = travel_pos[i + 1];
        let next = travel_pos[i + 2];
        let cost = total_cost - (prev - p).abs() - (p - next).abs() + (prev - next).abs();
        println!("{}", cost);
    }

}

Measured memory_bytes: 9340
#include <iostream>
#include <string>
#include <vector>
#include <cmath>

using namespace std;
int main()
{
    string  S;

    cin >> S;

    if (S[2] == S[3] && S[4] == S[5]) {
        cout << "Yes" << endl;
    }

    else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define il inline
#define sz(x) x.size()
#define maxn 100010
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll min(ll a,ll b){if(a<b)return a;else return b;}
ll lowbit(ll x){return x&(-x);}
ll prime(ll x){
   if(x<=1)return false;
   for(int i=2;i<=int(sqrt(x));i++){
	   if(x%i==0)return false;
   }return true;
}
bool cmp(ll a,ll b){return a>b;}
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline ll read() {
	char c = getchar(); ll w = 1; ll x = 0;
	while (!isdigit(c))
		(c == '-') && (w = -w), c = getchar();
	while (isdigit(c))
		x = (x << 1) + (x << 3) + (c ^ '0'), c = getchar();
	x *= w;
}
void fl(string name){
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
		  dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};
long long n, m, k;
 
signed main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	cin>>n>>m>>k;
	if (n <= k) 
	{
		k = k - n, printf("0 ");
		printf("%lld\n", max(1ll * 0, m - k));
	}
	else 
	{
		printf("%lld %lld\n", n - k, m);
	}
	return 0;
}




Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long LL;
const int maxn = 100005;
inline int getint() {
	register int r = 0; register bool b = true; register char c = getchar();
	while (c < '0' || c > '9') { if (c == '-') b = false; c = getchar(); }
	while (c >= '0' && c <= '9') { r = (r<<1)+(r<<3) + c - '0'; c = getchar(); }
	return b ? r : -r;
}
struct edge_t { int u, v; LL w; } e[maxn * 2];
struct data_t { int x, y, id; } a[maxn];
bool cmpxy(data_t a, data_t b) {
	if (a.x == b.x) return a.y < b.y;
	return a.x < b.x;
}
bool cmpyx(data_t a, data_t b) {
	if (a.y == b.y) return a.x < b.x;
	return a.y < b.y;
}
LL ans;
int f[maxn], n, cnte;
int Find(int x) { return f[x] == x ? x : f[x] = Find(f[x]); }
void ins(int x, int y, LL w) { ++cnte; e[cnte].u = x; e[cnte].v = y; e[cnte].w = w; }
bool mer(int x, int y) {
	int a = Find(x), b = Find(y);
	if (a == b) return false;
	f[a] = b; return true;
}
bool cmpw(edge_t a, edge_t b) { return a.w < b.w; }
int main() {
	n = getint();
	for (int i = 1; i <= n; ++i) { a[i].x = getint(); a[i].y = getint(); a[i].id = i; f[i] = i; }
	sort(a + 1, a + n + 1, cmpxy); for (int i = 1; i < n; ++i) ins(a[i].id, a[i+1].id, min(abs(a[i].x - a[i+1].x), abs(a[i].y - a[i+1].y)));
	sort(a + 1, a + n + 1, cmpyx); for (int i = 1; i < n; ++i) ins(a[i].id, a[i+1].id, min(abs(a[i].x - a[i+1].x), abs(a[i].y - a[i+1].y)));
	sort(e + 1, e + cnte + 1, cmpw);
	for (int i = 1; i <= cnte; ++i) if (mer(e[i].u, e[i].v)) ans += e[i].w;
	printf("%lld\n", ans);
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;

// fatorial.cpp depend on this.
#ifndef MOD_INT
#define MOD_INT
template<int mod>
struct ModInt{
	private:
		int x;

	public:
		ModInt() : x(0){}
		ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod){}
	
		ModInt &operator+=(const ModInt &p){
			if((x += p.x) >= mod) x -= mod;
			return *this;
		}
		ModInt &operator-=(const ModInt &p){
			if((x += mod - p.x) >= mod) x -= mod;
			return *this;
		}
		ModInt &operator*=(const ModInt &p){
			x = (int) (1LL * x * p.x % mod);
			return *this;
		}
		ModInt &operator/=(const ModInt &p){
			*this *= p.inverse();
			return *this;
		}
	
		ModInt operator-() const {return ModInt(-x);}
		ModInt operator+(const ModInt &p) const {return ModInt(*this) += p;}
		ModInt operator-(const ModInt &p) const {return ModInt(*this) -= p;}
		ModInt operator*(const ModInt &p) const {return ModInt(*this) *= p;}
		ModInt operator/(const ModInt &p) const {return ModInt(*this) /= p;}
		bool operator==(const ModInt &p) const {return x == p.x;}
		bool operator!=(const ModInt &p) const {return x != p.x;}
	
		template<typename T>
		operator T() const {return (T)x;}
	
		ModInt inverse() const {
			int a = x, b = mod, u = 1, v = 0, t;
			while(b > 0) {
				t = a / b;
				swap(a -= t * b, b);
				swap(u -= t * v, v);
			}
			return ModInt(u);
		}
	
		ModInt pow(int64_t n) const {
			ModInt ret(1), mul(x);
			while(n > 0) {
				if(n & 1) ret *= mul;
				mul *= mul;
				n >>= 1;
			}
			return ret;
		}
	
		friend ostream &operator<<(ostream &os, const ModInt &p){
			return os << p.x;
		}
	
		friend istream &operator>>(istream &is, ModInt &a){
			int64_t t;
			is >> t;
			a = ModInt< mod >(t);
			return (is);
		}
	
		static int get_mod(){return mod;}
};

using mint = ModInt<MOD>;
#endif


int main(void){
	int N, M;
	cin >> N >> M;
	vector<bool> available(N+2, true);
	for(int i = 0; i < M; i++){
		int a;
		cin >> a;
		available[a] = false;
	}

	vector<mint> vec(N+2, 0);
	vec[0] = 1;

	for(int i = 0; i < N; i++){
		if(available[i+1]) vec[i+1] += vec[i];
		if(available[i+2]) vec[i+2] += vec[i];
	}

	cout << vec[N] << '\n';

	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pb push_back
using namespace std;
ll n,k,ans,mod = 1000000007,a[20005];
ll m[20005],f[20005];
int main(){
    cin >> n >> k;
    
    for(int i=1; i<=n; i++){
        cin >> a[i];
        for(int j=1; j<i; j++){
            if(a[i] < a[j])
                m[i]++;
            if(a[i] > a[j])
                f[j]++;
        }
    }
    
    for(int i=1; i<=n; i++){
        ans += m[i] * ((k * (k + 1)) / 2 % mod);
        ans %= mod;
        k--;
        ans += f[i] * ((k * (k + 1)) / 2 % mod);
        ans %= mod;
        k++;
    }
    
    cout << ans;
    
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

int main()
{
	int n; cin >> n;
	vi v(n), es(n);
	REP(i, n) cin >> v[i];
	int tmp = 0;
	REP(i, n)
	{
		tmp--;
		if (v[i] == 0) tmp = INF;
		else if (v[i] < 0) chmin(tmp, -v[i]);
		else chmax(es[i], tmp);
	}
	tmp = 0;
	for (int i = n - 1; i >= 0; i--)
	{
		tmp--;
		if (v[i] == 0) tmp = INF;
		else if (v[i] < 0) chmin(tmp, -v[i]);
		else chmax(es[i], tmp);
	}
	ll ans = 0;
	REP(i, n) if (v[i]>0) ans += min(es[i], v[i]);
	cout << ans << endl;
	return 0;
}

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

int main(void){
	//--setup
	int N,M; cin>>N>>M;
	char SS[N+1];
	for(int i=N;i>=0;i--)cin>>SS[i];
	int S[N+1];
	for(int i=N;i>=0;i--)S[i]=SS[i]-'0';//reverse
	//----------
	vector<int> pips;
	for(int mySpace=0;mySpace<N;){
		//**/cout << "in:"<<mySpace<< " ";
		for(int pip=M;pip>0;pip--){
			if( mySpace+pip<=N&&S[mySpace+pip]==0 ){
				mySpace+=pip;
				//**/cout<<"pip: "<<pip;
				pips.push_back(pip);
				break;
			}
			if( mySpace==N )break;
			//no pip----------
			if( pip==1 ){
				cout << "-1" << endl;
				return 0;
			}
			//---------------
		}
	}
	for(int i=pips.size()-1;i>=0;i--)
		cout<<pips[i]<<" ";
	cout << endl;
	return 0;
}


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

using namespace std;

int n, a[100005], mk[100005];

int main()
{
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    sort(a + 1, a + n + 1);
    if (n % 3 == 0)
    {
        if (a[n / 3] == a[1] && a[n / 3 * 2] == a[n / 3 + 1] && a[n] == a[n / 3 * 2 + 1] && (a[1] ^ a[n / 2 + 1]) == a[n]) cout << "Yes" << endl;
        else cout <<  "No" << endl;
    }
    else
    {
        if (a[n] == 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 640
n = int(input())


def prime(n):
    if n == 1:
        n += 1
    while True:
        flag = 0
        for k in range(2, int(n**0.5) + 1):
            if n % k == 0:
                flag = 1
                break
        if flag == 0:
            return n
        n += 1


ans = prime(n)
print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int n;
    cin >> n;
    vector<int> arr(n, 0);
    for(int i = 0; i < n; i++)
        cin >> arr[i];
    int ans = 0;
    for(int i = 1; i < n-1; i++) {
        if (arr[i] > arr[i-1] && arr[i+1] > arr[i])
            ans += 1;
        else if (arr[i] < arr[i-1] && arr[i+1] <arr[i])
            ans += 1;
    }
    cout << ans << endl;
    return 0;
}



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

// * Shortcut

#define sort(s) sort(s.begin(), s.end());
#define ll long long
#define real long double

// * Constant
const ll mod = 1E9 + 7;
const ll fftmod = 998244353;
const ll inf = LONG_LONG_MAX;
const ll n_inf = LONG_LONG_MIN;

using namespace std;

bool prime(ll x)
{
	if (x < 2)
	{
		return false;
	}
	else if (x > 2)
	{
		if (x % 2 == 0)
			return false;
		else
		{
			for (ll i = 3; i <= sqrt(x); i += 2)
			{
				if (x % i == 0)
					return false;
			}
		}
	}
	return true;
}

bool vowel(char ch)
{
	ch = tolower(ch);
	return (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u' || ch == 'y');
}

ll fact(ll n)
{
	if (n == 0 || n == 1)
		return 1;
	else
		return n * fact(n - 1);
}

ll C(ll n, ll r)
{
	if (r == 0)
		return 1;
	if (n < r)
		return 0;

	/*
     Extra computation saving for large R,
     using property:
     N choose R = N choose (N-R)
    */
	if (r > n / 2)
		return C(n, n - r);

	double res = 1;

	for (int k = 1; k <= r; ++k)
	{
		res *= n - k + 1;
		res /= k;
	}

	return (ll)(res);
}

//  Variable

// ? Problem Local Function

ll fib(int n)
{
	long long p1 = 1, p2 = 1, ans;
	if (n <= 2)
		return 1;
	else
	{
		for (int i = 3; i <= n; i++)
		{
			ans = p1 + p2;
			p1 = p2;
			p2 = ans;
		}
	}
	return ans;
}

ll calls(int n)
{
	vector<ll> c;
	c.push_back(0);
	c.push_back(0);
	c.push_back(2);
	for (int i = 3; i <= n; i++)
	{
		c.push_back(c[i - 1] + c[i - 2] + 2);
	}
	return c[n];
}

vector<ll> cnt(100007, 0);

int main()
{
	freopen("submit.err", "w+", stderr);
	ll n, ans = 0;
	cin >> n;
	for (ll i = 0; i < n; i++)
	{
		ll x;
		cin >> x;
		if (x > 100000)
			ans++;
		else
		{
			cnt[x]++;
		}
	}
	for (ll i = 1; i < 100007; i++)
	{
		if (cnt[i] < i)
		{
			ans += cnt[i];
		}
		else
		{
			ans += cnt[i] - i;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
k, s = map(int, input().split())
xmin=0
xmax=0
if k>=s:
    xmin=0
    xmax=s
else:
    xmin=max(0,s-2*k)
    xmax=k
xs=[]
for i in range(xmin, xmax+1):
    xs.append(i)
#print(xs)
ymin=0
ymax=0
res=0
for i in xs:
    ymin=max(0,s-i-k)
    ymax=min(s-i,k)
    res+=ymax-ymin+1
    #print(str(ymax-ymin+1)+" for x="+str(i))
print(res)

Measured memory_bytes: 3064
//Range Search
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

static const int NIL = -1;
static const int MAX = 1000000;

class Point {
public:
    int id, x, y;
    Point() {}
    Point(int id, int x, int y): id(id), x(x), y(y) {}
    bool operator < ( const Point &p) const {
        return id < p.id;
    }
    void print() {
        printf("%d\n", id);
    }
};

bool lessX(const Point &p1, const Point &p2) {return p1.x < p2.x;}
bool lessY(const Point &p1, const Point &p2) {return p1.y < p2.y;}

int n;
Point P[MAX];

struct Node {
public:
    int location = NIL;
    Node * p = nullptr, * l = nullptr, * r = nullptr;
};

class Tree {
public:
    Node * root;
    Tree();
    Node * make2DTree(int l, int r, int depth);
    void find(Node * node, int sx, int tx, int sy, int ty, int depth, vector<Point> &ans);
};

Tree::Tree() {
    root = make2DTree(0, n, 0);
}

Node * Tree::make2DTree(int l, int r, int depth) {
    if(l >= r) return nullptr;
    int mid = (l + r) / 2;
    if(depth % 2 == 0) sort(P + l, P + r, lessX);
    else sort(P + l, P + r, lessY);

    auto node = new Node;
    node -> location = mid;
    node -> l = make2DTree(l, mid, depth + 1);
    node -> r = make2DTree(mid + 1, r, depth + 1);
    return node;
}

void Tree::find(Node * node, int sx, int tx, int sy, int ty, int depth, vector<Point> &ans) {
    int x = P[node -> location].x;
    int y = P[node -> location].y;
    if(sx <= x && x <= tx && sy <= y && y <= ty) ans.push_back(P[node -> location]);
    if(depth % 2 == 0) {
        if(node -> l != nullptr && sx <= P[node -> location].x) find(node -> l, sx,tx, sy, ty, depth + 1, ans);
        if(node -> r != nullptr && P[node -> location].x <= tx) find(node -> r, sx,tx, sy, ty, depth + 1, ans);
    }
    else if(depth % 2 != 0) {
        if(node -> l != nullptr && sy <= P[node -> location].y) find(node -> l, sx,tx, sy, ty, depth + 1, ans);
        if(node -> r != nullptr && P[node -> location].y <= ty) find(node -> r, sx,tx, sy, ty, depth + 1, ans);
    }
}

int main() {
    int q, x, y, sx, tx, sy, ty;
    scanf("%d", &n);
    for(int i = 0; i < n; i++) {
        scanf("%d %d", &x, &y);
        P[i].id = i;
        P[i].x = x;
        P[i].y = y;
    }
    Tree T;

    scanf("%d", &q);
    vector<Point> ans;
    for(int i = 0; i < q; i++) {
        scanf("%d %d %d %d", &sx, &tx, &sy, &ty);
        ans.clear();
        T.find(T.root, sx, tx, sy, ty, 0, ans);
        sort(ans.begin(), ans.end());
        for(auto a: ans) {
            a.print();
        }
        cout << endl;
    }
}


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

vector<pair<long long,long long>> prime_factorize(long long n){
    vector<pair<long long,long long>> res;
    for(long long p=2;p*p<=n;++p){
        if(n%p!=0) continue;
        int num=0;
        while(n%p==0){
            n/=p;
            ++num;
        }
        res.push_back(make_pair(p,num));
    }
    if(n!=1) res.push_back(make_pair(n,1));
    return res;
}

int main(){
    long long n;
    cin>>n;
    auto a=prime_factorize(n);
    
    long long ans=0;
    for(auto tp:a){
        long long cnt=tp.second;
        long long temp=0, cur=1;
        while(cnt>=cur) cnt-=cur++, ++temp;
        ans+=temp;
    }

    cout<<ans<<endl;
}

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

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

    vector<int> data(N);
    for(int i = 0; i < N; i++){
        int tmp; cin >> tmp;
        data[i] = tmp;
    }
    sort(data.begin(), data.end());
    int kankaku_max = 0;

    for(int i = 0; i < N-1; i++){
        int tmp = data[i+1] - data[i];
        kankaku_max = max(kankaku_max, tmp);
    }
    int tmp_a = (K - data[N-1]) + data[0];
    kankaku_max = max(kankaku_max, tmp_a);

    int ans = K - kankaku_max;
    cout << ans << endl;
}

Measured memory_bytes: 1024
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimize ("Ofast")
#pragma GCC optimize("unroll-loops")


using namespace std;

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

const ll INF = 1000000010;
const ll LOG = 25;
const int N = 2000 + 10;
int MOD;

int mul(int a, int b){
	return (a * 1ll * b) % MOD;
}

int add(int a, int b){
	a += b;
	a %= MOD;
	return a;
}

int dp[3 * N][3 * N], n;

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> MOD;
	dp[0][0] = 1;
	for (int i = 1; i <= 3 * n; i++){
		for (int j = 0; j <= i / 2; j++){
			dp[i][j] = add(dp[i][j], dp[i - 1][j]);
			if (j != 0){
				if (i > 1) dp[i][j] = add(dp[i][j], mul(i - 1, dp[i - 2][j - 1]));
				if (i > 2) dp[i][j] = add(dp[i][j], mul(i - 2, mul(i - 1, dp[i - 3][j - 1])));
			}
		}
	}	
	int ans = 0;
	for (int i = 0; i <= n; i++){
		ans = add(ans, dp[3 * n][i]);
	}
	cout << ans;











	return 0;
}


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

#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());

signed main()
{   
    gearup;
    ll l,r,d; cin >> l >> r >> d;
    ll res = 0;
    for(int i=l;i<=r;i++){
        if(i % d == 0)res++;
    }
    out(res);
}

Measured memory_bytes: 3644
import sys

input=sys.stdin.readline
s=input()
t=input()
n,m=len(s),len(t)

dp=[[0]*(m+1) for i in range(n+1)]
ans=[]

for i in range(n):
  for j in range(m):
    if s[i]!=t[j]:
      dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1])
    else:
      dp[i+1][j+1]=dp[i][j]+1
      
i,j=n,m      
while i>0 and j>0:
  if s[i-1]==t[j-1]:
    ans.append(s[i-1])
    i-=1
    j-=1
  elif dp[i][j]==dp[i-1][j]:
    i-=1
  else:
    j-=1
print(''.join(ans[::-1]))

Measured memory_bytes: 112476
#include <iostream>
#include<algorithm>
using namespace std;
int L[100005], R[100005];
int main()
{
	int N, M;
	cin >> N >> M;
	for (int i = 0;i < M;i++)
	{
		cin >> L[i] >> R[i];
	}
	sort(L, L + M);
	sort(R, R + M);
	if ((R[0] - L[M - 1]) < 0)cout << "0" << '\n';
	else cout << (R[0]-L[M-1]+1)<< '\n';
}

Measured memory_bytes: 1024
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;
const int NAX = 2e5 +11;
vector<int> G[NAX];
int ans[NAX], A[NAX];
vector<stack<int> > lis(NAX);

int upperBound(int x, int N) {
    int L = -1, R = N, M;
    while (L < R) {
        M = L + (R - L + 1) / 2;
        if (lis[M].top() <= x) {
            L = M;
        } else {
            R = M - 1;
        }
    }
    return L + 1;
}

int lowerBound(int x, int N) {
    int L = -1, R = N , M;
    while (L < R) {
        M = L + (R - L + 1) / 2;
        if (lis[M].top() >= x) {
            R = M - 1;
        } else {
            L = M;
        }
    }
    return L + 1;
}

void dfs(int u, int N, int pi = -1) {
    int place = lowerBound(A[u], N);
    lis[place].push(A[u]);
    ans[u] = lowerBound(INT_MAX, N) - 1;
    for (int &v: G[u]) {
        if (v == pi) {
            continue;
        }
        dfs(v, N, u);
    }
    lis[place].pop();
}

int main() {
    ios::sync_with_stdio(0);
    int N;
    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        lis[i + 1].push(INT_MAX);
    }
    lis[N + 1].push(INT_MAX);
    lis[N + 2].push(INT_MAX);
    lis[N + 3].push(INT_MAX);
    lis[0].push(INT_MIN);
    for (int i = 0; i + 1 < N; ++i) {
        int x, y;
        cin >> x >> y;
        G[x - 1].push_back(y - 1);
        G[y - 1].push_back(x - 1);
    }
    dfs(0, N);
    for (int i = 0; i < N; ++i) {
        cout << ans[i] << "\n";
    }
    return 0;
}


Measured memory_bytes: 164856
#include <stdio.h>
 
int N, M;
 
int x[100010];
int y[100010];
 
int box[100010];
bool exist[100010];
 
int main() {
 
	scanf("%d %d",&N,&M);
 
	int i;
 
	for (i = 0; i < M; i++) {
		scanf("%d %d",&x[i],&y[i]);
	}
 
	for (i = 1; i <= N; i++) {
		box[i] = 1;
		exist[i] = false;
	}
	exist[1] = true;
 
	for (i = 0; i < M; i++) {
 
		if (exist[x[i]]) {
			exist[y[i]] = true;
		}
 
		if (box[x[i]] == 1 && exist[x[i]]) {
			exist[x[i]] = false;
		}
 
		box[x[i]]--;
		box[y[i]]++;
	}
 
	int ans = 0;
 
	for (i = 1; i <= N; i++) {
		if (exist[i]) {
			ans++;
		}
	}
	printf("%d\n",ans);
 
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
    #define REP(i, n) for(int i = 0;i < n;i++)
    #define REPR(i, n) for(int i = n;i >= 0;i--)
    #define FOR(i, m, n) for(int i = m;i < n;i++)
    #define FORR(i, m, n) for(int i = m;i >= n;i--)
    #define SORT(v, n) sort(v, v+n);
    #define VSORT(v) sort(v.begin(), v.end());
    #define llong long long
    #define pb(a) push_back(a)
    #define INF 999999999
    using namespace std;
    typedef pair<int, int> P;
    typedef pair<llong, llong> LP;
    typedef pair<int, P> PP;
    typedef pair<llong, LP> LPP;

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

    int main()
    {
       int n;
       cin>>n;
       vector<int> a(n,0);
       REP(i,n) cin>>a[i];
       sort(a.begin(),a.end());
       cout<<a[n-1]-a[0]<<endl;
    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define fi first
#define se second
#define pb push_back
ll power(ll x,ll y,ll p)
{
    ll res = 1;      // Initialize result

    x = x % p;  // Update x if it is more than or
                // equal to p

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}
int main(){
  ll n;
  cin >> n;
  vector<ll> v(n) ;
  for(ll i=0;i<n;i++)
  {
    cin >> v[i] ;
    v[i] = v[i]-(i+1) ;
  }
  sort(v.begin(),v.end()) ;
  if(n%2==0)
  {
    ll mid = v[n/2] ;
    ll mid2 =  v[n/2 - 1] ;
    ll sum=0,sum1=0;
    for(ll i=0;i<n;i++)
    {
      //v[i] = v[i] ;
      sum = sum + abs(mid-v[i]) ;
      sum1 = sum1 + abs(mid2-v[i]) ;
    }
    cout << min(sum,sum1) << endl;
  }
  else
  {
    ll mid = v[n/2] ;
    ll sum=0;
    for(ll i=0;i<n;i++)
    {
      v[i] = mid-v[i] ;
      sum = sum + abs(v[i]) ;
    }
    cout << sum << endl;
  }
}


Measured memory_bytes: 1792