akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

//文字列について各 i について「S と S[i:|S|-1] の最長共通接頭辞の長さ」を記録した配列AをO(|S|)で構築
void zalgo(string& s,vector<int>& z){
    int c = 0, n = s.length();
    z.resize(n,0);
    rep1(i,n) {
        int l = i - c;
        if(i + z[l] < c + z[c]) z[i] = z[l];
        else{
            int j = max(0, c + z[c] - i);
            for(; i + j < n and s[j] == s[i+j]; ++j);
            z[i] = j; c = i;
        }
    }
    z[0] = n;
}
//ABC141E
int main(){
    int n;
    string s, t;
    cin >> n >> s;
    int ans = 0;
    rep(i,n){
        vei z(n-i);
        t = s.substr(i,n-i);
        zalgo(t,z);
        rep(j,n-i) ans = max(ans,min(j, z[j]));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<ctime>
#include<cstdlib>
#include<numeric>
#include <typeinfo>
using namespace std;
typedef long long ll;
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define rloop(i,a,b) for(int i=a;i>=b;i--)
const int inf=1e8;
const ll INF=1e16;
#define MOD 1000000007
#define mod 1000000009

int main(){
	int n;
	cin>>n;
	vector<ll> r(n);
	loop(i,0,n){
		cin>>r[i];
	}
	ll M=-1*INF;
	ll m=r[0];
	loop(i,1,n){
		m=min(m,r[i-1]);
		M=max(M,r[i]-m);
	}
	cout<<M<<"\n";
}

Measured memory_bytes: 4316
n,a,b,*h=map(int,open(0).read().split());i,j=0,2**47
while j-i>1:
 k=c=(j+i)//2
 for t in h:c+=min(0,(b*k-t)//(a-b))
 if c<0:i=k
 else:j=k
print(j)

Measured memory_bytes: 71228
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>

// BEGIN CUT HERE
#ifdef _MSC_VER
#include <agents.h>
#endif
// END CUT HERE 

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) begin(v), end(v)
#define REV(v) rbegin(v), rend(v)
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define MP make_pair
#define MT make_tuple
#define X first
#define Y second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

const int N = 2e6;
int gap[N], np[N];
vector<int> pr;

int main(){
	ios::sync_with_stdio(false);

	for (int i = 2; i < N; ++i){
		if (!np[i]){
			pr.push_back(i);
			for (int j = i * 2; j < N; j += i) np[j] = 1;
		}
	}

	rep(i, pr.size() - 1){
		for (int j = pr[i] + 1; j < pr[i + 1]; ++j){
			gap[j] = pr[i + 1] - pr[i];
		}
	}

	int n;
	while (cin >> n, n){
		cout << gap[n] << endl;
	}




	return 0;
}

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

using namespace std;

typedef long long ll;

#define BASE 8001
bool dpx[BASE][BASE*2];
bool dpy[BASE][BASE*2];

int main()
{
    string s;
    int x, y;
    cin >> s >> x >> y;

    bool isX = true;
    int cnt = 0;
    vector<int> vx, vy;
    for (int i = 0; i < s.size(); ++i)
    {
        char c = s[i];
        switch (c)
        {
            case 'T':
                isX ? vx.push_back(cnt) : vy.push_back(cnt);
                cnt = 0;
                isX = !isX;
                break;
            case 'F':
                ++cnt;
                break;
        }
    }
    isX ? vx.push_back(cnt) : vy.push_back(cnt);

    dpx[1][BASE + vx[0]] = true;
    for (int i = 1; i < vx.size(); ++i)
    {
        for (int j = 0; j < 2*BASE; ++j)
        {
            if (!dpx[i][j]) continue;
            dpx[i+1][j-vx[i]] = true;
            dpx[i+1][j+vx[i]] = true;
        }
    }

    dpy[0][BASE] = true;
    for (int i = 0; i < vy.size(); ++i)
    {
        for (int j = 0; j < 2*BASE; ++j)
        {
            if (!dpy[i][j]) continue;
            dpy[i+1][j-vy[i]] = true;
            dpy[i+1][j+vy[i]] = true;
        }
    }

    if (dpx[vx.size()][x+BASE] && dpy[vy.size()][y+BASE])
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }


    return 0;
}

Measured memory_bytes: 125696
#include<cstdio>
#include<cmath>
using namespace std;

int a , b;
int main()
{
	scanf("%d%d", &a, &b);
	int m = 1;
	int d = b;
	while(d > 0)
	{
		m *= 10;
		d /= 10;
	}
	int c = a * m + b;
	d = sqrt(c);
	if(d * d == c) printf("Yes\n");
	else printf("No\n");
}

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

using i64 = int_fast64_t;
using f64 = double;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    i64 n, m;
    cin >> n >> m;
    i64 l = 1, r = 1 + m;
    for (i64 i = 0; i < m; i++) {
        cout << l << " " << r << endl;
        if (i % 2 == 0) {
            l += m, r += m, l++;
        } else {
            l -= m, r -= m, r--;
        }
    }
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 3668
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
    S = input()
    K = int(input())
    if S[0] != S[-1]:
        ans = 0
        before = 0
        i = 0
        while i + 1 < len(S):
            while i + 1 < len(S) and S[i] == S[i + 1]:
                i += 1
            ans += (i + 1 - before)//2
            i += 1
            before = i
        print(ans*K)
    else:
        if len(set(S)) == 1:
            print(K*len(S)//2)
        else:
            i = 0
            while i + 1 < len(S) and S[i] == S[i + 1]:
                i += 1
            cut = i + 1
            L = (i + 1)//2
            i += 1
            
            before = i
            R = 0
            while i + 1 < len(S):
                while i + 1 < len(S) and S[i] == S[i + 1]:
                    i += 1
                R += (i + 1 - before)//2
                i += 1
                before = i
            
            S = S[cut:] + S[:cut]
            ans = 0
            before = 0
            i = 0
            while i + 1 < len(S):
                while i + 1 < len(S) and S[i] == S[i + 1]:
                    i += 1
                ans += (i + 1 - before)//2
                i += 1
                before = i
            ans = ans*(K - 1) + R + L
            print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>

using namespace std;

int a[100];
int b[100];
long long dp[100001];

int main() {
    int n, w, i, j;
    long long ans = 0;
    
    scanf("%d %d", &n, &w);
    
    for (i = 0; i < n; i++) scanf("%d %d", &a[i], &b[i]);
    
    for (i = 0; i <= 100000; i++) dp[i] = 1e18;
    
    dp[0] = 0;
    
    for (i = 0; i < n; i++) {
        for (j = 100000; j >= 0; j--) {
            if (j + b[i] <= 100000) dp[j + b[i]] = min(dp[j + b[i]], dp[j] + a[i]);
        }
    }
    
    for (i = 0; i <= 100000; i++) {
        if (dp[i] <= w) ans = i;
    }
    
    printf("%lld\n", ans);
    
    return 0;
}


Measured memory_bytes: 896
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <set>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
#include <cmath>
#include <map>
#include <iterator>
#include <climits>
#include <numeric>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <array>
#include <valarray>
#include <complex>
#include <random>
#include <functional>
#include <cassert>
#include <chrono>
#include <memory>

using namespace std;

//#define int long long
//region TEMPLATE
#define double long double
typedef long long ll;
typedef unsigned long long ull;

template<typename T>
void __read(T &a) { cin >> a; }

template<typename T, typename ... Args>
void __read(T &a, Args &... args) {
    cin >> a;
    __read(args...);
}

#define make(t, ...) t __VA_ARGS__; __read(__VA_ARGS__)
#define makev(a, n) VI a(n); FOR(n) cin >> a[i];
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FORIT(p) for(auto it = p.begin(); it != p.end(); it++)
#define FOR(b) for(signed i = 0; i <(b); i++)
#define FORE(i, l, r) for(int i = (l); i < (r); i++)
#define NFOR(i, n) for(int i = (((int) n)-1); i >= 0; i--)
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<pair<int, int>, int> PPII;
constexpr ll M7 = 1000000007ll;
constexpr ll M9 = 1000000009ll;
constexpr ll MFFT = 998244353ll;
template<class T>
void outv(T &a) { for (auto &x : a) cout << x << ' '; }
static mt19937 rnd(static_cast<unsigned>(chrono::steady_clock::now().time_since_epoch().count())); // NOLINT(cert-err58-cpp)
template<class T>
static auto __super_speed__ = (ios_base::sync_with_stdio(0), cin.tie(
        0)); // NOLINT(cert-err58-cpp,cppcoreguidelines-interfaces-global-init)
//endregion


int32_t main() {
    make(int, n);
    makev(a, n);
    makev(b, n);
    VI p(n);
    iota(ALL(p), 1);
    int x, y;
    int i = 0;
    do{
        if (p == a){
            x = i;
        }
        if (p == b){
            y = i;
        }
        i++;
    }while(next_permutation(ALL(p)));
    cout << abs(x - y);
    return 0;
}

Measured memory_bytes: 256
sx,sy,tx,ty = map(int, input().split())
dx=tx-sx
dy=ty-sy
s='R'*dx+'U'*dy+'L'*dx+'D'*dy+'L'+'U'*(dy+1)+'R'*(dx+1)+'D'+'R'+'D'*(dy+1)+'L'*(dx+1)+'U'
print(s)

Measured memory_bytes: 3060
#include<iostream>
#include<map>
#include<algorithm>
using namespace std;
int M[4040][4040];
int n,x[2][2000],y[2][2000],X[4001],Y[4001];
map<int,int>xx,yy;
main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>x[0][i]>>y[0][i]>>x[1][i]>>y[1][i];
		X[i*2]=x[0][i];
		Y[i*2]=y[0][i];
		X[i*2+1]=x[1][i];
		Y[i*2+1]=y[1][i];
	}
	sort(X,X+n*2);sort(Y,Y+n*2);
	for(int i=0;i<n*2;i++)xx[X[i]]=yy[Y[i]]=i;
	for(int i=0;i<n;i++)
	{
		int a=xx[x[0][i]],b=yy[y[0][i]],c=xx[x[1][i]],d=yy[y[1][i]];
		M[a][b]++;
		M[a][d]--;
		M[c][b]--;
		M[c][d]++;
	}
	for(int i=0;i<n*2;i++)for(int j=1;j<n*2;j++)M[i][j]+=M[i][j-1];
	for(int j=0;j<n*2;j++)for(int i=1;i<n*2;i++)M[i][j]+=M[i-1][j];
	long long sum=0;
	for(int i=0;i<n*2;i++)for(int j=0;j<n*2;j++)
	{
		sum+=1LL*(X[i+1]-X[i])*(Y[j+1]-Y[j])*!!M[i][j];
	}
	cout<<sum<<endl;
}



