akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2

using namespace std;

int MOD = 1000000007;
int a,b;
signed main(){

    cin >> a >> b;
    
    a--;
    b--;
    cout << "100 100" << endl; 
    rep(i,50){
        rep(j,100){
            if(i%2 == 1)cout << "#";
            else if(j%2 == 0)cout << "#";
            else if(a > 0){
                cout << ".";
                a--;
            }else cout << "#";
        }cout << endl;
    }

    REP(i,50){
        REP(j,100){
            if(i%2 == 0)cout << ".";
            else if(j%2 == 0)cout << ".";
            else if(b > 0){
                cout << "#";
                b--;
            }else cout << ".";
        }cout << endl;
    }

    return 0;
}
// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl 

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define int long long
using namespace std;
inline int read(){
	int f=1,ans=0;char c;
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){ans=ans*10+c-'0';c=getchar();}
	return ans*f;
}
const int N=200011;
int cnt,d1[N],d2[N],d3[N],head[N],n,siz[N];
/*d1到叶子节点最长路径*/
/*d2为除掉一个子树的最长路径*/
/*d3为下界*/
struct node{
	int u,v,nex;
}x[N<<1];
void add(int u,int v){
	x[cnt].u=u,x[cnt].v=v,x[cnt].nex=head[u],head[u]=cnt++;
}
int son[N],sum;
char str[N];
void dfs1(int f,int fath){
	if(str[f]=='1') siz[f]=1,d3[f]=0,sum++;
	for(int i=head[f];i!=-1;i=x[i].nex){
		if(x[i].v==fath) continue;
		dfs1(x[i].v,f);
		if(d1[x[i].v]+1>=d1[f]) son[f]=x[i].v,d2[f]=d1[f],d1[f]=d1[x[i].v]+1;
		else if(d1[x[i].v]+1>=d2[f]) d2[f]=d1[x[i].v]+1;
		if(siz[x[i].v]) d3[f]=min(d3[f],d1[x[i].v]+1);
		siz[f]+=siz[x[i].v];
	}return; 
}
void dfs2(int f,int fath,int v){
	int nowv;
	for(int i=head[f];i!=-1;i=x[i].nex){
		
		if(x[i].v==fath) continue;
		
		if(son[f]==x[i].v) nowv=max(v,d2[f])+1;
		else nowv=max(v,d1[f])+1;
		
		if(nowv>=d1[x[i].v]) d2[x[i].v]=d1[x[i].v],d1[x[i].v]=nowv;
		else if(nowv>d2[x[i].v]) d2[x[i].v]=nowv;
		
		if(sum-siz[x[i].v]) d3[x[i].v]=min(d3[x[i].v],nowv);
		dfs2(x[i].v,f,nowv);
	}
}int ans;
signed main(){
//	freopen("make.in","r",stdin);
	memset(head,-1,sizeof(head));
	n=read();
	for(int i=1;i<n;i++){
		int u=read(),v=read();
		add(u,v),add(v,u);
	}
	scanf("%s",str+1);
	memset(d3,127,sizeof(d3));
	dfs1(1,0);

	dfs2(1,0,0);
//	for(int i=1;i<=n;i++) printf("d1(%d):%d d2(%d):%d d3(%d):%d\n",i,d1[i],i,d2[i],i,d3[i]);
	for(int i=1;i<=n;i++){
		if(str[i]=='1') ans+=max(min(d1[i],d2[i]+2),0LL);
		else ans+=max(min(d1[i],d2[i]+2)-d3[i],0LL);
	}printf("%lld\n",ans+1);
}


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

int main() {
	// your code goes here
	int n;
	cin>>n;
	int a[n],b[n],c[n];
	
	for(int i=0;i<n;i++)
	cin>>a[i]>>b[i]>>c[i];
	
	int dp[n][3];
	dp[0][0]=a[0];
	dp[0][1]=b[0];
	dp[0][2]=c[0];
	
	for(int i=1;i<n;i++)
	{
		dp[i][0]= max(dp[i-1][1]+a[i],dp[i-1][2]+a[i]);
		dp[i][1]= max(dp[i-1][0]+b[i],dp[i-1][2]+b[i]);
		dp[i][2]= max(dp[i-1][1]+c[i],dp[i-1][0]+c[i]);
	}
	
	cout<<max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]);
	return 0;
}

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

int get_min(int A[], int n){
    int temp = A[0];
    rep(i, n){
        if(temp > A[i])temp = A[i];
    }
    return temp;
}

int main(){
    int a, b, m;
    int A[P], B[P];
    int X[P], Y[P], C[P];

    cin >> a >> b >> m;
    rep(i, a)cin >> A[i];
    rep(i, b)cin >> B[i];
    rep(i, m)cin >> X[i] >> Y[i] >>C[i];

    //int* A_min = min_element(A, A+P);
    //int* B_min = min_element(B, B+P);
    int A_min = get_min(A, a);
    int B_min = get_min(B, b);
    int min_choice = A_min + B_min;

    //cout << "debug  " << min_choice << endl;

    int temp;
    rep(i, m){
        temp = A[X[i] - 1] + B[Y[i] - 1] - C[i];
        if(temp < min_choice)min_choice = temp;
    }
    cout << min_choice << endl;

    return 0;
}

/*
最小値 + 最小値 : *A_min + *B_min
割引の組
*/

Measured memory_bytes: 2176
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;

int H[100005], n,k;
int dp[100005];

int abs( int x ){
	if ( x < 0 ) return -x;
	return x;
}

