akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long   ll;
typedef unsigned long long   ull;
typedef long double ld;
typedef pair<ll, ll>    pll;
typedef pair<ull, ull>    pull;
typedef pair<ll, ll>  pii;
typedef pair<ld, ld>  pld;
ld inter(pll a, pll b){
    return ((ld)a.ff-(ld)b.ff)/((ld)b.ss-(ld)a.ss);
}
vector<pll> v;
void add(pll x){
    while(v.size() >= 2){
        pll y = *(v.end()-1);
        pll z = *(v.end()-2);
        if(inter(x, z) <= inter(z, y))
            v.pop_back();
        else
            break;
    }
    v.pb(x);
}
ll binse(ll x){
    if(v.size() == 0)
        return 0;
    ll l = 0, r = v.size()-1;
    while(l < r){
        ll m = (l+r)/2;
        if(v[m].ff + x*v[m].ss < v[m+1].ff + x*v[m+1].ss)
            r = m;
        else
            l = m+1;
    }
    return v[l].ff + x*v[l].ss;
}
ll n, c;
ll h[200009];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    
    cin >> n >> c;
    for(ll i = 0; i < n; ++i)
        cin >> h[i];
    add({h[0]*h[0], -2*h[0]});
    for(ll i = 1; i < n-1; ++i){
        ll cons = h[i]*h[i]+c;
        ll funca = binse(h[i])+cons;
        //cout << i << " " << binse(h[i]) << "\n";
        add({funca+h[i]*h[i], -2*h[i]});
    }
    cout << h[n-1]*h[n-1]+c+binse(h[n-1]) << "\n";
    
}

Measured memory_bytes: 8048
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;

int main()
{

	ios_base:: sync_with_stdio(false); cin.tie(0);
	int n,k; cin>>n>>k;
	vector<int> a(n+1);
	for(int i=1; i<=n; i++) {
		cin>>a[i];
	}
	sort(a.begin()+1,a.end());
	ll sum=0;
	for(int i=1; i<=k; i++) {
		sum+=a[i];
	}

	cout<<sum<<endl;

	return 0;
}


Measured memory_bytes: 3656
#include "bits/stdc++.h"
#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##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N;
    cin >> N;
    int n1 = 0, n2 = 0, n3 = 0, sushi = 0;
    rep(i, N) {
        int a;
        cin >> a;
        if (a == 1) n1++;
        else if (a == 2) n2++;
        else n3++;
        sushi += a;
    }

    vv<vector<double>> dp = vvec(sushi + 1, N + 1, vector<double>(N + 1, 0));
    rep(s, sushi) rep(i2, N + 1) rep(i3, N + 1) {
        int i1 = s - 2 * i2 - 3 * i3;
        int i0 = N - i1 - i2 - i3;
        if (i1 < 0 || i1 > N || i0 < 0 || i0 > N) continue;

        if (i0 > 0 && i1 < N) dp[s + 1][i2][i3] += (dp[s][i2][i3] + (double)N / (i1 + i2 + i3 + 1)) * ((double)(i1 + 1) / (i1 + i2 + i3 + 1));
        if (i1 > 0 && i2 < N) dp[s + 1][i2 + 1][i3] += (dp[s][i2][i3] + (double)N / (i1 + i2 + i3)) * ((double)(i2 + 1) / (i1 + i2 + i3));
        if (i2 > 0 && i3 < n3) dp[s + 1][i2 - 1][i3 + 1] += (dp[s][i2][i3] + (double)N / (i1 + i2 + i3)) * ((double)(i3 + 1) / (i1 + i2 + i3));
    }

    write(dp[sushi][n2][n3]);
}

