akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
typedef long long ll;

int main(){
	ll n,m,k;
	cin >> n >> m >> k;
	vector<ll> a(n+1),b(m+1);
	REP(i,n) cin >> a[i];
	REP(i,m) cin >> b[i];
	REP(i,n) a[i] += a[i-1];
	REP(i,m) b[i] += b[i-1];
	ll ans = 0;
	rep(i,n+1){
		if(a[i] > k) break;
		ll l = 0;
		ll r = m+1;
		while(r-l>1){
			ll t = (r+l)/2;
			if(b[t] > k - a[i]){
				r = t;
			}else{
				l = t;
			}
		}
		ans = max(ans, i + l);
	}
	cout << ans << endl;
    return 0;
}

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


int main() {
    long long A, B, K; cin >> A >> B >> K;

    if (A + K - 1 >= B - (K - 1) ) {
        for (int j = A; j <= B; ++j) {
            cout << j << endl;
        }
    } else {
        for (int j = A; j <= A + K - 1; ++j) {
            cout << j << endl;
        }
        for (int j = B - (K - 1); j <= B; ++j) {
            cout << j << endl;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fi first
#define se second
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
typedef complex<double> com;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	int n;
	cin >> n;
	vector<int> prime;
	for (int i = 6; i < 55555; i+=5) {
		bool flag = true;
		for (int j = 2; j*j <= i; j++) {
			if (i%j == 0) flag = false;
		}
		if (flag) prime.pb(i);
	}
	for (int i = 0; i < n; i++) cout << prime[i] << ' ';
	cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define bp __builtin_popcountll
#define pb push_back
#define in(s) freopen(s, "r", stdin);
#define inout(s, end1, end2) freopen((string(s) + "." + end1).c_str(), "r", stdin),\
		freopen((string(s) + "." + end2).c_str(), "w", stdout);
#define fi first
#define se second
#define bw(i, r, l) for (int i = r - 1; i >= l; i--)
#define fw(i, l, r) for (int i = l; i < r; i++)
#define fa(i, x) for (auto i: x)
using namespace std;
const int mod = 1e9 + 7, inf = 1061109567;
const long long infll = 4557430888798830399;
const int N = 1e5 + 5;
int n, dp[N][3], a[N][3];
signed main() {
	#ifdef BLU
	in("blu.inp");
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	fw (i, 0, n) fw (j, 0, 3) cin >> a[i][j];
	fw (j, 0, 3) dp[0][j] = 0;
	fw (i, 1, n + 1) fw (j, 0, 3) {
		fw (k, 0, 3) if (j != k) dp[i][j] = max(dp[i][j], dp[i - 1][k] + a[i - 1][j]);
	}
	int ans = 0;
	fw (j, 0, 3) ans = max(ans, dp[n][j]);
	cout << ans;
	return 0;
}


Measured memory_bytes: 2560
N = gets.to_i
S = gets.chomp.split("")

min = N

for i in 0...N do
  leader = i
  if leader == 0 then
    turner_to_e = 0
    turner_to_w = S[1...N].count("E")
  else
    leaders_west = leader - 1
    if S[leaders_west] == "W" then
      turner_to_e += 1
    end
    if S[leader] == "E" then
      turner_to_w -= 1
    end
  end
  min = [min, turner_to_e + turner_to_w].min
end

p min

Measured memory_bytes: 30468
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<climits>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

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


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const int INF = INT32_MAX / 3;
const ll MOD = 1e9 + 7;

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


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


//xのn乗をmで余りを取る
ll mod_pow(ll x, ll n, ll m) {
	if (n == 0) {
		return 1LL;
	}
	else if (n % 2 == 0) {
		return mod_pow(x * x % m, n / 2, m);
	}
	else {
		return (x * mod_pow(x, n - 1, m)) % m;
	}
}



int main() {

	string s;
	cin >> s;

	string tmp;

	string before;
	before.push_back(s[0]);

	int ans = 1;
	for (int i = 1; i < s.size(); i++)
	{
		if (before == tmp + s[i]) {
			tmp += s[i];
		}
		else
		{
			before = tmp + s[i];
			tmp.clear();
			ans++;
		}

	}

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


Measured memory_bytes: 640
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <set>
using namespace std;
#define LL long long
#define LD long double
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define pii pair<int,int>
#define pli pair<LL,int>
#define pil pair<int,LL>
#define pll pair<LL,LL>
#define ff first
#define ss second
#define pb push_back
#define BTW(x,a,b) ((a) <= (x) && (x) <= (b))
#define _eq(a,b) (fabs((a)-(b)) < EPS)
#define _lt(a,b) (fabs((a)-(b)) > EPS && a < b)
#define _gt(a,b) (fabs((a)-(b)) > EPS && a > b)
#define _lte(a,b) !_gt(a,b)
#define _gte(a,b) !_lt(a,b)
const vector<pii> XY = {pii(0,-1),pii(0,1),pii(-1,0),pii(1,0)};
const LD EPS = 1e-8;
const LD PI = acos(-1.0L);
const LL INFLL =  4e18;
const int INF  =  2e9;
const int MOD  =  1e9 + 7;
//#define int long long

// read / write
template<typename T> void read(T& t) { cin >> t; }
template<typename T, typename ... U> void read(T& t, U& ... u) { read(t); read(u ...); }
template<typename T> void write(T t) { cout << t; }
template<typename T, typename ... U> void write(T t, U ... u) { write(t); write(u ...); }



// ------------------------------------------------- Vs
const int LOGN    =  16              + 1;
const int MAXN1   =  3e5            + 3;
const int MAXN2   =  8            + 3;
// ------------------------------------------------- Fs
int32_t main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); write(fixed, setprecision(12));
    int r,g,b,n; read(r,g,b,n);
    int ans = 0;
    for(int x = 0; x <= n; ++x)
    for(int y = 0; y <= n; ++y){
        int rest = n - x*r - y*g;
        ans += rest >=0 && rest%b == 0;
    }
    write(ans, "\n");
    return 0;
}

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

int main(){
  ll n, m;  cin >> n >> m;
  vector<ll> p(m);
  vector<string> s(m);
  rep(i,m){
    cin >> p[i] >> s[i];
    p[i]--;
  }
  vector<ll> dist(n);
  vector<ll> cwa(n);
  ll ac=0, wa=0;
  rep(i,m){
    if(s[i]=="AC" && dist[p[i]]!=1){
      dist[p[i]] = 1;
      ac++;
      wa += cwa[p[i]];
    }
    if(s[i]=="WA" && dist[p[i]]!=1)  cwa[p[i]]++;
  }
  cout << ac << " " << wa;
  return 0;
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define pb push_back
#define ft first
#define sd second
#define mp make_pair
#define fr(i,n) for(int i=0;i<(n);i++)
#define Fr(i,n) for(int i=0;i++<(n);)
#define ifr(i,n) for(int i=(n)-1;i>=0;i--)
#define iFr(i,n) for(int i=(n);i>0;i--)

const ll MOD=1e9+7;

ll ad(ll x,ll y=0){
  return (x+y)%MOD;
}
int main(){
    ll n,c[200010]={},s[200010]={},dp[200010]={1};
    cin>>n;
    Fr(i,n){
        cin>>c[i];
        if(c[i]==c[i-1]){
            dp[i]=dp[i-1];
            continue;
        }
        dp[i]=ad(dp[i-1],s[c[i]]);
        s[c[i]]=ad(s[c[i]],dp[i-1]);
    }
    cout<<dp[n]<<endl;
}

Measured memory_bytes: 4992
#include<iostream>   //AA06( 14/ 06/ 20) If u see my code, Have a Good Day! (^_^)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)

using namespace std;

int main()
{
    fastio;

    int A[5], i;

    for(i = 0; i < 5; ++i) {

        cin >> A[i];

        if(A[i] == 0) {

            cout << i + 1 << endl;

            break;
        }
    }

    return 0;
}


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

int main(){
  string S,T;
  cin >>S >>T;
  int SL=S.length();
  int TL=T.length();
  if(TL>SL){
    cout<<"UNRESTORABLE"<<endl;
      return 0;
  }
  
  //cout<<SL<<" "<<TL<<endl;  
  bool flag=1;
  int pos=0;
  
  for (int i=0;i<=SL-TL;i++){
    flag=1;
    //cout<<"$"<<i<<endl;
    for (int j=0;j<TL;j++){ 
      if(  ( S.at(SL-1-j-i)!=T.at(TL-j-1) ) && ( S.at(SL-1-j-i)!='?') ){
        flag=0;
        //cout<<i<<" "<<j<<"not mach"<<endl;
        break;
      }
      //cout<<i<<"#"<<j<<endl;
    }
    //cout<<"POS1 "<<flag<<endl;
    if(flag==1){
      //cout<<i<<"%"<<flag<<endl;
      pos=i;
      break;
    }
    //cout<<"POS2 "<<endl;
  }
  if(flag==0){
    cout<<"UNRESTORABLE"<<endl;
    return 0;
  }
  //cout<<"HERE"<<endl;
  for(int i=0;i<TL;i++){
    S.at(SL-pos-1-i)=T.at(TL-1-i);
  }
  for(int i=0;i<SL;i++){
    if(S.at(i)=='?'){
      S.at(i)='a';
    }
  }
  cout<<S<<endl;
  //cout<<pos<<endl;
  return 0;
}

    
    

Measured memory_bytes: 256
import numpy as np
n,k=map(int,input().split())
p=list(map(int, input().split()))
p=np.array(p)
p=(p+1)/2
x=[0]
x.extend(p.cumsum())
ans=0
for i in range(k-1,n+1):
    ans=max(x[i]-x[i-k],ans)
print(ans)

Measured memory_bytes: 33948
n=int(input())
arr=[int(i) for i in input().split()]
total=1
arr.sort()
if(arr[0]==0):
    print(0)
else:

    for i in range(n):
        if(arr[i]>10**18):
            total=-1
            break
        else:
            total*=arr[i]
            if total>10**18:
                total=-1
                break
    print(total)


Measured memory_bytes: 21776
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
//  #ifndef ONLINE_JUDGE
//     freopen ("INPUT.txt" , "r" , stdin);
//     freopen ("OUTPUT.txt" , "w" , stdout);
//  #endif
 
// -------------------------------------Code starts here---------------------------------------------------------------------     

   int n;
   cin>>n;
   set<int>s;
   int x;
   for(int i=0;i<n;i++)
   {
      cin>>x;
      s.insert(x);
   }
   if(s.size()==n)
   {
      cout<<"YES";
   }
   else
   {
      cout<<"NO";
   }
   

// -------------------------------------Code ends here------------------------------------------------------------------
     clock_t clk;
 	clk = clock();
 
    clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }


Measured memory_bytes: 9600
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>


typedef long long ll;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBAC
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

int gcd(int a, int b) {
	int c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t,sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

bool is_prime(int x) {
	if (x <= 1) return false;
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

map<string, int> memo;

using P=pair<int, int>;

struct Clock {
	int hour, minute, second;
	void set(int h, int m, int s) {
		hour = h; minute = m; second = s;
	}
	string to_str() {
		string h, m, s;
		h = to_string(hour);
		m= to_string(minute);
		s= to_string(second);
		if (h.size() < 2) h = "0" + h;
		if (m.size() < 2) m = "0" + m;
		if (s.size() < 2) s = "0" + s;
		return h + ":" + m + ":" + s;
	}
	void shift(int diff_second) {
		int h, m;
		h = diff_second / 3600;
		m = diff_second / 60;
		diff_second %= 60;
		second += diff_second;
		
	}
};
int main() {
	//sort(a.begin(),a.end());
	int a;
	string s;
	cin >> a >> s;
	if (a >= 3200) cout << s;
	else cout << "red";
	return 0;
}









Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

/*
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };
*/

using namespace std;

class Dice
{
  public:
    int s[6];
    int *s1 = &s[-1];
    void roll(char dir)
    {
        int tmp[6];
        int *tmp1 = &tmp[-1];

        memcpy(tmp, s, sizeof(int) * 6);
        switch (dir)
        {
        case 'N':
            s1[1] = tmp1[2];
            s1[2] = tmp1[6];
            s1[6] = tmp1[5];
            s1[5] = tmp1[1];
            break;
        case 'E':
            s1[1] = tmp1[4];
            s1[4] = tmp1[6];
            s1[6] = tmp1[3];
            s1[3] = tmp1[1];
            break;
        case 'W':
            s1[1] = tmp1[3];
            s1[3] = tmp1[6];
            s1[6] = tmp1[4];
            s1[4] = tmp1[1];
            break;
        case 'S':
            s1[1] = tmp1[5];
            s1[5] = tmp1[6];
            s1[6] = tmp1[2];
            s1[2] = tmp1[1];
            break;
        }
    }
};

int main()
{
    Dice d;
    for (int i = 0; i < 6;i++)
        cin >> d.s[i];

    string str;
    cin >> str;

    for (int i = 0; i < str.size(); i++)
        d.roll(str[i]);

    cout << d.s1[1] << endl;
}


Measured memory_bytes: 3188
F=->{gets.split.map &:to_i}
*,k=F[]
a,B=F[]<<k,F[]
m=i=a.index{0>k-=_1}
A=a[0..i]
while a=A.pop
k+=a
(k-=B.shift;i+=1)until B[0]>k rescue A.clear
m=[m,1+i-=1].max
end
p m

Measured memory_bytes: 41724
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int oddCount = 0;
		for (int i = 1; i <= N; i++) {
			if (i % 2 != 0) {
				oddCount++;
			}
		}
		System.out.println(String.format("%.10f", (double) oddCount / (double) N));
	}
}

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

int main() {
  int N, K, x, sum=0;
  cin >> N; 
  cin >> K;
  for(int i=0; i < N; i++){
    cin >> x;
    if(K-x > x){
      sum = sum + 2 * x;
    }
    else if(K-x <= x){
      sum = sum + 2 * (K-x);
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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 (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll R;
    cin >>R;
    
    if(R<1200){
        cout<<"ABC"<<endl;
    }else if(R<2800){
        cout<<"ARC"<<endl;
    }else{
        cout<<"AGC"<<endl;
    }


    return 0;
    

}

Measured memory_bytes: 3604
import java.util.Scanner;

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

        if (b.charAt(0) == 'A') System.out.println('T');
        else if (b.charAt(0) == 'T') System.out.println('A');
        else if (b.charAt(0) == 'C') System.out.println('G');
        else if (b.charAt(0) == 'G') System.out.println('C');

    }
}

Measured memory_bytes: 21204
///
//AOJのの回答プログラム
// create:20180908
//


#include <iostream>

using namespace std;
int main(void)
{
	int a, b;
	
	cin >> a >> b ;
	if (a > b) {
		cout << "a > b" << "\n";
	}
	else if (a < b) {
		cout << "a < b" << "\n";
	}
	else if (a == b) {
		cout << "a == b" << "\n";
	}
	
	return 0;
}





Measured memory_bytes: 3080
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int D = sc.nextInt();
        int result = Math.min(B,D) - Math.max(A,C);
        if(result < 0)result = 0;
        System.out.println(result);
    }
}

Measured memory_bytes: 21716
use std::io;
use std::cmp;
use io_ext::Reader;

fn main() {
    let stdin = io::stdin();
    let mut r = Reader::new(io::BufReader::new(stdin.lock()));
    let n: usize = r.read_line().parse().unwrap();
    let b = ((n as f64).sqrt() + 1.0) as usize;
    let mut sum = n + 1 - 2;
    for i in 1..(b + 1) {
        if n % i == 0 {
            sum = cmp::min(sum, i + (n / i) - 2);
        }
    }
    println!("{}", sum);
}

/// Extension of io module.
pub mod io_ext {
    use std::io::BufRead;

    pub struct Reader<R> {
        buf: String,
        inner: R,
    }

    impl<R> Reader<R> {
        #[inline]
        pub fn new(inner: R) -> Self {
            Reader { buf: String::new(), inner: inner }
        }

        #[inline]
        pub fn into_inner(self) -> R {
            self.inner
        }
    }

    impl<R: BufRead> Reader<R> {
        #[allow(deprecated)]
        #[inline]
        pub fn read_line(&mut self) -> &str {
            self.buf.clear();
            self.inner.read_line(&mut self.buf).unwrap_or_else(|e| panic!("{}", e));
            self.buf.trim_right()
        }
    }
}

/// Module supporting to parse strings.
pub mod parse {
    use std::str::FromStr;
    use std::borrow::Borrow;

    pub trait ParseNext: Iterator {
        fn parse_next<F: FromStr>(&mut self) -> F;
    }

    impl<'a, S: Borrow<str>, I: Iterator<Item=S>> ParseNext for I {
        fn parse_next<F: FromStr>(&mut self) -> F {
            if let Some(s) = self.next() {
                match s.borrow().parse() {
                    Ok(x) => x,
                    Err(_) => panic!("provided string cannot be parsed")
                }
            } else {
                panic!("iterator has no next element")
            }
        }
    }
}


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

