akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);



int main(){fastio
    ll n,k;cin>>n>>k;
    bool b[n+1];rep(i,1,n)b[i]=false;
    ll d;
    rep(i,0,k-1){
        cin>>d;
        ll a;
        rep(j,0,d-1){
            cin>>a;
            b[a]=true;
        }
    }
    ll ans=0;
    rep(i,1,n){
        if(!b[i]){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

typedef vector<int> lieqn;

long long mabs(long long a){
	if(a<0){
		return -1*a;
	}
	return a;
}

lieqn gcd(lieqn a,lieqn b){
	if(a.at(2) < b.at(2)){
		lieqn temp=a;
		a=b;
		b=temp;
	}
	if(b.at(2)==0){
		return a;
	}
	
	a.at(0)-=((a.at(2)/b.at(2))*b.at(0));
	a.at(1)-=((a.at(2)/b.at(2))*b.at(1));
	a.at(2)%=b.at(2);
	
	return gcd(a,b);
}

int main(){
	long long a,b;
	cin >> a >> b;
	lieqn lea;
	lieqn leb;

	lea.push_back(1);
	lea.push_back(0);
	lea.push_back(a);
	leb.push_back(0);
	leb.push_back(1);
	leb.push_back(b);

	lieqn leans=gcd(lea,leb);

	long long x=leans.at(0);
	long long y=leans.at(1);
	long long px=x;
	long long py=y;
	long long pabsm=mabs(x)+mabs(y);
	x+=b;
	y-=a;
	long long absm=mabs(x)+mabs(y);
	while(absm<pabsm){
		px=x;
		py=y;
		pabsm=mabs(x)+mabs(y);
		x+=b;
		y-=a;
		absm=mabs(x)+mabs(y);
	}
	cout << px << " " << py << endl;

}


Measured memory_bytes: 1220
#include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> state;
long double pi = acos(-1);
const int INF = 1001001001;
const int N_MAX = 100001;

// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
char changeS(char alpha){
  if(0x41 <= alpha and alpha <= 0x5A)return (alpha + 0x20);
  else if(0x61 <= alpha and alpha <= 0x7A)return (alpha - 0x20);
  return alpha;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }
int ceil(int a,int b){
  // a/bの切り上げを考える
  return (a+b-1)/b;
}

int main(){
  int n;
  cin >> n;
  int h[n], dp[n];

  rep(i,n)cin >> h[i];

  memset(dp, 0, sizeof(dp));

  dp[1] = abs(h[1] - h[0]);

  for (int i = 2;i < n;i++) {
    dp[i] = min(dp[i - 2] + abs(h[i] - h[i-2]), dp[i-1] + abs(h[i] - h[i-1]));
  }
  cout << dp[n-1] << endl;
  
}

Measured memory_bytes: 4400
from collections import Counter

def inpl(): return list(map(int, input().split()))

A, B = inpl()
for i, s in enumerate(list(input())):
    if i < A:
        try:
            int(s)
        except:
            print("No")
            exit()
    elif i == A:
        if s == "-":
            pass
        else:
            print("No")
            exit()
    else:
        try:
            int(s)
        except:
            print("No")
            exit()
print("Yes")

Measured memory_bytes: 3316
#include <stdio.h>
#include <vector>
#include <iostream>
#include <sstream>

using namespace std;

vector<string> split(const string &s, char delim) {
    vector<string> elems;
    stringstream ss(s);
    string item;
    while (getline(ss, item, delim)) {
    if (!item.empty()) {
            elems.push_back(item);
        }
    }
    return elems;
}

int main() {
  string s;
  cin >> s;
  vector<string> v = split(s, '/');
  string y = v.at(0);
  string m = v.at(1);
  string d = v.at(2);
  printf("%s/%s/%s\n", "2018", m.c_str(), d.c_str());
}

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

ll f(ll b, ll n){
    if(b==1){return 99999999999999;}
    if(n<b){return n;}
    ll ret = f(b,n/b) + n%b;
    return ret;
}

int main(){
    ll n, s;
    cin >> n >> s;
    if(s == n){
        cout << n+1 << endl;
        return 0;
    }else if(n<s){
        cout << -1 << endl;
        return 0;
    }
    ll ans = 99999999999999;
    for(int i = 2; i <= int(sqrt(n))+1; i++){
        ll ret = f(i,n);
        if(ret == s){
            ans = min(ans, ll(i));
        }
    }
    for(int p = 1; p <= int(sqrt(n)); p++){
        ll b = (n-s)/p+1;
        if(f(b,n) == s){
            ans = min(ans, b);
        }
    }
    if(ans == 99999999999999){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }
    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <iomanip>

#include <vector>
#include <set>
#include <bitset>
#include <map>
#include <deque>
#include <string>

#include <algorithm>
#include <numeric>
#include <random>

#include <cstdio>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>

using namespace std;

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define sz(a) static_cast<int>((a).size())
#define endl '\n'

using ll = long long;

const ll INF = static_cast<ll>(1e9) + 7;
const int MAXN = static_cast<int>(1e6) + 17;

int n, c, k;
int t[MAXN];

bool read() {
    if (!(cin >> n >> c >> k))
        return false;

    forn (i, n)
        cin >> t[i];

    return true;
}

void solve() {
    sort(t, t + n);
    int cur = 0, kek = -1, ans = 0;

    for (int i = 0; i < n; ++i) {
        if (kek < t[i]) {
            cur = 0;
        }

        if (cur == 0) {
            ++ans;
            kek = t[i] + k;
        }

        cur = (cur + 1) % c;
    }

    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::mt19937 rand('S' + 'E' + 'R' + 'E' + 'Z' + 'H' + 'K' + 'A');

    while (read())
        solve();

    return 0;
}



Measured memory_bytes: 640
#include <stdio.h>
int main(void) {
int h, w, i, j;
scanf("%d %d", &h, &w);
while( h != 0 && w != 0 ) {
for(i = 0; i < h; ++i ) {
for(j = 0; j < w; ++j ) {
putchar('#');
}
putchar('\n');
}
putchar('\n');
scanf("%d %d", &h, &w);
}
return 0;
}

Measured memory_bytes: 1000
#include <stdio.h>
#include <math.h>
int main()
{
    long n,d;
    int ans=0;
    scanf("%d %d",&n,&d);
    int x[200000];
    int y[200000];
    int i;
    for (i = 0; i<n;i++)
    {
        scanf("%d %d",&x[i],&y[i]);
    }
    for (i=0;i<n;i++)
    {
        if ( pow(x[i],2.0) + pow(y[i],2.0) <= pow(d,2.0))
        {
            ans++;
        }
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 3292
#include <stdio.h>
int main (void)
{ double r,S,l,P;
  P=3.14159265358979323846;
  scanf("%lf",&r);
  S=P*r*r;
  l=P*2*r;
  printf("%lf %lf\n",S,l);
  


return 0;	
}

Measured memory_bytes: 1748
#include<bits/stdc++.h>
using namespace std;
#define PI          acos(-1)
#define INF         0x3f3f3f3f
#define sc(n)       scanf("%d",&n);
#define ssc(n)      scanf("%s",n);
#define lsc(n)      scanf("%lld",&n);
#define dsc(n)      scanf("%lf",&n);
#define LL          long long int
#define UI          unsigned int
#define ULL         unsigned long long int
#define DB          double
#define pii         pair<int,int>
#define VI          vector<int>
#define MII         map<int,int>
#define PB          push_back
#define MP          make_pair
#define M(mx,a)     mx=max(mx,a)
#define IT          ::iterator
#define all(a)      a.begin(),a.end()
#define mems(a,b)   memset(a,b,sizeof(a))
#define F(i,a,b)    for(i=a;i<b;i++)
#define IN(n,aa)    for(i=0;i<n;i++)scanf("%d",&aa[i]);
#define PNT(n,aa)   for(i=0;i<n;i++)printf("%lld ",aa[i]);
#define mod         1000000007
#define NUM         100009
#define NUM2        1000000000



int main()
{
    int T=1,QQ=0;
    //cin >> T ;
    while(T--)
    {
        int n,m,i,j=0,sm=0;
        sc(n)sc(m)
        int aa[n];
        for(i=0;i<n;i++)
        {
            sc(aa[i]);
            sm+=aa[i];
        }
        double avgg=1.0*sm/4/m;
        for(i=0;i<n;i++)
        {
            if(avgg<=1.0*aa[i])j++;
        }
        if(j>=m)cout << "Yes" ;
        else cout << "No" ;
    }
}
//printf("Case %d: ",++QQ);


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int H,W;

signed main(){
    cin>>H>>W;

    int ans=LLONG_MAX;
    if(H%3==0||W%3==0)chmin(ans,0ll);
    chmin(ans,H);chmin(ans,W);

    rep(t,2){
        for(int i=H/3-10;i<=H/3+10;i++){
            if(i<=0||i>=H)continue;

            for(int j=W/2-10;j<=W/2+10;j++){
                if(j<=0||j>=W)continue;

                int a=i*W;
                int b=j*(H-i);
                int c=(W-j)*(H-i);
                int latte=0;

                chmax(latte,abs(a-b));
                chmax(latte,abs(b-c));
                chmax(latte,abs(c-a));
                chmin(ans,latte);
            }
        }
        swap(H,W);
    }
    cout<<ans<<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;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl; 有効桁数指定
// *min_element(c + l, c + r) *max_element(c + l, c + r) 配列の中のmin-max
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// ~ は、-1の時だけfalse

int main () {

    string s;cin>>s;

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

}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int h,n;
	scanf("%i%i",&h,&n);
	int a[n+1],r=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%i",&a[i]);
		r+=a[i];
	}
	if(r>=h)	printf("Yes");
	else	printf("No");
	return 0;
}


Measured memory_bytes: 512
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main()
    {
        Console.WriteLine(new[] { 0 }.Aggregate(new { In = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(), Val = " " }, (n, v) => new { In = new int[0], Val = Enumerable.Repeat(0, n.In[0]).Select(_ => Console.ReadLine().Split(' ').Select(int.Parse).ToArray()).Where(p => p[1] <= n.In[1]).Select(p => p[0]).OrderBy(p => p).Select(p => (int?)p).FirstOrDefault()?.ToString() ?? "TLE" }).Val);
    }
}

Measured memory_bytes: 13524
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long A,B,C,D,E;
  cin >> A >> B >> C >> D >> E;
  cout << A+B+C+D+E+
    ((10-A%10)%10+(10-B%10)%10+(10-C%10)%10+(10-D%10)%10+(10-E%10)%10)
    +min(min((A-1)%10,(B-1)%10),min(min((C-1)%10,(D-1)%10),(E-1)%10))-9
    << endl;
  
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 8
#define M 15
int sum[N][N];

void xu(int);
int num[N];
int tum[N];
int rum[M];
int hum[M];

void fan(){
  int i, j;
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(sum[i][j]){
	if(num[i] != j) return;
      }
    }
  }
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(num[i] == j) printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}
  

int main(){
  int n, i, j, a, b;

  for(i=0;i<N;i++)num[i] = tum[i] = 0;
  for(i=0;i<M;i++)rum[i] = hum[i] = 0;
  
		     

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

  for(i=0;i<n;i++){
    scanf("%d%d",&a,&b);
    sum[a][b] = 1;
  }

  xu(0);

  return 0;
}

void xu(int i){
  int j;

  if(i == N){
      
  fan();
    return;
  }
  
  for(j=0;j<N;j++){
    if(tum[j] == -1 || rum[i + j] == -1 || hum[i - j + 7] == -1) continue;

num[i] = j;
    tum[j] = rum[i + j] = hum[i - j + 7] = -1;
    xu(i+1);
    num[i] = tum[j] = rum[i+j] = hum[i - j + 7] = 0;
  }
}




Measured memory_bytes: 2112
/*
    Author - Param Kothari
    Ah shit, here we go again
*/

#include <bits/stdc++.h>
 
using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mk make_pair

typedef long long ll;
typedef long double ld;

void solve(){
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    for(int i = 0; i < n; i++){
        cin >> x[i] >> y[i];
    }
    for(int i = 0; i < n - 2; i++){
        bool ok = true;
        for(int j = 0; j < 3; j++){
            ok &= (x[i + j] == y[i + j]);
        }
        if(ok){
            cout << "Yes\n";
            return;
        }
    }
    cout << "No\n";
    return;
}

int main(){
    IOS;
    int t = 1;
    // cin >> t;
    for(int i = 1; i <= t; i++){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3644
// Problem : C - Pyramid
// Contest : Virtual Judge - Showdown
// URL : https://vjudge.net/contest/391413#problem/C
// Memory Limit : 1048 MB
// Time Limit : 3000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*ヽ｀、ヽ｀｀、ヽ｀ヽ｀、、ヽ ｀ヽ 、ヽ｀｀ヽヽ｀ヽ、ヽ｀
ヽ｀、ヽ｀｀、ヽ 、｀｀、 ｀、ヽ｀ 、｀ ヽ｀ヽ、ヽ ｀、ヽ｀｀、
ヽ、｀｀、｀、ヽ｀｀、 、ヽヽ｀、｀、、ヽヽ、｀｀、 、 ヽ｀、
ヽ｀｀、 ヽ｀ヽ｀、、ヽ ｀ヽ 、 ヽ｀｀｀｀ヽヽヽ｀、、ヽ｀、、ヽ*/
#include <bits/stdc++.h> 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long   ll;
typedef long double ld;
typedef complex< ld > cd;
 
typedef pair<int, int> pi;
typedef pair<ll, ll>   pl;
typedef pair<ld, ld>   pd;
 
typedef vector< int > vi;
typedef vector< ld >  vd;
typedef vector< ll >  vl;
typedef vector< pi >  vpi;
typedef vector< pl >  vpl;
typedef vector< cd >  vcd;
 
#define l00p(i, a, b) for (int i=a; i<(b); i++)
#define loop(i, a)    for (int i=0; i<(a); i++)
#define rep1(i, a, b) for (int i = (b)-1; i >= a; i--)
#define rep(i, a)     for (int i = (a)-1; i >= 0; i--)
#define trav(a, x)    for (auto& a : x)
#define uid(a, b)     uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f  first
#define s  second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
//#define MOD 998244353
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); 
	int n,pp=0;
	cin>>n;
	vi x(n),y(n),h(n);
	loop(i,n)
	{
		cin>>x[i]>>y[i]>>h[i];
		if(h[i])
		pp=i;
	}
	int cx,cy,H;
	loop(i,101)
	{
		loop(j,101)
		{
			bool flag=true;
			H=h[pp]+abs(i-x[pp])+abs(j-y[pp]);
			loop(k,n)
			if(h[k]!=max(0,H-abs(i-x[k])-abs(j-y[k])))
				flag = false;
			if(flag)
			{
				cout<<i<<" "<<j<<" "<<H;
				return 0;
			}
		}
	}
	return 0;
}
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3648
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <math.h>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll INF = 1000000000000000000LL;
using namespace std;

const int MOD = 1000000007;

int main(){
    ll H,W,N,res;
    cin >> H >> W >> N;

    res = (N-1) / max(H,W) + 1;

    cout << res << endl;

    return 0;    
}


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a[7];
    for (int i = 0; i < 7; i++) cin >> a[i];

    long long ans = a[1];
    int aI = a[0];
    int aJ = a[3];
    int aL = a[4];

    if (aI > 0 && aJ > 0 && aL > 0) {
        if ((aI % 2 && aJ % 2 && aL % 2) || (aI % 2 && aJ % 2 && !(aL % 2)) ||
            (aI % 2 && !(aJ % 2) && aL % 2) ||
            (!(aI % 2) && aJ % 2 && aL % 2)) {
            ans += 3;
            aI--;
            aJ--;
            aL--;
        }
    }

    ans += 2 * (aI / 2);
    ans += 2 * (aJ / 2);
    ans += 2 * (aL / 2);
    cout << ans << endl;
    return 0;
}


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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;
template <typename T>
T modpow(T x, T n, const T mod) {
    T ret = 1;
    while(n > 0) {
        if(n & 1) (ret *= x) %= mod;
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

int main() {
    ll n, m, i, j, k;
    cin >> n >> k;
    ll ret[k + 1] = {};
    for(i = k; i >= 1; i--) {
        ll cnt = k / i;
        ret[i] = modpow(cnt, n, MOD);
    }
    ll ans = 0;
    /*for(i = 1; i <= k; i++) {
        (ans += i*ret[i]) %= MOD;
    }
    cout << ans << endl;
    */
   //cout << ret[1] << endl;
    for(i = k; i >= 2; i--) {
        for(j = 1; j * j <= i; j++) {
            if(i % j == 0) {
                ret[j] = (MOD + ret[j] - ret[i]) % MOD;
                if(i / j != j && i / j != i) {
                    (ret[i / j] += MOD - ret[i]) %= MOD;
                }
            }
        }
    }
    //cout << ret[1] << endl;
    for(i = 1; i <= k; i++) {
        (ans += i * ret[i]) %= MOD;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    int N;cin>>N;
    vector<pair<long,long>> scd(N);

    for(int i=0;i<N;i++){
        long x,l;cin>>x>>l;
        scd.at(i).first=x+l;
        scd.at(i).second=x-l;
    }
    sort(scd.begin(),scd.end());
    long res=1;
    long x=scd.at(0).first;
    for(int i=1;i<N;i++){
        if(x<=scd.at(i).second){
            res++;
            x=scd.at(i).first;
        }
    }

    cout<<res<<endl;
}

Measured memory_bytes: 1792
// Let's bring the sky down :)
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 1e2 + 5;
const int K = 1e5 + 5;
ll dp[N][K];    //[idx][profit] -> weight
ll we[N], v[N];
int main()
{
    ios_base ::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n, w;
    cin >> n >> w;
    int maxi = 0;
    for(int i = 0; i < n; i++)
        cin >> we[i] >> v[i], maxi += v[i];
    // profit can't exceed maxi, 0...maxi is the range of all possible profits
    for(int i = 1; i <= maxi; i++)
        dp[0][i] = INT_MAX;
    for(int i = 0; i < n; i++){
        for(int j = 0; j <= maxi; j++){
            if(j >= v[i])
                dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + we[i]);
            else
                dp[i + 1][j] = dp[i][j];
        }
    }
    int ans = 0;
    for(int i = 0; i <= maxi; i++)
        if(dp[n][i] <= w) ans = i;
    cout << ans;
return 0;
}


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

int n;
vector<int> a;
vector<long long> asum;
vector<int> axor;
vector<long long> diff;
int main()
{
    cin >> n;
    a.resize(n);
    // asum.resize(n+1, 0);
    // axor.resize(n + 1, 0);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        // asum[i + 1] = asum[i] + a[i];
        // axor[i + 1] = axor[i] ^ a[i];
    }

    int start = 0;
    int end = 1;
    int sumtmp = a[0];
    int xortmp = a[0];
    long long ans = 0;

    while (end <= n)
    {
        if (sumtmp == xortmp)
        {
            ans += (end - start);
            sumtmp += a[end];
            xortmp = xortmp ^ a[end];
            end++;
        }
        else
        {
            sumtmp -= a[start];
            xortmp = xortmp ^ a[start];
            start++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <tuple>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <random>
#include <cstdlib>
#define INT_MAX 2147483647
#define INT_MIN -2147483646
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

static const int N = 10005;

struct vertex {
	int id;
	int p;
	int d;
	bool operator<(const vertex & another) const {
		return (d != another.d ? d>another.d : id>another.id);
	}
};

struct edge {
	int end;
	int w;
};

int main() {
	int n;
	cin >> n;
	vector<vector<edge>> E(N);
	Loop(i, n) {
		int u, k;
		cin >> u >> k;
		Loop(i, k) {
			int v, c;
			cin >> v >> c;
			E[u].push_back({ v,c });
		}
	}
	//
	priority_queue<vertex> pq;
	vi color(N, 0), dist(N, 0);
	pq.push({ 0,-1,0 });
	while (pq.size() > 0) {
		vertex v = pq.top();
		pq.pop();
		if (color[v.id] == 1) continue;
		dist[v.id] = v.d;
		color[v.id] = 1;
		Loop(j, E[v.id].size()) {
			pq.push({ E[v.id][j].end, v.id, dist[v.id] + E[v.id][j].w });
		}
	}
	Loop(i, n) {
		cout << i << " " << dist[i] << endl;
	}
	return 0;
}

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

int main()
{
string str,str2;
string str3;
string str4;
int n,m,d;
cin>>str;
cin>>n;
for(int i=0;i<n;i++)
{
cin>>str2;
cin>>m>>d;
if(str2=="print"){
cout<<str.substr(m,d-m+1)<<endl;
}
else if(str2=="reverse"){
str4=str.substr(m,d-m+1);
str3=str4;
int wp=str4.size();
for(int j=0;j<wp;j++)
{
str[j+m]=str4[wp-j-1];
}



}
else if(str2=="replace"){
cin>>str3;
str=str.replace(m,d-m+1,str3);
}

}


return 0;
}

Measured memory_bytes: 1224
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define DEBUG true
#ifdef ONLINE_JUDGE
#undef DEBUG
#define DEBUG false
#endif 

using namespace std;

#define MAXN ((int)2e5+5)
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9 + 9)
#define ll long long
#define _ << " " <<
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define TRACE(x) if(DEBUG) cerr << #x << " = " << x << endl;
#define TRACE2(x,y) if(DEBUG) cerr << #x << " = " << x << " | " << #y << " = " << y << endl;
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl "\n"
#define pii pair<int,int>
#define mid ((l+r)/2)

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);
	
	int a,b;
	cin >> a >> b;

	if(a > 9 or a < 1 or b > 9 or b < 1)
		cout << -1 << endl;
	else
		cout << a * b << endl;


}

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

typedef long long ll;

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

  vector<ll> c(27,0);
  for(int i=1;i<=26;++i) cin>>c[i];

  vector<vector<ll>> s(D+1,vector<ll>(27,0));
  for(int i=1;i<=D;++i){
    for(int j=1;j<=26;++j){
      cin>>s[i][j];
    }
  }

  vector<ll> t(D+1);
  for(int i=1;i<=D;++i) cin>>t[i];

  int64_t score=0;

  vector<set<ll>> next(27);

  for(int i=1;i<=D;++i){
    next[t[i]].insert(i);
  }

  for(int i=1;i<=26;++i){
    next[i].insert(0);
    next[i].insert(D+1);
  }

  for(int i=1;i<=D;++i){
    score += s[i][t[i]];
    for(int j=1;j<=26;++j){
      auto k=next[j].upper_bound(i);
      --k;
      ll l=*k;
      score -= c[j]*(i-l);
    }
  }

  int M;
  cin>>M;
  for(int i=0;i<M;++i){
    int d,q;
    cin>>d>>q;

    //up

    ll l,r;
    auto j=next[q].lower_bound(d);
    r=*j;
    --j;
    l=*j;
    score += s[d][q]+((r-d)*(d-l))*c[q];
    next[q].insert(d);

    //down

    next[t[d]].erase(d);
    auto k=next[t[d]].lower_bound(d);
    r=*k;
    --k;
    l=*k;
    score -= s[d][t[d]]+((r-d)*(d-l))*c[t[d]];

    //update
    t[d]=q;
    cout<<score<<"\n";
  }

}


Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
int x[110]={},y[110]={};
int N,M,X,Y;
int main(){
  cin >> N >> M >> X >> Y;
  for(int i=0;i<N;i++){
    cin >> x[i];
  }
  for(int i=0;i<M;i++){
    cin >> y[i];
  }
  sort(x,x+N);//小さい順
  sort(y,y+M);
  if(y[0]-x[N-1]>0 && x[N-1]<Y && X<y[0]) cout << "No War" << endl;
  else cout << "War" << endl;
  return 0;
}


Measured memory_bytes: 256
# include <cmath>
# include <iostream>
# include <queue>
# include <set>
# include <stack>
# include <string>
# include <vector>


using namespace std;


int main() {
    string s; cin >> s;
    int ans;
    if (s == "SUN") ans = 7;
    if (s == "MON") ans = 6;
    if (s == "TUE") ans = 5;
    if (s == "WED") ans = 4;
    if (s == "THU") ans = 3;
    if (s == "FRI") ans = 2;
    if (s == "SAT") ans = 1;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 888
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#pragma GCC target ("sse4")
#pragma comment(linker, "/stack:200000000")

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

#define deb(x) cout << #x << " is " << x << "\n";

using namespace std;
using namespace __gnu_pbds;

const double PI = 2 * acos(0.0);
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >>n;
    while(!isprime(n))
        n++;
    cout <<n;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 1000000+5;
const int dx[] = {0,0,-1,1,-1,-1,1,1,0};
const int dy[] = {-1,1,0,0,-1,1,-1,1,0};
using namespace std;
LL bucket[10];
pair<int,int> node[N];
map<pair<int,int>,int> mp;
int main(){
    LL h,w,n;
    scanf("%lld%lld%lld",&h,&w,&n);
    for(int i=1;i<=n;i++){
        int x,y;
        scanf("%d%d",&node[i].first,&node[i].second);
    }

    for(int i=1;i<=n;i++){
        for(int j=0;j<9;j++){
            int nx=node[i].first+dx[j];
            int ny=node[i].second+dy[j];
            if(nx>=1&&nx<=h&&ny>=1&ny<=w){
                pair<int,int> temp(nx,ny);
                mp[temp]++;
            }
        }
    }

    LL sum=0;
    LL tot=(h-2)*(w-2);
    map<pair<int,int>,int>::iterator it;
    for(it=mp.begin();it!=mp.end();it++){
        int x=it->first.first;
        int y=it->first.second;
        int val=it->second;
        if(x>=2&&x<=h-1&&y>=2&y<=w-1){
            bucket[val]++;
            sum++;
        }
    }
    bucket[0]=tot-sum;
    
    for(int i=0;i<=9;i++)
        printf("%lld\n",bucket[i]);

    return 0;
}

Measured memory_bytes: 57344
//R<3S
#include <bits/stdc++.h>
#define hell 1000000007
#define PI 3.14159265358979323844
#define mp make_pair
#define pb push_back
#define fi first 
#define se second
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))  
#define REVERSE(v) reverse(ALL(v))
#define endl "\n"
#define vecmax(v) max_element(all(v))
#define vecmin(v) min_element(all(v))
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(x) for(auto i : x)
#define sz(a) (int)a.size()
#define sl(a) (int)a.length()
#define int long long
#define ld long double 
#define pii std::pair<int, int> 
#define pll std::pair<ll, ll>  
#define vi vector<int>  
#define vl vector<ll>
#define vvi vector<vi > 
#define vii vector<pii >
#define mii map<int,int>
#define mll map<ll,ll>