int f( int pos ){
	if ( pos == n ) return 0;
	int &ans = dp[pos];
	if ( ans != -1 ) return ans;
	ans = 1e9;
	for ( int i = 1; i <= k && i +pos <= n; i++ ){
		ans = min( ans, f(pos+i) + abs(H[pos] - H[pos+i]));
	}
	return ans;
}

int main(){

	memset(dp,-1,sizeof(dp));
	scanf("%d%d",&n,&k);
	for ( int i = 1; i <= n; i++ ){
		scanf("%d",&H[i]);
	}

	printf("%d\n",f(1));
	return 0;
}

Measured memory_bytes: 8752
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {
	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		ArrayList<Integer> result = new ArrayList<Integer>();
		
		try{
			while(true){
				char[] romanValue = br.readLine().toCharArray();
				result.add(parseInt(romanValue));
			}
		}catch(Exception e){
			//何もしないで出力処理に移る
		}
		
		for(int n : result){
			System.out.println(n);
		}
	}
	
	public static int parseInt(char romanValue){
		int value = 0;
		switch(romanValue){
		case 'I':
			value = 1;
			break;
		case 'V':
			value = 5;
			break;
		case 'X':
			value = 10;
			break;
		case 'L':
			value = 50;
			break;
		case 'C':
			value = 100;
			break;
		case 'D':
			value = 500;
			break;
		case 'M':
			value = 1000;
			break;
		}
		return value;
	}
	
	private static int[] getNumbers(char[] romanValue){
		int[] numbers = new int[romanValue.length];
		for(int i = 0; i < numbers.length; i++){
			numbers[i] = parseInt(romanValue[i]);
		}
		
		//大きい数字の前にある小さな数は負数
		if(numbers.length > 1){
			for(int i = 1; i < numbers.length; i++){
				if(numbers[i] > numbers[i - 1]){
					numbers[i - 1] *= -1;
				}
			}
		}
		
		return numbers;
	}
	
	public static int parseInt(char[] romanValue){
		int value = 0;
		int[] numbers = getNumbers(romanValue); 
		for(int i = 0; i < numbers.length; i++){
			value += numbers[i];
		}
		return value;
	}
	
}

Measured memory_bytes: 9364
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,a) for(int i=0;i<(a);++i)
#define MP make_pair
#define INF 1e9
#define F first
#define S second
#define MAX_N 100000
using namespace std;
typedef long long LL;
typedef pair<LL, int> P;
int N, C;
int in[MAX_N][3];
vector<LL> BIT, pt;
vector<vector<LL> > pts;
vector< vector<LL>::iterator > ite;
vector<P> cond; // condition
int sum(int i)
{
	int s = 0;
	while(i > 0)
	{
		s += BIT[i];
		i -= i & -i;
	}
	return s;
}
void add(int i, int x)
{
	while(i < BIT.size())
	{
		BIT[i] += x;
		i += i & -i;
	}
}
bool comp(const P& a, const P& b){
		return a.first == b.first ? a.second > b.second : a.first < b.first;
}
int main()
{
	cin >> N >> C;
	pt.resize(N);
	pts.resize(N);
	ite.resize(N);
	REP(i, N)
	{
		cond.push_back(MP(0, i));
	}
	REP(i, C)
	{
		cin >> in[i][0];
		if(!in[i][0])
		{
			cin >> in[i][1] >> in[i][2];
			--in[i][1];
			pt[in[i][1]] += in[i][2];
			cond.push_back(MP(pt[in[i][1]], in[i][1]));
		}
		else
		{
			cin >> in[i][1];
		}
	}
	sort(cond.begin(), cond.end(), comp);
	REP(i, cond.size())
	{
		pts[cond[i].S].push_back(i);
	}
	REP(i, N)
	{
		ite[i] = pts[i].begin();
	}
	BIT.resize(cond.size() + 1);
	FOR(i, 1, N + 1)
	{
		add(i, 1);
	}
	
	REP(i, C)
	{
		if(!in[i][0])
		{
			add(*ite[in[i][1]] + 1, -1);
			++ite[in[i][1]];
			add(*ite[in[i][1]] + 1, 1);
	
		}
		else
		{
			int s = 1, e = cond.size(), mid;
			while(s < e)
			{
				mid = (s + e) / 2;
				sum(mid) < N - in[i][1] + 1 ? s = mid + 1 : e = mid; 
			}
			cout << cond[s - 1].S + 1 << " " << cond[s - 1].F << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 15736
#include <iostream>
#include <cstdio>
#include <map>
#include <vector>
#include <cstring>
#include <algorithm>
#include <list>
#include <stack>
#include <queue>
using namespace std;
 
typedef list<int> L;
typedef pair <int,int> P;
typedef vector<int> V;
typedef queue<P> Q;
typedef stack<int> S;
typedef map<string,int> M;
 
const int MAX = 100;
const int INF = -1;
 
int h, w, d[MAX][MAX];
char f[MAX][MAX];
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
 
int bfs () {
    int res = 0;
    memset(d, INF, sizeof(d));
 
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (d[i][j] == INF) {
                Q q;
                q.push(P(i,j));
 
                d[i][j] = res;
 
                while (q.size()) {
                    P p = q.front(); q.pop();
                    for (int k = 0; k < 4; k++) {
                        int nx = p.first + dx[k], ny = p.second + dy[k];
                        if (0 <= nx && nx < h && 0 <= ny && ny < w && d[nx][ny] == INF && f[p.first][p.second] == f[nx][ny]) {
                            d[nx][ny] = res;
                            q.push(P(nx,ny));
                        }
                    }
                }
 
                res++;
            }
        }
    }
 
    return res;
}
 
int main()
{
    while (cin >> h >> w, h) {
        for (int i = 0; i < h; i++)
            cin >> f[i];
        cout << bfs() << endl;
    }
 
    return 0;
}

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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define ANS(ans) cout << (ans) << endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

// repetition
//------------------------------------------
#define FOR(i, a, b) for (ll i = (a); i <= (b); ++i)
#define REP(i, n) for (long long i = 0; i < (n); ++i)

template <int MOD>
struct Fp {
  long long val;
  constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
    if (val < 0) val += MOD;
  }
  constexpr int getmod() {
    return MOD;
  }
  constexpr Fp operator-() const noexcept {
    return val ? MOD - val : 0;
  }
  constexpr Fp operator+(const Fp &r) const noexcept {
    return Fp(*this) += r;
  }
  constexpr Fp operator-(const Fp &r) const noexcept {
    return Fp(*this) -= r;
  }
  constexpr Fp operator*(const Fp &r) const noexcept {
    return Fp(*this) *= r;
  }
  constexpr Fp operator/(const Fp &r) const noexcept {
    return Fp(*this) /= r;
  }
  constexpr Fp &operator+=(const Fp &r) noexcept {
    val += r.val;
    if (val >= MOD) val -= MOD;
    return *this;
  }
  constexpr Fp &operator-=(const Fp &r) noexcept {
    val -= r.val;
    if (val < 0) val += MOD;
    return *this;
  }
  constexpr Fp &operator*=(const Fp &r) noexcept {
    val = val * r.val % MOD;
    return *this;
  }
  constexpr Fp &operator/=(const Fp &r) noexcept {
    long long a = r.val, b = MOD, u = 1, v = 0;
    while (b) {
      long long t = a / b;
      a -= t * b;
      swap(a, b);
      u -= t * v;
      swap(u, v);
    }
    val = val * u % MOD;
    if (val < 0) val += MOD;
    return *this;
  }
  constexpr bool operator==(const Fp &r) const noexcept {
    return this->val == r.val;
  }
  constexpr bool operator!=(const Fp &r) const noexcept {
    return this->val != r.val;
  }
  friend constexpr ostream &operator<<(ostream &os, const Fp<MOD> &x) noexcept {
    return os << x.val;
  }
  friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
    if (n == 0) return 1;
    auto t = modpow(a, n / 2);
    t = t * t;
    if (n & 1) t = t * a;
    return t;
  }
};