int main(){
    while(1){
        int r0,w0,c,r;
        cin >> r0 >> w0 >> c >> r;
        if(r0==0) break;

        if(w0*c > r0){
            cout << (int)ceil((double)(w0*c-r0)/r) << endl;
        }else{
            cout << 0 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3092
from collections import deque

n = int(input())

g = [deque([]) *n for _ in range(n)]

for i in range(n):
    u, k, *V = list(map(int, input().split()))
    V.sort()
    for v in V:
        g[u-1].append(v-1)
        # g[v-1].append(u-1)

time = 0
arrive_time = [-1] * n
finish_time = [-1] * n
def dfs(v):
    global time
    time += 1
    stack = [v]
    arrive_time[v] = time
    while stack:
        v = stack[-1]
        if g[v]:
            w = g[v].popleft()
            if arrive_time[w] < 0:
                time += 1
                arrive_time[w] = time
                stack.append(w)
        else:
            time += 1
            finish_time[v] = time
            stack.pop()

    return [arrive_time, finish_time]

for i in range(n):
    if arrive_time[i] < 0:
        ans = dfs(i)

for j in range(n):
    temp = [j+1, ans[0][j], ans[1][j]]
    print(*temp)


Measured memory_bytes: 6088
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

const int INF = 1e9;
const long long LINF = 1e18;

int main() {
    string S;
    cin >> S;

    char last = S[0];
    for (int i = 1; i < S.size(); i++) {
        if (S[i] == last) {
            cout << "Bad" << endl;
            return 0;
        }
        last = S[i];
    }

    cout << "Good" << endl;
    return 0;
}


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

int jud=2,ans=0;
int grid[52][52]={0};
void search(int w, int h)
{
  if(grid[w][h]==2){
    ans++; grid[w][h]=0;
    if(grid[w][h-1]) search(w,h-1);
    if(grid[w-1][h]) search(w-1,h);
    if(grid[w][h+1]) search(w,h+1);
    if(grid[w+1][h]) search(w+1,h);
  } else if(grid[w][h]==1){
    if(jud==2) jud=1;
    else if(jud==-1){
      jud=0;
    }
  } else if(grid[w][h]==-1){
    if(jud==2) jud=-1;
    else if(jud==1){
      jud=0;
    }
  }
}

int main()
{
  int w,h,i,j;
  char c;

  for(;;){
    cin>>w>>h;
    if(!(w|h)) break;

    for(i=0;i<h+2;i++)
      for(j=0;j<w+2;j++)
	grid[j][i]=0;
    for(i=1;i<h+1;i++)
      for(j=1;j<w+1;j++){
	cin>>c;
	if(c=='.') grid[j][i]=2;
	if(c=='B') grid[j][i]=1;
	if(c=='W') grid[j][i]=-1;
      }
    int ansB=0,ansW=0;
    for(i=1;i<h+1;i++)
      for(j=1;j<w+1;j++){
	if(grid[j][i]==2){
	  search(j,i);
	  if(jud==1) ansB+=ans;
	  else if(jud==-1) ansW+=ans;
	}
	jud=2; ans=0;
      }
    cout<<ansB<<" "<<ansW<<endl;
  }
}


Measured memory_bytes: 1356
N, x = map(int, input().split())
a = list(map(int, input().split()))

res = 0
for i in range(len(a)-1):
    b = a[i]+a[i+1]
    if x < b:
        res += b-x
        a[i+1] -= min(b-x, a[i+1])

print(res)
            
            


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

int primes[1230] = { 2, 3 };

int count = 0;

void gen_primes(void)
{

	int prime_count = 2;
	int i, j, flag;
	for (i = 5; i < 10000; i += 2) {
		for (j = 0, flag = 1; primes[j] * primes[j] <= i; j++)
			if (i % primes[j] == 0)
				flag = 0;
		if (flag) {
			primes[prime_count] = i;
			prime_count++;
		}
	}
	return;
}

void calc(int N, int i)
{
	if (i < 0)
		return;
	if (N - primes[i] == 0)
		count++;
	else if (N - primes[i] > 0)
		calc(N - primes[i], i - 1);
	else
		return;
	return;
}

int main(void)
{
	gen_primes();
	int N, i, k;
	for (;;) {
		cin >> N;
		if (N == 0)
			return 0;
		for (i = 0; i < 1230; i++)
			if (N == primes[i]) {
				count++;
				k = i - 1;
				break;
			} else if (N < primes[i]) {
				k = i - 1;
				break;
			}
		for (i = k; i >= 0; i--)
			calc(N, i);
		cout << count << endl;
		count = 0;
	}
	return 0;
}

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

int main(){
  int a,b,c;
  cin >> a >> b;
  c = a * b;
  if(c % 2 == 0){
    cout << "Even" << endl;
  }
  if(c % 2 != 0){
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(...)
#include <complex.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;


int main( ) {
    ios::sync_with_stdio(false); cin.tie(0);
    #ifdef LOCAL
     //    freopen("input.in", "r",  stdin);
    #endif
    vi a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(a.begin() , a.end());
    bool ok = ((a[0] == a[1] && a[1] != a[2])) || (a[0] != a[1] && a[1] == a[2]);
    cout << (ok ? "Yes" : "No") << '\n';



    return 0;
}













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

int main(){
  int n; cin >> n;
  if(n == 1) cout << "Hello World";
  else if(n == 2){
    int a,b; cin >> a >> b;
    cout << a + b;
  }
}

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

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define mp make_pair
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

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

  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << max(max(a*d, a*c), max(b*c, b*d)) << endl;
}


Measured memory_bytes: 3656
N=int(input())
G=[[] for _ in range(N)]
for i in range(N-1):
  x,y,d=map(int,input().split())
  x-=1
  y-=1
  G[x].append((y,d))
  G[y].append((x,d))
Q,K=map(int,input().split())
stack=[K-1]
unseen=[1]*N
dist=[float('inf')]*N
dist[K-1]=0
while stack:
  u=stack.pop()
  unseen[u]=0
  for v,d in G[u]:
    if unseen[v]:
      dist[v]=min(dist[v],dist[u]+d)
      stack.append(v)
for q in range(Q):
  x,y=map(int,input().split())
  print(dist[x-1]+dist[y-1])

Measured memory_bytes: 45868
N = int(input())
H = list(map(int, input().split()))

ans   = 0
count = 0


for j in range(N):
    if N == 1:
       break
 
    if H[j] >= H[j+1]:
        count += 1
    else:
        ans    = max(ans, count)
        count  = 0

    if j == N-2:
        if count > ans:
            ans   = count
        break

print(ans)

Measured memory_bytes: 14224
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int n, z, w;
    cin >> n >> z >> w;
    vint a(n);
    rep(i, n) {
        cin >> a[i];
    }
    int ans;
    if (n == 1) ans = abs(a[0] - w); 
    else ans = max(abs(a[n-1] - w), abs(a[n-2] - a[n-1]));
    cout << ans << endl;
    return 0;
}

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

X = int(input())
n = 2*X

candidate = list(range(2, n+1)) #候補
prime = []
limit = n**0.5 + 1 

while True:
    p = candidate[0] 
    if limit <= p:
        prime.extend(candidate) 
        break
    prime.append(p)
    candidate = [i for i in candidate if i % p != 0]

for number in prime:
    if number >= X:
        print(number)
        exit()


Measured memory_bytes: 11800
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N; cin >> N;
    vector<int> cnt(1000000, 0);
    for (int i = 0; i < N; i++)
    {
        int a; cin >> a;
        if(a > 0) cnt[a-1]++;
        cnt[a]++;
        cnt[a+1]++;
    }
    cout << *max_element(cnt.begin(), cnt.end()) << endl;
    return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()

int main(){
    long h;
    cin >> h;

    long count=1;
    long ans=0;
    while(h>=1){
        h /= 2;
        ans += count;
        count *= 2;
    }

    cout << ans << endl;
} 


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int next = 1;
		int count = 0;
		int a;
		for (int i = 0; i < n; i++) {
			a = scanner.nextInt();
			if (a == next)
				next++;
			else
				count++;
		}
		System.out.println(next > 1 ? count : -1);
	}

}


Measured memory_bytes: 64696
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define INF 0x7f7f7f7f 
const int MAXN=1e6;
int n;
int ans=INF;
char s[MAXN];
int sum[MAXN];
using namespace std;
int min(int a,int b)
{
	if(a>b) return b;
	else return a;
}
int main()
{
	scanf("%d",&n);
	scanf("%s",s+1); 
	for(int i=1;i<=n;i++)
	{
		int now=0;
		if(s[i]=='E') 	now=1;
		sum[i]=sum[i-1]+now;
	}
	for(int i=1;i<=n;i++)
	{
		ans=min(ans,(i-1)-sum[i-1]+(sum[n]-sum[i]));
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 3584
#pragma GCC optimize ("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
#define FORD(i, a, b) for (int i=(a); i>(b); i--)
#define PPC(x) __builtin_popcount(x)
#define MSB(x) (31 - __builtin_clz(x))
#define SZ(x) ((int)(x).size())
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define ithBit(m, i) ((m) >> (i) & 1)
#define ft first
#define sd second
#define kw(a) ((a) * (a))
#ifdef DEBUG
#include "debug.h"
#else
#define dbg(...) 0
#endif
using namespace std;

const int maxN = 1 << 19;

long long T[maxN];
const long long INF = 1000000000000000000ll;

void solve()
{
	long long n;
	scanf ("%lld", &n);
	int res = 0;
	for (long long i=2; i*i<=n; i++) if (n % i == 0)
	{
		int c = 0;
		while (n % i == 0)
			n /= i, c++;
			
		int j = 0, s = 0;
		while (s + j+1 <= c)
			j++, s += j;
		res += j;
	}
	
	if (n != 1ll)
		res++;
	printf("%d\n", res);
}

int main()
{
	int t = 1;
	//scanf ("%d", &t);
	while (t--)
		solve();
	return 0;
}





Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(15); //"for float-base
  // problem"
  int A, B;
  cin >> A >> B;
  if (A > 9 || B > 9)
    cout << -1 << endl;
  else
    cout << A * B << endl;
}

Measured memory_bytes: 3568
#include<stdio.h>
int main()
{
    int a,b,c,k;
    scanf("%d%d%d%d",&a,&b,&c,&k);
    int sum=0;
    if(k>0&&a>0)
    {
        if(k>=a)
        {
            sum=sum+a;
          k=k-a;
        }
        else
        {
            sum=sum+k;
            k=k-k;
        }

    }
    if(k>0&&b>0)
    {
        if(k>=b)
        {
            k=k-b;
        }
        else
        {
            k=k-k;
        }
    }
    if(k>0&&c>0)
    {
        sum=sum-k;
        k=0;
    }
    printf("%d\n",sum);
}


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

def main():
    N = int(input())
    g = 1
    tmp = 1
    while tmp < N:
        g += 1
        tmp += g
    if tmp != N:
        print("No")
        return
    ans = [list() for i in range(g+1)]
    i, j = 0, 0
    for count in range(N):
        if i == j:
            ans[i].append(count+1)
            ans[-1].append(count+1)
            i += 1
            j = 0
        else:
            ans[i].append(count+1)
            ans[j].append(count+1)
            j += 1
    print("Yes")
    print(g+1)
    for i in range(g+1):
        print(len(ans[i]), end=" ")
        for j in range(len(ans[i])-1):
            print(ans[i][j], end=" ")
        print(ans[i][-1])

if __name__ == "__main__":
    main()

Measured memory_bytes: 12424
from datetime import datetime
import math

def measure(f):
    measure_start = datetime.now()
    v = f()
    print(datetime.now() - measure_start)
    return v

input = raw_input
range = xrange
    
def init():
    table = [True] * 1000001
    table[0] = False
    table[1] = False
    n = len(table)

    def prime(p):
        for i in range(p + p, n, p):
            table[i] = False
    prime(2)
    prime(3)
    prime(5)
    prime(7)
    prime(11)
    prime(13)

    for i in range(2, int(math.sqrt(n) + 1)):
        if (i % 2 != 0 and i % 3 != 0 and i % 5 != 0 and
            i % 7 != 0 and i % 11 != 0 and i % 13 != 0):
            for j in range(i * i, n, i):
                table[j] = False
#    for i in range(len(table)):
#        if table[i]:
#            print(i)
    return table
    
def solve(price, ps, is_prime):
    dp = [0] * ((price >> 5) + 1)

    for i in range(0, price + 1,ps[0]):
        dp[i >> 5] |= 1 << (i & 31)
    dp[0] = 1
    
    for i in range(1, len(ps)):
        cur_p = ps[i]
        r = cur_p & 31
        rest = 0
        if cur_p >= 32:
            for p in range(cur_p, price + 1, 32):
                i1 = (p - cur_p) >> 5
                i2 = p >> 5
                v = dp[i1]
                dp[i2] |= (v << r) | rest
                rest = (v >> (32 - r)) & ((1 << r) - 1)
        else:
            for p in range(cur_p, price + 1):
                dp[p >> 5] |= (dp[(p - cur_p) >> 5] >> ((p - cur_p) & 31) & 1) << (p & 31)
            
    p = -1
    for i in range(0, price + 1):
        if is_prime[i] and (dp[i >> 5] >> (i & 31)) & 1 == 1:
            p = i
    if p == -1:
        print("NA")
    else:
        print(p)
    
def main():
    table = init()
    while True:
        n, price = map(int,input().split())
        if n == 0 and price == 0:
            return
        ps = []
        for i in range(n):
            ps.append(int(input()))
        solve(price, ps, table)

main()

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

typedef pair<int,int> P;

int main(){
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++){
        if (s[i] == '?') s[i] = 'D';
    }
    cout << s << "\n";
}

Measured memory_bytes: 3720
#include <iostream>
#include <vector>
#include <cstring>
using namespace std;
#define pb push_back
int n;
bool sieve[40000];
vector<int> primes;

void solve() {
  int res = 0;
  for (int i = 0; i < primes.size(); i += 1) {
    int t_sum = primes[i];
    for (int j = i; j < primes.size(); j += 1) {
      if (t_sum + primes[j] == n) {
        res++;
        break;
      } else if (t_sum + primes[j] > n) {
        break;
      }
    }
  }
  cout<<res<<endl;
}

int main (int argc, char const* argv[]) {
  // set sieve
  memset(sieve, true, sizeof sieve);
  for (int i = 2; i < 40000; i += 1) {
    if (sieve[i]) {
      primes.pb(i);
      for (int j = i+i; j < 40000; j += i) {
        sieve[j] = false;
      }
    }
  }
  
  while (cin>>n, n) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 992
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
    // Atcoder
    // template: cpp
    ll a, b, k;
    cin >> a >> b >> k;
    // a = 8;
    // b = 12;
    // k = 2;

    vector<ll> res;

    rep(i, min(a, b)) {
        if(a % (i + 1) == 0 && b % (i + 1) == 0)
            res.push_back(i + 1);
    }
    sort(all(res));
    reverse(all(res));
    cout << res.at(k - 1);
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int ans = 1;
		if (n % 2 == 0) {
			ans = n;
		} else {
			ans = 2 * n;

		}
		System.out.println(ans);

	}

}