using namespace std;
int n,k;
int a[101];
int dp[100005][2];
int find(int x,int turn)
{
	// cout<<x<<" "<<turn<<endl;
	if(x==0)return dp[x][turn]=1-turn;
	if(x<0)return turn;
	if(dp[x][turn]!=-1)return dp[x][turn];
	int maxm=-1;
	int minm=3;
	rep(i,n)
	{
		if(turn==0)
		{
			minm=min(minm,find(x-a[i],1-turn));
		}
		else
		{
			maxm=max(maxm,find(x-a[i],1-turn));
		}
	}
	if(turn==0)return dp[x][turn]=minm;
	else return dp[x][turn]=maxm;
}
void solve()
  {

	cin>>n>>k;
	rep(i,100005)
	{dp[i][0]=-1;dp[i][1]=-1;}
	rep(i,n)cin>>a[i];
	cout<<(find(k,0)==0?"First":"Second");

  }



signed main()
{
   std::ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   int t;
   t=1;
   //cin>>t;
   while(t--)
    {
        solve();
    }


   return 0;
}


Measured memory_bytes: 11384
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#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;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  int n;
  cin >> n;
  int a[n+1]={0};
  int mx = 0, ans = 0;
  for(int i=1;i<=n;i++){
    cin >> a[i];
    ans+=max(0LL,mx-a[i]);
    mx = max(mx,a[i]);
  }
  cout << ans << endl;