Measured memory_bytes: 647168
#include <iostream>
#include <vector>
#include <algorithm>
#define int long long
using namespace std;
int upper(int N, const vector<int> &A, int y, int x) {
  if (A[N - 1] * y > x) return 0;
  int lo = -1;
  int hi = N - 1;
  while (hi - lo > 1) {
    int mid = (lo + hi) / 2;
    if (A[mid] * y <= x) {
      hi = mid;
    } else {
      lo = mid;
    }
  }
  return N - hi;
}
int lower(int N, const vector<int> &A, int y, int x) {
  if (A[0] * y > x) return 0;
  int lo = 0;
  int hi = N;
  while (hi - lo > 1) {
    int mid = (lo + hi) / 2;
    if (A[mid] * y <= x) {
      lo = mid;
    } else {
      hi = mid;
    }
  }
  return lo + 1;
}
int check(int N, const vector<int> &A, int x) {
  int C = 0;
  for (int i = 0; i < N; i++) {
    int add;
    if (A[i] == 0) {
      if (x >= 0) add = N - 1;
      else add = 0;
    }
    else if (A[i] < 0) {
      add = upper(N, A, A[i], x);
      if (A[i] * A[i] <= x) add--;
    } else {
      add = lower(N, A, A[i], x);
      if (A[i] * A[i] <= x) add--;
    }
    C += add;
  }
  return C / 2;
}
int solve(int N, int K, const vector<int> &A) {
  int lo = (int)-1e18;
  int hi = (int)1e18;
  while (hi - lo > 1) {
    int mid = (lo + hi) / 2;
    if (check(N, A, mid) >= K) {
      hi = mid;
    } else {
      lo = mid;
    }
  }
  return hi;
}
signed main() {
  int N, K; cin >> N >> K;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  sort(A.begin(), A.end());
  cout << solve(N, K, A) << endl;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MM 1000000000;
#define INF (ll)1e18
#define pi acos(-1.0)
#define MAX 1000000005
#define NIL -1
ll mod = 1e9+7;
int main(){
    int n; cin >> n;
    bool flg = true;
    ll ans = 1;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    if(n%2 && a[0]) flg = false;
    if(n%2) a.erase(a.begin());
    for(int i = 0; i < a.size(); i += 2){
        if(a[i] != a[i+1] || a[i] != i+1+n%2){
            flg = false;
        }
    }
    if(flg){
        for(int i = 0; i < a.size()/2; i++){
            ans = ans*2%mod;
        }
    } else {
        ans = 0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
using namespace std;
const int N=1e6+7,mod=1e9+7;
int n,d,h,f[N],fac[N],inv[N],sf[N],s[N<<2];
int qpow(int a,int b)
{
	int ret=1;
	while(b)
	{
		if(b&1)ret=1ll*ret*a%mod;
		a=1ll*a*a%mod,b>>=1;
	}
	return ret;
}
void update(int k,int v,int l,int r,int rt)
{
	if(l==r){s[rt]=v;return;}
	int mid=l+r>>1;
	if(k<=mid)update(k,v,lson);
	else update(k,v,rson);
	s[rt]=(s[rt<<1]+s[rt<<1|1])%mod;
}
int query(int L,int R,int l,int r,int rt)
{
	if(L<=l&&r<=R)return s[rt];
	int mid=l+r>>1,ret=0;
	if(L<=mid)ret+=query(L,R,lson);
	if(R>mid)ret+=query(L,R,rson);
	return ret%mod;
}
int main()
{
	scanf("%d%d%d",&n,&h,&d);
	fac[0]=1;for(int i=1;i<=n;i++)fac[i]=1ll*fac[i-1]*i%mod;
	for(int i=1;i<=n;i++)sf[i]=(sf[i-1]+fac[i])%mod;
	update(0,fac[n],0,h,1);
	for(int i=1;i<=h;i++)
	{
		f[i]=query(max(0,i-d),i-1,0,h,1);
		if(i<h)f[i]=1ll*f[i]*sf[n]%mod,update(i,f[i],0,h,1);
	}
	printf("%d",f[h]);
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> mochi(N);
  for (int i = 0; i < N; i++) {
    cin >> mochi.at(i);
  }
  
  sort(mochi.begin(), mochi.end());
  
  int count = 1;
  
  for (int i = 0; i < N-1; i++) {
    if (mochi.at(i) < mochi.at(i+1)) {
      count++;
    }
    
  }
  
  cout << count << endl;

}

Measured memory_bytes: 256
import collections
N = int(input())
A = list(map(int,input().split()))
D = collections.Counter(A)
Q = int(input())
#print(D)
ans = sum(A)
for i in range(Q):
    B,C = map(int,input().split())
    #print(D[B],type(D[B]))
    ans += (C-B)*D[B]
    D[C] = D[B] + D[C]
    D[B] = 0
    #print(D)
    print(ans)

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

int main() {
  int H, N;
  cin >> H >> N;
  int damage = 0;
  int64_t sum = 0;
  for (int i = 0; i < N; i++){
    cin >> damage;
    sum += damage;
  }
  if (sum < H){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long int a,b,c,d,p,i,j;
  cin>>a>>b>>c>>d;
  p=a*c;
  for(i = a;i<=b;i=i+(b-a))
  {
    for(j = c;j<=d;j=j+(d-c))
    {
      if(p<(i*j))
      p = (i*j) ;
      if(j==d)
        break;
    }
    if(i==b)
      break;
   }
  cout<<p;
  return 0;
}

Measured memory_bytes: 3608
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	string N;
	cin>>N;
	puts((N[0]==N[1]&&N[0]==N[2])||(N[1]==N[2]&&N[1]==N[3])?"Yes":"No");
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 101
#define INF 100000000
#define NIL -1

int main(){
  int i,j,n,u,v,min,ans=0,A[N][N],d[N],p[N],color[N];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf(" %d",&A[i][j]);
    }
  }

  //prim
  for(u=0;u<n;u++){
    if(u<1){
      d[u]=0;
      p[u]=-1;
    }
    else{
      d[u]=INF;
      p[u]=NIL;
    }
    color[u]=0;
  }
  
  while(1){
    min=INF;
    for(i=0;i<n;i++){
      if(color[i] != 1 && d[i]<min){
	min=d[i];
	u=i;
      }
    }
    if(min==INF){
      break;
    }
    
    color[u]=1;

    for(j=0;j<n;j++){
	if(color[j] != 1 && A[u][j] != -1){
	  if(A[u][j]<d[j]){
	    p[j]=u;
	    d[j]=A[u][j];
	  }
	}
    }	
  }
  for(i=0;i<n;i++){
    ans+=d[i];
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define LL long long
#define F(x,y,z) for(int x=y;x<=z;++x)
#define D(x,y,z) for(int x=y;x>=z;--x)
using namespace std;
string s;
int main(){
	cin>>s;
	int k=0,ans=0;
	for(auto i:s){
		ans+=k;
		ans-=i=='p';
		k^=1;
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 512
import sys
def main():
    s=sys.stdin.readline().strip()
    d,m,p,c={0:1},0,1,0
    for a in reversed(s):
        m+=(int(a)*p)
        k=m%2019
        p=(p*10)%2019
        d[k]=d[k]+1 if k in d else 1
    for v in d.values():c+=v*(v-1)//2
    print(c)
if __name__=='__main__':main()

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

int main() {
  int x, y;
  cin >> x >> y;
  int a = x * 2;
  int b = 0;
  for (int i = 0; i <= x; i++) {
    if (2 * i + a == y) {
      b = 1;
      break;
    }
  }
    if (b == 1) {
      cout << "Yes" << endl;
    }
    else if (b == 0) {
      cout << "No" << endl;
    }
}


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    string S;
    cin >> S;
    int l = -1, r = -1;
    REP(i, S.length())
    {
        if (i + 1 >= S.length())
            break;
        if (S[i] == S[i + 1])
        {
            l = i + 1;
            r = i + 2;
        }
        if (i + 2 >= S.length())
            break;
        if (S[i + 1] == S[i + 2] || S[i] == S[i + 2] || S[i] == S[i + 1])
        {
            l = i + 1;
            r = i + 3;
            break;
        }
    }
    cout << l << " " << r << endl;
    return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline std::ostream& operator << (std::ostream& out, const std::vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

template<typename T>
struct edge {
	int to;
	T cost;
	edge(int t, T c) {
		to = t;
		cost = c;
	}
};

template<typename T>
void dijkstra(int s, vector<vector<edge<T>>>& path, vector<T>& d) {
	using pi = pair<T, int>;
	priority_queue<pi, vector<pi>, greater<pi>> q;
	q.push(P(0, s));
	d[s] = 0;
	while (!q.empty()) {
		P p = q.top();
		q.pop();
		int v = p.second;
		if (d[v] < p.first)continue;
		REP(i, path[v].size()) {
			edge<T> e = path[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				q.push(P(d[e.to], e.to));
			}
		}
	}
	return;
}

int main() {
	IOS;
	/*ll k, n;
	cin >> k >> n;
	vector<ll> a(n);
	REP(i, n) {
		cin >> a[i];
	}
	ll m = 0;
	REP(i, n - 1) {
		chmax(m, a[i + 1] - a[i]);
	}
	chmax(m, a[0] + k - a[n - 1]);
	put(k - m);*/
	int n, x, y;
	cin >> n >> x >> y;
	x--;
	y--;
	using e = edge<int>;
	vector<vector<edge<int>>> path(n);
	REP(i, n - 1) {
		path[i].push_back(e(i + 1,1));
		path[i + 1].push_back(e(i,1));
	}
	path[x].push_back(e(y, 1));
	path[y].push_back(e(x, 1));
	vector<ll> res(n, 0);
	REP(i, n) {
		vector<int> d(n, INT_MAX / 2);
		dijkstra(i, path, d);
		REP(j, n) {
			res[d[j]]++;
		}
	}
	FOR(i, 1, n) {
		put(res[i]/2);
	}
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> P;

signed main(){
    int H, W; cin >> H >> W;
    int N; cin >> N;
    vector<int> a(N);
    for(int i = 0; i < N; i++) cin >> a[i];
    vector<vector<int> > color(H + 1, vector<int> (W + 1));
    P p = P(1, 1);
    for(int i = 0; i < N; i++){
        for(int j = 0; j < a[i]; j++){
            color[p.first][p.second] = i + 1;
            if(p.first %2 == 1 && p.second != W) p.second++;
            else if(p.first %2 == 1 && p.second == W) p.first++;
            else if(p.first %2 == 0 && p.second != 1) p.second--;
            else if(p.first %2 == 0 && p.second == 1) p.first++;
        }
    }
    for(int i = 1; i <= H; i++){
        for(int j = 1; j <= W; j++){
            cout << color[i][j] << " ";
        }
        cout << endl;
    }
}


Measured memory_bytes: 512
//
//  main.cpp
//  AOJ1179
//
//  Created by aki33524 on 2014/07/08.
//  Copyright (c) 2014年 aki33524. All rights reserved.
//

#include <iostream>
using namespace std;

int Y, M, D;

int cal(int ey, int em, int ed){
    int cnt = 0;
    for(int y=1; y<=ey; y++){
        for(int m=1 ; m<=10; m++){
            for(int d=1; d<=20-(y%3!=0 && m%2==0); d++){
                cnt++;
                if(ey == y && em == m && ed == d)
                    return cnt;
            }
        }
    }
}

int main(int argc, const char * argv[])
{
    int N;
    cin >> N;
    for(int i=0; i<N; i++){
        cin>>Y>>M>>D;
        cout << cal(1000, 1, 1) - cal(Y, M, D) << endl;
    }
    
    return 0;
}

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

#define rep(i,n) for(int i=0; i<n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)

ll n,a,b;
ll h[100010],k[100010];

bool isOK(ll x){//x回の爆発で全部倒せるかどうか
  ll sum = 0;
  rep(i,n){
    k[i] -= b*x;
  }
  rep(i,n){
    if(k[i] > 0){
      sum += (k[i]+a-b-1)/(a-b);
    }
  }
  return sum <= x;
}
int main(){
  cin >> n >> a >> b;
  rep(i,n){
    cin >> h[i];
  }

  int ok = 2000000010, ng = 0;
  while(abs(ok-ng)>1){
    rep(i,n){
      k[i] = h[i];
    }
    ll mid = (ok+ng)/2;
    if(isOK(mid)){
      ok = mid;
    }else{
      ng = mid;
    }
  }
  cout << ok << endl;
}

Measured memory_bytes: 1792
def main():
    N = int(input())
    work = []
    time=0
    for i in range(N):
        a,b = map(int,input().rstrip().split(' '))
        ob = {'A': a,'B':b}
        work.append(ob)
    work = sorted(work,key = lambda x: x['B'])
    for w in work:
        time += w['A']
        if time > w['B']:
            print('No')
            return 0
    print('Yes')

if __name__ == "__main__":
    main()

Measured memory_bytes: 80376
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;
typedef long long LL;

LL n, a, b;
int main()
{
	while(scanf("%lld %lld %lld", &n, &a, &b) != EOF)
	{
		if(n == 1)
		{
			if(a != b)
				printf("0\n");
			else printf("1\n");
		}
		else
		{
			if(a > b) printf("0\n");
			else {
				LL cnt = n - 2;
				LL ans = (b * cnt) - (a * cnt) + 1;
				printf("%lld\n", ans);
			}
		}
	}
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef pair<pii,pii> pippi;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<61;
int iinf=1<<30;
double pi=3.14159265358979323846;
double pi2=pi/2.0;
double eps=1e-8;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto& itr:mp)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
//#define endl "\n"
int dh[4]={1,0,-1,0};
int dw[4]={0,1,0,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umh unordered_map<int,int,custom_hash>
ll gcd(ll a,ll b){
    if(a<0)a=-a;
    if(b<0)b=-b;
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll c=gcd(a,b);
    return a*b/c;
}
ll Pow(ll n,ll k){
    if(k<0)return 0;
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
    now%=md;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    string s,t;cin>>s>>t;
    int ans=1000000000;
    rep(i,0,s.size()){
        int la=i+t.size();
        if(la>s.size())break;
        int sum=0;
        rep(j,i,la){
            if(s[j]!=t[j-i])sum++;
        }
        Min(ans,sum);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
 
#define A_MAX 1000000
 
using namespace std;
 
int scanint() { 
	char c = getchar_unlocked();
    int x = 0;
    for(; (c<48)||(c>57);c = getchar_unlocked());
    for(; (c>47)&&(c<58);c = getchar_unlocked())
        x = 10 * x + c - 48;
    return x;
} 
 
int min_factor[A_MAX + 1];
int q[A_MAX + 1];
int a[A_MAX + 1];
 
int main() {
 
    vector<int> primes;
    for (int i = 2; i <= A_MAX; ++i) {
        if (!min_factor[i]) {
            min_factor[i] = i;
            primes.push_back(i);
        }
        for (int p : primes) {
            int n = i * p;
            if (n > A_MAX) {
                break;
            }
            min_factor[n] = p;
            if (p == min_factor[i]) {
                q[n] = q[i];
                break;
            } else {
                q[n] = i;
            }
        }
    }
 
    int N = scanint();
    for (int i = 0; i < N; ++i) {
        ++a[scanint()];
    }
 
    bool is_pairwise_coprime = true;
    for (int n = A_MAX; n > 1; --n) {
        int an = a[n];
        if (an) {
            if (an > 1) {
                if (an == N) {
                    printf("not coprime\n");
                    return 0;
                }
                is_pairwise_coprime = false;
            }
            a[min_factor[n]] += an;
            a[q[n]] += an;
        }
    }
    if (is_pairwise_coprime) {
        printf("pairwise coprime\n");
    } else {
        printf("setwise coprime\n");
    }
 
    return 0;
}

Measured memory_bytes: 15472
#include<bits/stdc++.h>
#define ll long long int
#define fip ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define reptUsual(b) for(i=0; i<b; ++i)
#define reptArIn(i,a,b,ar) for( i=a; i<b; ++i) cin>>ar[i];
#define rept(i,a,b) for(i=a; i<b; ++i)
#define maX(a,b)    ( (a) > (b) ? (a) : (b))
#define miN(a,b)    ( (a) < (b) ? (a) : (b))
#define pb(a) push_back(a)
using namespace std;

int main()
{
    fip;
  	int x,a;
  	cin>>x>>a;
  if(x<a)
    cout<<"0";
  else
    cout<<"10";

    return 0;

}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

void check_dfs(int pos);
bool check_isgoal_dfs(int pos);

int N;
vector<int> check_graph[2505];
bool isvisit[2505], isvisit_2[2505];
bool isgoal[2505];

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

    int M, p;
    cin >> N >> M >> p;
    vector<pair<P, int>> graph;
    for(int i = 0; i < M; ++i) {
        int a, b, c;
        cin >> a >> b >> c;
        check_graph[a].pb(b);
        c = -c;
        c += p;
        graph.pb(MP(MP(a, b), c));
    }

    check_dfs(1);
    for(int i = 1; i <= N; ++i) {
        for(int j = 1; j <= N; ++j) {
            isvisit_2[j] = false;
        }
        if(isvisit[i]) {
            isgoal[i] = check_isgoal_dfs(i);
        }
    }

    LL res[2505];
    for(int i = 0; i <= N; ++i) res[i] = LINF;
    res[1] = 0;

    for(int i = 0; i <= M; ++i) {
        for(int j = 0; j < graph.size(); ++j) {
            int from, to, cost;
            from = graph[j].F.F;
            to = graph[j].F.S;
            cost = graph[j].S;
            if(res[from] == LINF) continue;
            res[to] = min(res[to], res[from] + cost);
        }
    }

    for(int i = 0; i < graph.size(); ++i) {
        if(res[graph[i].F.F] != LINF && res[graph[i].F.S] > res[graph[i].F.F] + graph[i].S && isgoal[graph[i].F.S]) {
            cout << -1 << endl;
            return 0;
        }
    }

    cout << max(-res[N], 0ll) << endl;

    return 0;
}

void check_dfs(int pos) {
    if(isvisit[pos]) return;
    isvisit[pos] = true;

    for(int i = 0; i < check_graph[pos].size(); ++i) {
        check_dfs(check_graph[pos][i]);
    }

    return;
}

bool check_isgoal_dfs(int pos) {
    if(isvisit_2[pos]) return false;
    isvisit_2[pos] = true;

    if(pos == N) {
        return true;
    }

    bool goal = false;
    for(int i = 0; i < check_graph[pos].size(); ++i) {
        goal |= check_isgoal_dfs(check_graph[pos][i]);
    }

    return goal;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>

#define MAX 100000

int binary_search( int * ary, int key, int size );
int main() {
        int s_ary[MAX], q_ary[MAX];
        int n, q, cnt = 0, flag = 0;

        scanf( "%d", &n );
        for ( int i = 0 ; i < n ; i++ ) {
                scanf( "%d", &s_ary[i] );
        }

        scanf( "%d", &q );
        for ( int i = 0 ; i < q ; i++ ) {
                scanf( "%d", &q_ary[i] );
        }

        for ( int i = 0 ; i < q ; i++ ) {
                if ( binary_search( s_ary, q_ary[i], n ) ) { cnt++; }
        }

        printf( "%d\n", cnt );
}

int binary_search( int * ary, int key, int size ) {
        int left = 0, right = size;
        int mid;

        while ( left < right ) {
                mid = ( left + right ) / 2;
                if ( key == ary[mid] ) {
                        return 1;
                } else if ( key > ary[mid] ) {
                        left = mid + 1;
                } else if ( key < ary[mid] ) {
                        right = mid;
                }
        }

        return 0;
}




Measured memory_bytes: 2360
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long ll;
typedef pair<ll,ll> P;


int n, a[100];

int main(){
	cin >> n;
	int cnt = 0;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		cnt += a[i];
	}
	
	sort(a, a+ n);
	
	cout << cnt - a[n-1]/2 << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef unsigned long long ull;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

ull f(ull x, int n, ull a[]){
  ull sum = 0;
  for(int i = 0; i < n; i++){
    sum += x ^ a[i];
  }
  return sum;
}

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

  int n;
  ull k;
  cin >> n >> k;
  ull a[n];
  for(int i = 0; i < n; i++) cin >> a[i];

  int d[64];
  fill(d, d + 64, 2);

  for(int i = 0; i < 64; i++){
    int c0 = 0, c1 = 0;
    for(int j = 0; j < n; j++){
      if(((1l << i) & a[j]) != 0) ++c0;
      else ++c1;
    }
    if(c0 > c1) d[i] = 0;
    else if(c0 < c1) d[i] = 1;
  }

  ull x = 0;
  for(int i = 63; i >= 0; i--){
    if(d[i] == 1){
      ull tmp = (1ll << i) | x;
      if(tmp <= k) x = tmp;
    }
  }

  ull ans = f(x, n, a);

  cout << ans << endl;

  return 0;
}

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

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

int main(){
	int N,M,X,Y;
	cin >> N >> M >> X >> Y;
	int x=X, y=Y, tmp;
	REP(i,N){
		cin >> tmp;
		x = max(x, tmp);
	}
	REP(i,M){
		cin >> tmp;
		y = min(y, tmp);
	}
	if(x<y) cout << "No War\n";
	else cout << "War\n";
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define int long long
#define endl '\n'
#define pi 3.14159265
int mod=10;
int p(int a,int b)
{
    int res=1;
    while(b)
    {
        if(b%2!=0)
            res*=a;
        res%=mod;
        a*=a;
        a%=mod;
        b/=2;
    }
    return res; 
}
int32_t main()
{
    IOS;
    int n;
    cin>>n;
    vector<int> v(n);
    for(int i=0;i<n;i++)
        cin>>v[i];
    int ans=0;
    for(int i=1;i<n-1;i++)
    {
        if(v[i]<max(v[i-1],v[i+1])&&v[i]>min(v[i-1],v[i+1]))
            ans++;
    }
    cout<<ans;
}   

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
using namespace std;

#define REP(i,n) for(int i=0;(i)<(n);(i)++)
#define ll long long

bool visited[60];
int cnt;
int N;
bool adj[60][60];

void dfs(int x) {
	if (visited[x]) return;
	visited[x] = true;
	cnt++;
	REP(i, N) {
		if (adj[x][i]) dfs(i);
	}
	return;
}

int main() {
	int M;
	int a[60], b[60];
	
	REP(i, 50) { REP(j, 50) { adj[i][j] = false; } }
	cin >> N >> M;
	REP(i, M) {
		cin >> a[i] >> b[i];
		a[i]--;
		b[i]--;
		adj[a[i]][b[i]] = adj[b[i]][a[i]] = true; //0-indexed
	}
	
	int ans = 0;
	REP(i, M) {
		adj[a[i]][b[i]] = adj[b[i]][a[i]] = false;
		REP(i, 50) { visited[i] = false; }
		cnt = 0;

		dfs(0);
		if (cnt != N) ans++;

		adj[a[i]][b[i]] = adj[b[i]][a[i]] = true;
	}

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

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	Scanner sc = new Scanner(System.in);

	int INF = 1 << 28;
	double EPS = 1e-9;

	int n;
	P ps1, ps2, ps3;
	P k, s;

	void run() {
		n = sc.nextInt();
		for (int i = 0; i < n; i++) {
			int xp1 = sc.nextInt();
			int yp1 = sc.nextInt();
			int xp2 = sc.nextInt();
			int yp2 = sc.nextInt();
			int xp3 = sc.nextInt();
			int yp3 = sc.nextInt();
			int xk = sc.nextInt();
			int yk = sc.nextInt();
			int xs = sc.nextInt();
			int ys = sc.nextInt();
			ps1 = new P(xp1, yp1);
			ps2 = new P(xp2, yp2);
			ps3 = new P(xp3, yp3);
			k = new P(xk, yk);
			s = new P(xs, ys);
			solve();
		}
	}

	void solve() {
		if (crsSS(k, s, ps1, ps2) ^ crsSS(k, s, ps2, ps3)
				^ crsSS(k, s, ps3, ps1)) {
			println("OK");
		} else {
			println("NG");
		}
	}

	boolean crsSS(P p1, P p2, P q1, P q2) {
		if (max(p1.x, p2.x) + EPS < min(q1.x, q2.x))
			return false;
		if (max(q1.x, q2.x) + EPS < min(p1.x, p2.x))
			return false;
		if (max(p1.y, p2.y) + EPS < min(q1.y, q2.y))
			return false;
		if (max(q1.y, q2.y) + EPS < min(p1.y, p2.y))
			return false;
		return signum(p2.sub(p1).det(q1.sub(p1)))
				* signum(p2.sub(p1).det(q2.sub(p1))) < EPS
				&& signum(q2.sub(q1).det(p1.sub(q1)))
						* signum(q2.sub(q1).det(p2.sub(q1))) < EPS;
	}

	class P {
		double x, y;

		P() {
			this(0, 0);
		}

		P(double x, double y) {
			this.x = x;
			this.y = y;
		}

		P add(P p) {
			return new P(x + p.x, y + p.y);
		}

		P sub(P p) {
			return new P(x - p.x, y - p.y);
		}

		P mul(double m) {
			return new P(x * m, y * m);
		}

		P div(double d) {
			return new P(x / d, y / d);
		}

		double abs() {
			return Math.sqrt(abs2());
		}

		double abs2() {
			return x * x + y * y;
		}

		double arg() {
			return Math.atan2(y, x);
		}

		// inner product
		double dot(P p) {
			return x * p.x + y * p.y;
		}

		// outer product
		double det(P p) {
			return x * p.y - y * p.x;
		}

		P rot90() {
			return new P(-y, x);
		}

		// conjugation
		P conj() {
			return new P(x, -y);
		}
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s) {
		System.out.print(s);
	}

	void println(String s) {
		System.out.println(s);
	}

	public static void main(String[] args) {
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
#define FastIO() ios::sync_with_stdio(false), cin.tie(0);
#define error(args...)                       \
{                                            \
    cerr<<"LINE "<<__LINE__;                 \
    string _s = #args;                       \
    replace(_s.begin(), _s.end(), ',', ' '); \
    stringstream _ss(_s);                    \
    istream_iterator<string> _it(_ss);       \
    err(_it, args);                          \
    cerr<<endl;                              \
}
void err(istream_iterator<string> it)
{
} 
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
  cerr<<' '<< *it << " = " << a ;
  err(++it, args...);
} 
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 1e6+9, M = 1e7, OO = 0x3f3f3f3f;
char str[200];


int main()
{
  int n;
  scanf("%d",&n);
  scanf("%s",str);
  if(n&1) printf("No\n");
  else
  {
    for(int i=0;i<n/2;++i)
    {
      if(str[i]!=str[i+(n-1)/2+1])
      {
        printf("No\n");
        return 0;
      }
    }
    printf("Yes\n");
  }
  
  
  #ifdef _LOCAL_DEFINE
  cerr << (double)clock() * 1.0 / CLOCKS_PER_SEC << endl;
  #endif
  return 0; 
}

Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 1e9
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int main() {
	vector<int> sosuu;
	for (int i = 6; i <= 300000; ++i) {
		if ((i % 7 == 1 || i % 7 == 6)) {
			int ok = 1;
			for (int q = 0; q < sosuu.size(); ++q) {
				if (i % sosuu[q] == 0) {
					ok = 0;
					break;
				}
			}
			if (ok == 1) {
				sosuu.push_back(i);
			}
		}
	}
	while (true) {
		int a;
		cin >> a;
		if (a == 1) return 0;
		cout << a << ":";
		REP(i, sosuu.size()) {
			if (a % sosuu[i] == 0) {
				cout << " " << sosuu[i];
			}
		}
		cout << endl;
	}
}


Measured memory_bytes: 3284
#include <bits/stdc++.h>
typedef long long ll;
#define mod 1000000009
#define MK make_pair
#define EB emplace_back
#define PB push_back
#define F first
#define S second
using namespace std;
void solve()
{
	int a,b;
	cin>>a>>b;
	cout<<a*b<<endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t=1;
	//cin>>t;
	while(t--)
		solve();
	return 0;
}

Measured memory_bytes: 3652
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using Enu = System.Linq.Enumerable;

public class Program
{
    static readonly int Mod = (int)1e9 + 7;
    static void Add(ref long a, long b) { if ((a += b) >= Mod) a -= Mod; }

    public void Solve()
    {
        int N = Reader.Int(), C = Reader.Int();
        var A = Reader.IntArray(N);
        var B = Reader.IntArray(N);

        int Bmax = B.Max();
        var powSum = new long[Bmax + 1, C + 1];
        for (int x = 1; x <= Bmax; x++)
            for (long n = 0, p = 1; n <= C; n++, p = p * x % Mod)
                powSum[x, n] = (powSum[x - 1, n] + p) % Mod;

        var dp = new long[C + 1];
        dp[0] = 1;
        for (int i = 0; i < N; i++)
        {
            var nextdp = new long[C + 1];
            for (int sum = 0; sum <= C; sum++)
                for (int add = 0; sum + add <= C; add++)
                {
                    long v = Mod + powSum[B[i], add] - powSum[A[i] - 1, add];
                    Add(ref nextdp[sum + add], v % Mod * dp[sum] % Mod);
                }
            dp = nextdp;
        }

        Console.WriteLine(dp[C] % Mod);
    }

}


class Entry { static void Main() { new Program().Solve(); } }
class Reader
{
    static TextReader reader = Console.In;
    static readonly char[] separator = { ' ' };
    static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
    static string[] A = new string[0];
    static int i;
    static void Init() { A = new string[0]; }
    public static void Set(TextReader r) { reader = r; Init(); }
    public static void Set(string file) { reader = new StreamReader(file); Init(); }
    public static bool HasNext() { return CheckNext(); }
    public static string String() { return Next(); }
    public static int Int() { return int.Parse(Next()); }
    public static long Long() { return long.Parse(Next()); }
    public static double Double() { return double.Parse(Next()); }
    public static int[] IntLine() { return Array.ConvertAll(Split(Line()), int.Parse); }
    public static int[] IntArray(int N) { return Range(N, Int); }
    public static int[][] IntTable(int H) { return Range(H, IntLine); }
    public static string[] StringArray(int N) { return Range(N, Next); }
    public static string[][] StringTable(int N) { return Range(N, () => Split(Line())); }
    public static string Line() { return reader.ReadLine().Trim(); }
    public static T[] Range<T>(int N, Func<T> f) { var r = new T[N]; for (int i = 0; i < N; r[i++] = f()) ; return r; }
    static string[] Split(string s) { return s.Split(separator, op); }
    static string Next() { CheckNext(); return A[i++]; }
    static bool CheckNext()
    {
        if (i < A.Length) return true;
        string line = reader.ReadLine();
        if (line == null) return false;
        if (line == "") return CheckNext();
        A = Split(line);
        i = 0;
        return true;
    }
}

Measured memory_bytes: 5336
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let k:usize = read();
    let arr:Vec<usize> = (0..n).map(|_| read()).collect();
    let p = arr.iter().position(|&i| i == 1).unwrap();
    let mut x = 1;
    let mut ans = 0;
    loop {
        x += k-1;
        ans += 1;
        if x >= n {
            break;
        }
    }
    println!("{}", ans);
}

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

using namespace std;

const int MOD = 1000000007;

int main() {
    long long M;
    cin>>M;
    long long sum=0;
    long long count=0;
    long long d[M];
    long long c[M];
    for(int i=0;i<M;i++){
        cin>>d[i]>>c[i];
        sum+=(d[i]*c[i]);
        count+=c[i];
    }
    cout<<((count-1)+((sum-1)/9))<<endl;


}





Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
int a;
cin>>a;
int b=a%10;
int c=((a%100)-b)/10;
int d=(a-(a%100))/100;
if(a==b*100+c*10+d)
cout<<"Yes";
else
cout<<"No";
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <utility>
#include <string>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

#define modp(x, y) (((y) + (x) % (y)) % (y))

int main(int argc, char* argv[])
{
	int x, a, b;
	scanf("%d %d %d", &x, &a, &b);
	if(abs(x - a) < abs(x - b)) printf("A\n");
	else printf("B\n");

	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<queue>
#include<string>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cassert>
#include<ctime>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<vector>
#include<functional>
#include<complex>

using namespace std;

typedef long long            ll;
typedef unsigned             ui;
typedef unsigned long long   ull;
typedef pair<int,int>        i_i;
typedef pair<ll,int>         ll_i;
typedef pair<ll,ll>          ll_ll;
typedef pair<double,int>     d_i;
typedef pair<double,double>  d_d;
typedef vector<int>          vi;
typedef vector<vector<int> > vii;

#ifdef DEBUG
#define dprintf      printf
#define dputs        puts
#define dout(x)      cout<<#x" = "<<(x)<<endl
#define darray(x,n)  {int i;rep(i,n)cout<<#x"["<<i<<"] = "<<*((x)+i)<<endl;}
#define dloop(i,s,g) for(int (i)=(s);(i)<(g);(i)++)
#define drep(i,n)    for(int (i)=0;(i)<(n);(i)++)
#define dstop()      scanf("%*c")
#else
#define dprintf      (1)?0:printf
#define dputs        (1)?0:puts
#define dout(x)
#define darray(x,n)
#define dloop(i,s,g) if(int i=0){}else
#define drep(i,n)    if(int i=0){}else
#define dstop()
#endif

#define F    first
#define S    second
#define pb   push_back
#define mp   make_pair

#define loop(i,s,g) for((i)=(s);(i)<(g);(i)++)
#define rep(i,n)    for((i)=0;(i)<(n);(i)++)
#define all(x)      (x.begin(),x.end())
#define in(T,...) T __VA_ARGS__; impl(__VA_ARGS__)
#define array(T,id,n) T id[(n)]; for(int i=0;i<(n);i++)cin>>id[i]
#define putv(n)     cout<<(n)<<endl

//#define int long long
#ifndef int
#define INF __INT32_MAX__
#else
#define INF __INT64_MAX__
#endif

void impl(){};
template <typename T,typename... TS >
void impl(T &head,TS &... tail)
{
  cin>>head;
  impl(tail ...);
}

signed main(void)
{
  in(int,a);
  putv(a/3);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Maxn 200007
using namespace std;
int n;
int a[Maxn],b[Maxn];
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for (int i=1;i<=n;i++)
		scanf("%d",&b[i]);
	long long cnt1=0,cnt2=0;
	for (int i=1;i<=n;i++)
		if (b[i]<a[i]) cnt2+=a[i]-b[i];
		else
		{
			if ((b[i]-a[i])%2==0) cnt1+=(b[i]-a[i])/2;
			else
			{
				++cnt2;
				cnt1+=(b[i]-a[i]+1)/2;
			}
		}
	if (cnt1<cnt2) printf("No\n"); else printf("Yes\n");
	return 0;
}


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

using namespace std;

using ll = long long;
ll arr[100001] = {0};

void SieveOfEratosthenes(ll n) {
    bool prime[n+1];
    memset(prime, true, sizeof(prime));
    for (ll p = 2; p * p <= n; ++p){
        if (prime[p] == true) {
            for (ll i = p * p; i <= n; i += p)
                prime[i] = false;
        }
    }
    for (ll p = 2; p <= n; ++p)
       if (prime[p] && prime[(p + 1) / 2])
          arr[p] = 1;
    for(ll i = 1; i < 100001; ++i){
        arr[i] += arr[i - 1];
    }
}

int main(){
    ll q; cin >> q;
    SieveOfEratosthenes(100001);
    while(q--){
        ll l, r; cin >> l >> r;
        if(l == 1) cout << arr[r] - 1<< endl;
        else cout << arr[r] - arr[l - 1] << endl;
    }
    return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <map>
#include <queue>

using namespace std;

int main(){
  int N,M;
  cin >> N >> M;
  int AB[N][2];
  int ans = 0;
  map<int, vector<int>> table;
  for(int i=0; i<N; i++){
    int a,b;
    cin >> a >> b;
    table[a].push_back(b);
  }
  priority_queue<int, vector<int>, less<int>> que;
  for(int i=1; i<=M; i++){
    que.push(0);
    for(int j=0; j<table[i].size(); j++){
      que.push(table[i][j]);
    }
    ans += que.top();
    que.pop();
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 11520
s = input()
r1 = s.replace('?','D').count('D') + s.replace('?','D').count('PD')
r2 = s.replace('?','P').count('D') + s.replace('?','P').count('PD')
if r1 >= r2:
    print(s.replace('?','D'))
else:
    print(s.replace('?','P'))

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

using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep3(i, n) for (int i = 1; i < (int)(n+1); i++)
#define rep4(i, s, n) for (int i = (s); i < (int)(n+1); i++)
#define repr(i,n) for (int i = (n-1); i>=0;i--)
#define repr2(i,s,n) for (int i = (n-1); i>=(int)(s);i--)
#define repr3(i,n) for(int i = (n);i>0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
const ll INF = 1001001000100010;
const ld PI = 3.14159265358979323846;



int main() {

ll A;
ld B;
cin>>A>>B;

cout<<(ll)floor(A*B)<<endl;

return 0;
}

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

int main(){
  ll N, M;
  cin >> N >> M;

  vector<pair<ll, ll>> X(N);

  rep(i, N){
    cin >> X[i].first >> X[i].second;
  }

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

  ll cnt = 0;
  ll ans = 0;
  ll res = M;
  while (res > 0){
    ans += X[cnt].first * min(res, X[cnt].second);
    res -= X[cnt].second;
    cnt ++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4764
import sys
input = sys.stdin.readline
import numpy as np
N = int(input())
A = [[0,0,0]]
for _ in range(N):
    A.append([int(x) for x in input().split()])
A = np.array(A)
for i in range(1, N+1):
    A_ = abs(A[i] - A[i-1])
    if A_[0] < A_[1] + A_[2]:
        print("No")
        sys.exit()
    A_mod = (A_[1] + A_[2]) % 2
    if A_[0] % 2 != A_mod:
        print("No")
        sys.exit()
print("Yes")

Measured memory_bytes: 32384
use proconio::input;
use num::integer::lcm;

fn f(mut x: i64) -> i64 {
  let mut y = 0;
  while (x & 1) == 0 {
    y += 1;
    x >>= 1;
  }
  y
}

fn main() {
  input! {
    n: i64, m: i64,
    a: [i64; n],
  };
  let a: Vec<i64> = a.iter().map(|x|x/2).collect();
  
  let l = a.iter().fold(1, |x, &y| lcm(x, y));
  
  let y = f(a[0]);
  if !a.iter().all(|&x| y == f(x)) {
    println!("0");
  } else {
    let cnt = m / l;
    let ans = (cnt + 1) / 2;

    println!("{}", ans);
  }
}

Measured memory_bytes: 4492