const int MOD = 1000000007;
using mint = Fp<MOD>;

int main() {
  ll n, k;

  cin >> n >> k;

  mint ans = 0;

  FOR(i, k, n + 1) {
    ll m = i * (i - 1) / 2;
    ll M = (n - i + 1 + n) * i / 2;
    ans += M - m + 1;
  }

  ANS(ans);

  return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define ff first
#define ar array
#define ss second
#define ll long long int
#define mem(x) memset(x,0,sizeof(x))
#define setbits(x)  __builtin_popcount(x)
#define ull unsigned long long int
#define all(c) (c).begin(),(c).end()
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define db double
#define endl "\n"
#define  fbo(x) find_by_order(x)
#define  ook(x) order_of_key(x)
 
using namespace __gnu_pbds;
using namespace std;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair<ll,ll > iil;
typedef pair<ll,int> li;
typedef pair<int,int> ii;
typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    os1;
typedef tree<int, null_type, greater<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    os2;

inline void fast()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
const ll pi=31;
const ll MOD[2] = {1187278649, 1149736019};//for double hashing
const ll mod=(ll)(1e9)+7;
ll pmod(ll x,ll n){
  ll r=1;
  while(n>0)
  {
    if(n&1LL)
      r=(r*x)%mod;
    x=(x*x)%mod;
    n=n/2;
    n%=mod;
  }
  return r;
}
ll pMod(ll x,ll n,ll mod)
{ ll r=1;
  while(n>0)
  {
    if(n&1LL)
      r=(r*x)%mod;
    x=(x*x)%mod;
    n=n/2;
    n%=mod;
  }
  return r;
 
}
 
//think recursively also;
const int mxn=1e5;
ll a[mxn+1];
ll dp[mxn+1];
ll n;
void solve()
{ 
  cin>>n;
  for(int i=1;i<=n;i++)
  {
    cin>>a[i];
  }
  
  for(int i=1;i<=n;i++)
  {
      if(i-1>0)
        dp[i]=dp[i-1]+abs(a[i]-a[i-1]);
      if(i-2>0)
        dp[i]=min(dp[i],dp[i-2]+abs(a[i]-a[i-2]));
  }
  cout<<dp[n]<<endl;
  
}
int main()
{
  fast();
   // int t;
   // cin>>t;
   // for(int casee=1;casee<=t;casee++)
  {//cout<<"Case #"<<casee<<": ";
    solve();
  }
 
 
 
}

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

int main(){
  string name;
  cin >> name;
  vector<string> nick(50);
  for(int i=0;i<3;i++){
  	nick.at(i) = name.at(i);
  }
  for(int i=0;i<nick.size();i++){
  cout << nick.at(i);
  }
   cout << endl;
}

Measured memory_bytes: 3628
#include <vector>
#include <iostream>
using namespace std;
#define ll long long
vector<int> adj[100001];
ll ans[100001][2];
ll MOD = 1000000007;
void dfs(int i,int par){
    ll prodW = 1;
    ll prodTot = 1;
    for(int next : adj[i]){
        if(next!=par){
            dfs(next,i);
            prodW*=ans[next][0];
            prodTot*=(ans[next][0]+ans[next][1]);
            prodW%=MOD;
            prodTot%=MOD;
        }
    }
    ans[i][1] = prodW;
    ans[i][0] = prodTot;
}
int main(){
    int n;
    cin >> n;
    for(int i=0;i<n-1;i++){
        int x,y;
        cin >> x >> y;
        x--; y--;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    dfs(0,-1);
    ll ret = ans[0][0]+ans[0][1];
    ret%=MOD;
    cout << ret << endl;

}


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

class Program {
    static void Main(string[] args) {
        int n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var s = new int[a.Max() + 2];
        foreach (int i in a) {
            if (i != 0) s[i - 1]++;
            s[i]++;
            s[i + 1]++;
        }
        Console.WriteLine(s.Max());
    }
}

Measured memory_bytes: 20576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPR(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(x) ll(x.size()) 
using P = pair<int, int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 2e9;
const ll LINF = (1LL<<60);

ll floor_sum(ll n, ll m, ll a, ll b) {
  ll ans = 0;
  if (a >= m) {
    ans += (n - 1) * n * (a / m) / 2;
    a %= m;
  }
  if (b >= m) {
    ans += n * (b / m);
    b %= m;
  }

  ll y_max = (a * n + b) / m, x_max = (y_max * m - b);
  if (y_max == 0) return ans;
  ans += (n - (x_max + a - 1) / a) * y_max;
  ans += floor_sum(y_max, a, m, (a - x_max % a) % a);
  return ans;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int t; cin >> t;
  while(t--){
    ll n,m,a,b;
    cin >> n >> m >> a >> b;
    cout << floor_sum(n,m,a,b) << '\n';
  }

  return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<int,int> P;
#define fi first
#define se second
#define all(v) (v).begin(),v.end()
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
int main(){
    int n;cin>>n;
    vector<P> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i].fi;
        a[i].se=i;
        }
        sort(all(a));
        int cnt=0;
    for(int i=0;i<n;i++){
        if(a[i].se%2!=i%2)cnt++;
    }
    cout<<cnt/2<<endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
int i,j;
int count=0;


void Process(int A[ ], int n){
	for(i=0;i<n-1;i++)
		printf("%d ",A[i]);
	printf("%d\n",A[i]);
}


void BubbleSort(int A[ ], int n){
	int j,temp;
		for(i = 0; i < n-1; i++){
			for(j = n-1; j > i; j--)
			if(A[j-1] > A[j]){
				temp = A[j-1];
				A[j-1] = A[j];
				A[j] = temp;
				count++;
			}		
	}
}


int main(void){
	int N;
	scanf("%d",&N);
	int A[100];
	for(i=0;i<N;i++)
		scanf("%d",&A[i]);
	
	BubbleSort(A, N);
	Process(A, N);

	printf("%d\n",count);
	
	return 0;
}

Measured memory_bytes: 1828
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e10;
int main(){
    ll n, k; cin >> n >> k;
    vector<ll> a(n);
    for(ll i=0; i<n; ++i){
        cin >> a[i];
    }
    ll r = INF, l = 0;
    ll res = 0;
    for(ll j=0; j<100; ++j){
        if(r-l<=1){break;}
        ll mid = (r+l)/2;
        
        ll sum = 0;
        for(ll i=0; i<n; ++i){
            sum += (a[i]-1)/mid;
        }
        
        if(sum>k){l = mid;}
        else{r = mid;}
    
    }
    
    cout << r << endl;
    return 0;
}

Measured memory_bytes: 4768
#include <stdio.h>
int main(void){
    int i,n;
    long long int l1=2;
    long long int l2=1;
    long long int x;
    scanf("%d\n",&n);
    switch (n){
	case 0:
	    printf("%d\n",2);
	    break;
	case 1:
	    printf("%d\n",1);
	    break;
	default:
	    for (i=0;i<n-1;i++){
		x=l1+l2;
		l1=l2;
		l2=x;
	    }
	    printf("%lld\n",x);
	    break;
	}

    return 0;
    }



Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////


int main() {
	ll N, H, W;
	cin >> N >> H >> W;
	
	ll ans = 0;

	repn(i, N) {
		ll a, b;
		cin >> a >> b;

		if (a >= H && b >= W) { ans++; }
	}

	cout << ans;
	

	system("PAUSE");
}


Measured memory_bytes: 504
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
string S;
  cin >>S;
  S.at(3)='8';
  cout << S<< endl;
}
  

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as BS
import qualified Data.Vector.Unboxed as VU
import Control.Monad
import Data.Array.Unboxed
import Data.Array.ST

solve :: Int -> VU.Vector Double -> UArray (Int,Int) Double
solve n ps =
  runSTUArray $ do
    dp <- newArray ((0,0),(n,n)) (0.0 :: Double)
    writeArray dp (0,0) 1.0
    forM_ [0..n-1] $ \i -> 
      forM_ [i..n-1] $ \j -> do
        rd1 <- readArray dp (i,j)
        rd2 <- readArray dp (i+1,j+1)
        rd3 <- readArray dp (i,j+1)
        
        writeArray dp (i+1,j+1) $ rd2 + rd1 * (ps VU.! j)
        writeArray dp (i,j+1) $ rd3 + rd1 * (1.0 - (ps VU.! j))
    return dp

main = do
  n <- readLn :: IO Int
  ps <- VU.fromList . map (read . BS.unpack) . BS.words <$> BS.getLine :: IO (VU.Vector Double)
  let dp = solve n ps
  print $ sum [e | ((iy,ix),e) <- assocs dp, iy >= (n `quot` 2)+1, ix == n]

Measured memory_bytes: 71676
#include<iostream>
using namespace std;
typedef long long ll;
int main(){
	ll k;
	cin >> k;
	if(k==0){
		cout << 2 << endl;
		cout << 1 << " " << 1 << endl;
		return 0;
	}
	ll a=50+(k-1)/50;
	ll bl=(k-1)%50;
	int b=(int)bl;
	cout << "50" << endl;
	ll ng=a-b;
	for(int i=0;i<50;i++){
		if(i!=0) cout << " ";
		cout << a-i-(b<i?1:0);
	}
	cout << endl;
	return 0;
}


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

using namespace std;

const int N = 1e5;

int n, m;
struct data {
        int p;
        int y;
        int idx;
        int x;
}d[N+5];

bool cmp(const data &a, const data &b)
{
        if (a.p == b.p)
                return a.y < b.y;
        return a.p < b.p;
}

bool cmp2(const data &a, const data &b)
{
        return a.idx < b.idx;
}

int main()
{
        std::ios::sync_with_stdio(false);
        while ( cin >> n >> m )
        {
                for (int i = 0; i < m; i++)
                {
                        cin >> d[i].p >> d[i].y;
                        d[i].idx = i;
                }

                sort(d, d+m, cmp);

                int xx = 2;
                d[0].x = 1;
                for (int i = 1; i < m; i++)
                {
                        if (d[i].p != d[i-1].p)
                        {
                                d[i].x = xx = 1;
                                xx++;
                        }
                        else
                        {
                                d[i].x = xx++;
                        }
                }

                sort(d, d+m, cmp2);

                for (int i = 0; i < m; i++)
                {
                        printf("%06d%06d\n", d[i].p, d[i].x);
                }
        }
        return 0;
}

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

using namespace std;

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define vpi vector<pi >
#define pi pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define all(n) n.begin(), n.end()

#define FROMTO(var, from, to) for (register int var = (from), var##down = ((int)(to)) < ((int)(from));var##down ? (var >= (int)(to)) : (var <= (int)(to));var##down ? var-- : var++)
#define UPTO(var, from, to)   for (register int var = (from); var <= ((int)to); var++)
#define DOWNTO(var, from, to) for (register int var = (from); var >= ((int)to); var--)
#define FOR(var, to)          UPTO(var, 0, (to)-1)
#define DOWN(var, from)       DOWNTO(var, (from)-1, 0)

#define INIT(var, val) FOR(i,countof(var)) var[i] = val
#define INPUT(var) FOR(i,countof(var)) cin >> var[i]
#define INPUT1(var) FOR(i,countof(var)) cin >> var[i], var[i]--

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)
#define QSORT(v,b) qsort(v,countof(v),sizeof(*v),b)

#define MOD 1000000007
#define INF ((1 << 30)-1)
#define LINF ((1LL << 62)-1)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

struct Comb {
    vector<vector<s64> > data;
    Comb(int n) { // O(n^2)
        data = vector<vector<s64> >(n+1,vector<s64>(n+1,1));
        UPTO(i,1,n) {
            FOR(j,i+1) {
                if (!j || j == i) data[i][j] = 1;
                else data[i][j] = data[i-1][j-1] + data[i-1][j];
            }
        }
    }

    s64 ncr(int n, int r) {
        return data[n][r];
    }
};

static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}