Measured memory_bytes: 23764
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int nums[n];
    for(int i=0;i<n;i++){
        int h;
        cin>>h;
        nums[i] = h;
    }
    int dp [n];
    dp[0] = 0;
    dp[1] = abs(nums[1] - nums[0]);
    for(int i=2;i<n;i++){
        int x = dp[i-1] + abs(nums[i-1]-nums[i]);
        int y = dp[i-2] + abs(nums[i-2]-nums[i]);
        dp[i] = min(x,y);
    }
    cout<<dp[n-1];

}


Measured memory_bytes: 4340
import numpy as np

H,W = map(int, input().split())

a = [list(str(input())) for i in range(H)]
b = []

for i in range(H):
    for j in range(W):
        if a[i][j]!=".":
            b.append(a[i])
            break

del_targets = []
b_arr = np.array(b)

#print(b_arr)
            
for j in range(W):
    #print(b_arr[:,j])
    if b_arr[:,j].tolist().count(".") == len(b_arr[:,j].tolist()):
        del_targets.append(j)
        
ans = np.delete(b_arr, del_targets, 1)

for i in range(len(ans)):
    print(str(''.join(ans[i,:])))

Measured memory_bytes: 12620
#include <algorithm>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <thread>
#include <tuple>
#include <type_traits>
#include <vector>