Measured memory_bytes: 66696
import numpy as np

if __name__ == "__main__":
	n,t = map(int,raw_input().split())
	li = map(int,raw_input().split())

	minv = li[0]
	dm = 0
	ans = 1
	for i in range(1, len(li)):
		minv = min(minv, li[i])
		if(dm == li[i] - minv):
			ans += 1
		elif(dm < li[i]-minv):
			dm = li[i] - minv
			ans = 1

	print ans

Measured memory_bytes: 18796
#ifndef ONLINE_JUDGE
#include "default.h"
#else
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#endif

using namespace std;
using namespace __gnu_pbds;


#pragma GCC target("popcnt")  //https://godbolt.org/z/yQv94Y 

typedef long long int ll;
typedef unsigned long long int  ull;
typedef long double ld;

const ld pi = 4.0*atan(1.0);
#define xlr8 ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cout.precision(10); cout<<fixed


typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
// T.insert(a), T.erase(a), T.size()
// T.order_of_key(a) -- number of elements strictly less than a
// *T.find_by_order(k) -- k-th element in increasing order

struct Timer
{   chrono::time_point<chrono::high_resolution_clock> start , end; chrono:: duration<float> dur;
    Timer(){start = chrono::high_resolution_clock::now();}
    ~Timer(){   end = chrono::high_resolution_clock::now(); dur = end - start;  cout<<"\nTime Elapsed : " <<dur.count() << " s\n";  }
};