int int_less(const void *a, const void *b) {
  return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
  return (*((const int*)b) - *((const int*)a));
}

int main() {
    int n = ri();
	int a = ri();
	int b = ri();
	cout << min(a,b) << " " << max(0,a+b-n) << endl;
    return 0;
}


Measured memory_bytes: 384
import sys

def main():
    tmp = input()
    k = input().replace('\n','').split()
    k = [int(k) for k in k]
    if len(k) != len(set(k)):
        print('NO')
    else:
        print('YES')
if __name__ == '__main__':
    input = sys.stdin.readline
    main()


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

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> q;
  int num;
  rep(i,n){
    cin >> num;
    q.push_back(num);
  }
  sort(q.begin(),q.end());
  int res=0;
  for(int i=0;i<k;i++) res+=q[i];
  cout << res;
  return 0;
}

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

int main() {
    int n;
    cin >> n;
    int a[100];
    rep(i, n) cin >> a[i];
    sort(a, a + n);
    cout << (a[n - 1] - a[0]) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int n,m,i,j;
	char a[200][200];
	cin>>n>>m;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
		{
			cin>>a[i][j];
		}
	}
	for(i=1;i<=2*n;i++)
	{
		for(j=1;j<=m;j++)
		{
			cout<<a[(i+1)/2][j];
		}
		cout<<endl;
	}
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define loop(i,a,b)        for(int i=a;i<b;i++)
int mx=0;
vector<int>ad[200005];
bool vis[200005];
int dfs(int u){
	int ans=0;
	if(!vis[u]){
		vis[u]=true;
		ans++;
		for(auto v:ad[u])ans+=dfs(v);
	}
    return ans;

}
int main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output1.txt","w",stdout);
	#endif
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int n,m,x,y;
	cin>>n>>m;
	memset(vis,false,sizeof(vis));
	loop(i,0,m){
		cin>>x>>y;
		x-=1;
		y-=1;
	    ad[x].push_back(y);
	    ad[y].push_back(x);
	}
	for(int i=0;i<n;i++){
		if(!vis[i])mx=max(mx,dfs(i));
	}
    cout<<mx<<endl;
 
}