#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    int n, m, k;
    cin >> n >> m >> k;
    vector<ll> a(n + 1), b(m + 1);
    ll t;

    for (int i = 1; i < n + 1; i++) {
        cin >> t;
        a[i] = a[i - 1] + t;
    }
    for (int i = 1; i < m + 1; i++) {
        cin >> t;
        b[i] = b[i - 1] + t;
    }

    int ans = 0;
    for (int i = 0; i < n + 1 && a[i] <= k; i++) {
        auto it = upper_bound(b.begin(), b.end(), k - a[i]);
        int j = distance(b.begin(), it) - 1;
        ans = max(ans, i + j);
    }
    cout << ans << endl;
}


Measured memory_bytes: 6040
#include <iostream>

using namespace std;

bool a[100005];
typedef long long ll;
const ll mod = 1e9 + 7;
ll dp[100005];
int main() {
  int n,m;
  cin >> n >> m;

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

  dp[0] = 1;

  for(int i = 0; i < n; i++) {
    if(dp[i] == 0) continue;
    if(!a[i+1]) {
      dp[i+1] += dp[i];
      dp[i+1] %= mod;
    }
    if(!a[i+2]) {
      dp[i+2] += dp[i];
      dp[i+2] %= mod;
    }
  }

  cout << dp[n] % mod << endl;
}


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

