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

ll n;
string s;

int main(){
    cin >> n >> s;
    ll res=0;
    for(ll i=0;i<1000;i++){
        ll a=i/100;
        ll b=(i%100)/10;
        ll c=i%10;
        bool flag=false;
        bool aa=false;
        bool bb=false;
        bool cc=false;
        for(ll i=0;i<n;i++){
            if(!aa&&s[i]-'0'==a) aa=true;
            else if(aa&&!bb&&s[i]-'0'==b) bb=true;
            else if(aa&&bb&&!cc&&s[i]-'0'==c){
                cc=true;
                flag=true;
                break;
            }
        }
        if(flag) res++;
    }
    cout << res << endl;
    return 0;
}  


Measured memory_bytes: 3688
N = int(input())
A = list(map(int,input().split()))
even = 0
odd = 0
for i in range(N):
  if A[i] % 2 == 0:
    even += 1
odd = N - even
if odd % 2 == 0: 
  print('YES')
else:
  print('NO')

Measured memory_bytes: 14108
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>

using namespace std;

const int MOD = 1e9 + 7;
const int INF = 1 << 30;
const int MAXN = 5005;

struct Edge
{
	int to, next;
}e[MAXN*2];
int head[MAXN], te = 1;

inline void addE(int u, int v) 
{
	e[++te] = (Edge){v, head[u]}, head[u] = te;
}

long long g[MAXN][MAXN], fac[MAXN], inv[MAXN];

int fa[MAXN], sz[MAXN], n, x, y, r;

void Root()
{
	static int q[MAXN], val[MAXN], st = 0, ed = 1;
	q[0] = 1;
	while (st < ed)
	{
		int u = q[st++];
		for (int j = head[u]; j != 0; j = e[j].next)
			if (e[j].to != fa[u])
				fa[e[j].to] = u, q[ed++] = e[j].to;
	}
	int mn = INF;
	for (int i = n - 1; i >= 0; i--)
	{
		int u = q[i];
		sz[u] = 1, val[u] = 0;
		for (int j = head[u]; j != 0; j = e[j].next)
			if (fa[u] != e[j].to)
				sz[u] += sz[e[j].to], val[u] = max(val[u], sz[e[j].to]);
		val[u] = max(val[u], n - sz[u]);
		if (val[u] < mn)
			mn = val[u], r = u;
	}
}

void dfs(int u)
{
	sz[u] = 1;
	for (int j = head[u]; j != 0; j = e[j].next)
		if (e[j].to != fa[u])
			fa[e[j].to] = u, dfs(e[j].to), sz[u] += sz[e[j].to];
}

long long qpow(long long a, int b)
{
	long long ret = 1;
	while (b)
	{
		if (b & 1) ret = ret * a % MOD;
		a = a * a % MOD;
		b >>= 1;
	}
	return ret;
}

void init()
{
	fac[0] = 1, inv[0] = 1;
	for (int i = 1; i <= n; i++)
		fac[i] = fac[i - 1] * i % MOD;
	for (int i = 1; i <= n; i++)
		inv[i] = qpow(fac[i], MOD - 2);
}

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

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

int main() 
{
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 1; i < n; i++)
	{
		cin >> x >> y;
		addE(x, y), addE(y, x);
	}

	Root();

	memset(fa, 0, sizeof(fa));
	memset(sz, 0, sizeof(sz));
	dfs(r);

	int N;
	vector<int> S(1);
	for (int j = head[r]; j != 0; j = e[j].next)
		S.push_back(sz[e[j].to]);
	N = S.size() - 1;

	init();

	int H = 0;
	g[0][0] = 1;
	for (int i = 1; i <= N; i++)
	{
		for (int j = 0; j <= S[i]; j++)
			for (int k = 0; k <= H; k++)
				g[i][j + k] += g[i - 1][k] * C(S[i], j) % MOD * A(S[i], j) % MOD, g[i][j + k] %= MOD;
		H += S[i];
	}
	
	long long res = fac[n];
	for (int k = 1; k < n; k++)
		res += qpow(-1, k) * g[N][k] * fac[n - k] % MOD, res %= MOD;
	if (res < 0)
		res += MOD;
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 194304
#include <bits/stdc++.h>    
#include <unordered_map>
using namespace std;
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cerr<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define endl "\n"
#define fo(i,n) for(int i=0;i<n;i++)
#define foo(i,x,n) for(int i=x;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define w(x) int x;cin>>x;while(x--)
#define display(a,n) {fo(i,n) {cout<<a[i]<<" ";}cout<<endl;}
#define fil(a,n,val) {fo(i,n) a[i]=val; }
#define sp(x,y) cout<<fixed<<setprecision(y)<<x<<endl;
const ll MOD   = 1000*1000*1000+7;
const ll MOD2  = 998244353;
const ll N = 1000*1000+5;
const double PI  = 3.14159265;
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
ll search(vl arr, ll l, ll r, ll x){if (r >= l) {ll mid = l + (r - l) / 2;if (arr[mid] == x)return mid;if (arr[mid] > x)return search(arr, l, mid - 1, x);return search(arr, mid + 1, r, x);} return -1;}
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll lcm(ll a , ll b){return (a*b)/ gcd(a,b);}
ll power(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){ if (y & 1) res = (res*x) % p; y = y>>1;x = (x*x) % p; } return res; }
ll modInverse(ll n, ll p){return power(n, p-2, p);}
const int maxn=3e5+5;

int n;
ll dp[maxn][105];
ll a[105],k;

ll solve(int candies, int lvl){
	if(candies==0&&lvl==n)
		return 1;
	if(candies<0)
		return 0;
	if(lvl>=n)
		return 0;
	if(dp[candies][lvl]!=-1)
		return dp[candies][lvl];
	ll ans=0;
	ans=(((solve(candies-1,lvl)+solve(candies,lvl+1))%MOD-solve(candies-1-a[lvl],lvl+1))+MOD)%MOD;
	return dp[candies][lvl]=ans;
}