template<typename T>
void getVec(vector<T>& a , int st, int en)
{
    int dif = (en > st ? 1 : -1);
    for(int  i = st ; i!= en ; i+= dif)
        cin>>a[i];
}
template<typename T>
void getVecPair(vector<pair<T , T > >& a , int st, int en)
{
    int dif = (en > st ? 1 : -1);
    for(int  i = st ; i!= en ; i+= dif)
        cin>>a[i].first>>a[i].second;
}


//76149
template<int D, typename T> 
struct Vec : public vector<Vec<D - 1, T>> {
  static_assert(D >= 1, "Vector dimension must be greater than zero!");
  template<typename... Args>
  Vec(int n = 0, Args... args) : vector<Vec<D - 1, T>>(n, Vec<D - 1, T>(args...)) {
  }
};
template<typename T>
struct Vec<1, T> : public vector<T> {
  Vec(int n = 0, T val = T()) : vector<T>(n, val) {
  }
};


// const int MAX = 1000;
// Vec<2 , int > dp(MAX + 1, MAX + 1, -1);


int main()
{
    xlr8;
    int testCases  = 1;
    // cin>>testCases;
    while (testCases--)
    {
        int k;
        cin>>k;
        while(k--)
        {
            cout<<"ACL";
        }
        cout<<"\n";
        
    }
}


Measured memory_bytes: 3652
# coding: utf-8
#累積和
N=int(input())
S=[i for i in input()]

pls_E=[0]*N
pls_W=[0]*N

#初期値
if S[N-1]=='E':
    pls_E[N-1]=1
else:
    pls_E[N-1]=0
    
if S[0]=='W':
    pls_W[0]=1
else:
    pls_W[0]=0

#Wの累積和(左から)
for i in range(1,N):
    if S[i]=='W':
        pls_W[i]=pls_W[i-1]+1
        
    else:
        pls_W[i]=pls_W[i-1]

#Eの累積和（右から）
for i in range(N-2,-1,-1):
    if S[i]=='E':
        pls_E[i]=pls_E[i+1]+1
    else:
        pls_E[i]=pls_E[i+1]

#print(pls_W,pls_E)
ans=float('inf')
for i in range(1,N-1):
    ans=min(ans,pls_W[i-1]+pls_E[i+1])
    
print(min(ans,pls_E[1],pls_W[N-2]))

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

using namespace std;

#define ll  long long
#define vi  vector<int>
#define pi  pair<int,int>
#define mp  make_pair
#define pb  push_back
#define MOD 1e9 + 7
#define PAI  3.1415
#define all(x) (x).begin(),(x).end()
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define pr(x) cout << x << endl
#define Endl endl
#define rep(i,n) for(int i = 0 ; i < n; i++)

const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int inf = 99999999;
const ll linf = 1LL << 62;

ll gcd(ll a,ll b){
  if(a < b)swap(a , b);
  if(a % b == 0) return b;
  else gcd(b, a%b);
}

ll lcm(ll a,ll b){
  if(a < b)swap(a , b);
  return (a/gcd(a , b))*b;
}

int main(){

  int n , d , x;
  vi v;
  cin >> n >> d >> x ;
  rep(i,n){
    int a;cin >> a;
    v.pb(a);
  }
  int ans = 0;

  rep(i,v.size()){
    rep(j,1000){
      if(d < 1 + v[i] * j)break;
      else ans++;
    }
  }
  pr(ans + x);
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof (x))
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define kill _z_kill
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outv(x) cerr<<#x" = "<<x<<"  "
#define outtag(x) cerr<<"--------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
	For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