using namespace std;

const int N = 45;
const int M = 18;
const int mod = (int) 1e9 + 7;

int n, x, y, z;
int dp[N][1 << M];

int add(int a, int b) {
  int ret = a + b;
  if (ret >= mod) ret -= mod;
  return ret;
}

int sub(int a, int b) {
  int ret = a - b;
  if (ret < 0) ret += mod;
  return ret;
}

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

int main() {
  scanf("%d %d %d %d", &n, &x, &y, &z);
  dp[0][0] = 1;
  int m = 1 << (x + y + z);
  y += z;
  x += y;
  x--, y--, z--;
  int bad = (1 << z) | (1 << y) | (1 << x);
  for (int i = 0; i < n; i++) for (int mask = 0; mask < m; mask++) {
    if (dp[i][mask] == 0) continue;
    for (int d = 1; d <= 10; d++) {
      int nmask = ((mask << d) | (1 << (d - 1))) & (m - 1);
      if ((nmask & bad) != bad) {
        dp[i + 1][nmask] = add(dp[i + 1][nmask], dp[i][mask]);
      }
    }
  }
  int ans = 0;
  int pw = 1;
  for (int i = 0; i < n; i++) pw = mul(pw, 10);
  for (int mask = 0; mask < m; mask++) ans = sub(ans, dp[n][mask]);
  ans = add(ans, pw);
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 41216
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

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

	vector<int> P;
	for (int i = 0; i < N; i++) {
		int p;
		cin >> p;
		P.push_back(p);
	}

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

	int total = 0;
	for (int i = 0; i < K; i++) {
		total += P[i];
	}

	cout << total << endl;

}