return 0;
}
///....


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

long long a[200005];

int main()
{
    long long i, n, product = 1;

    cin >> n;

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

    for(i=0; i<n; i++)
    {
        if(product == 0)
        {
            cout << 0 << endl;
            return 0;
        }
        else if(product<=1000000000000000000 && a[i]<= 1000000000000000000/product)
            product = product*a[i];
        else
        {
            cout << -1 << endl;
            return 0;
        }
    }

    cout << product << endl;

    return 0;
}


Measured memory_bytes: 4424
from collections import Counter
n = int(input())
nums = list(map(int,input().split(" ")))

c = Counter(nums)
a = 0
for k,v in c.items():
    if v >=2:
        a+=(v-1)*v//2

for num in nums:
    curr = -1
    if c[num] >= 2:
        curr = a - (c[num]-1)
    else:
        curr = a
    print(curr)


Measured memory_bytes: 26780
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int A,B,C,D,E,F,a,b,all=0;
	scanf("%d %d %d %d %d %d",&A,&B,&C,&D,&E,&F);
	all+=max(E,F)+A+C+D+B;
	a=min(A,B);
	b=min(C,D);
	all-=min(a,b);
	printf("%d\n",all);
	return 0;
}


Measured memory_bytes: 3208
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
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();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//pair sort
bool compare_by_b(pair<LL, LL> a, pair<LL, LL> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}