Measured memory_bytes: 21036
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,sum,pos,k,cntt,be[405][405],af[405][405];
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz");
char s[405][405];
struct edge{int to,cost;};
bool alvi[405][405];
bool vi[405][405];

//-------------------------↓↓↓↓↓↓------------------------

void dfs(ll y,ll x,int fl){
    if(alvi[y][x])return;
    d=0;
    rep(i,4){
        ll nx=x+dx[i],ny=y+dy[i];
        if(nx>=0&&nx<w&&ny>=0&&ny<h){
            if(fl==1){
                if(s[ny][nx]=='.'){
                    d=1;
                    break;
                }
            }
            else{
                if(s[ny][nx]=='#'){
                    d=1;
                    break;
                }
            }
        }
    }
    if(!d)return;
    if(s[y][x]=='#')cnt++,alvi[y][x]=true;
    else cntt++,alvi[y][x]=true;
    af[y][x]++;
    rep(i,4){
        ll nx=x+dx[i],ny=y+dy[i];
        if(nx>=0&&nx<w&&ny>=0&&ny<h){
            if(fl==1){
                if(s[ny][nx]=='.'){
                    //if(c)cout<<y<<" "<<x<<" "<<ny<<" "<<nx<<"\n";
                    dfs(ny,nx,0);
                }
            }
            else{
                if(s[ny][nx]=='#'){
                    //if(c)cout<<y<<" "<<x<<" "<<ny<<" "<<nx<<"\n";
                    dfs(ny,nx,1);
                }
            }
        }
    }
}

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

    cin>>h>>w;
    rep(i,h){
        rep(j,w){
            cin>>s[i][j];
        }
    }
    rep(i,h){
        rep(j,w){
            cnt=0;
            cntt=0;
            if(s[i][j]=='#'&&!alvi[i][j]){
                dfs(i,j,1);
                ans+=cnt*cntt;
            }
        }
    }
    Cout(ans);
    return 0;
}


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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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