int main(){
	fastio();
	cin>>n>>k;

	fo(i,n) {cin>>a[i];}
	fill(dp,-1);

	cout<<solve(k,0)<<endl;


}

Measured memory_bytes: 257508
#include <bits/stdc++.h>
using namespace std;
#define fix(f,n) std::fixed<<std::setprecision(n)<<f
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long int ll;
typedef unsigned long long int ull;
#define vi vector<int>
#define pii pair<int,int>
#define vii vector<pii>
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a>b)?b:a)
#define max3(a,b,c) ((a>b)?(a>c)?a:c:(b>c)?b:c)
#define min3(a,b,c) ((a<b)?(a<c)?a:c:(b<c)?b:c)
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define pb push_back
#define mp make_pair
#define mod 998244353
#define MAX 1000000001
 
int X[4]={1,-1,0,0};
int Y[4]={0,0,1,-1};
int vis[1001][1001]={};
char arr[1001][1001];
int h,w;
int cal[1001][1001]={};
 
bool valid(int x,int y){
    if(x<0 || y<0 || x>=h || y>=w || arr[x][y]=='#' || vis[x][y]){
        return 0;
    }
    return 1;
}
 
int main(){
	fast;
	int test=1;
	//cin >> test;
	while(test--){
	    cin >> h >> w;
	    queue<pair<int,int>>q,qt;
	    int cx,cy,ex,ey;
	    cin >> cx >> cy >> ex >> ey;
	    cx--;cy--;ex--;ey--;
	    qt.push({cx,cy});
	    vis[cx][cy]=1;
	    for(int i=0 ; i<h ; i++){
	        for(int j=0 ; j<w ; j++){
	            cin >> arr[i][j];
	            cal[i][j]=1000000001;
	        }
	    }
	    cal[cx][cy]=0;
	    int arr[h][w];
	    memset(arr,-1,sizeof arr);
	    while(1){
	        while(!qt.empty()){
	            int x=qt.front().first;
	            int y=qt.front().second;
	            qt.pop();
	            q.push({x,y});
	            for(int i=0 ; i<4 ; i++){
	                int dx=x+X[i];
	                int dy=y+Y[i];
	                if(valid(dx,dy)){
	                    cal[dx][dy]=cal[x][y];
	                    vis[dx][dy]=1;
	                    qt.push({dx,dy});
	                }
	            }
	        }
	        while(!q.empty()){
	            int x=q.front().first;
	            int y=q.front().second;
	            q.pop();
	            for(int i=(x-2) ; i<=(x+2) ; i++){
	                for(int j=(y-2) ; j<=(y+2) ; j++){
	                    if(valid(i,j)){
	                        qt.push({i,j});
	                        vis[i][j]=1;
	                        cal[i][j]=cal[x][y]+1;
	                    }
	                }
	            }
	        }
	        if(qt.empty()){
	            break;
	        }
	    }
	    if(vis[ex][ey]){
	        cout << cal[ex][ey] << endl;
	    }else{
	        cout << -1 << endl;
	    }
	}
	return 0;
}