void solve(string S, long long K){
    if(K==1){
        cout<<S[0]<<endl;
    }
    else{
        bool flag=false;
        REP(i,K){
            if(S[i]!='1'){
                cout<<S[i]<<endl;
                return;
            }
        }
        cout<<'1'<<endl;
    }
    return;
}

int main(){
    string S;
    cin>>S;
    long long K;
    scanf("%lld",&K);
    solve(S, K);
    return 0;
}


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

using namespace std;

#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define mk make_pair

typedef long long LL;
typedef pair<int,int> Interval;

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {
    _for(i,0,v.size()) os << v[i] << " ";
    return os;
}

template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){
    for(typename set<T>::iterator it = v.begin();it != v.end();it++)
    os << *it <<" ";
    return os;
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){
    os << v.first <<" "<<v.second<<endl;
    return os;
}

const int maxn = 1e5+5;
LL A[maxn];
LL B[maxn];
LL C[maxn];

vector<int> vi;
vector<int> ansA;
vector<int> ansB;
vector<int> ansC;

struct CmpAB{
    bool operator()(const int &a,const int &b){
        return (A[a]-B[a]) > (A[b] - B[b]);
    }
};
struct CmpAC{
    bool operator()(const int &a,const int &b){
        return (A[a]-C[a]) > (A[b] - C[b]);
    }
};