// 最大公約数
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  ll N; cin >> N;
  vector<ll> ans(N+1, 0);

  ll lmax = sqrt(N);
  rep1(x, lmax) {
    rep1(y, lmax) {
      rep1(z, lmax) {
	ll v = x*x+y*y+z*z+x*y+y*z+z*x;
	if(v <= N) ans[v] ++;
      }
    }
  }
  rep1(i, N) {
    cout << ans[i] << endl;
  }

}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace __gnu_pbds;
using namespace std;
/*
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
*/
#define ull unsigned long long int
#define ll long long int
#define MAX 1000000007
//1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>
#define piii pair<int,pii>
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FO ifstream fin("a.in");ofstream fout("a.out");
#define TEST int testcase;cin>>testcase;while(testcase--)
#define all(x) (x).begin(),(x).end()
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
#define endl "\n"
#define plll pair<ll,pll>
#define no {cout<<"NO"<<endl;return;}
#define yes {cout<<"YES"<<endl;}
typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const int maxn=1000000;


void solve(){

    int n,x,t;
    cin>>n>>x>>t;
    int cnt=0,T=0;
    while(cnt<n){
        cnt+=x;
        T+=t;
    }
    cout<<T;
}

int main(){
    IO

    //TEST
    solve();

    return(0);
}



Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int n,h[100005],f[100005];
	cin >> n;
	for (int i=1;i<=n;i++)
		cin >> h[i];
	f[1]=0,f[0]=0,h[0]=0;
	for (int i=1;i<n;i++)
		f[i+1]=min(i==1?10000000:(f[i-1]+abs(h[i+1]-h[i-1])),f[i]+abs(h[i]-h[i+1]));
	cout << f[n];
	return 0;
}

Measured memory_bytes: 4376
#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;

const int N = 200;
int n, m;
int odd;
int a[N];
int b[N];

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++)
	{
		scanf("%d", &a[i]);
		if (a[i] & 1) odd++;
	}
	if (odd > 2)
	{
		printf("Impossible\n");
		return 0;
	}
	if (odd == 0)
	{
		int k = 0;
		if (a[0] != 2)
			b[k++] = a[0] - 2;
		b[k++] = 1;
		for (int i = 1; i < m; i++)
			b[k++] = a[i];
		b[k++] = 1;
		for (int i = 0; i < m; i++)
			printf("%d ", a[i]);
		printf("\n");
		printf("%d\n", k);
		for (int i = 0; i < k; i++)
			printf("%d ", b[i]);
		printf("\n");
		return 0;
	}
	if (odd == 1)
	{
		for (int i = 0; i < m; i++)
			if (a[i] & 1)
			{
				swap(a[0], a[i]);
				break;
			}
		int k = 0;
		if (a[0] != 1)
			b[k++] = a[0] - 1;
		for (int i = 1; i < m; i++)
			b[k++] = a[i];
		b[k++] = 1;
		for (int i = 0; i < m; i++)
			printf("%d ", a[i]);
		printf("\n");
		printf("%d\n", k);
		for (int i = 0; i < k; i++)
			printf("%d ", b[i]);
		printf("\n");
		return 0;
	}
	if (odd == 2)
	{
		for (int i = 0; i < m; i++)
			if (a[i] & 1)
			{
				swap(a[0], a[i]);
				break;
			}
		for (int i = m - 1; i > 0; i--)
			if (a[i] & 1)
			{
				swap(a[m - 1], a[i]);
				break;
			}
		int k = 0;
		if (a[0] != 1)
			b[k++] = a[0] - 1;
		for (int i = 1; i < m; i++)
			b[k++] = a[i];
		b[k - 1]++;
		for (int i = 0; i < m; i++)
			printf("%d ", a[i]);
		printf("\n");
		printf("%d\n", k);
		for (int i = 0; i < k; i++)
			printf("%d ", b[i]);
		printf("\n");
		return 0;
	}
	throw;

	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException, NumberFormatException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine().trim());
        int[][] arr = new int[n][3];
        String[] s;
        for(int i=0 ; i <n ; i++)
        {
            s = br.readLine().trim().split("\\s+");
            for(int j=0 ; j<3 ; j++)
                arr[i][j] = Integer.parseInt(s[j]);
        }

        int[][] dp = new int[n][3];
        for(int i=0 ; i<3 ; i++)
            dp[0][i] = arr[0][i];

        for(int i=1 ; i<n ; i++)
        {
            for(int j=0 ; j<3 ; j++)
            {
                int x = (j+1) % 3;
                int y = (j+2) % 3;

                dp[i][j] = arr[i][j] + Math.max(dp[i-1][x], dp[i-1][y]);
            }
        }

        int ans = Math.max(dp[n-1][0], Math.max(dp[n-1][1], dp[n-1][2]));

        System.out.println(ans);
    }
}


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