#define User_Time ((double)clock()/CLOCKS_PER_SEC)
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned uint;
typedef long double LD;
typedef vector <int> vi;
typedef pair <int,int> pii;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int mod=998244353;
int Pow(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=(LL)x*x%mod)
		if (y&1)
			ans=(LL)ans*x%mod;
	return ans;
}
void Add(int &x,int y){
	if ((x+=y)>=mod)
		x-=mod;
}
void Del(int &x,int y){
	if ((x-=y)<0)
		x+=mod;
}
int Add(int x){
	return x>=mod?x-mod:x;
}
int Del(int x){
	return x<0?x+mod:x;
}
void ckmax(int &x,int y){
	if (x<y)
		x=y;
}
void ckmin(int &x,int y){
	if (x>y)
		x=y;
}
const int N=305;
int n;
char s[N];
int dp[N][N][N],g[N][N][N],f[N][N][N];
int main(){
	cin>>(s+1);
	n=strlen(s+1);
	dp[0][0][0]=1;
	For(a,0,n)
		Fod(i,n,0)
			Fod(j,n,0){
				if (dp[a][i][j]){
//					printf("[%d][%d][%d]\n",a,i,j);
					f[a][i][j]=1;
					if (a<=n-2){
						f[a+1][i][j]=1;
					}
					if (i>0){
						if (i+j>=2)
							dp[a][i-1][j]=1;
						if (a<n){
							dp[a+1][i][j]=1;
							if (s[a+1]=='0')
								dp[a+1][i-1+1][j]=1;
							else
								dp[a+1][i-1][j+1]=1;
						}
					}
					if (j>0){
						if (i+j>=2)
							dp[a][i][j-1]=1;
						if (a<n){
							dp[a+1][i][j]=1;
							if (s[a+1]=='0')
								dp[a+1][i+1][j-1]=1;
							else 
								dp[a+1][i][j-1+1]=1;
						}
					}
					if (a<=n-2){
						For(k,a+1,a+2){
							if (s[k]=='0')
								dp[a+2][i+1][j]=1;
							else
								dp[a+2][i][j+1]=1;
						}
					}
				}
				if (f[a][i][j]){
					if (a<n){
						if (i>0)
							f[a][i-1][j]=1;
						if (j>0)
							f[a][i][j-1]=1;
					}
				}
			}
	g[n+1][0][0]=1;
	int ans=1;
	Fod(b,n,1){
		For(i,0,n)
			For(j,0,n)
				g[b][i][j]=g[b+1][i][j];
		if (s[b]=='1'){
			For(i,1,n)
				For(j,0,n)
					Add(g[b][i][j],g[b][i-1][j]);
		}
		else {
			For(i,0,n)
				For(j,1,n)
					Add(g[b][i][j],g[b][i][j-1]);
		}
		For(i,0,n)
			For(j,0,n){
				if (i+j>b+1)
					continue;
				int v=0;
				int ii=i,jj=j;
				For(k,b,n){
					if (f[k][ii][jj]){
//						printf("[%d][%d][%d]\n",k,ii,jj);
						v=1;
						break;
					}
					if (s[k+1]=='0')
						ii++;
					else
						jj++;
				}
				if (v) assert(i+j<=b),
//					printf("g[%d][%d][%d] = %d\n",b,i,j,g[b][i][j]),
					Add(ans,g[b][i][j]);
			}
	}
	cout<<ans<<endl;
	return 0;
}
/*
001
001 0 1 01 10
*/

Measured memory_bytes: 168296
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
using vi = vector<ll>;
using pi = pair<ll, ll>;
const int maxn = 2e3 + 33, mod = 1e9 + 7;
ll f[maxn], inv[maxn];
void setup() {
	f[0] = inv[0] = 1;
	for(int i = 1; i < maxn; i++) {
		f[i] = (f[i-1]*i)%mod;
		if(i==1) inv[i] = 1;
		else inv[i] = (mod - inv[mod%i]*(mod/i)%mod)%mod;
	}
	for(int i = 1; i < maxn; i++) inv[i] = (inv[i]*inv[i-1])%mod;
}
ll nck(ll n, ll k) {
	ll r = f[n]*inv[k]%mod;
	return r*inv[n-k]%mod;
}
int n, k, a[22];
ll dp[22][maxn];//dp day/left

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	setup();
	cin >> n >> k;
	for(int i = 0; i < k; i++) cin >> a[i];
	dp[0][n] = 1;
	for(int i = 0; i < k; i++) {
		for(int lft = 0; lft <= n; lft++) {
			for(int ch = 0; ch <= min(lft, a[i]); ch++) {
				(dp[i+1][lft-ch] += (dp[i][lft]*nck(n-ch, a[i]-ch)%mod)*inv[ch]%mod) %= mod;
			}
		}
	}
	cout << (f[n]*dp[k][0]%mod);
}



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

int main() {
  int N;
  int64_t A=0,B=0;
  cin>>N;
  vector<int> p(N);
  for(int i=0;i<N;i++){
    cin>>p.at(i);
  }
  int Z=0;
  for(int i=0;i<N;i++){
    Z+=p.at(i);
    if(i%2==0){
      if(Z>=0){
        A+=1+Z;
        Z=-1;
      }
    }
    else{
      if(Z<=0){
        A+=1-Z;
        Z=1;
      }
    }
  }
  Z=0;
  for(int i=0;i<N;i++){
    Z+=p.at(i);
    if(i%2==1){
      if(Z>=0){
        B+=1+Z;
        Z=-1;
      }
    }
    else{
      if(Z<=0){
        B+=1-Z;
        Z=1;
      }
    }
  }
  cout<<min(A,B)<<endl;
                
}

Measured memory_bytes: 640
import java.util.*;
	import java.util.Map.Entry;
	 
	 
	 class Main {
		 static int mod =  (int) (Math.pow(10,9)+7);
		 static List<ArrayList<Integer>>  list = new ArrayList<ArrayList<Integer>>();
	    public static void main(String[] args) {
	    	
	        Scanner sc = new Scanner(System.in);
	        int N = sc.nextInt();	
	        long[] a = new long[N];
	        long[] R = new long[N];
	        long[] L = new long[N];
	        long ans=0;
	        for (int i=0 ; i<N; i++) {
	            a[i] = Long.parseLong(sc.next());
	            R[i] = i+a[i];
	            L[i] = i-a[i];
	            if(R[i]==L[i])ans--;
	        }
	        
	        Arrays.parallelSort(R);
	        Arrays.parallelSort(L);
	        int rcnt=0;
	        int lcnt=0;
	        while(rcnt!=N-1) {
	        	if(lcnt>=N)break;
	        	if(R[rcnt]==L[lcnt]) {
	        		long tmp=R[rcnt];
	        		int rr=0;
	        		int lr=0;
	        		while(R[rcnt]==tmp) {
	        			rr++;
	        			rcnt++;
	        		}
	        		while(lcnt<N&&L[lcnt]==tmp) {
	        			lr++;
	        			lcnt++;
	        		}
	        		ans=ans+(long)rr*lr;
	        		
	        	} else if(R[rcnt]>L[lcnt]) {
	        		lcnt++;
	        	} else {
	        		rcnt++;
	        	}
	        }
	        
	        ans=Math.max(ans, 0);
	        System.out.println(ans);
	        
	    }
	}