struct CmpBC{
    bool operator()(const int &a,const int &b){
        return (B[a]-C[a]) > (B[b] - C[b]);
    }
};

int X,Y,Z;
LL sum1[maxn];
LL sum2[maxn];

int main()
{
    cin >> X >> Y >> Z;
    int N = X+Y+Z;

    _rep(i,1,N){
        vi.push_back(i);
        scanf("%lld %lld %lld",&A[i],&B[i],&C[i]);
    }


    sort(ALL(vi),CmpAB());

    LL ans = 0;
    priority_queue<int,vector<int>,CmpAC> pq1;
    priority_queue<int,vector<int>,CmpBC> pq2;

    _for(i,0,X){
        pq1.push(vi[i]);
        ans += A[vi[i]];
    }

    sum1[0] = ans;

    _for(i,1,Z+1){
        int now = X - 1 + i;
        int nn = vi[now];
        int ch = pq1.top();
        sum1[i] = sum1[i-1];

        if(A[nn] - C[nn] > A[ch] - C[ch]){
            sum1[i] -= A[ch];
            sum1[i] += (A[nn]+C[ch]);
            pq1.pop();
            pq1.push(nn);
        }else sum1[i] += C[nn];

    }

    reverse(ALL(vi));

    ans = 0;

    _for(i,0,Y){
        pq2.push(vi[i]);
        ans += B[vi[i]];
    }
    sum2[0] = ans;
    //cout << ans << endl;

    _for(i,1,Z+1){
        int now = Y - 1 + i;
        int nn = vi[now];
        int tp = pq2.top();
        sum2[i] = sum2[i-1];

        if((B[nn] - C[nn]) > B[tp] - C[tp]){
            sum2[i] -= B[tp];
            sum2[i] += (B[nn]+C[tp]);
            pq2.pop();
            pq2.push(nn);
        }else sum2[i] += C[nn];
    }

    reverse(sum2,sum2+Z+1);

    ans = 0;
    _rep(i,0,Z){
        //cout << sum1[i] <<" "<<sum2[i]<<endl;
        ans = max(ans,sum1[i]+sum2[i]);
    }
    //cout << vi << endl;

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


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

    int n = 0, prev = 0;
    cin >> n;
    int ans = 0;
    for(int i = 0; i < n; i++){
        int x = 0;
        cin >> x;
        if( i > 0){
            if(x >= prev){
                ans++;
            }
        }
        prev = max(prev, x);
    }
    ans++;
    cout << ans << "\n";
   return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

int l[100005];

int main() {
  int n;
  scanf("%d", &n);
  for(int i = 0; i < n; i++) {
    scanf("%d", &l[i]);
  }
  ll r = 0;
  for(int i = 0; i < n; i++) {
    r += l[i]/2;
    l[i] %= 2;
    if(l[i] && l[i+1]) {
      l[i+1]--;
      r++;
    }
  }
  printf("%lld\n", r);
}


Measured memory_bytes: 640
#include<stdio.h>
#include<math.h>
int main(void){
	int a,b,c,k;
	scanf("%d %d %d %d",&a,&b,&c,&k);
	if(a<b){if(b<c){c*=pow(2,k);}else{b*=pow(2,k);}}
	else{if(a<c){c*=pow(2,k);}else{a*=pow(2,k);}}
	printf("%d",a+b+c);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

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

    vector<int> a(n);
    REP(i, n) cin >> a[i];

    vector<int> road;
    vector<int> count(n + 1, -1);
    int tail = 0;
    int loop = 1;

    int v = 1;
    while (count[v] == -1) {
        count[v] = road.size();
        road.push_back(v);
        v = a[v - 1];
    }
    tail = count[v];
    loop = road.size() - tail;

    if (k < tail) cout << road[k] << '\n';
    else {
        k -= tail;
        k %= loop;
        cout << road[tail + k] << '\n';
    }
    return 0;
}


Measured memory_bytes: 5800
N, x = map(int, input().split())
A = list(map(int, input().split()))
ans = 0

for i in range(1, N-1):
  v1 = max(A[i-1]+A[i]-x,0)
  v2 = max(A[i+1]+A[i]-x,0)
  if v1>0 and v2>0:
    m = min(v1, v2, A[i])
    A[i] -= m
    ans += m

for i in range(N-1):
  v = max(A[i]+A[i+1]-x, 0)
  m = min(v, A[i])
  A[i] -= m
  ans += m
  
for i in range(1,N):
  v = max(A[i-1]+A[i]-x, 0)
  m = min(v, A[i])
  A[i] -= m
  ans += m
  
print(ans)

Measured memory_bytes: 14812
#include <iostream>
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef pair<int,int> P;
int n,m,r,ch[100000],a,b,c;
map<int,int>mp[100000];
vector<P> v[100000];
priority_queue<P,vector<P>,greater<P>> pque;
int main(void){
    cin>>n>>m>>r;
    for(int i=0;i<m;i++){
        cin>>a>>b>>c;
        v[a].push_back({b,c});
        //v[b].push_back({a,c});
    }
    pque.push({1,r});
    while(pque.size()){
        P p=pque.top();
        pque.pop();
        if(ch[p.S]!=0)continue;
        ch[p.S]=p.F;
        for(P x:v[p.S]){
            if(ch[x.F]==0){
                pque.push({p.F+x.S,x.F});
            }
        }
    }
    for(int i=0;i<n;i++){
        if(ch[i]==0)cout<<"INF"<<endl;
        else{
            cout<<ch[i]-ch[r]<<endl;
        }
    }
}



Measured memory_bytes: 18776
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;

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

    bool ans = true;
    rep(i, 0, s.size())
    {
        if (s[i] == 'U' or s[i] == 'D')
            continue;
        if (i % 2 == 0)
            ans &= s[i] == 'R';
        else
            ans &= s[i] == 'L';
    }

    if (ans)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define P(x) {if (debug) cout << x << endl;}
#define H(x) P(#x << ": " << (x))
#define FR(i,a,b) for (int i=(a); i<(b); i++)
#define F(i,n) FR(i,0,n)
#define DR(i,a,b) for (int i=(b); i-->(a);)
#define D(i,n) DR(i,0,n)
#define S(s) (int)(s).size()
#define ALL(v) v.begin(), v.end()
#define MI(a,v) a = min(a,v)
#define MA(a,v) a = max(a,v)
#define V vector
#define pb push_back
#define mt make_tuple
using namespace std;
template<class T> ostream& operator<<(ostream& os, V<T> v) {
    F(i,S(v)) os<<(i?" ":"")<<v[i]; return os;}
const bool debug = 1;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin>>n;
    V<int> a(n), b;
    F(i,n) cin>>a[i];
    b = a;
    sort(ALL(b));
    F(i,n) {
        int k = lower_bound(ALL(b), a[i]) - b.begin();
        if (k < n/2)
            cout<<b[n/2]<<"\n";
        else
            cout<<b[n/2-1]<<"\n";
    }
}