Measured memory_bytes: 3588
#pragma region head
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
#define double long double
typedef double ld;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;
const double PI = acos(-1.0);

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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;
}

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
#pragma endregion

signed main() {
  int N;
  cin >> N;
  vector<int> A(N);
  int sum = 0;
  rep(i, N) {
    cin >> A[i];
    sum += A[i];
  }

  int num1 = N * (N + 1) / 2;
  if (sum % num1 != 0) {
    cout << "NO\n";
    return 0;
  }

  int op = sum / num1;

  vector<int> diff(N);
  rep(i, N) {
    diff[i] = A[(i + 1) % N] - A[i];
  }

  int down = 1 - N;
  int cnt = 0;
  rep(i, N) {
    int numer = diff[i] - op;
    int denom = down - 1;
    if (numer % denom != 0 || numer / denom < 0) {
      cout << "NO\n";
      return 0;
    } else {
      cnt += numer / denom;
    }
  }

  if (cnt == op)
    cout << "YES\n";
  else
    cout << "NO\n";
}

Measured memory_bytes: 1792
//Single Source Shortest Path I
#include <iostream>
#include <climits>
using namespace std;

static const int N = 100;
static const int WHITE = 0;
static const int BLACK = 1;
int n, A[N][N], colors[N], d[N];