class disless{
public:
  bool operator()(const pair<int,pair<int,int> >& disleft,const pair<int,pair<int,int> >& disright) const{
    if(disleft.first == disright.first) return disleft.second.first < disright.second.first;
    return disleft.first < disright.first;
  }
};

int main(){
  vector <pair<int,pair<int,int> > > data;
  for(int i=1;i<=150;i++){
    for(int j=i+1;j<=150;j++) data.push_back(make_pair(i*i+j*j,make_pair(i,j)));
  }
  sort(data.begin(),data.end(),disless());
  int h,w,dis;
  while(cin >> h >> w,w||h){
    dis = h*h+w*w;
    for(int i=0;i<data.size();i++){
      if(data[i].second.first == h && data[i].second.second == w){
	cout << data[i+1].second.first << " " << data[i+1].second.second << endl;
	break;
      }
    }
  }
}

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

int main() {
int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int hSum = h2-h1;
  int mSum = m2-m1;
  int total = hSum*60+mSum-k;
  cout << total << endl;
    
}


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

int main() {
  //input K,X
  int K, X, min;
  cin >> K >> X;
  //find min
  min = X - K + 1;
  int N = 2 * K -1;
  for (int i=0; i< N; min++){
    cout << min;
    if (i<(N-1)){
      cout << " ";    
    }
    i++;
  }
}


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

using namespace std;
using ll = long long;

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

  string n;
  cin >> n;
  ll sum = 0;
  for (auto c : n) {
    sum += (c - '0');
  }
  cout << (sum % 9 == 0 ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 3760
#include <iostream>
#include <queue>
#include <algorithm>

using namespace std;

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

  deque<int> deq;
  int N; cin >> N;

  while(N--){
    string cmd; cin >> cmd;
    if(cmd == "insert"){
      int x; cin >> x;
      deq.push_front(x);
    }
    else if(cmd == "delete"){
      int x; cin >> x;
      auto it = find(deq.begin(), deq.end(), x);
      if(it != deq.end())
	deq.erase(it);
    }
    if(cmd == "deleteFirst")
      deq.pop_front();
    if(cmd == "deleteLast")
      deq.pop_back();
  }

  if(!deq.empty()){
    cout << deq.front();
    for(auto it=deq.begin()+1;it!=deq.end();++it)
      cout << " " << *it;
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 5308
import sys


def input():
    return sys.stdin.readline().strip()


def main():
    N, K = map(int, input().split())
    answer = 0
    for b in range(1, N + 1):
        p = N // b
        q = N % b
        answer += p * max(0, b - K)
        answer += max(0, q - K + 1)
    if K == 0:
        answer -= N
    print(answer)


if __name__ == "__main__":
    main()


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

int main()
{
    int n, x, cnt = 0;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> x;
        if (i&1 && x&1) cnt++;
    }
    cout << cnt;
}

Measured memory_bytes: 3508
import numpy as np
N, W = map(int, input().rstrip().split(' '))
weight_array = np.zeros(W+1)

for _ in range(N):
  w, v = map(int, input().rstrip().split(' '))
  weight_array[w:] = np.maximum(weight_array[:-w]+v, weight_array[w:])
print(int(weight_array[-1]))

Measured memory_bytes: 29580
import java.io.*;
class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int l = Integer.parseInt(br.readLine());
        double thirds = l/3.0;
        double res = thirds*thirds*thirds;
        System.out.println(res);
    }
}


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


int main(){
 
  int A,B,C,K;
  
  cin >> A >> B>> C>> K;
  
  if(A>=K){
    cout << K << endl;
  }else if(A+B>=K){
    cout << A << endl;
  }else{
    cout << A-(K-A-B) << endl;
  }
  
}