Measured memory_bytes: 64872
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n, a;
		n = sc.nextInt();
		a = sc.nextInt();
		sc.close();
		int ans = n * n - a;
		System.out.println(ans);
	}

}


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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,a,b,cnt=1,ans=0;
	cin>>n;
	cin>>a;
	for(int i=0;i<n-1;i++){
		cin>>b;
		if(b==a){
			cnt++;
		}else{
			ans+=cnt/2;
			cnt=1;
		}
		a=b;
	}
	ans+=cnt/2;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define ld long double
#define ll long long
#define pb push_back
#define F first
#define S second
#define X real()
#define Y imag()
#define EPS 1e-6
#define pi acos(-1)
#define vec(a,b) (b)-(a)
#define ec_norm(a) (a).X*(a).X+(a).Y*(a).Y
#define norm(a) hypot((a).X,(a).Y)
#define angle(a) atan2((a).Y,(a).X)
#define dot(a,b) (conj(a)*(b)).X
#define cross(a,b) (conj(a)*(b)).Y
#define rotate(a,b,ang) ((b)-(a))*exp(point(0,(ang)))+(a)
#define reflect(p,a,b) conj(((p)-(a))/((b)-(a)))*((b)-(a))+(a)
typedef complex<ld> point;
const int A = 3e2 + 2;
const int mod = 1e9 + 7;
int n;
ld dp[A][A][A];
bool vis[A][A][A];
ld solve(int c1, int c2, int c3) {
    int c0 = n - c1 - c2 - c3;
    if (c0 == n) return 0;
    if (vis[c1][c2][c3])
        return dp[c1][c2][c3];
    vis[c1][c2][c3] = 1;
    ld val = 1;
    if (c1)
        val += solve(c1 - 1, c2, c3) * (c1 / (n * 1.0));
    if (c2)
        val += solve(c1 + 1, c2 - 1, c3) * (c2 / (n * 1.0));
    if (c3)
        val += solve(c1, c2 + 1, c3 - 1) * (c3 / (n * 1.0));
    val /= (1.0 - c0 / (n * 1.0));
    return dp[c1][c2][c3] = val;
}
int main() {
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin >> n;
    int freq[3] = {};
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        freq[x - 1]++;
    }
    cout << setprecision(9) << fixed << solve(freq[0], freq[1], freq[2]);
    return 0;
}

Measured memory_bytes: 227896
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define MOD 1000000007ll
#define INF 1000000000ll
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

ll _pow(ll a, ll n) {
	if(n==0) return 1;
	else {
		ll res = 1;
		ll buf = a;
		while(n>0) {
			if(n%2==1) {
				res *= buf;
				res %= MOD;
			}
			buf *= buf;
			buf %= MOD;
			n/=2;
		}
		return res;
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	string s;
	cin>>n>>s;
	vector<vector<ll>> dp(n+1,vector<ll>(5001,0));
	dp[0][0]=1;
	FOR(i,1,n+1) REP(j,5001) {
		if(j==0) dp[i][j]+=dp[i-1][j];
		if(j>0) dp[i][j]+=2*dp[i-1][j-1];
		if(j<5000)dp[i][j]+=dp[i-1][j+1];
		dp[i][j]%=MOD;
	}
	ll tmp=_pow(2,(ll)s.size());
	tmp=_pow(tmp,MOD-2);
	cout<<(dp[n][(ll)s.size()]*tmp)%MOD<<endl;
	return 0;
}


Measured memory_bytes: 195840
#include <stdio.h>

int Fin(int);

int main(){
  int n;

  scanf("%d",&n);
  printf("%d\n",Fin(n));

  return 0;
}

int Fin(int n){
  int i, n1 = 1, n2 = 1, tmp = 1;
  
  for(i = 1; i < n; i++){
    tmp = n1 + n2;
    n1 = n2;
    n2 = tmp;
  }
  
  return tmp;
}


Measured memory_bytes: 2088
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 1; i <= n; i++)
#define REP(i, n) for(int i = 0; i < n; i++)
#define MP make_pair
#define FI first
#define SE second
#define VI vector<int>
#define CLR(x) memset(x, 0, sizeof(x))
#define SZ(x) (x.size())
#ifdef QWERTIER
#define err(x) cerr<<x<<endl;
#else
#define err(x)
#endif
typedef long long LL;


#define N 10010
#define R 110
int h, w, a[N], n, color[R][R];
int main() {
#ifdef QWERTIER
  freopen("in.txt", "r", stdin);
#endif
  scanf("%d%d", &h, &w);
  scanf("%d", &n);
  int r = 0, c = 0, dir = 1;
  FOR (i, n) {
    scanf("%d", &a[i]);
    while (a[i]--) {
      color[r][c] = i;
      c += dir;
      if (c < 0) {
        r++;
        c = 0;
        dir = 1;
      } else if (c >= w) {
        r++;
        c = w - 1;
        dir = -1;
      }
    }
  }
  REP (i, h) {
    REP (j, w)
      printf("%d%s", color[i][j], j==w-1?"\n":" ");
  }
  return 0;
}


Measured memory_bytes: 384
//
// tested with : g++ (GCC) 8.3.0
//

#include <iostream>
#include <string>
using namespace std;