void dijkstra() {
    int u, mind;
    for(int i = 0; i < N; i++) {
        colors[i] = WHITE;
        d[i] = INT_MAX;
    }
    d[0] = 0;
    while(1) {
        u = -1;
        mind = INT_MAX;
        for(int i = 0; i < n; i++) {
            if(colors[i] == WHITE && d[i] < mind) {
                u = i;
                mind = d[i];
            }
        }
        if(u == -1) break;
        colors[u] = BLACK;
        for(int i = 0; i < n; i++) {
            if(A[u][i] != -1) {
                d[i] = min(d[i], mind + A[u][i]);
            }
        }
    }

}

int main() {
    int u, k, v, c;
    cin >> n;
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < N; j++) {
            A[i][j] = -1;
        }
    }
    for(int i = 0; i < n; i++) {
        cin >> u >> k;
        for(int j = 0; j < k; j++) {
            cin >> v >> c;
            A[u][v] = c;
        }
    }

    dijkstra();

    for(int i = 0; i < n; i++) {
        cout << i << " " << d[i] << endl;
    }
}


Measured memory_bytes: 3148
#include <iostream>
#include <cstring>

using namespace std;

typedef long long ll;

ll tree[100005];

void init(void)
{
    memset(tree, -1, sizeof(tree));
}