Measured memory_bytes: 3636
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    REP(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    REP(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

int main()
{
    ll N, A, B;
    cin >> N;
    cin >> A;
    cin >> B;
    ll s = N / (A + B);
    ll c = N % (A + B);
    ll ans = s * A + min(c, A);

    cout << ans << endl;
}


Measured memory_bytes: 256
/* Ajay Jadhav */
#include <bits/stdc++.h>
 
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
const int N=3005;
int n;
double a[N];
double dp[N+5][N+5];

double f(int i, int x)
{
	if (x == 0)
		return 1;
	if (i == 0)
		return 0;
	if (dp[i][x] >= -0.9)
		return dp[i][x];
 
	return dp[i][x] = a[i]*f(i-1,x-1)+(1-a[i])*f(i-1,x);
}

void solve()
{
    cin>>n;
    memset(dp, -1, sizeof dp);
    rep(i,1,n+1) cin>>a[i];
    cout<<fixed<<setprecision(10)<<f(n,(n+1)/2);
}
 
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 71296
def test():
    inp = [1, 1]
    while True:
        inp = list(map(int, input().split()))
        if inp[0] == 0 and inp[1] == 0:
            break
        inp.sort()
        print(f'{inp[0]} {inp[1]}')
 

if __name__ == '__main__':
    test()


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }

int n;
int h[505][505];
bool rm[505][505];

template<class T>
struct Q {
	int h = 0, t = 0;
	T q[250005];
	void reset() { h = t = 0; }
	int size() { return t - h; }
	T front() { // assert(h < t);
		return q[h]; }
	bool empty() { return size() == 0; }
	void pop() { h++; }
	void push(T x) { q[t++] = x; }
};

queue<pii> qq;
const int dir[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	read(n);
	
	// calculate initial cost
	rep(i, 1, n + 1) rep(j, 1, n + 1) {
		h[i][j] = min(
				min(i - 1, n - i),
				min(j - 1, n - j));
	}

	ll ans = 0;
	rep(i, 0, n * n) {
		int t; cin >> t; --t;
		//qq.reset();
		int p = t / n + 1, q = t % n + 1;
		ans += h[p][q];
		rm[p][q] = 1;
		qq.push({p, q});
		while (!qq.empty()) {
			int x, y; tie(x, y) = qq.front(); qq.pop();
			rep(d, 0, 4) {
				int nx = x + dir[d][0], ny = y + dir[d][1];
				int nd = h[x][y] + int(!rm[x][y]);
				if (nd < h[nx][ny]) {
					h[nx][ny] = nd;
					qq.push({nx, ny});
				}
			}
		}
	}

	die(ans);
}


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

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i,0,n) cin >> h[i];
  int ans = 0, cnt = 0;
  rep(i,0,n-1) {
    if (h[i] >= h[i+1]) {
      cnt++;
    } else {
      cnt = 0;
    }
    ans = max(ans,cnt);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3788
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>

#include<queue>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF 1844674407370955161
typedef long long int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MOD 1000000007

template<typename T>
int vector_finder(std::vector<T> vec, T number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

template<typename T>
T gcd(T a,T b){
	if(b>0){
		return gcd(b, a % b);
	}else{
		return a;
	}
}

template<typename T>
T lcm(T a,T b){
	T g = gcd(a, b);
	return a * b / g;
}

void clear( std::queue<pair<int,int> > &q )
{
   std::queue<pair<int,int> > empty;
   std::swap( q, empty );
}
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
template<typename T>
std::vector<T> enum_div(T n)//nの約数を列挙
{
	std::vector<T> ret;
	for(T i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}


class DisjointSet{
    public:
        vector<int> rank, p;

        DisjointSet(){
        }

        DisjointSet(int size){
            rank.resize(size, 0);
            p.resize(size, 0);
            for (int i = 0; i < size;i++){
                makeSet(i);
            }
        }
        void makeSet(int x){
            p[x] = x;
            rank[x] = 0;
        }

        bool same(int x,int y){
            return findSet(x) == findSet(y);
        }
        void unite(int x,int y){
            link(findSet(x), findSet(y));
        }
        void link(int x,int y){
            if(rank[x]>rank[y]){
                p[y] = x;
            }else{
                p[x] = y;
                if(rank[x]==rank[y]){
                    rank[y]++;
                }
            }
        }
        int findSet(int x){
            if(x!=p[x]){
                p[x] = findSet(p[x]);
            }
            return p[x];
        }
};

int main()
{
    int N;
    cin >> N;
    vector<pair<ll, ll> > tsk;
    REP(i, 0, N)
    {
        ll B, A;
        cin >> A >> B;
        tsk.push_back(make_pair(B, A));
    }
    sort(tsk.begin(), tsk.end());

    ll now = 0;
    REP(i,0,N){
        now += tsk[i].second;
        if(now>tsk[i].first){
            cout << "No" << endl;
            return 0;
        }
    }

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

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

int main(){
    
    int X, A, B;
    cin >> X >> A >> B;

    if(B <= A){
        cout << "delicious" << endl;
    }else if(B <= A + X){
        cout << "safe" << endl;
    }else{
        cout << "dangerous" << endl;
    }

    return 0;
}

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

int res[501][501];

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

	int n;

	cin >> n;

	for(long long int k=1; ;k++)
	{
		long long int val = k*(k+1)/2;
		if(val>n)
		{
			break;
		}
		if(val==n)
		{
			k += 1;
			long long int num = 1;
			for(int i=0;i<k-1;i++)
			{
				res[i][0] = num;
				res[k-1][i] = num++;
			}
			for(int i=0;i<k-1;i++)
			{
				for(int j=i+1;j<k-1;j++)
				{
					res[i][j] = num;
					res[j][i+1] = num++;
				}
			}
			cout << "Yes" << '\n';
			cout << k << '\n';
			for(int i=0;i<k;i++)
			{
				cout << k-1 << ' ';
				for(int j=0;j<k-1;j++)
				{
					cout << res[i][j] << ' ';
				}
				cout << '\n';
			}
			return 0;
		}	
	}
	cout << "No" << '\n';
    return 0;
}


Measured memory_bytes: 2304