Measured memory_bytes: 5376
# -*- coding: utf-8 -*-
# 整数の入力
nab = [int(s) for s in input().split()]

N = nab[0]
A = nab[1]
B = nab[2]

count = 0
for i in range(N):
  target = str(i+1)
  total = 0
  for j in range(len(target)):
    total = total + int(target[j])

  if total >= A and total <= B:
    count = count + int(target)

print(count)


Measured memory_bytes: 8848
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    double n,p,q,t,a,x,y,z,w,f,mn;
    string s;
    vector<ll>v;
    deque<ll>dq;
    cin>>n>>t>>a;
    for(ll i=0;i<n;i++)
    {
        cin>>q;
        v.push_back(q);
    }
    mn=67678465783468724598;
    for(ll i=0;i<n;i++)
    {
        x=v[i];
        p=t-(x*0.006);
        x=p-a;
        x=abs(x);
        if(x<mn)
        {
        mn=x; f=i;
        }
    }
   cout<<f+1<<endl;
}





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

#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define FOR(i,l,r) for(long long i=l; i<r; i++)
#define FOR_REV(i,r,l) for(long long i=r; i>=l; i--)
#define pb push_back
#define mp make_pair

#define MOD 1000000007

int main()
{
    FAST_IO;

    ll n,k;
    cin>>n>>k;

    ll ans = 0;
    
    FOR (i,k,n+2)
    {
        ans += (i)*(n+1-i) + 1;
        ans = ans%MOD;
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 3576
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <utility>

using namespace std;



int main() {
	pair<int, int> x;
	pair<int, int> y;
	cin >> x.first >> x.second >> y.first >> y.second;

	int a = max(x.first, y.first);
	int b = min(x.second, y.second);

	if (b - a < 0) {
		cout << 0 << endl;
	}
	else {
		cout << b - a << endl;
	}

	return 0;
}

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

int main(){
  int A, B; cin >> A >> B;
  A = (A+13)%15;
  B = (B+13)%15;
  if(A == B) cout << "Draw" << endl;
  else cout << (A > B?"Alice":"Bob") << endl;
}

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

namespace ITP1_7_D
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] size = Console.ReadLine().Split(' ');              
            int n = int.Parse(size[0]);
            int m = int.Parse(size[1]);
            int l = int.Parse(size[2]);
            long[,] vectorA = new long[n, m];
            long[,] vectorB = new long[m, l];
            long[,] vectorC = new long[n, l];
            
            MyVector.SetVector(n, m, vectorA);
            MyVector.SetVector(m, l, vectorB);

            for (int i = 0; i < n; i++)
                for (int j = 0; j < l; j++)
                    for (int k = 0; k < m; k++)
                        vectorC[i, j] += vectorA[i, k] * vectorB[k, j];
                                             
            MyVector.ShowVector(n, l, vectorC);
        }
    }
    class MyVector
    {
        static public void SetVector(int a,int b,long[,] data)
        {
            for (int i=0;i< a; i++)
            {
                int[] input = Console.ReadLine().Split(' ').Select(x => Convert.ToInt32(x)).ToArray();
                for (int j = 0; j < b; j++)
                    data[i, j] = input[j];                
            }
        }
        static public void ShowVector(int a,int b,long[,] data)
        {
            for (int i = 0; i < a; i++)
            {
                string s;
                for (int j = 0; j < b; j++)
                {
                    Console.Write(data[i, j]);
                    s = j == (b - 1) ? "\n" : " ";
                    Console.Write(s);
                }
            }
        }
    }
}

Measured memory_bytes: 10228
n = int(input())
data = list(map(lambda x:(float(x[0]),x[1]),[input().split() for i in range(n)]))
print(sum([i[0] for i in data if i[1] == 'JPY'])+sum([i[0] for i in data if i[1] == 'BTC'])*380000.0)

Measured memory_bytes: 3060