int root(int a)
{
    if (tree[a] < 0) {
        return a;
    } else {
        return tree[a] = root(tree[a]);
    }
}

void unite(int a, int b)
{
    a = root(a);
    b = root(b);

    if (a != b) {
        tree[a] += tree[b];
        tree[b] = a;
    }

    return;
}

int same(int a, int b)
{
    return root(a) == root(b);
}

ll lang[100005];

int main()
{
    init();
    
    ll n, m;
    ll k;
    ll a;
    
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        cin >> k;

        for (int j = 0; j < k; j++) {
            cin >> a;

            if (lang[a] == 0) {
                lang[a] = i;
            }

            unite(lang[a], i);
        }
    }

    if (-1 * tree[root(1)] == n) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 1792
n, k = map(int, input().split())
a = sorted(list(map(int, input().split())))
f = sorted(list(map(int, input().split())), reverse=True)

ok, ng = a[-1]*f[0], -1
while ok-ng > 1:
	x = (ok+ng)//2
	tmp = 0
	for i in range(n):
		tmp += max(0, a[i] - x//f[i])
	if tmp > k:
		ng = x
	else:
		ok = x
print(ok)


Measured memory_bytes: 121036
#include <iostream>

using namespace std;

int main()
{
    int N, M, K[32], A[32][32], count[32] = {0}, ans;

    cin >> N >> M;
    for (int i = 0; i < N; i++) {
        cin >> K[i];
        for (int j = 0; j < K[i]; j++) {
            cin >> A[i][j];
            count[A[i][j] - 1]++;
        }
    }

    ans = 0;
    for (int i = 0; i < M; i++) {
        if (count[i] == N) {
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256