Measured memory_bytes: 16348
#include<bits/stdc++.h>
#define L long long
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define pii pair<pi,int>
#define aa first
#define bb second
#define xx aa.aa
#define yy aa.bb
#define zz bb
#define mp make_pair
#define mpp(a,b,c) mp(mp(a,b),c)
using namespace std;
int n,m,a,b,c,d,w[410],f[410],u[410];
inline int fa(int i)
{
	return i==f[i]?i:f[i]=fa(f[i]);
}
int main()
{
	//freopen("b102.txt","r",stdin);
	//freopen("x.out","w",stdout);
	int i,j,k,l;
	scanf("%d%d",&n,&m);
	for(i=1;i<=2*m;i++)
	  f[i]=i;
	for(i=1;i<=n;i++)
	  {
	   scanf("%d%d%d%d",&a,&b,&c,&d);
	   if(c)
	     j=c+m;
	   else
	     j=a;
	   if(d)
	     k=d;
	   else
	     k=b+m;
	   w[j]++;
	   w[k]--;
	   f[fa(j)]=fa(k);
	   u[j]=u[k]=1;
	  }
	for(l=1;l<=2*m;l++)
	{
	for(i=1,j=k=0;i<=2*m;i++)
	  if(fa(i)==l)
	  if(w[i]>0)
	    if(i<=m)
	      j+=w[i];
	    else
	      break;
	  else if(w[i]<0)
	    if(i>m)
	      k+=-w[i];
	    else
	      break;
	if(i<=2*m || j!=k)
	  {
	   printf("NO\n");
	   return 0;
	  }
	if(!j && !k)
	  {
	   for(i=1,j=k=0;i<=2*m;i++)
	     if(fa(i)==l)
	     if(u[i])
	       if(i<=m)
	         j++;
	       else
	         k++;
	   if(j+k)
	     {
	      printf("NO\n");
	      return 0;
		 }
	  }
	}
	printf("YES\n");
	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
#include <string.h>
using namespace std;

#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define REP(i,e) for (int i = 0; i != int(e); i++)
#define FORIT(i, A) for (auto i : A)
#define ISEQ(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << endl
#define SZ(x) ((int)(x).size())

int compare(const std::string& buf, const std::string& str)
{
}

int main(int argc, char const *argv[])
{
	int n;
	std::string s;
	std::getline(std::cin, s);
	std::stringstream ss(s);
	ss >> n;
	REP(i, n)
	{
		std::getline(std::cin, s);
		int k = 0;
		int l = s.length();
		while(k+7 <= l)
		{
			if (s.substr(k, 7) == "Hoshino")
				s.at(k+6) = 'a';
			k++;
		}
		std::cout << s << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3036
import itertools

def dist(a, b):
    return ((a[0]-b[0])**2 + (a[1]-b[1])**2)**0.5

n = int(input())
cities = [tuple(map(int, input().split())) for _ in range(n)]

p = itertools.permutations(range(n), 2)
print(sum(dist(cities[x[0]], cities[x[1]]) for x in p) / n)

Measured memory_bytes: 3064
import sys
N = int(input())
u = []
v = []
for k in range(N):
  x, y = map(int, input().split())
  u.append(x + y)
  v.append(x - y)

mod = u[0] % 2

for k in range(1, N):
  if (u[k] % 2) != mod:
    print(-1)
    sys.exit()

if mod == 1:
  print(31)
  print(*[2**r for r in reversed(range(31))])
  for k in range(N):
    U = (u[k] + 2**31 - 1) / 2
    V = (v[k] + 2**31 - 1) / 2
    for r in reversed(range(31)):
      if U // 2**r == 1:
        U -= 2**r
        if V // 2**r == 1:
          V -= 2**r
          print('R', end='')
        else:
          print('U', end='')
      else:
        if V // 2**r == 1:
          V -= 2**r
          print('D', end='')
        else:
          print('L', end='')
    print('')
else:
  print(32)
  print(*([2**r for r in reversed(range(31))]+[1]))
  for k in range(N):
    U = (u[k] + 2**31) / 2 - 1
    V = (v[k] + 2**31) / 2 - 1
    for r in reversed(range(31)):
      if U // 2**r == 1:
        U -= 2**r
        if V // 2**r == 1:
          V -= 2**r
          print('R', end='')
        else:
          print('U', end='')
      else:
        if V // 2**r == 1:
          V -= 2**r
          print('D', end='')
        else:
          print('L', end='')
    print('R')

Measured memory_bytes: 4620
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int main()
{
    long long h, w; 
    cin >> h >> w; 
    
    if(h == 1 | w == 1){
        cout << 1;
        return 0; 
    }
    
    if(h %2 == 0 | w%2 == 0){
        cout << (h*w)/2;
    }else{
        cout << ((h*w)/2)+1;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
typedef long long ll;
using namespace std;
const ll mod=1000000007;

int main() {
  string s;
  cin >> s;
  if(s[2]==s[3]&&s[4]==s[5])cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

int main() {
  int n, k;
  cin >> n >> k;

  vector<int> snuke(n, 0);
  int ans = 0;

  for (int j = 0; j < k; j++){
    int d;
    cin >> d;
    for (int i = 0; i < d; i++) {
      int a;
      cin >> a;
      snuke.at(a-1)++;
    }
  }
  for (int i = 0; i < n; i++) {
    if (snuke.at(i) == 0) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
s = input()
K = int(input())
n = len(s)
substr = set()
for i in range(n):
    for j in range(i + 1, i + 1 + K):
        if j <= n:
            substr.add(s[i:j])
substr = list(substr)
substr.sort()
print(substr[K - 1])

Measured memory_bytes: 4464
#include <bits/stdc++.h>
#define ri register
#define int long long
#define E (n+1)
using namespace std; const int N=200010;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
int n,f[N][17],g[N][17],t[210], res=-1e18;
signed main()
{
    n=read();
    for(ri int i=0;i<n;i++)
    for(ri int j=0;j<10;j++)
    f[i][j]=read();

    for(ri int i=0;i<n;i++)
    for(ri int j=0;j<=10;j++)
    g[i][j]=read();

    for(ri int i=1;i<(1ll<<10);i++)
    {
        memset(t,0,sizeof(t));
        for(ri int j=0;j<n;j++)
        for(ri int k=0;k<10;k++)
        if(f[j][k] && ((i>>k)&1ll)) t[j]++;
        
        int qwq=0;
        for(ri int j=0;j<n;j++) qwq+=g[j][t[j]];

        res=max(res,qwq);
    }
    printf("%lld\n",res);
    return 0;
}

Measured memory_bytes: 3784
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = a;i < n;i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main(){
    int y[2],m[2],d[2],type = -1;
    
    rep(i,0,2){
        cin >> y[i] >> m[i] >> d[i];
    }
    
    if(m[0] > m[1]){
        type = 1;
    }
    else if(m[0] < m[1]){
        type = 2;
    }
    else{
        if(d[0] > d[1]){
            type = 1;
        }
        else if(d[0] < d[1]){
            type = 2;
        }
        else{
            type = 3;
        }
    }
    
    switch(type){
        case 1:
            if(y[0] < y[1]){
                cout << abs(y[0]-y[1]) << endl;
            }
            else{
                cout << abs(y[0]-y[1])+1 << endl;
            }
            
            break;
        case 2:
            if(y[0] > y[1]){
                cout << abs(y[0]-y[1]) << endl;
            }
            else{
                cout << abs(y[0]-y[1])+1 << endl;
            }
            
            break;
        case 3:
            cout << abs(y[0]-y[1]) << endl;
            break;
    }
    
    return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;
ll mod = 1000000007;
int gcd(ll a, ll b) { return (b % a == 0) ? a : gcd(b - a * (b / a), a); }
int main()
{
	ll i,j,n,k;
	cin>>n;ll a[n],d[n];
	for(i=0;i<n;i++){cin>>a[i];}
	d[0]=0;d[1]=abs(a[1]-a[0]);
	for(i=2;i<n;i++)
	{
d[i]=min(d[i-1]+abs(a[i]-a[i-1]),d[i-2]+abs(a[i]-a[i-2]));
	}
	cout<<d[n-1];
	return 0;
}

Measured memory_bytes: 5200
from collections import defaultdict
N = int(input())
d = defaultdict(int)
for _ in range(N):
    s = input()
    d[s]+=1
m = max(d.values())
ans = []
for k, v in d.items():
    if v == m:
        ans.append(k)
ans.sort()
print(*ans, sep = '\n')

Measured memory_bytes: 98192
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;


struct UF{
  vector<int> par;
  vector<int> sz;
  void init(int N){
    par.resize(N);
    sz.resize(N,1);
    for(int i=0; i<N; i++) par[i] = i;
  }
  int find(int N){
    if(par[N] == N) return N;
    return par[N] = find(par[N]);
  }
  void unite(int x, int y){
    int rx = find(x);
    int ry = find(y);
    if(rx == ry) return;
    par[rx] = ry; 
    sz[ry] += sz[rx];
  }
  bool same(int x, int y){
      int rx = find(x);
      int ry = find(y);
      return rx == ry;
  }
  int size(int N){
      return sz[find(N)];
  }
};


int N,K,L,a,b;

int main(void){
    cin>>N>>K>>L;
    pair<int, int> pp;
    vector<pair<int, int>> p(N);
    UF rouf; rouf.init(N+1);
    for(int i=0;i<K;i++){
        cin>>a>>b;
        rouf.unite(a,b);
    }
    UF rauf; rauf.init(N+1);
    for(int i=0;i<L;i++){
        cin>>a>>b;
        rauf.unite(a,b);
    }
    map<pair<int, int>, int> cnt;
    for(int i=0;i<N;i++){
        cnt[make_pair(rouf.find(i+1), rauf.find(i+1))]++;
    }
    for(int i=0;i<N;i++){
        if(i >= 1)cout << " ";
        cout<<cnt[make_pair(rouf.find(i+1), rauf.find(i+1))];
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 16640
## coding: UTF-8
N = int(input())
a = []

for i in range(N):
    a.append(int(input()))

#print(a) #入力されたリストの受け取り
'''
b = [] #被りがなかったものに関しては取り入れる
for i in range(len(a)):
    if( (a[i] in b) == False ):
        b.append(a[i])
    #print(a[i] in b)
    #b.append(a[i])
'''
a=sorted(a)
b = []
last = 0
for i in range(len(a)):
    if(last != a[i]):
        b.append(a[i])
        last = a[i]


#print(b)
print(len(b))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define fi first
#define se second
#define show(x) cout<<#x<<"="<<x<<"\n"
typedef long long ll;
template<typename T>
void print_to(std::ostream &os,const char *,const char *tail,const T &fst){
  os<<fst<<tail;
}
template<typename Fst,typename... Rst>
void print_to(std::ostream &os,const char *del,const char *tail,const Fst &fst,const Rst &... rst){
  os<<fst<<del;
  print_to(os,del,tail,rst...);
}
template<typename Iter>
void print_to_(std::ostream &os,const char *del,const char *tail,Iter bgn,Iter end){
  for(Iter it=bgn;it!=end;){
    os<<*it;
    if(++it!=end)os<<del;
    else os<<tail;
  }
}
template<typename Fst,typename... Rst>
void println(const Fst &fst,const Rst &... rst){
  print_to(std::cout,"\n","\n",fst,rst...);
}
template<typename Fst,typename... Rst>
void print(const Fst &fst,const Rst &... rst){
  print_to(std::cout," ","\n",fst,rst...);
}
template<typename Iter>
void println_(Iter bgn,Iter end){
  print_to_(std::cout," ","\n",bgn,end);
}
using namespace std;
//const int MOD=(ll)1e10+7;
const int dy[]={1,0,-1};
const int dx[]={1,0,-1};
int n,m,h,w;
string s;
int a[2][101];

int bfs(){
  queue<pair<pair<int,int>,int> > q;
  q.push(make_pair(make_pair(0,0),0));
  int res=0;
  while(!q.empty()){
    int nowy=q.front().fi.fi;
    int nowx=q.front().fi.se;
    int nowcnt=q.front().se;
    q.pop();
    if(nowy==1 && nowx==n-1){
      res=max(res,nowcnt+a[nowy][nowx]);
      continue;
    }
    if(nowy!=1){
      q.push(make_pair(make_pair(nowy+1,nowx),nowcnt+a[nowy][nowx]));
    }
    if(nowx!=n-1){
      q.push(make_pair(make_pair(nowy,nowx+1),nowcnt+a[nowy][nowx]));
    }
  }
  return res;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout<<fixed;
#ifdef LOCAL_DEFINE
  FILE *stream1;
  //FILE *stream2;
  stream1=freopen("in","r",stdin);
  //stream2=freopen("out","w",stdout);
  if(stream1==NULL)return 0;
  //if(stream2==NULL)return 0;
#endif
  cin>>n;
  for(int i=0;i<2;i++){
    for(int j=0;j<n;j++){
      cin>>a[i][j];
    }
  }
  print(bfs());
#ifdef LOCAL_DEFINE
  cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
  fclose(stream1);
  //fclose(stream2);
#endif
    return 0;
}






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

namespace Volume0
{
    class Program
    {
        static void Main(string[] args)
        {
            string s;
            while((s = Console.ReadLine()) != null)
            {
                double[] i = s.Split(' ')
                            .Select(e => double.Parse(e))
                            .ToArray();
                var x = (i[2] * i[4] - i[1] * i[5]) 
                              / (i[0] * i[4] - i[1] * i[3]);
                var y = (i[5] * i[0] - i[2] * i[3])
                              / (i[0] * i[4] - i[3] * i[1]);
                Console.WriteLine("{0:F3} {1:F3}", x, y);
            }
        }
    }
}

Measured memory_bytes: 9512
#include <stdio.h>
int main(void){
  int A,B,C,D;
  scanf("%d %d %d %d",&A,&B,&C,&D);
  int min,max,s;
  if(A>C){
    min=A;
  }
  else{
    min=C;
  }
  if(B<D){
    max=B;
  }
  else{
    max=D;
  }
  s=max-min;
  if(s>0){
    printf("%d\n",max-min);
  }
  else{
    printf("0\n");
  }
  return 0;
}

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

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

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

int main(){
	int N,K;
	cin >> N >> K;
	vector<int> a(N);
	vector<bool> dp(K+1,false);
	
	for(auto &i:a){
		cin >> i;
		dp[i]=true;
	}
	
	for(int k=0;k<K;k++){
		for(int i=0;i<N;i++){
			if(k+a[i]<=K)dp[k+a[i]]=dp[k+a[i]]||(!dp[k]);
		}
	}
	if(dp[K])cout << "First" << endl;
	else cout << "Second" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iterator>
#include<memory>
#include<string>
#include<sstream>


//class element_{};
//class operand_{};
template<class T, std::size_t N>
class stack {
	T tab[N];
	T* point;
public:
	stack() :tab{}, point{ &tab[0] } {}
	auto size()const { return std::distance(this->begin(), this->end()); }
	auto& push(const T& x) {

		++this->point;
		*(this->point) = x;
		return *this;
	}

	auto pop() {
		auto tmp = *this->point;
		this->point--;
//		*this->point = -1;
		return tmp;
	}

	auto empty()const {
		return this->size() == 0;
	}

	decltype(auto) begin() { return std::begin(tab); }
	decltype(auto) end() { return (this->point + 1); }

	decltype(auto) begin()const { return std::cbegin(tab); }
	decltype(auto) end()const { return this->point + 1; }

	decltype(auto) cbegin()const { return this->begin(); }
	decltype(auto) cend()const { return this->end(); }

	auto top()const->const T& { return *(this->point); }
	auto bottom()const->const T& { return tab[0]; }//???

};


template<class Stack>
class operation{
public:
	virtual auto operate(Stack*const sp)->operation& = 0;
	virtual ~operation() {}
};

template<class Stack>
class plus final :public operation<Stack> {
	using super = operation<Stack>;
public :
	virtual auto operate(Stack*const sp)->plus<Stack>& override{
		auto x = sp->pop();
		auto y = sp->pop();
		sp->push(x + y);
		return *this;
	}
};

template<class Stack>
class minus final :public operation<Stack> {
	using super = operation<Stack>;
public:
	virtual auto operate(Stack*const sp)->minus<Stack>& override{
		auto x = sp->pop();//right
		auto y = sp->pop();//left
		sp->push(y - x);
		return *this;
	}
};

template<class Stack>
class multi final :public operation<Stack> {
	using super = operation<Stack>;
public:
	virtual auto operate(Stack*const sp)->multi<Stack>& override{
		auto x = sp->pop();
		auto y = sp->pop();
		sp->push(x * y);
		return *this;
	}
};




template<class T,std::size_t N>
auto add(stack<T, N>*const sp) {
	auto& s= *sp;
	auto x = s.pop();
	auto y = s.pop();
	s.push(x + y);
	return sp;
}



int main() {

	stack<int, 200> s;

	
	std::unique_ptr<operation<decltype(s)>> op{nullptr};

	std::string x;
	std::getline(std::cin, x);
	std::stringstream ss{ x };
	while ( ss >> x ) {
		
//		std::cout << x << "\n";

		if (x == "+") {
			op.reset(new plus<decltype(s)>{});
			op->operate(&s);
		}else if (x == "*") {
			op.reset(new multi<decltype(s)>{});
			op->operate(&s);
		}else if (x == "-") {
			op.reset(new minus<decltype(s)>{});
			op->operate(&s);
		}else s.push(std::stoi(x));

//		if (op != nullptr)
/*
		for (auto&e : s) {
			std::cout << e << " ";
		}std::cout << "\n";
*/
	}


//	for (auto&e : s) {
//		std::cout << e << " ";
//	}std::cout << "\n";

	std::cout << s.pop() << "\n";
	return 0;
}




Measured memory_bytes: 3160
#pragma GCC optimize ("O3")
// #pragma GCC target ("avx")
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
int A[] = {
1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
};

void MAIN() {
    scanf("%d", &N);
    N--;
    printf("%d\n", A[N]);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



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

#define rep(i,n) for (int i=0; i< (n); i++)
typedef std::pair<int, int> P;
typedef long long int ll;

using namespace std;

const int MOD = 1e9+7;

ll c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 2000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i + 1][j] = (c[i+1][j] + c[i][j]) % MOD;
      c[i + 1][j + 1] = (c[i+1][j+1] + c[i][j]) % MOD;
    }
  }
}

ll comb(int n, int r) {
    return c[n][r];
}

int main(){
    int n, k;
    cin >> n >> k;
    init();
    for(int i=1; i <= k; i++) {
        ll ans = comb(n-k+1, i) * comb(k-1, i-1);
        printf("%lld\n", ans % MOD);
    }
    return 0;
}

Measured memory_bytes: 61952
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

vector<string> ss;
Int cnt[26];

int main(){
    string s; cin >> s;
    Int len = s.length();
    for (int i = 0; i < len; i++){
        cnt[(int)(s[i] - 'a')]++;
    }
    Int ans = len * (len-1) / 2;
    for (int i = 0; i < 26; i++){
        if (cnt[i] > 0){
            ans -= cnt[i] * (cnt[i] - 1) / 2;
        }
    }
    cout << ans+1 << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int main() {
    int N,A,B;
    cin >> N >> A >> B;
    A -= B;
    vector<ll> vec(N);
    for(int i = 0;i < N;i++) {
        cin >> vec.at(i);
    }
    ll ng = 0;
    ll ok = 10000000000;
    ll middle;
    while(ok - ng > 1) {
        middle = (ok + ng) / 2;
        vector<ll> cnt = vec;
        for(int i = 0;i < N;i++) {
            cnt.at(i) -= middle * B;
        }
        ll cnt2 = 0;
        for(int i = 0;i < N;i++) {
            cnt2 += max(0ll,(cnt.at(i) + A - 1) / A);
        }
        if(cnt2 <= middle) {
            ok = middle;
        }
        else {
            ng = middle;
        }
    }
    cout << ok << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t,i,j;
    while(cin >> t){
            int arr[1000];
        for( i =0; i<2*t; i++){
            cin >> arr[i];
        }
        sort(arr,arr+i);
        int s=0;
        for(j=0; j<2*t; j++){
            if(j%2==0)
                s+=arr[j];
        }
        cout << s<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import sys

input = sys.stdin.readline

n = int(input().strip())
ps = list(map(int, input().strip().split(' ')))
count = 0
for i in range(n - 2):
    sub = ps[i: i + 3]
    sub.sort()
    if sub[1] == ps[i + 1]:
        count += 1
print(count)

Measured memory_bytes: 3060
#include<stdio.h>
#include<math.h>
int main ()
{
    int a,t,b;
    scanf("%d %d",&a,&b);
    if(a+b>a-b)
        t=a+b;
    else
        t=a-b;
    if(t<a*b)
        t=a*b;
    printf("%d",t);
    return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cctype>
#include <map>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

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

    vector<int> vec(n);
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        vec.push_back(a);
    }

    sort(vec.begin(), vec.end(), greater<int>());
    
    int alice = 0;
    int bob = 0;
    for (int i = 0; i < n; i++)
    {
        int point = vec[i];
        if (i % 2 == 0)
        {
            alice += point;
        }
        else
        {
            bob += point;
        } 
    }
    
    cout << alice - bob << endl;
}

Measured memory_bytes: 256
#coding: utf-8
import math
N = int(input())
L = []
for i in range(N-1):
    l = list(map(int,input().split()))
    L.append(l)

for i in range(N-1):
    t = 0
    for j in range(i,N-1):
        l = L[j]
        c = l[0]
        s = l[1]
        f = l[2]
        if t <= s:
            t = s+c
        else:
            n = math.ceil((t-s)/f)
            t = s+n*f+c
    print(t)

print(0)

Measured memory_bytes: 9104
#include<bits/stdc++.h>
using namespace std;
#define deb(x)   cout<<"> "<<#x<<" : "<<x<<endl;
#define deb2(x,y)cout<<"> "<<#x<<"->"<<x<<"  "<<#y<<"->"<<y<<endl;
#define LINE   cout << "--- LINE NO : " << __LINE__ <<"  ---"<< endl;
#define pnr(a)   for(auto x:a){cout<<x<<" ";}cout<<endl;
#define pnr2(a)  for(auto x:a){cout<<x.first<<" "<<x.second<<endl;}

#define  vt            vector
#define  ff            first
#define  ss            second
#define  int           long long
#define  db            long double
#define  pii           pair<int,int>
#define  Maxpq(x)      priority_queue<x>
#define  Minpq(x)      priority_queue<x,vt<x>,greater<x>>

#define  pb            push_back
#define  si(x)         (int)x.size()
#define  all(x)        x.begin(),x.end()
#define  mem(a,x)      memset(a,x,sizeof(a))
#define  FOR(a)        for(auto& x :  a )
#define  forr(i,n)     for(int i=0;i<n;i++)

#define  pi            2*acos(0.0)
#define  inf           (int)1e18
#define  mxn           (int)2e5+5
#define  mod           (int)1e9+7

int mainx()
{
	string s;
	cin >> s;
	map<char , int> mp;
	FOR(s)
	{
		if (x >= 'a'  and x <= 'z')
			mp[x]++;
	}
	bool bx = false;
	for (auto x : mp)
	{
		if (x.ss % 2)
		{
			bx = true;
			break;
		}
	}
	if (bx)
	{
		cout << "No" << endl;
	}
	else
		cout << "Yes" << endl;
	return 0;
}


inline void __INCLUDE() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt","w",stdout);
#endif
}

int32_t main() {

	//INCLUDE();

	ios::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL);

	//cout << fixed << setprecision(20);

	int tt = 1;
	//cin>>tt;
	for (int t = 1 ; t <= tt ; t++ )
	{
		// cout<<"Case #"<<i<<": ";
		mainx();
	}
	return 0 ;
}



Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#ifndef Online_Judge
#define dbg(x...) do{cout << "\033[32;1m" << #x << "->" ; err(x);} while(0)
void err(){cout << "\033[39;0m" << endl;}
template<template<typename...> class T,typename t,typename... A>
void err(T<t> a,A... x){for (auto v:a) cout << v << ' '; err(x...);}
template<typename T,typename... A>
void err(T a,A... x){cout << a << ' '; err(x...);}
#else
#define dbg(...)
#endif
int main()
{
	int year,month,day;
	char c;
	cin>>year>>c>>month>>c>>day;
	if(year<2019)
	{
		cout<<"Heisei"<<endl;
	}
	else if(year==2019){
		if(month<4) cout<<"Heisei"<<endl;
		else if(month==4)
		{
			if(day<=30) cout<<"Heisei"<<endl;
			else cout<<"TBD"<<endl;
		}
		else cout<<"TBD"<<endl;
	}
	else cout<<"TBD"<<endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from math import ceil


def solve():
    N = int(input())
    P = list(map(int, input().split()))
    count = 0
    for i, p in zip(range(1, N + 1), P):
        if i != p:
            count += 1
        if count >= 3:
            break
    return 'YES' if count <= 2 else 'NO'


def main():
    print(solve())


if __name__ == "__main__":
    main()


Measured memory_bytes: 38384
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};

struct weighted_union{
    vector<int> par;
    vector<int> depth;
    vector<int> heavy;
    vector<int> siz;

    weighted_union(int n) : par(n),depth(n,0),heavy(n,0),siz(n,1){
        rep(i,n) par[i]=i;
    }
    int find(int x){
        if(par[x]==x) return x;
        int parent=find(par[x]);
        heavy[x] +=heavy[par[x]];
        return par[x]=parent;
    }
    int wei(int x){
        find(x);
        return heavy[x];
    }
    void unite(int x,int y,int w){//yはxよりw重い
        w +=wei(x)-wei(y);
        x=find(x),y=find(y);
        if(x==y) return;
        siz[x] +=siz[y];
        siz[y] =siz[x];
        if(depth[x]<depth[y]){
            par[x]=y;
            heavy[x]=-w;
        }
        else{
            par[y]=x;
            heavy[y]=w;
            if(depth[x]==depth[y]) depth[x] ++;
        }
    }
    bool same(int x,int y){
        return find(x)==find(y);
    }
    int size(int x){
        return siz[find(x)];
    }
    int diff(int x,int y){//w[y]-w[x],比較不可ならinf
        if(!same(x,y)) return inf;
        return wei(y)-wei(x);
    }
};

int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n,q;
    cin>>n>>q;
    weighted_union wuf(n);
    int x,y,z;
    int f;
    rep(i,q){
        cin>>f;
        if(f){
            cin>>x>>y;
            z=wuf.diff(x,y);
            if(z==inf) cout<<'?'<<endl;
            else cout<<z<<endl;
        }
        else{
            cin>>x>>y>>z;
            wuf.unite(x,y,z);
        }
    }
}


Measured memory_bytes: 4496
# frozen_string_literal: true

n = gets.to_i
nn = n
digits = []
while nn != 0
  digits << nn % 10
  nn /= 10
end
ketac = digits.size
msd = digits.last
table = (1..9).map { |i| Array.new(9, 0) }
(1..9).each do |signi|
  (1..9).each do |lesig|
    tmp = (2...ketac).sum do |d|
      10**(d - 2)
    end + (signi == lesig && lesig <= n ? 1 : 0)
    case signi <=> msd
    when -1
      tmp += 10**(ketac - 2)
    when 0
      unless ketac < 2
        full = digits[1...-1].reverse!.inject(0) { |prod, d| prod * 10 + d }
        full = 0 if digits[1..-2].empty?
        full += 1 if lesig <= digits[0]
        tmp += full
      end
    end
    table[signi - 1][lesig - 1] = tmp
  end
end
res = (0..8).sum do |i|
  (0..8).sum do |j|
    table[i][j] * table[j][i]
  end
end
p res


Measured memory_bytes: 14264
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <tuple>

using namespace std;

int main()
{
    int a, b, h;
    cin >> a >> b >> h;

    cout << (a+b)*h/2 << endl;
    
    return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
        var WHxy = ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
        var (W, H) = (WHxy[0], WHxy[1]);
        var (x, y) = (WHxy[2], WHxy[3]);

        var area = ((double)W * H) / 2.0;

        var isMultiple = (W == x * 2 && H == y * 2) ? 1 : 0;

        WriteLine($"{area} {isMultiple}");
    }
}


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

const ll mod = 1000000007;
ll N;
int a[100010];
int box[100010];


ll beki(ll n){
  ll ans=1;
  n/=2;
  while(n>0){
    ans%=mod;
    ans=ans*2;
    n--;
  }


  return ans;
}


int main(){
  cin>>N;

  rep(i,N)cin>>a[i];
  bool flag=true;

  if(N%2==0){
    for(int i=0;i<N;i++){
      box[a[i]]++;
    }
    for(int i=1;i<=N-1;i+=2){
      if(box[i]!=2)flag=false;
    }
  }else{
    for(int i=0;i<N;i++){
      box[a[i]]++;
    }

    if(box[0]!=1){
      flag=false;
    }
    for(int i=2;i<=N-1;i+=2){
      if(box[i]!=2)flag=false;
    }
  }

  if(flag){
    cout<<beki(N)%mod<<endl;
  }else{
    cout<<'0'<<endl;
  }




}


Measured memory_bytes: 1024
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val Array(a, b, k) = in.readLine().split("\\s+").map(_.toLong)

    val takahashi = Math.max(0, a - k)
    val aoki = Math.max(0, b - (k - (a - takahashi)))

    out.println(List(takahashi, aoki).mkString(" "))

    out.flush()
  }
}


Measured memory_bytes: 27204
#include <stdio.h>
#include <string.h>
int main(void){
 int n=0,s=0,e=0,w=0,i;
 char c[1001];
 scanf("%s",c);
 for(i=0;i<strlen(c);i++){
  if(c[i]=='N') n=1;
  else if(c[i]=='S') s=1;
  else if(c[i]=='E') e=1;
  else w=1;
 }
 puts(n==s && e==w?"Yes":"No");
 return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
typedef long long ll;

int main(){
    int a,b,t;
    cin >> a >> b >> t;
    cout << b*(t/a) << endl;
    return 0;
}

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

using namespace std;
#define sz(a) int(a.size())
#define ll  long long
#define mod (long long)(1e9+7)
#define endl '\n'
#define ENGZ ios::sync_with_stdio(0);ios_base::sync_with_stdio(0);cin.tie(0) , cout.tie(0) ;
#define pi (acos(-1))
#define F first
#define S second


ll fp(ll n , ll p )
{
    if(p==0)
        return 1;
    if(p==1)
        return n ;
    ll res = fp(n,p/2)%mod ;
    res=((res)*(res))%mod ;
    if(p%2)
        res=(res*n)%mod ;
    return res ;
}

ll n , k , arr[101] ;


ll sol(int idx)
{
    ll a = 0 , b = 0 , tmp = 0 ;
    priority_queue<ll , vector<ll> , greater<ll>> pq ;
    for(int i=0 ; i<=idx ; i++)
    {
        while(sz(pq)>0)pq.pop() ;
        tmp = 0 ;
        for(int j=1 ; j<=i ; j++)
        {
            pq.push(arr[j]);
            tmp+=arr[j] ;
        }
        b = idx - i ;
        for(int j=n ; j>n-b ; j--)
        {
            pq.push(arr[j]);
            tmp+=arr[j] ;
        }
        b = k-idx ;
        while(sz(pq) && pq.top() <= 0 && b)
        {
            b -- ;
            tmp -= pq.top();
            pq.pop();
        }
        a = max(a , tmp);
    }
    return a ;
}
int main()
{
    ENGZ;
    cin>>n >>k ;
    for(int i=1 ; i<=n ; i++)
    {
        cin>>arr[i] ;
    }
    ll ans = 0 ;
    for(int i=1 ;i<=min(n,k) ; i++)
    {
        ans = max(ans , sol(i));
    }
    cout<<ans <<endl ;
    return 0;
}


Measured memory_bytes: 3484
l, r = map(int, input().split())
n = r-l+1
if n >= 2019:
    print(0)
else:
    x = l % 2019
    if x > r%2019:
        print(0)
    else:
        ans = 2018
        for i in range(l,r):
            for j in range(i+1,r+1):
                ans = min(ans,(j*i)%2019)
        print(ans)

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

int main() {
  
  int N; cin >> N; 
  
  vector<int> H(N+1);
  
  for (int i = 0; i < N; i++) { 
    cin >> H[i];
  }
  
  H[N] = 1000000000 + 1;
  
  int max =0;
  
  int a, b;
  a = -1;
  
  for (int i = 0; i < N; i++) {
    
    if (H[i] < H[i+1]) {
      
      b = i;
      
      if (b - a - 1 > max) {
        max = b - a - 1;
      }
      
      a = i;
    }
  }
  
  cout << max << endl;
  
}

Measured memory_bytes: 640
n, a, b = map(int,input().split())

mod = 10**9+7

def combi(n,r):
    x, y = 1,1
    for i in range(n-r+1,n+1):
        x *= i
        x %= mod
        
    for j in range(1,r+1):
        y *= j
        y %= mod
    yinv = pow(y,mod-2,mod)
    
    return x*yinv%mod

def main():
    nca = combi(n,a)
    ncb = combi(n,b)
    ans = pow(2,n,mod)-1 - (nca + ncb)
        
    print(ans%mod)
    
main()

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

namespace ConsoleApp15
{
    class Class362
    {
        static void Main()
        {
            long N = long.Parse(Console.ReadLine());
            var dic = new Dictionary<long, int>();
            for (long i = 2; i <= (int)Math.Sqrt(N); i++)
            {
                while (N % i == 0)
                {
                    N /= i;
                    if (!dic.ContainsKey(i))
                    {
                        dic[i] = 1;
                    }
                    else
                    {
                        dic[i]++;
                    }
                }
            }
            if (N != 1) dic[N] = 1;
            long count = 0;
            foreach (long i in dic.Keys)
            {
                long s = 0;
                long c = 0;
                for (c = 1; s <= dic[i]; c++)
                {
                    s += c;
                }
                count += c - 2;
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 27808
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n;
  cin >> n;
  vector<queue<ll>> que(n);

  rep(i, n) {
    rep(_, n - 1) {
      ll a;
      cin >> a;
      a--;
      que[i].push(a);
    }
  }

  bool upd = true;
  ll tsukaday = 0;
  while (upd) {
    upd = false;
    vll done(n);
    rep(i, n) {
      if (done[i] || que[i].empty()) continue;
      ll toi = que[i].front();
      if (done[toi] == 0 && que[toi].front() == i) {
        que[i].pop();
        que[toi].pop();
        done[i] = 1;
        done[toi] = 1;
        upd = true;
      }
    }
    if(upd) tsukaday++;
  }

  bool ok = true;
  rep(i, n) if (!que[i].empty()) {
    ok = false;
    break;
  }

  ll ans = ok ? tsukaday : -1;
  cout << ans << endl;

  return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> S(n);
  repeat(i,n) cin >> S[i];
  
  int count = 0;
  repeat(i,n-2){
    if(S[i]<S[i+1]&&S[i+1]<S[i+2]){
      count++;
    }else if(S[i]>S[i+1]&&S[i+1]>S[i+2]){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <stack>
#include <cmath>
#include <queue>
#include <set>
#include <map>
using namespace std;

int main() {
    int m;
    cin >> m ;
    cout << 48 - m << endl;

    return 0;
}


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

using namespace std;
using ll = long long;
using P = pair<int,int>;

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


Measured memory_bytes: 3628
/*
 *  AUTHOR : MANAV PATEl
*/
#include<bits/stdc++.h>
#include<functional>
//#include<boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace std;

namespace fastio {

	template <class T> istream &operator>>(istream &os, vector<T> & vec) {
		for (auto &u : vec)os >> u;
		return os;
	}
	template <class T> ostream &operator<<(ostream &os, const vector<T> & vec) {
		for (auto &u : vec)os << u << " ";
		return os;
	}
	template<class T1, class T2> inline istream& operator>>(istream& os, pair<T1, T2>& p) {
		return os >> p.first >> p.second;
	}
	template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
		return os << p.first << " " << p.second;
	}
	template <class T> ostream &operator<<(ostream &os, set<T> & con) {
		for (auto &u : con) os << u << " ";
		return os;
	}
	void re() {}
	template <typename T, typename... args> void re(T& x, args&... tail) {
		cin >> x;
		re(tail...);
	}
	void pr() {}
	template <typename T> void pr(const T& x) {
		cout << x;
	}
	template <typename T, typename... args> void pr(const T& x, const args&... tail) {
		cout << x << " ";
		pr(tail...);
	}
	template <typename... args> void prln(const args&... tail) {
		pr(tail...);
		cout << "\n";
	}
}
using namespace fastio;

typedef long long int ll;
typedef long double ld;

const ll mod = 1e9+7;
const ll mod1 = 998244353;

#define fill(a)  memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back

int main()
{
	cin.sync_with_stdio(false);
	cin.exceptions(cin.failbit);
	cin.tie(0);
	string s;
	re(s);
	if(s[0]==s[1] || s[1]==s[2] || s[2]==s[3])
	{
		cout<<"Bad";
	}
	else
		cout<<"Good";
}


Measured memory_bytes: 256