akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>

using namespace std;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

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

const int OO = (int) 2e9;
const double eps = 1e-9;

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	int n, a, b;
	cin >> n >> a >> b;
	if ((b - a - 1) & 1)
		puts("Alice");
	else
		puts("Borys");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;       //     ____   _   _  __   __
#define ll long long       //    / ___| | |_| |   / /
const ll INF = 0x3f3f3f3f; //   | |     |  _  |   V /
const ll N   = 1e5 + 5;    //   | |___  | | | |   | |
const ll MOD = 1e9 + 7;    //    ____| |_| |_|   |_|
ll read() {
  ll   x = 0, f = 1;
  char ch = getchar();

  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1; ch = getchar();
  }

  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0'; ch = getchar();
  }
  return x * f;
}

ll n, a[N], b[N], c[N];
ll ans;

int main() {
  n = read();

  for (int i = 1; i <= n; i++) a[i] = read();

  for (int i = 1; i <= n; i++) b[i] = read();

  for (int i = 1; i < n; i++) c[i] = read();

  for (int i = 1; i <= n; i++) {
    ans += b[a[i]];

    if ((i > 1) && (a[i - 1] + 1 == a[i])) {
      ans += c[a[i - 1]];

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


Measured memory_bytes: 256
#include <iostream>
#include <math.h> 

using namespace std;

int main()
{
    double H,N,A,total=0;
    cin >> H >> N;
    for(int i=0; i<N; i++){
        cin>>A;
        total+=A;
    }
    if(total >= H)
    cout << "Yes";
    else
    cout <<"No";
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

int main()
{
    int n;
    cin >> n;
    ll t[100002], a[100002];
    for(int i = 0; i < n; i++) cin >> t[i];
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i++) if(i == 0 || t[i] > t[i - 1]) if(a[i] < t[i]){
        cout << 0 << endl;
        return 0;
    }
    for(int i = n - 1; i >= 0; i--) if(i == n - 1 || a[i] > a[i + 1]) if(t[i] < a[i]){
        cout << 0 << endl;
        return 0;
    }
    ll ans = 1;
    for(int i = 0; i < n; i++){
        if(t[i] == t[i - 1] && a[i] == a[i + 1]) ans = ans * min(t[i], a[i]) % MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
/**
 * File    : C.cpp
 * Author  : Kazune Takahashi
 * Created : 11/24/2018, 8:48:33 PM
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int N;
string S;
int Q;
int k[100];
typedef tuple<int, ll> X;
vector<X> D, C;

int main()
{
  cin >> N >> S >> Q;
  for (auto i = 0; i < Q; i++)
  {
    cin >> k[i];
  }
  int m = 0;
  for (auto i = 0; i < N; i++)
  {
    if (S[i] == 'D')
    {
      D.push_back(X(i, m));
    }
    else if (S[i] == 'M')
    {
      m++;
    }
    else if (S[i] == 'C')
    {
      C.push_back(X(i, m));
    }
  }
  int D_size = D.size();
  int C_size = C.size();
  for (auto q = 0; q < Q; q++)
  {
    int K = k[q];
    ll ans = 0;
    ll ind_d = 0;
    ll left = 0;
    ll right = 0;
    ll sum = 0;
    while (ind_d < D_size)
    {
      while (left < C_size && get<0>(C[left]) < get<0>(D[ind_d]))
      {
        sum -= get<1>(C[left]);
        left++;
      }
      while (right < C_size && get<0>(C[right]) - get<0>(D[ind_d]) < K)
      {
        sum += get<1>(C[right]);
        right++;
      }
      ans += sum - (right - left) * get<1>(D[ind_d]);
      ind_d++;
    }
    cout << ans << endl;
  }
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


struct query { ll l, r; };
ll MA = 100010;

int main() {
  int N; cin >> N;
  ll A[N]; rep(i,N) cin >> A[i];
  int Q; cin >> Q;
  query q[Q]; rep(i,Q) cin >> q[i].l >> q[i].r;  

  ll count[MA] = {}; rep(i,N) count[A[i]]++;
  ll result = 0; rep(i,N) result += A[i];
  rep(i,Q) {
    result += (q[i].r-q[i].l) * count[q[i].l];
    cout << result << endl;
    count[q[i].r] += count[q[i].l];
    count[q[i].l] = 0;
    // debug(count,count+5);
  }

  return 0;
}

Measured memory_bytes: 6728
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
int main()
{
	int n;
	int point[101]={0};
	int p[101]={0};
	cin >> n;
	for(int i=0;i<n*(n-1)/2;i++)
	{
		int a,b,c,d;
		cin >> a >> b >> c >> d;
		if(c==d)
		{
			point[a]++;
			point[b]++;
			p[a]++;
			p[b]++;
		}
		else if(c<d)
		{
			point[b]+=3;
			p[b]+=3;
		}
		else
		{
			point[a]+=3;
			p[a]+=3;
		}
	}
	sort(p,p+n+1,greater<int>());
	map<int,int> m;
	int k=1;
	int e=0;
	for(int i=1;i<=n;i++)
	{
		if(m.find(p[i])==m.end())
		{
			m[p[i]]=(k++)+e;
		}
		else
		{
			e++;
		}
	}
	for(int i=1;i<=n;i++)
	{
		cout << m[point[i]]+1 << endl;
	}
	return 0;
}

Measured memory_bytes: 1212
#include <iostream>

using namespace std;

typedef long long ll;
#define x first
#define y second
#define mp make_pair

string s;
int n;

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n;
cin >> s;
for(int i = 0 ; i < (int)s.size() ; ++i){
	int x = s[i] - 'A';
	x = (x + n) % 26;
	s[i] = x + 'A';
}
cout << s << endl;

return 0;
}



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

int main() {
  ll N;
  cin >> N;
  if (N % 2 == 1) {
    cout << 0 << endl;
    return 0;
  }
  ll res = 0;
  ll count = 0;
  for (ll base = 5; base <= N; base *= 5) {
    res += N / base / 2;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 384
n, k = map(int, input().split())
ans = 0
for i in range(1,n+1):
	ans_temp = 1/n
	for j in range(1000):

		if i >= k:
			ans += ans_temp
			break
		else:
			i = i * 2
			ans_temp = ans_temp/2
print(ans)
	


Measured memory_bytes: 2940
#include<stdio.h>
#include<string.h>
int A[100000],M[100000],L,N,i,j,m,t,r=0;
int s(int p)
{
	int r=0,l=0;
	if(M[p]>=0)
		return M[p];
	if(A[p]<A[p+1])r=s(p+1);
	if(A[p]<A[p-1])l=s(p-1);
	return M[p]=(r>l?r:l)+L-A[p];
}
int main()
{
	memset(M,-1,sizeof(M));
	scanf("%d%d",&N,&L);
	for(i=0;i<N;i++)
		scanf("%d",&A[i]);
	for(i=0;i<N;i++)
		r=r>s(i)?r:s(i);
	printf("%d\n",r);
	return 0;
}

Measured memory_bytes: 2752
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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


int main() {

	int n; cin >> n;
	string s; cin >> s;
	string t = "ABC";

	int ans = 0;
	for (int i = 0; i + 2 <= n - 1; i++) {
		if (t == s.substr(i, 3)) ans++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3200
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // TODO 自動生成されたメソッド・スタブ
        Scanner sc = new Scanner(System.in);
        int i = 25 - Integer.parseInt(sc.next());
        String ans = "Christmas";
        for (int j = 0; j < i; j++) {
            ans += " Eve";
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define sort(v,n) sort(v,v+n);
#define vsort(v) sort(v.begin(),v.end());
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
typedef pair<int,int> p;
typedef pair<ll,ll> lp;
typedef priority_queue<int> PQ;
typedef priority_queue<int,vector<int>,greater<int> > RPQ;
bool is_uruu(int y) {
        return y % 4 == 0 && (y % 100 != 0 || y % 400 == 0);
}
const ll MOD=1e9+7;
const double PI=acos(-1.0);
//----------------------------------------------------------------------------------------------------------------------------------//
int n;
int a[100000];
ll sum[100000];
int main(){
        cin>>n;
        for(int i=0; i<n; i++) cin>>a[i];
        sort(a,n);
        sum[0]=a[0];
        for(int i=1; i<n; i++) {
                sum[i]=sum[i-1]+a[i];
        }
        int ans=n;
        for(int i=n-2; i>=0; i--) {
                if(sum[i]*2<a[i+1]) {ans-=i+1; break;}
        }
        cout<<ans<<endl;
}


Measured memory_bytes: 1408
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL A, B, C, X, Y, ans;

int main()
{
	in >> A >> B >> C >> X >> Y;
	ans = 1123456789012345;
	for (LL i = 0; i <= 2 * (X + Y); i += 2)
	{
		LL res = 0;
		LL a = X - i / 2;
		LL b = Y - i / 2;
		if (a < 0) a = 0;
		if (b < 0) b = 0;
		res += C * i;
		res += A * a;
		res += B * b;
		ans = std::min(ans, res);
	}
	out << ans << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int gcd(int a, int b) {
  if(b == 0) { return a; }
  return gcd(b, a % b);
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> A(N);
  REP(i, N) cin >> A[i];
  for(int i = 0; i < N - 1; i++) {
    A[i + 1] = gcd(A[i], A[i + 1]);
  }
  cout << A[N - 1] << endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define sz size
#define se second
#define fe first
#define mper make_pair
#define all(x) x.begin(), x.end()
#define mal ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
#define saken string
using namespace std;

const ll INF = (ll)1e11 + 7;
const ll MAXN = 2e5 + 100;
ll n, t1[MAXN * 4], t2[MAXN * 4];

void build(ll v = 1, ll tl = 1, ll tr = n) {

    if(tl == tr) {t1[v] = -1; t2[v] = INF;return;}

    ll tm = (tl + tr) >> 1;

    build(v + v, tl, tm);
    build(v + v + 1, tm + 1, tr);

    t1[v] = max(t1[v + v], t1[v + v + 1]);
    t2[v] = min(t2[v + v], t2[v + v + 1]);

}

void update(ll pos, ll v = 1, ll tl = 1, ll tr = n) {

    if(tl == tr) {t1[v] = t2[v] = pos * 1ll;return;}

    int tm = (tl + tr) >> 1;

    if(pos <= tm) update(pos, v + v, tl, tm);
    else update(pos, v + v + 1, tm + 1, tr);

    t1[v] = max(t1[v + v], t1[v + v + 1]);
    t2[v] = min(t2[v + v], t2[v + v + 1]);

}

ll get(ll l, ll r, bool type, ll v = 1, ll tl = 1, ll tr = n) {

    if(r < tl || tr < l) return (type == 0) * -1ll + (type == 1) * INF * 1ll;

    if(l <= tl && tr <= r) {

        if(!type) {return t1[v];}
        else {return t2[v];}

    }

    ll tm = (tl + tr) >> 1;

    if(!type) return max( get(l, r, type, v + v, tl, tm), get(l, r, type, v + v + 1, tm + 1, tr) );
    else return min( get(l, r, type, v + v, tl, tm), get(l, r, type, v + v + 1, tm + 1, tr) );

}

int main(){

cin >> n;

vector < pair <ll, ll> > v;

ll ai;

for(int i = 1; i <= n; ++i) {
    cin >> ai;
    v.pb(mper(ai, i));
}

build();

sort(all(v));

ll ans = 0;

for(auto it : v) {

    ll pos = it.se;
    ll val = it.fe;

    ll left = get(1, pos, 0);
    ll right = get(pos, n, 1);

    if(left == -1) {left = 1;}
    else {left++;}

    if(right == INF) {right = n;}
    else {right--;}

    ll dis = (pos - left + 1) * 1ll * (right - pos + 1) * 1ll;

    ans += (dis * val);

//    cout << left << ' ' << right << ' ' << dis * val << '\n' ;

    update(pos);

}

cout << ans;

return 0;
}



Measured memory_bytes: 16236
#include <bits/stdc++.h>
#define mset(a,b) memset(a,b,sizeof a)
#define mcpy(a,b) memcpy(a,b,sizeof b)
#define max(a,b) ((a)<(b)?(b):(a))
#define min(a,b) ((a)<(b)?(a):(b))
#define swap(a,b) a^=b^=a^=b
#define lb(x) ((x)&(-(x)))
#define inf 0x3f3f3f3f
#define N 500010
using namespace std;
typedef long long ll;
int main(){
	int n,a,b;
	cin>>n>>a>>b;
	if(n==1){
		if(a!=b)puts("0");else puts("1");
	}else if(a>b)puts("0");
	else printf("%lld",1ll*b*(n-1)+a-(1ll*a*(n-1)+b)+1);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<ctime>
using namespace std;
typedef long long ll;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
    int x = 0; char ch = gc(); bool positive = 1;
    for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
    for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
    return positive ? x : -x;
}
inline void write(int a){
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    if(a<0){
    	a=-a; putchar('-');
    }
    write(a); puts("");
}
const int N=305;
int dp[N][N][N],n,m;
char s[N];
int main(){
    scanf("%s",s+1); m=read(); n=strlen(s+1);
    memset(dp,0x3f,sizeof(dp));
    for(int i=0;i<=n+1;i++){
        memset(dp[i][i],0,sizeof(dp[i][i]));
        if(i)memset(dp[i][i-1],0,sizeof(dp[i][i-1]));
    }
    for(int o=2;o<=n;o++)
        for(int i=1;i<=n;i++){
            int j=i+o-1;
            if (j>n)
                break;
            for(int k=0;k<=m;k++){
                if (k)
                    dp[i][j][k]=dp[i+1][j-1][k-1];
                if (s[i]==s[j])
                    dp[i][j][k]=min(dp[i][j][k],dp[i+1][j-1][k]);
                dp[i][j][k]=min(dp[i][j][k],dp[i+1][j][k]+1);
                dp[i][j][k]=min(dp[i][j][k],dp[i][j-1][k]+1);
            }
        }
    cout<<n-dp[1][n][m]<<endl;
}

Measured memory_bytes: 111104
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> A(N + 1), B(N);
	for (int i = 0; i < N + 1; ++i) {
		cin >> A[i];
	}
	for (int i = 0; i < N; ++i) {
		cin >> B[i];
	}
	long long sum = 0;
	for (int i = 0; i < N; ++i) {
		int u1 = min(B[i], A[i]);
		sum += u1;
		A[i] -= u1;
		B[i] -= u1;
		int u2 = min(B[i], A[i + 1]);
		sum += u2;
		A[i + 1] -= u2;
		B[i] -= u2;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 4012
#include <stdio.h>

int main(){
	int n,i,j,a[100];
	float x1,y1,x2,y2,x3,y3,x4,y4,b,c;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%f %f %f %f %f %f %f %f",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
		b=(y2-y1)/(x2-x1);
		c=(y4-y3)/(x4-x3);
if(b==c){printf("YES\n");}else{printf("NO\n");}
	}
	return 0;
}

Measured memory_bytes: 616
/*----- || Hare Krishna || -----*/

/*  "WHY DO WE FALL, BRUCE?"  */

//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")

#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
#define elif else if
#define pb push_back
#define pf push_front
#define PI 3.1415926535897932384
#define MOD 1000000007
using namespace std;

char alpha[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

string s;
int t;

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n;
    cin >> n;
    vector<pair<int,int>> vec;
    for(int i=0; i<n; i++){
    	int a,b;
    	cin >> a >> b;
    	vec.pb({a,b});
	}
	
	for(int i=0; i<n-2; i++){
		
		if(vec[i].first==vec[i].second && vec[i+1].first==vec[i+1].second && vec[i+2].first==vec[i+2].second){
			cout<<"Yes";
			return 0;
		}
		
	}
	cout <<"No";	
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int N,K; cin >> N >> K;
    string S; cin >> S;
    if(S==string(N,'1')){
        cout << N << endl;
        return 0;
    }
    VI front, back;
    front.push_back(0);
    REP(i,N-1) if(S[i]=='0' && S[i+1]=='1') front.push_back(i+1);
    if(S[N-1]=='1') front.pop_back();

    REP(i,N-1) if(S[i]=='1' && S[i+1]=='0') back.push_back(i);
    back.push_back(N-1);
    if(S[0]=='1'){
        REVERSE(back); back.pop_back(); REVERSE(back);
    }

    int ans = 0;
    REP(i,front.size()){
        chmax(ans, back[min(i+K-1, (int)back.size()-1)] - front[i] + 1);
    }

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

Measured memory_bytes: 1020
#include <stdio.h>

int main(){

    int n,m,i,j,d,A[150][150],b[150],c[150]; 
 
	 scanf("%d",&n);  	 
  	 scanf("%d",&m);  	 
 	 
  	 
    for(i=1;i<=n;++i){
	  for(j=1;j<=m;++j){
	   scanf("%d",&d);
	     A[i][j]=d;
	     c[i]=0;   	     
	  }
    }	 	  

    for(j=1;j<=m;++j){
 	    scanf("%d",&d);
	     b[j]=d;
     }

    for(i=1;i<=n;++i){
 	  for(j=1;j<=m;++j){
         c[i]+=A[i][j]*b[j];
        //printf("%c %d \n",sut,num);
      }
	}	 
	
	for(i=1;i<=n;++i){ 
        printf ("%d\n",c[i]);
    }
    	

	return 0;
}

Measured memory_bytes: 660
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
 
// 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>;
 
typedef long long ll;
typedef long double ld;
typedef pair <long long,long long> ii;
// typedef complex<long double> point;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll n;
	cin >> n;
	for (int z=1;z<=9;z++){
		if (n % z == 0 && (n/z) <= 9) {
			cout << "Yes" << endl; 
			return 0;
		}
	}
	cout << "No" << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring> 
#include<cassert>
#include<cmath>
#include<sstream>
#include<fstream>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<bitset>
using namespace std;
bool dp[5005][5005];
int a[5005],b[5005];
bool can[5005];
int N,k,n;
bool check(int T)
{
	if(a[T]>=k) return 0;
	n=0;
	memset(dp,0,sizeof dp);
	for(int i=0;i<N;i++)
	{
		if(i==T) continue;
		b[n++]=a[i];
	}
	dp[0][0]=1;
	if(b[0]<k)dp[0][b[0]]=1;
	bool flag=1;
	for(int i=1;i<n;i++)
	{
		if(b[i]>=k) continue;
		
		for(int j=0;j<k;j++)
		{
			dp[i][j]=dp[i-1][j];
			if(j>=b[i])dp[i][j]|=dp[i-1][j-b[i]];
			if(dp[i][j]&&k-a[T]<=j&&k>j)
			{
				flag=0;
				break;
			}
	//		cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
			
		}
		if(!flag) break;
	}
	for(int i=k-a[T];i<k;i++)
	{
		if(dp[n-1][i])
		{
			flag=0;
		}
	}
	return flag;
}
int main()
{
	cin>>N>>k;
	for(int i=0;i<N;i++) cin>>a[i];
	sort(a,a+N);
	int cnt=-1;
	int l=0,r=N-1,mid;
	while(l<=r)
	{
		mid=(l+r)/2;
		bool flag=check(mid);
		if(flag)
		{
			cnt=mid;
			l=mid+1;
		}
		else r=mid-1;
	}
	cout<<cnt+1<<endl;
}

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

#define int long long

double n, k, d[200005];
double x,resp=0, w_sum=0;
vector<double>ve;

void check(int k)
{
	double maxsum=0;
	for(int i=0; i<k; i++)
		maxsum+=ve[i];

	double wsum=maxsum;
	for(int i=k; i<n; i++)
	{
		wsum+= ve[i] - ve[i-k];
		maxsum = max(maxsum, wsum); 
	}

	resp = maxsum;
}

int32_t main()
{
	cin >> n >> k;

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

		x = (d[i]+1)/2;
		ve.push_back(x);
	}

	check(k);

	cout << setprecision(9) << fixed;
	cout << resp << '\n';
}

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
typedef long long int LL;

const int INF = 2e9;

int n, t[10010];
int dp[2][5010][2];
int main()
{
  scanf("%d", &n);
  for(int i = 1; i < n; i++)
    scanf("%d", &t[i]);

  dp[1][1][1] = INF;

  for(int i = 1; i < n; i++){
    for(int j = 1; j <= min(i, n / 2) + 1; j++){
      dp[(i + 1) & 1][j][0] = INF;
      dp[(i + 1) & 1][j][1] = INF;
    }
    for(int j = 1; j <= min(i, n / 2); j++){
      dp[(i + 1) & 1][j + 1][0] = min(dp[(i + 1) & 1][j + 1][0], dp[i & 1][j][0]);
      dp[(i + 1) & 1][j][1] = min(dp[(i + 1) & 1][j][1], dp[i & 1][j][0] + t[i]);
      dp[(i + 1) & 1][j + 1][0] = min(dp[(i + 1) & 1][j + 1][0], dp[i & 1][j][1] + t[i]);
      dp[(i + 1) & 1][j][1] = min(dp[(i + 1) & 1][j][1], dp[i & 1][j][1]);
    }
  }
  
  printf("%d\n", min(dp[0][n / 2][0], dp[0][n / 2][1]));
  return 0;
}

Measured memory_bytes: 1304
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
using namespace std;
const int MAXN=1e5+5;
int p[MAXN],vis[MAXN],error;
struct node{
	int x,y;
}push;
int n,m;
vector <node> vec[MAXN];
void solve(int x){
	for (int i=0; i<vec[x].size(); i++){
		node g=vec[x][i];
		if (vis[g.x])
		  if (g.y+p[x]!=p[g.x]){
		  	error=1;		
		  	return;
		  }
		  else continue;
		 vis[g.x]=1;
		 p[g.x]=p[x]+g.y;
		 solve(g.x);
		 if (error) return;
	}
}
int main(){
	scanf("%d%d",&n,&m);
		memset(vis,0,sizeof(vis));
		memset(p,0,sizeof(p));
		error=0;
		for (int i=0; i<m; i++){
			int a,b,l;
			scanf("%d%d%d",&a,&b,&l);
			push.x=b;
			push.y=l;
			vec[a].push_back(push);
			push.x=a;
			push.y=-l;
			vec[b].push_back(push);
		}
		for (int i=0; i<n; i++)
		  if (!vis[i]){
		  	solve(i);
		  	if (error) break;
		  }
		if (!error) printf("Yes\n");
		else printf("No\n");
	
	return 0;
}

Measured memory_bytes: 12416
n = input()

N = len(n)-1

i = 0
ans = 0
for i in range(2**N):
    # print("i=",i)
    n2 = n
    for j in range(N):
        if(i>>j)&1:
            n2= n2[:(N-j)] + " " + n2[N-j:]
            # print(n2)
    
    n3 = n2.split()
    for k in range(len(n3)):
        ans += int(n3[k])
    # print(n3)
print(ans)

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

int n, W;
long long dp[100004];

int main() {
	cin>>n>>W;
	int v, w;
	for(int i = 0 ; i<=100000;i++)
		dp[i] = 1e18;
	dp[0] = 0;
	for(int i = 1;i<=n;i++){
		cin>>w>>v;
		for(int j = 100000;j>=v;j--){
			dp[j] = min(dp[j],dp[j-v]+w);
		}
	}
	int ans = 0;
	for(int i = 0 ; i<=100000;i++)
		if(dp[i]<=W)	ans = i;
	cout<<ans;
	return 0;
}

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

class Program {
    static void Main(string[] args) {
        var s = ReadLine();

        var start = s.Substring(0,1);
        var end = s.Substring(s.Length - 1, 1);
        var len = (s.Length - 2).ToString();

        WriteLine(start + len + end);
    }
}



Measured memory_bytes: 13140
#include <stdio.h>

int main(void) {
	int a,b,c,d,n,ans;
	while(scanf("%d",&n)!=EOF) {
		ans=0;
		for(a=0;a<10;a++) 
		for(b=0;b<10;b++) 
		for(c=0;c<10;c++) 
		for(d=0;d<10;d++) 
		if(a+b+c+d==n) 
		ans++;
		printf("%d\n",ans);
	}
	return 0;
}

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    long int n,num;
    cin>>n;
    list<int>li;
    for(int i=0;i<n;i++){
        string cad;
        cin>>cad;
        if(cad=="insert"){
            cin>>num;
            li.push_front(num);
        }
        else{
            if(cad=="delete"){
                 cin>>num;
                 for(list<int>::iterator it = li.begin(); it != li.end(); it++) {
                    if(*it==num){
                        li.erase(it);
                        break;
                    }
                 }
            }
            else{
                if(cad=="deleteFirst"){
                    li.pop_front();
                }
                else{
                        li.pop_back();

                }
            }
        }


    }

    while(!li.empty()){
        cout<<li.front();
        li.pop_front();
        if(!li.empty())
            cout<<" ";

    }
    cout<<"\n";
    return 0;
}



Measured memory_bytes: 34368
str = gets.chomp
gets.to_i.times do
  command = gets.split
  a = command[1].to_i
  b = command[2].to_i
  case command[0]
  when "print"
    puts str[a..b]
  when "reverse"
    str = str[0, a] + str[a..b].reverse + str[b + 1..-1]
  when "replace"
    str = str[0, a] + command[3] + str[b + 1..-1]
  end
end


Measured memory_bytes: 8900
def func(S):
   if len(S)==1:
      return int(S)
   else: 
      flag=True  
      for i in range(1,len(S)):
         if S[i]!="9":
            flag=False
      
      if flag==False:
         S_0=max(0,int(S[0])-1)
         S_list=[S_0]
         for i in range(1,len(S)):
            S_list.append(9)
         return sum(S_list)
      
      else:
         S_list=list(map(int,[c for c in S]))
         return sum(S_list)

S=input()
total=func(S)
print(total)

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

const long long INF = 1LL << 60;

long long p[101000][3];
long long dp[101000][3];

template<class T> inline bool chmax(T &a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}

int main(){
    int N;
    cin >> N;
    // a = 0, b = 1, c = 2
    for(int i = 0; i < N; i++){ 
        cin >> p[i][0] >> p[i][1] >> p[i][2];
    }
    for(int i = 0; i < 101000; i++){ 
        dp[i][0] = dp[i][1] = dp[i][2] = 0;
    }

    for(int i = 0; i < N; i++){ 
        // a
        chmax(dp[i+1][1], dp[i][0] + p[i][0]);
        chmax(dp[i+1][2], dp[i][0] + p[i][0]);
        // b
        chmax(dp[i+1][0], dp[i][1] + p[i][1]);
        chmax(dp[i+1][2], dp[i][1] + p[i][1]);
        // c
        chmax(dp[i+1][0], dp[i][2] + p[i][2]);
        chmax(dp[i+1][1], dp[i][2] + p[i][2]);
    }
    cout << max(dp[N][0], max(dp[N][1], dp[N][2])) << endl;
}

Measured memory_bytes: 4992
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int C = sc.nextInt();
    int B[] = new int[M];
    for (int i = 0; i < M; i++) {
      B[i] = sc.nextInt();
    }
    int A[][] = new int[N][M];
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < M; j++) {
        A[i][j] = sc.nextInt();
      }
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
      int sum = 0;
      for (int j = 0; j < M; j++) {
        sum += B[j] * A[i][j];
      }
      sum += C;
      if (sum > 0) {
        ans++;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
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; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
const int mod=1e9+7;

ll c[51][51];

void makec(){
  rep(i,51) rep(j,i+1){
    if(i==0)c[i][j]=1;
    else if(j==0||j==i)c[i][j]=1;
    else c[i][j]=c[i-1][j-1]+c[i-1][j];
  }
  return;
}

int main(){
  int n,a,b;cin>>n>>a>>b;
  ll v[n];rep(i,n)cin>>v[i];
  sort(v,v+n,greater<ll>());
  makec();
  ll ans=0;
  if(v[0]==v[a-1]){
    int ctr=0;
    rep(i,n){
      if(v[i]==v[0])ctr++;
    }
    rep(i,a,b+1){
      ans+=c[ctr][i];
    }
  }
  else{
    ll p=v[a-1];
    int forward=0;
    rep(i,a-1){
      if(v[i]==p)forward++;
    }
    int backward=0;
    rep(i,a-1,n){
      if(v[i]==p)backward++;
    }
    ans=c[forward+backward][forward+1];
  }
  long double res=0;
  rep(i,a)res+=v[i];
  cout<<setprecision(25)<<res/(double)a<<endl;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

a,b = LI()
if a > b:
    a,b = b,a
if (b-a) % 2:
    print('IMPOSSIBLE')
else:
    print(b - (b-a)//2)

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

int main() {
    int h, w, d; cin >> h >> w >> d;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            int x = ((i + j) / d % 2 + 2) % 2;
            int y = ((i + w - j) / d % 2 + 2) % 2;
            cout << "RYGB"[x << 1 | y];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 512
import math
import sys
import collections
import bisect
readline = sys.stdin.readline


def main():
    s = list(readline().rstrip())
    sumS = 0
    m = s.count('B')
    for i in range(len(s) - 1):
        if s[i] == 'B':
            sumS += (len(s) - m) - i
            m -= 1
    print(sumS)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10800
N,x = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
for i in range(len(a)-1):
    if a[i]+a[i+1] > x:
        diff = a[i]+a[i+1]-x
        if a[i+1] >= diff:
            a[i+1] -= diff
            ans += diff
        else:
            ans += diff
            diff -= a[i+1]
            a[i+1] = 0
            a[i] -= diff
print(ans)


Measured memory_bytes: 14132
#include<stdio.h>

#define N 1000

int main(void)
{
	int i,j,n_fruit,k_fruit,price=0,fruit[N],temp;

	scanf("%d%d",&n_fruit,&k_fruit);

	for(i=0;i<n_fruit;i++){
		scanf("%d",&fruit[i]);
	}

	

	for(i=0;i<n_fruit;i++){
		for(j=i+1;j<n_fruit;j++){
			if(fruit[i]>fruit[j]){
				temp = fruit[i];
				fruit[i] = fruit[j];
				fruit[j] = temp;
			}
		}
	}

	for(i=0;i<k_fruit;i++){
		price += fruit[i];
	}

	printf("%d\n",price);

	return 0;
}


Measured memory_bytes: 1728
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const N = input[0][0];

  return /(.)\1{2}/.test(N) ? "Yes" : "No";
};

console.log(main(read()));


Measured memory_bytes: 29568
#include <bits/stdc++.h>
using namespace std;
long long n,n1=1,n2=1,ans;
bool vis[31622996];
long long prime[31622996],p[29];
int cnt,cnt2,dep;


void dfs() {
	if(dep==cnt2) {
		long long x=n1,y=n2,ax=1,bx=0,ay=0,by=1;
		if(x>y) swap(x,y),swap(ax,ay),swap(bx,by);
		//x=a*n1+b*n2 y=a*n2+b*n2
		//a*n1+b*n2=1
		while(x!=1) {
			ay-=(y/x)*ax,by-=(y/x)*bx;
			y%=x;
			swap(x,y),swap(ax,ay),swap(bx,by);
		}
//		cout<<n1<<' '<<n2<<' '<<ax<<' '<<bx<<'\n';
		if(ax==0||bx==0) return;
		ans=min(((-bx)%n1+n1)%n1*n2,ans);
		ans=min(((-ax)%n2+n2)%n2*n1,ans);
		return;
	}
	n1*=p[dep++];
	dfs();
	n1/=p[dep-1],n2*=p[dep-1];
	dfs();
	n2/=p[--dep];
}

int main(void) {
	for(register int i=2; i<31622776; ++i) 
		if(!vis[i]) {
			prime[cnt++]=i;
			for(register int j=i; j<31622776; j+=i) 
				vis[j]=1;
		}
	cin>>n;
	if(n==1) {
		cout<<1;
		return 0;
	}
	n*=2,ans=n;
	for(int i=0; i<cnt; ++i)
		if(n%prime[i]==0) {
			p[cnt2]=1;
			while(n%prime[i]==0)
				n/=prime[i],p[cnt2]*=prime[i];
			++cnt2;
		}
	if(n!=0) p[cnt2++]=n;
	dfs();
	cout<<ans;
}

Measured memory_bytes: 49772
#include"iostream"
#include<stdlib.h>
#include<stdio.h>
#include<time.h>
#include<list>
#include<map>
#include<string>
#include<algorithm> 
#include <queue> 
#include <sstream>
#include <fstream>
#include<cmath>
#define INF 1000000000
#define LL long long
using namespace std;

vector<LL> v;
vector<LL> vv;
long long N, M, ans, A[31][31], K[31],C[31];
string s;



int main() {
	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];
			C[A[i][j]]++;
		}
	}
	ans = 0;
	for (int i = 1; i < M+1; i++) {
		if (C[i] == N) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inf 2100000000
using namespace std;
struct flow
{
	int first[200010],last[200010],next[200010],des[200010],vol[200010],cop[200010],dis[200010],cur[200010],n,tt;
	void init(int pn)
	{
		n=pn;
		tt=1;
	}
	void adde(int u,int v,int l)
	{
		des[++tt]=v;vol[tt]=l;
		if (!first[u]) first[u]=last[u]=tt;else last[u]=next[last[u]]=tt;
		des[++tt]=u;vol[tt]=0;
		if (!first[v]) first[v]=last[v]=tt;else last[v]=next[last[v]]=tt;
	}
	bool bfs(int s,int t)
	{
		for (int i=1;i<=n;i++) dis[i]=2100000000;
		dis[t]=0;int head=1,tail=0;cop[head]=t;
		while (head!=tail)
		{
			int p=cop[++tail];
			for (int k=first[p];k;k=next[k]) if ((dis[des[k]]==2100000000)&&(vol[k^1]))
			{
				dis[des[k]]=dis[p]+1;
				cop[++head]=des[k];
			}
		}
		return dis[s]!=2100000000;
	}
	int dfs(int s,int t,int minvol=2100000000)
	{
		if (s==t) return minvol;
		int bg=0;
		for (int k=cur[s];k;k=next[k]) if (dis[des[k]]==dis[s]-1)
		{
			cur[s]=k;
			int now=dfs(des[k],t,min(minvol-bg,vol[k]));
			vol[k]-=now;vol[k^1]+=now;bg+=now;
			if (bg==minvol) break;
		}
		return bg;
	}
	int dinic(int s,int t)
	{
		int ans=0;
		while (bfs(s,t))
		{
			for (int i=1;i<=n;i++) cur[i]=first[i];
			ans+=dfs(s,t);
		}
		return ans;
	}
}flow;
int st[110][110],top;
char a[110][110];
int bgx,bgy,edx,edy;
int main()
{
	int n,m;scanf("%d%d\n",&n,&m);
	for (int i=1;i<=n;i++)
	for (int j=1;j<=m;j++)
	{
		a[i][j]=getchar();
		if (a[i][j]!='.') st[i][j]=++top;
		if (a[i][j]=='S') {bgx=i;bgy=j;}
		if (a[i][j]=='T') {edx=i;edy=j;}
		if (j==m) scanf("\n");
	}
	flow.init(top*2+n+m);
	for (int i=1;i<=top;i++) flow.adde(i,i+top,1);
	for (int i=1;i<=n;i++)
	for (int j=1;j<=m;j++) if (st[i][j])
	{
		flow.adde(st[i][j]+top,2*top+i,inf);
		flow.adde(2*top+i,st[i][j],inf);
		
		flow.adde(st[i][j]+top,2*top+n+j,inf);
		flow.adde(2*top+n+j,st[i][j],inf);
	}
	int ans=flow.dinic(st[bgx][bgy]+top,st[edx][edy]);
	if (ans>1e8) ans=-1;
	cout<<ans<<endl;
}
	

Measured memory_bytes: 4992
#pragma GCC optimize("Ofast")
#include<stdio.h>
#include<algorithm>
using namespace std;
int n,m,q;
struct Q{
	int a,b,c,d;
}query[55];
int ans[15],maxv=0;
void DFS(int pos,int v){
		int i;
	if(pos==n+1){
		int temp=0;
		for(i=0;i<q;i++){
			if(ans[query[i].b]-ans[query[i].a]==query[i].c)
				temp+=query[i].d;
		}	
		maxv=max(maxv,temp);
		return;
	}

	for(i=v;i<=m;i++){
		ans[pos]=i;
		DFS(pos+1,i);
	}
}
int main(){
	int i;
	scanf("%d%d%d",&n,&m,&q);
	for(i=0;i<q;i++)	
		scanf("%d%d%d%d",&query[i].a,&query[i].b,&query[i].c,&query[i].d);
	DFS(1,1);
	printf("%d\n",maxv);
}


Measured memory_bytes: 1720
#include <bits/stdc++.h>
using namespace std;
const int N = 500 + 10, base = 2500 + 1;
int a[N][N];
long long ps;
int main() {
	int n, m, nn, mm;
	cin >> n >> m >> nn >> mm;
	for (int i = 0; i < n; i++) 
		for (int j = 0; j < m; j++)
			a[i][j] = base;
	int inf = -1 * base * (nn * mm - 1) - 1;
	for (int i = nn - 1; i < n; i += nn)
		for (int j = mm - 1; j < m; j += mm) 
			a[i][j] = inf;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++) 
			ps += a[i][j];
	if (ps > 0) {
		cout << "Yes\n";
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) 
				cout << a[i][j] << " ";
			cout << endl;
		}
	}
	else 
		cout << "No";
	return 0;
}	


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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

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

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	string s;
	cin >> s;

	map<char, int> m;
	rep(i, s.size()){
		m[s[i]]++;
	}
	for(char c = 'a'; c <= 'z'; c++){
		if(m[c] == 0){
			cout << c << endl;
			return 0;
		}
	}
	cout << "None" << endl;
	return 0;
}

Measured memory_bytes: 512
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
//constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

int dpA[(int)2e5 + 5] = {};
int dpB[(int)2e5 + 5] = {};
int mini[(int)2e5 + 5] = {};

int main(void){
	fill_n(mini, 2e5 + 5, INF);
	ll n, k, c;
	cin >> n >> k >> c;
	c++;
	string s;
	cin >> s;
	rep(i, n){
		if(i) dpA[i] = dpA[i - 1];
		if(s[i] == 'o') chmax(dpA[i], 1);
		if(i >= c && s[i] == 'o') chmax(dpA[i], dpA[i - c] + 1);
		chmin(mini[dpA[i]], (int)i);
	}

	repr(i, n){
		if(i < n - 1) dpB[i] = dpB[i + 1];
		if(s[i] == 'o') chmax(dpB[i], 1);
		if(i + c < n && s[i] == 'o') chmax(dpB[i], dpB[i + c] + 1);
	}

	Vec ans;
	rep(i, n){
		if(s[i] == 'o' && i == 0 && dpB[i + 1] < k) ans.pb(i + 1);
		else if(s[i] == 'o' && i != 0 && dpA[i - 1] + dpB[max(i + 1, mini[dpA[i - 1]] + c)] < k) ans.pb(i + 1);
		//if(i) co({(int)i, dpA[i - 1] + dpB[mini[dpA[i - 1]] + c]});
	}
	for(ll i : ans) co(i);

	return 0;
}


Measured memory_bytes: 5748
import sys
input = sys.stdin.readline
a = [0 for i in range(5)]
n = int(input())
for i in range(5):
    a[i] = int(input())
if n % a[0] == 0:
    time = n // a[0]
else:
    time = n // a[0] + 1
min = a[0]
for i in range(4):
    if min > a[i+1]:
        if n % min == 0:
            time1 = n // min
        else:
            time1 = n // min + 1
        if n % a[i+1] == 0:
            time2 = n // a[i+1]
        else:
            time2 = n // a[i+1] + 1
        time += (time2 - time1)
        min = a[i+1]
    time += 1
print(time)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(void){
    while(true){
        int m, Nmax, Nmin;
        cin >> m >> Nmin >> Nmax;
        if(m == 0){
            break;
        }
        int P[m];
        for(int i = 0; i < m; i++){
            cin >> P[i];
        }
        int maxGap = 0;
        int ret = 0;
        for(int i = Nmin - 1; i < Nmax; i++){
            if(P[i] - P[i + 1] >= maxGap){
                maxGap = P[i] - P[i + 1];
                ret = i + 1;
            }
        }
        cout << ret << endl;
    }
}

Measured memory_bytes: 3072
#include<cstdio>
#include<cstring>
#include<iostream>
#include<stdlib.h>
#include<ctime>
#include<string>
#include<cmath>
#include<algorithm>
#include<complex>
#include<vector>
#include<set>
#include<map>
#include<queue>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define LL long long
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef pair<int,int> pa;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
int n,ans,t,a[500010];
int main(){
	cin>>n;
	FOR(i,1,n) cin>>a[i];
	FOR(i,1,n) if (a[i]==a[i-1]) ++t;
	else{
		ans+=t/2;
		t=1;
	}
	ans+=t/2;
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

int main(int argc, const char * argv[]) {
    vector<int> vc;
    
    int q;
    
    cin>>q;
    
    while(q){
        int x;
        
        cin>>x;
        
        switch(x){
            case 0:
                cin>>x;
                vc.push_back(x);
                break;
            case 1:
                int p;
                cin>>p;
                cout<<vc.at(p)<<endl;
                
                break;
            case 2:
                vc.pop_back();
                break;
        }
        --q;
    }
    
}



Measured memory_bytes: 3924
def z_algorithm(s):
  n = len(s)
  z = [None] * n
  z[0] = n
  
  i = 1
  j = 0
  while i < n:
    while i + j < n and s[j] == s[i + j]:
      j += 1
    z[i] = j
    if j == 0:
      i += 1
      continue
    k = 1
    while i + k < n and z[k] + k < j:
      z[i + k] = z[k]
      k += 1
    i += k
    j -= k
  return z

N = int(input())
S = input()

answer = 0
for j in range(N):
  T = S[j:]
  Z = z_algorithm(T + "$" + S)
  lenT = len(T)
  lenZ = len(Z)
  for i in range(lenT, lenZ - lenT):
    if i + Z[i] < lenZ - lenT + 1:
      answer = max(answer, Z[i])

print(answer)

Measured memory_bytes: 120284