int main() {
    int a, b, c, x;
    cin >> a >> b >> c >> x;

    int result = 0;
    int count = 0;
    for (int i = 0; i <= a; i++) { //0からAまでが大切(通りでは)
        for (int j = 0; j <= b; j++) {
            for (int k = 0; k <= c; k++) {
                result = (500 * i) + (100 * j) + (50 * k);
                if (x == result)
                    count++;
            }
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
def c_same_integers(A, B, C):
    max_value = max(A, B, C)
    t = []
    ans = 0
    for e in [A, B, C]:
        if e == max_value:
            t.append(max_value)
            continue
        if e % 2 == max_value % 2:
            t.append(max_value)
        else:
            t.append(max_value - 1)
        ans += (max_value - e) // 2
    t.sort(reverse=True)
    x, y, z = t
    if x == y == z:
        pass
    elif x == y:
        ans += 2
    elif y == z:
        ans += 1
    return ans

A,B,C = [int(i) for i in input().split()]
print(c_same_integers(A, B, C))

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>bool chmin(T&a,const T&b){return a>b?(a=b,1):0;}
template<class T>bool chmax(T&a,const T&b){return a<b?(a=b,1):0;}

const int INF = 1001001001;
const int MAX_N = 200000 + 10;
int a[MAX_N];
int dp[1 << 26];

int main2() {
  string s; cin >> s;
  int N = (int)s.size();

  a[0] = 0;
  REP(i, N) {
    a[i+1] = a[i] ^ (1 << (s[i] - 'a'));
  }
  REP(i, 1<<26) dp[i] = INF;
  dp[0] = 0;
  int f = 0;
  for (int i = 1; i <= N; i++) {
    int cur = a[i];
    f = dp[cur] + 1;
    for (int c = 0; c < 26; c++) {
      int next = cur ^ (1 << c);
      chmin(f, (dp[next] + 1));
    }
    chmin(dp[a[i]], f);
  }
  cout << f << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws) main2();
  return 0;
}



Measured memory_bytes: 263556
from collections import deque
def solve1():
    print(sum(A)-min(A)*2)
    que=deque(A)
    while(len(que)>1):
        l,r=que.popleft(),que.pop()
        if que or (not que and l-r>=r-l):
            print(l,r)
            m=l-r
            que.appendleft(m)
        else:
            print(r,l)
def solve2():
    li=list(map(abs,A))
    print(sum(li)-min(li)*2)
    que=deque(A)
    while(len(que)>1):
        l,r=que.popleft(),que.pop()
        if que or (not que and r-l>=l-r):
            print(r,l)
            m=r-l
        else:
            print(l,r)
        que.append(m)
def solve3():
    li=list(map(abs,A))
    print(sum(li))
    minus,plus=[],[]
    for i in range(N):
        if A[i]>=0:
            plus.append(A[i])
        else:
            minus.append(A[i])
    mque,pque=deque(sorted(minus)),deque(sorted(plus))
    for i in range(N-1):
        m,p=mque.pop(),pque.pop()
        if i==N-2:
            print(p,m)
        else:
            if len(mque)==0:
                print(m,p)
                mque.append(m-p)
            else:
                print(p,m)
                pque.append(p-m)
N=int(input())
A=sorted(map(int,input().split()))

if min(A)>=0:
    solve1()
elif max(A)<=0:
    solve2()
else:
    solve3()

Measured memory_bytes: 91980
#include <bits/stdc++.h>
using namespace std;
int main(){

int L, R, d;
cin >> L >> R >> d;

int ans = 0;

for (int i = L; i <= R; i++){
    if(i % d == 0){
        ans++;
    }
}

cout << ans << endl;

return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define all(n) n.begin(),n.end()
#define ld long double

#define ll long long
#define endl "\n"
#define ff first
#define ss second
#define pb push_back
#define pll pair<ll,ll>
// lan 24
const ll maxn= 1e6+100;
const ll mod = 1e9;
const ll base=1e2;

ll a[maxn];


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
        if (fopen("balls.in","r"))
       {
           freopen("balls.in","r", stdin);
           freopen("balls.out", "w",stdout);
       }
      ll n,m ;
       cin>>n>>m ;
       for (int i=1;i<=n;i++)
       {
           cin>>a[i];
       }
       ll l=1, h= 1e15;
       while (l<=h)
       {
           ll mid =(l+h)/2;
           ll cnt=0;
           for (int i=1;i<=n;i++)
           {
               ll t=(a[i]+mid-1)/mid;
               t-=1;
               cnt+=t;
 //               cout <<t<<Endl;

           }
           if (cnt<=m) h=mid-1;
           else l=mid+1;
       }
       cout <<l;

}


Measured memory_bytes: 5188
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

int main(){
	
	long long int N, M;
	
	cin >> N >> M;
	
	int a[500][500];
	
	for(int i = 0; i < N; i++){
		for(int j = 0; j < M; j++){
			cin >> a[i][j];
		}
	}
	
	int ans = N;
	
	for(int i = 1; i <= N; i++){
		bool used[500] = {};
		int index[500] = {};
		bool flag = false;
		for(int j = 0; j < M; j++){
			int count[500] = {};
			for(int k = 0; k < N; k++){
				count[a[k][index[k]]]++;
				//cout << a[k][index[k]] << " ";
			}
			//cout << endl;
			int max = 0;
			int del;
			for(int k = 1; k <= M; k++){
				if(count[k] > max){
					max = count[k];
					del = k;
				}
			}
			if(max <= i){
				flag = true;
				break;
			}
			used[del] = true;
			for(int k = 0; k < N; k++){
				while(true){
					if(used[a[k][index[k]]]){
						index[k]++;
					}else{
						break;
					}
				}
			}
		}
		if(flag){
			ans = i;
			break;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}



Measured memory_bytes: 896
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <ctime>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
	string s;
	cin >> s;
	int a[26] = {};
	REP(i,s.length()){
		a[s[i]-'a']++;
	}
	int x = 0;
	REP(i,26){
		x += a[i] % 2;
	}
	int ans;
	if (x <= 1) ans = 0;
	else ans = x/2;
	cout << ans << endl;


    return 0;
}

Measured memory_bytes: 3136
#include<stdio.h>
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<utility>
#include<stack>
#include<algorithm>
#include<string>
#include<string.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;

const int N = 800;
char maps[N + 5][N + 5];
int dist[N + 5][N + 5];

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int a, b, c; cin >> a >> b >> c;
    int cnt = 0;
    while(a%2 == 0 && b%2 == 0 && c%2 == 0){
        if(a == b && b == c){
            cout << -1 << endl;
            return 0;
        }
        int tmpa = a / 2, tmpb = b / 2, tmpc = c / 2;
        a = tmpb + tmpc;
        b = tmpa + tmpc;
        c = tmpa + tmpb;
        cnt++;
    }
    cout << cnt << endl;
}

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


#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define ll long long
#define el '\n'

using namespace std;


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

    int n;
    cin >> n;

    int ar[n+1];
    for (int i=1;i<=n;i++) cin >> ar[i];

    int cnt=0;
    for (int i=1;i<=n;i++){
        if (ar[i]!=i) cnt++;
    }

    if (cnt<=2){
        cout << "YES" << el;
        return 0;
    }

    cout << "NO" << el;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

int n;
int a[30];
int b[30];
int c[30];

int main()
{
    cin.tie(0); ios_base::sync_with_stdio(false);
    cin >> n;
    Forn(i, n) cin >> a[i];
    Forn(i, n) cin >> b[i];
    Forn(i, n-1) cin >> c[i];
    int ans = 0;
    Forn(i, n)
    {
        ans += b[a[i]];
        if(i<n && a[i]+1 == a[i+1]) ans += c[a[i]];
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<set>
#include<map>
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	int N,K;
	cin>>N>>K;
	if(K==0)
	exit(0);
	if(N>100&&N<1&&K>100&&K<1)
	exit(0);
	int x,y;
	x=N/K;
	y=N%K;
	if(y==0)
	cout<<0<<endl;
	else{
		if(N<K)
		cout<<1<<endl;
		else{
			cout<<1<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 256
from itertools import combinations
n = int(input())
k = 0
for i in range(2*n+1):
  if i * (i - 1) == 2 * n:
    k = i
    break
if k:
  ans = [[k-1] for _ in range(k)]
  i = 1
  for a, b in combinations(range(k), 2):
    ans[a].append(i)
    ans[b].append(i)
    i += 1
  print('Yes')
  print(k)
  for ansi in ans:
    print(' '.join(list(map(str, ansi))))
else:
  print('No')


Measured memory_bytes: 9204
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(int)(m);(i)<(int)(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

template< typename T > T modpow(T x, T n, const T& p) {
	T ret = 1;
	while (n > 0) {
		if (n & 1) (ret *= x) %= p;
		(x *= x) %= p;
		n >>= 1;
	}
	return ret;
}

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};
int main() {
	init();

	int N; cin >> N;
	map<int, ll>mp;
	rep(i, 0, N) {
		ll a; cin >> a;
		for (int j = 0;(1LL << j) <= a;++j) {
			if (a & (1LL << j))mp[j]++;
		}
	}
	mint ans = 0;
	for (auto p : mp) {
        ans += ((p.second * (N - p.second)) % mod * modpow(2LL, (ll)p.first, mod));
	}
	cout << ans.x << "\n";

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Random;
import java.util.Arrays;
import java.util.Comparator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		if (n % 10 == 9) {
			System.out.println("Yes");
		} else if (n / 10 % 10 == 9) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		
		
		
		
	}
}

Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n,k;
    cin>>n>>k;

    int a[n];

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

    int sum=0;

    for(int i=0; i<k; i++){
        sum+=a[i];
    }

    cout<<sum<<endl;
    return 0;

}


Measured memory_bytes: 3620
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll a,b;
    cin >> a >> b;
    if (b%a == 0) cout << a+b<<endl;
    else cout <<b-a<<endl;
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
#include <stdio.h>
#include <stdbool.h>


int main(int argc, char **argv)
{
    char a, b;
    bool is_liar;

    scanf("%c %c", &a, &b);
    is_liar = (b == 'H') ? true : false;
    is_liar = (a == 'H') ? is_liar : !is_liar;
    printf("%c\n", (is_liar) ? 'H' : 'D');
    return 0;
}


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

using namespace std;

#define ll  long long
#define ld  double

#define sz(x)   (int)x.size()
#define all(x)  x.begin(),x.end()

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 305;
const int   mod = 1e9 + 7;

void add(int &a,int b)  {
    a += b;
    if (a >= mod)
        a -= mod;
}
void sub(int &a,int b)  {
    a -= b;
    if (a <  0)
        a += mod;
}
int mul(int a,int b)    {
    return  1ll * a * b % mod;
}
int Pow(int a,int b)    {
    int ans = 1;
    while (b)   {
        if(b & 1)   ans = mul(ans,a);
        a = mul(a,a);   b >>= 1;
    }
    return  ans;
}
int inv(int a,int p)    {
    return  a == 1 ? 1 : p - 1ll * p * inv(p % a,a) / a;
}

typedef pair<int,int>   ii;

vector<ii>  Q[N];

int f[N][N][N];

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

    int n;  cin >> n;
    int m;  cin >> m;

    for(int i = 0 ; i < m ; ++i)    {
        int l;  cin >> l;
        int r;  cin >> r;
        int x;  cin >> x;

        Q[r].pb(l,x);

        if (x > r - l + 1)  {
            cout << 0;
            return  0;
        }
    }
    f[1][0][0] = 1;
    f[0][1][0] = 1;
    f[0][0][1] = 1;

    for(int i = 1 ; i < n ; ++i)
    for(int j = 0 ; j < i ; ++j)
    for(int k = 0 ; k <= j ; ++k)   if(!j || j != k)    {
        vector<int> v = {k,j,i};

        do  {
            int val = f[v[0]][v[1]][v[2]];
            if (val == 0)
                continue;

            for(int c = 0 ; c < 3 ; ++c)    {
                bool ok = 1;
                int  nv = v[c];

                v[c] = i + 1;

                for(ii  T : Q[i + 1])   {
                    int C = 0;
                    if (T.X <= v[0])    C++;
                    if (T.X <= v[1])    C++;
                    if (T.X <= v[2])    C++;

                    if (T.Y != C)   {
                        ok = 0;
                        break;
                    }
                }
                if (ok) add(f[v[0]][v[1]][v[2]],val);

                v[c] = nv;
            }
        }   while (next_permutation(all(v)));
    }
    int ans = 0;

    for(int i = 0 ; i < n ; ++i)
    for(int j = 0 ; j < n ; ++j)
        add(ans,f[n][i][j]),
        add(ans,f[i][n][j]),
        add(ans,f[i][j][n]);

    cout << ans << endl;

}

Measured memory_bytes: 110848
from collections import Counter
abc_list = list(map(int,input().split()))
abc_counter = Counter(abc_list)
most_counter = abc_counter.most_common()
if most_counter[0][0] == 5 and most_counter[0][1] == 2:
    if most_counter[1][0] == 7 and most_counter[1][1] == 1:
        print("YES")
    else:
        print("NO")
else:
    print("NO")

Measured memory_bytes: 3316
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N;
    cin >> N;
    int ret = 0, p10 = 1;
    while (p10 <= N) {
        int digits = min(p10 * 9, N + 1 - p10);
        ret += digits;
        p10 *= 100;
    }

    cout << ret << endl;

    return 0;
};


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

m = [[0 for _ in range(n)] for _ in range(n)]

for _ in range(n):
    tmp = [int(x) for x in input().split()]
    u = tmp[0]
    k = tmp[1]
    l = tmp[2:]
    for x in l:
        m[u-1][x-1] = 1

dl = [float('inf') for _  in range(n)]
dl[0] = 0

q = [0]

while q:
    t = q.pop()
    tl = m[t]
    for i,x in enumerate(tl):
        if x == 1:
            if dl[i] > dl[t] + 1:
                q.append(i)
                dl[i] = dl[t] + 1
            else:
                pass
        else:
            pass


for i,x in enumerate(dl):
    if x == float('inf'):
        print(i+1, -1)
    else:
        print(i+1, x)



Measured memory_bytes: 5724
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <fstream>
#include <set>
#include <stack>
#include <queue>
#include <list>
using namespace std;
typedef long long int64;
typedef vector<int> vec;
typedef vector<int64> vec64;
#define db(x) cout << "> " << #x << ": " << x << "\n";
#define ss cout << " ";
#define ct(x) cout << x;
#define nn cout << "\n";
#define cts(x) cout << x << " ";
#define ctn(x) cout << x << "\n";
// // // // // // // // // // // // // // // // // // //
int q, n;

void solve(){

    return;
}


int main(){
    int a,b,c;
    cin >> a >> b >> c;
    for (int i = b; i <=c; i++){
        if (i % a == 0){
            ctn("OK");
            return 0;
        }
    }
    ctn("NG");
    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<map>
#include<algorithm>
#include<queue>
#include<set>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) (a).begin(),(a).end()
#define fs first
#define sc second
using namespace std;

typedef pair<int,int> P;
typedef vector<P> H;

int n,k;
H snake(8);
set<P> block;
P goal;
int dy[] = {-1,-1,0,1,1,0}, dx[] = {0,1,1,0,-1,-1};
vector<H> can;

void rec(H x,int depth,int prv){
  if(depth == n){  
    can.push_back(x);
    return;
  }

  bool f1 = false, f2 = true;
  rep(d,6){
    P adj = x[depth];
    adj.fs += dx[d]; adj.sc+=dy[d];

    if(depth==0 || adj == x[depth-1])f1 = true;
    rep(i,depth-1){
      if(adj == x[i]){
	f2 = false;
	break;
      }
    }
    if(!f2)break;
  } 
  if(f1 && f2)rec(x,depth+1,prv);

  if(prv+1 != depth){
    rep(d,6){
      P nxt = x[depth];
      nxt.fs += dx[d]; nxt.sc += dy[d];
      if(block.find(nxt) != block.end())continue;

      bool f = true;
      rep(i,depth){
	if(x[i] == nxt){
	  f = false;
	  break;
	}
      }
      if(!f)continue;

      f1 = false, f2 = true;
      rep(d2,6){
	P adj = nxt;
	adj.fs += dx[d2]; adj.sc += dy[d2];

	if(depth==0 || adj == x[depth-1])f1 = true;
	rep(i,depth-1){
	  if(adj == x[i]){
	    f2 = false;
	    break;
	  }
	}
	if(!f2)break;
      } 
      if(f1 && f2){
	swap(nxt,x[depth]);
	rec(x,depth+1,depth);
	swap(nxt,x[depth]);
      }
    }
  }
}

int main(){
  while(cin >> n,n){
    rep(i,n)cin >> snake[i].fs >> snake[i].sc;
    cin >> k;
    block.clear();
    rep(i,k){
      cin >> goal.fs >> goal.sc;
      block.insert(goal);
    }
    cin >> goal.fs >> goal.sc;
 
    map<H,int> m;
    m[snake] = 0;
    queue<H> q;
    q.push(snake);

    while(q.size()){
      snake = q.front(); q.pop();
      int nxt = m[snake]+1;

      can.clear();
      rec(snake,0,-2);
      rep(i,can.size()){
	if(m.find(can[i])==m.end()){
	  if(can[i][0] == goal){
	    cout << nxt << endl;
	    goto END;
	  }
	  m[can[i]] = nxt;
	  q.push(can[i]);
	}
      }
    }
  END:;

  }
}

Measured memory_bytes: 30312