akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647 >> 1);
static const ll LLINF = (9223372036854775807 >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;

namespace Printer{
    template<class T>
    void print(T x){
        cout << x << endl;
    }

    template<class T>
    void print(T x, T y){
        cout << x << "," << y << endl;
    }

    template<class T>
    void print(vector<T> v){
        rep(i, v.size()){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    template<class T>
    void print(vector<vector<T> > vv){
        rep(i, vv.size()){
            rep(j, vv[i].size()){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void print(pair<int, int> p){
        cout << "(" << p.first << ", " << p.second << ")" << endl;
    }
};
using namespace Printer;

//--global--//



//----------//

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//

    int n, m;
    cin >> n >> m;
    if(n == m){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    string s;
    cin >> s;
    for(auto c: s){
        if(c == '9'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


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

int main(){
	ll h,w;
	cin >> h >> w;
	
	if(h == 1 && w == 1){
		cout << 1 << endl;
	}
	else if(h == 1 || w == 1){
		cout << h*w-2 << endl;
	}
	else{
		cout << (h-2)*(w-2) << endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin,(a).rend()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, a; cin >> n >> a;
	dunk(n * n - a);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNextInt()){
			int H = sc.nextInt();
			int W = sc.nextInt();
			if(H == 0 && W == 0)break;
			
			for(int i = 0; i < H; i++){
				
				for(int u = 0; u < W; u++){
					if(i == 0 || i == H-1)
						System.out.print("#");
					else{
						if(u == 0 || u == W-1)
							System.out.print("#");
						else
							System.out.print(".");
					}
				}
				
			System.out.println();
			}
			System.out.println();
		}
		}
}

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

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)
#define F first
#define S second
#define X first
#define Y second

using namespace std;

int n, m;
vector<int> vx, vy;
int tx[5005], ty[5005], unzipx[5005], unzipy[5005], imos[5005][5005];
map<int, int> zipx, zipy;
pair< pair<int,int>, pair<int,int> > p[500005];

int main() {
  cin>>n>>m;
  REP(i,0,n){
    cin>>tx[i]>>ty[i];
    vx.push_back(tx[i]);
    vy.push_back(ty[i]);
  }
  REP(i,0,m){
    cin>>p[i].F.X>>p[i].F.Y>>p[i].S.X>>p[i].S.Y;
  }

  //compression
  sort(vx.begin(), vx.end());
  sort(vy.begin(), vy.end());
  vx.erase(unique(vx.begin(), vx.end()), vx.end());
  vy.erase(unique(vy.begin(), vy.end()), vy.end());
  REP(i,0,vx.size()){
    zipx[vx[i]] = i;
    unzipx[i] = vx[i];
  }
  REP(i,0,vy.size()){
    zipy[vy[i]] = i;
    unzipy[i] = vy[i];
  }

  //Initializing imos array
  REP(i,0,5005)REP(j,0,5005) imos[i][j] = 0;
  REP(i,0,n){
    imos[zipy[ty[i]]][zipx[tx[i]]]++;
  }
  //creating imos array
  REP(i,0,vy.size()){
    REP(j,1,vx.size()){
      imos[i][j] += imos[i][j-1];
    }
  }
  REP(j,0,vx.size()){
    REP(i,1,vy.size()){
      imos[i][j] += imos[i-1][j];
    }
  }

  REP(i,0,m){
    vector<int>::iterator a1x = lower_bound(vx.begin(),vx.end(),p[i].F.X),
      a1y = lower_bound(vy.begin(),vy.end(),p[i].F.Y),
      a2x = upper_bound(vx.begin(),vx.end(),p[i].S.X)-1,
      a2y = upper_bound(vy.begin(),vy.end(),p[i].S.Y)-1;
    int z1x = zipx[*a1x], z1y = zipy[*a1y], z2x = zipx[*a2x], z2y = zipy[*a2y];
    int ans = imos[z2y][z2x];
    if(z1y > 0) ans -= imos[z1y-1][z2x];
    if(z1x > 0) ans -= imos[z2y][z1x-1];
    if(z1y > 0 && z1x > 0) ans += imos[z1y-1][z1x-1];
    //fo exception
    if(p[i].F.Y > unzipy[vy.size()-1] || p[i].F.X > unzipx[vx.size()-1]) cout<<0<<endl;
    else if(p[i].S.Y < unzipy[0] || p[i].S.X < unzipx[0]) cout<<0<<endl;
    else cout<<ans<<endl;
  }

  return 0;
}

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

int main() {
  int n; cin >> n;
  int sum = 0;

  int minNum,maxNum;
  for(int i = 0; i < n; ++i){
    cin >> minNum >> maxNum;
    sum += maxNum - minNum +1;
  }
  cout << sum << endl;
}

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

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(16);

    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    cout << s1[0] << s2[0] << s3[0] << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n) / gcd(n, m)*abs(m);//gl=xy
}
 
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;
}
 
using namespace std;

vector<vector<bool>>visited;
int h,w;
vector<vector<int>>c;

void dfs(int x,int y){
  visited[x][y]=true;
  for(int i=-1;i<=1;++i){
    for(int j=-1;j<=1;++j){
      if(i==0&&j==0)continue;
      if(x+i>=0&&x+i<h&&y+j>=0&&y+j<w){
        if(c[x+i][y+j]==1){
          if(!visited[x+i][y+j])dfs(x+i,y+j);
        }
      }
    }
  }
}

void solve(){
  visited.assign(h,vector<bool>(w));
  c.assign(h,vector<int>(w));
  rep(i,h)rep(j,w)cin>>c[i][j];
  int ans=0;
  rep(i,h){
    rep(j,w){
      if((!visited[i][j])&&(c[i][j]==1))dfs(i,j),++ans;
    }
  }
  cout<<ans<<"\n";
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  while(1){
    cin>>w>>h;
    if(h==0&&w==0)return 0;
    solve();
  }
	return 0;
}



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

using namespace std;

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

const int MAXN = 1e5 + 5;

ll N, H;
ll B[MAXN];

int main(){
    cin.tie(0);
    cin.sync_with_stdio(0);

    cin >> N >> H;

    ll maxA = 0;
    for(int a = 0; a < N; a++){
        ll A;
        cin >> A >> B[a];
        maxA = max(maxA, A);
    }
    sort(B, B + N);
    reverse(B, B + N);

    ll ans = (H + maxA - 1) / maxA;
    for(int a = 0; a < N; a++){
        H -= B[a];
        ans = min(ans, max(0ll, (H + maxA - 1) / maxA) + a + 1);
    }
    cout << ans;
}


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

const int maxn = 2e5;

int n, son[maxn][2];
long long len[maxn], lim;
typedef pair<long long, long long> Pair;
vector<Pair> set[maxn];

void Combine(vector<Pair> &s, int u, int v) {
  s.clear();
  if (set[u].empty()) {
    return;
  }

  // u -> v
  int j = 0;
  for (int i = 0; i < set[u].size(); ++i) {
    if (set[u][i].second + len[u] + set[v][j].first + len[v] > lim) {
      continue;
    }
    while (j + 1 < set[v].size() &&
           set[u][i].second + len[u] + set[v][j + 1].first + len[v] <= lim) {
      ++j;
    }
    s.push_back({set[u][i].first + len[u], set[v][j].second + len[v]});
  }
  int mid = s.size();

  // v -> u
  j = set[v].size() - 1;
  for (int i = set[u].size() - 1; i >= 0; --i) {
    if (set[v][j].second + len[v] + set[u][i].first + len[u] > lim) {
      continue;
    }
    while (j - 1 >= 0 &&
           set[v][j - 1].second + len[v] + set[u][i].first + len[u] <= lim) {
      --j;
    }
    s.push_back({set[v][j].first + len[v], set[u][i].second + len[u]});
  }
  reverse(s.begin() + mid, s.end());
  inplace_merge(s.begin(), s.begin() + mid, s.end());

  mid = 0;
  for (int i = 0; i < s.size(); ++i) {
    if (i == 0 || s[i].second < s[i - 1].second) {
      s[mid++] = s[i];
    }
  }
  s.resize(mid);
}

bool Check(void) {
  for (int i = n - 1; i >= 0; --i) {
    if (son[i][0] == -1) {
      set[i] = {{0, 0}};
    } else {
      int &u = son[i][0], &v = son[i][1];
      if (set[u].size() > set[v].size()) {
        swap(u, v);
      }
      Combine(set[i], u, v);
    }
  }
  return set[0].size() > 0;
}

int main(void) {
  scanf("%d", &n);
  memset(son, -1, sizeof son);
  for (int i = 1; i < n; ++i) {
    int par;
    scanf("%d%lld", &par, len + i);
    --par;
    swap(son[par][0], son[par][1]);
    son[par][0] = i;
  }
  long long low = 0, high = (long long)maxn * maxn;
  while (low < high) {
    lim = low + high >> 1;
    if (Check()) {
      high = lim;
    } else {
      low = lim + 1;
    }
  }
  printf("%lld\n", low);
  return 0;
}


Measured memory_bytes: 30980
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
ll mod = 1e9+7;
ll INF = 1e17;
/*ll gcd(ll a,ll b)
{
    if(a==0)
    return(b);
    return(gcd(b%a,a));
}*/
/*ll power(ll a,ll b,ll p)
{
	ll res=1;
	a%=p;
	while(b>0)
	{
		if(b&1)
		res=res*a%p;
		a=a*a%p;
		b>>=1;
	}
	return(res);
}*/
/*void dfs(ll x)
{
	vis[x]=true;
	for(ll i=0;i<v[x].size();i++)
	{
		if(vis[v[x][i]]==false)
		dfs(v[x][i]);
	}
}*/
/*ll b_search(ll arr[],ll n,ll s)
{
	ll l=0,r=n-1;
	while(l<=r)
	{
		ll mid=l+(r-l)/2;
		if(arr[mid]==s)
		return(mid);
		if(arr[mid]<s)
		l=mid+1;
		else
		r=mid-1;
	}
	return(-1);
}*/
void solve()
{
	string s;
	cin>>s;
	if((s[2]==s[3]) && (s[4]==s[5]))
	cout<<"Yes";
	else
	cout<<"No";
}
int main()
{
	IOS
	ll t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
    return(0);
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

struct tree {
	int value;
	unique_ptr<tree>ltree, rtree;
	tree(const int value_):value(value_) {

	}

};
void ins(unique_ptr<tree>&t, int num) {
	if (t == nullptr) {
		t = make_unique<tree>(num);
	}
	else {
		if (num < t->value) {
			ins(t->ltree, num);
		}
		else {
			ins(t->rtree, num);
		}
	}
}
void dfs(unique_ptr< tree>&t,bool mid,vector<int>&v) {
	if (mid) {
		v.emplace_back(t->value);
	}
	if (t->ltree) {
		dfs(t->ltree, mid, v);
	}
	if (!mid) {
		v.emplace_back(t->value);
	}
	if (t->rtree) {
		dfs(t->rtree, mid, v);
	}
	
	return;
}

int main() {
	int N; cin >> N;
	unique_ptr<tree> t(nullptr);
	while (N--) {
		string st;  cin >> st ;
		if (st == "print") {
			vector<int> v;
			for (int i = 0; i < 2; ++i) {
				dfs(t, bool(i), v);
				cout << " ";
				for (int i = 0; i < v.size(); ++i) {
					cout << v[i];
					if (i == v.size() - 1)cout << endl;
					else cout << " ";
				}
				v.clear();
			}
			
		}
		else {
			int a; cin >> a;
			ins(t, a);
		}
	}
	return 0;
}


Measured memory_bytes: 20576
use std::io;
use std::io::prelude::*;
use std::collections::HashMap;

fn main() {
    let _ = get_line();
    let mut initials: HashMap<char, i64> = HashMap::new();
    for name in get_lines() {
        *initials.entry(name.chars().next().unwrap()).or_insert(0) += 1;
    }
    println!("{}", solve(&initials));
}

fn solve(initials: &HashMap<char, i64>) -> i64 {
    let nums: Vec<i64> = "MARCH"
        .chars()
        .map(|c| *initials.get(&c).unwrap_or(&0))
        .collect();
    let mut ans = 0;
    for group in combs(&nums, 3) {
        ans += group.iter().fold(1, |a, v| a * v);
    }
    ans
}

fn combs<T: Clone + std::fmt::Debug>(v: &[T], n: usize) -> Vec<Vec<T>> {
    if n == 0 {
        return vec![vec![]];
    }
    // v.iter.enumerate.take.map(recur).fold would be nice..
    let mut gen = vec![];
    for (i, val) in v.iter().enumerate().take(v.len() - n + 1) {
        for mut sub in combs(&v[i + 1..], n - 1) {
            sub.push(val.clone());
            gen.push(sub);
        }
    }
    gen
}

fn get_lines() -> Vec<String> {
    let stdin = io::stdin();
    let lock = stdin.lock();
    let lines = lock.lines().map(|l| l.unwrap()).collect(); // for lifetime?
    lines
}

fn get_line() -> String {
    let mut inp = String::new();
    io::stdin().read_line(&mut inp).expect("read error");
    inp.trim().to_string()
}

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


int main(){
	string s;
	cin >> s;
	LL ans = 0;
	int n = s.size();
	int num = 0;
	for(int i = 0; i < n; i++){
		if(s[i] == 'W'){
			ans += i - num;
			num++;
		}
	}
	cout << ans << '\n';
}

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

using namespace std;

int tab[100010];
vector<int> v;

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

	int n;
	int res=1;
	bool czy1=1, czy2=0;
	cin >> n >> tab[1];
	v.push_back( tab[1] );
	for( int a, i=2; i<=n; i++ ) {
        cin >> a;
        if( *v.rbegin() > *v.begin() ) {
            if( a >= *v.rbegin() ) {
                //v.push_back( a );
            } else {
                v.clear();
                res++;
            }
        } else if( *v.rbegin() < *v.begin() ) {
            if( a <= *v.rbegin() ) {
                //v.push_back( a );
            } else {
                v.clear();
                res++;
            }
        }
        v.push_back( a );
	}
    cout << res;
	return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> p(n), q(n);
    rep(i,n) cin >> p[i];
    rep(i,n) cin >> q[i];
    vector<int> a(n);
    rep(i,n) a[i] = i+1;
    int ans;
    
    map<vector<int>, int> mp;
    do{
        mp[a] = mp.size();
    }while(next_permutation(a.begin(),a.end()));
    
    ans = abs(mp[p] - mp[q]);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5248
const MOD: usize = 1e9 as usize + 7;
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let m: usize = sc.read();

    let s: Vec<u32> = sc.vec(n);
    let t: Vec<u32> = sc.vec(m);

    let mut dp = vec![0; m + 1];
    dp[0] = 1;
    for i in 0..n {
        let s = s[i];
        let mut carry = 0;
        let mut next = dp.clone();
        next[0] = 1;
        for j in 0..m {
            carry += dp[j];
            carry %= MOD;
            if s == t[j] {
                next[j + 1] += carry;
                next[j + 1] %= MOD;
            }
        }
        //        println!("dp={:?}", dp);
        dp = next;
    }
    //    println!("dp={:?}", dp);

    let mut ans = 0;
    for a in dp.into_iter() {
        ans += a;
        ans %= MOD;
    }
    println!("{}", ans);
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<vector<pair<int, int> > > vvp;
typedef vector<pair<int,int> > vp;
typedef vector<vector<int> > vvi;
typedef vector<int> vi;
typedef vector<vector<bool> > vvb;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<string, int> psi;
typedef pair<int, int> pii;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define yn(f) (f?"yes":"no")
#define YN(f) (f?"YES":"NO")
#define Yn(f) (f?"Yes":"No")
#define mod 1000000007
#define intmax 2147483647
#define intmin -2147483648
#define longmax 9223372036854775807
#define longmin -9223372036854775808
#define nil -1
int main() {
	string s; cin >>s;
	string ans = "";
	for (int i = 0; i < s.length(); i++)
	{
		if (i % 2 == 0)ans += s[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
n = gets.to_i
h = gets.split.map(&:to_i)
dp = Array.new(n)
dp[0] = 0
dp[1] = (h[1] - h[0]).abs
(2..n-1).each do |i|
  a = dp[i-1] + (h[i] - h[i-1]).abs 
  b = dp[i-2] + (h[i] - h[i-2]).abs
  dp[i] = [a, b].min
end
puts dp.last


Measured memory_bytes: 11396
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip> 
#include <bits/stdc++.h>
using namespace std;
double pi=3.14159265358979323846264338;
const int MOD=1000000007;

int arr[200001];
int main() {
	
	int n;
	cin>>n;
	for(int i=0;i<n;i++)cin>>arr[i];
	sort(arr,arr+n);
	if(n==2){cout<<arr[n-1]<<endl;return 0;};
	long long ans=arr[n-1];
	for(int i=3;i<=n;i++){
		ans+=arr[n-(i-1)/2-1];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4372
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

ll dp[MAX];

int main(){
  ll N;cin>>N;
  vector<ll> a(N);
  ll i,j,k,l;
  rep(i,N) cin>>a[i];
  fill(dp,dp+N,INF+1);
  for(i=N-1;i>=0;i--){
    *upper_bound(dp,dp+N,a[i]) = a[i];
  }
  ll ans=(lower_bound(dp,dp+N,INF+1)-dp);
  cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n; cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; i++) cin >> p[i];
    int ans = 0;
    for (int i = 1; i < n-1; i++) {
        if (max({p[i-1], p[i], p[i+1]}) != p[i] && min({p[i-1], p[i], p[i+1]}) != p[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
  using namespace std;
  int A, B, C, D;
  int flagT = 0;

  cin >> A >> B >> C >> D;
  while (1)
  {
    C -= B;
    if (C <= 0)
    {
      flagT = 1;
      break;
    }
    A -= D;
    if (A <= 0)
    {
      flagT = -1;
      break;
    }
  }
  if (flagT == 1)
  {
    cout << "Yes";
  }
  else
  {
    cout << "No";
  }

  return 0;
}

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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

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

    int n;
    cin >> n;

    vi h(n);
    rep(i, 0, n) { cin >> h[i]; }

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

    return 0;
}

Measured memory_bytes: 640
/**
 * @brief  : c++ code for AtCoder
 * @author : rk222
 * @created: 2019.07.07 21:24:09
 */

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<int, P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i, x) for (int i = 0; i < x; i++)
#define rep1(i, x) for (int i = 1; i <= x; i++)
#define rrep(i, x) for (int i = x - 1; i >= 0; i--)
#define rrep1(i, x) for (int i = x; i > 0; i--)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define uniq(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define mp1(a, b, c) P1(a, P(b, c))

#define disp(x) cout << #x << ": " << x << endl
#define disp_vec(v)                                                                           \
    cout << #v << ":";                                                                        \
    rep(i, v.size()) cout << " " << v[i];                                                     \
    cout << endl

const int INF = 1000000007;
const int M = 1000000007;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};

/* ------------------------------------- */

int main() {
    ll n, a[100010];
    scanf("%lld", &n);
    rep(i, n) scanf("%lld", &a[i]);

    ll ret[100010];
    rep(i, n) {
        if (i == 0) {
            ret[i] = 0;
            continue;
        }
        ret[i] = 2LL * (a[i - 1] - ret[i - 1] / 2LL);
    }
    ll x = a[n - 1] - ret[n - 1] / 2LL;
    rep(i, n) {
        if (i == 0) {
            ret[i] = x;
            continue;
        }
        ret[i] = 2LL * (a[i - 1] - ret[i - 1] / 2LL);
    }
    rep(i, n) {
        if (i == 0) {
            printf("%lld", ret[i]);
            continue;
        }
        printf(" %lld", ret[i]);
    }
    printf("\n");

    /* --------------------------------- */
    return 0;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(kbrni,n)cout<<" "<<a[kbrni];cout<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define svecp(v) cout<<#v<<":";each(kbrni,v)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

vector<int> G[MAX_N];
int ans;

bool dfs(int u,int p)
{
    int ch = 0;
    int res = 0;
    each(v,G[u]){
        if(v != p){
            ch++;
            if(dfs(v,u)){
                res++;
            }
        }
    }
    ans += max(ch-res-1,0);
    return (ch >= 2) || (res>=1);
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        G[a].pb(b),G[b].pb(a);
    }
    int r = -1;
    rep(i,n){
        if(len(G[i]) >= 3){
            r = i;
            break;
        }
    }
    if(r < 0){
        cout << "1\n";
        return 0;
    }
    ans = 0;
    dfs(r,-1);
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 9088
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    int a, b;
    read(a, b);

    string x = string(b, char('0' + a));
    string y = string(a, char('0' + b));
    print(min(x, y));

    return 0;
}


Measured memory_bytes: 256
import copy

def CountingSort(A, B, k):
    C = [0] * k

    # C[i] に i の出現数を記録する
    for j in range(n):
        C[A[j]] += 1

    # C[i] に i 以下の数の出現数を記録する
    for i in range(1, k):
        C[i] = C[i] + C[i - 1]

    for j in range(n)[::-1]:
        B[C[A[j]]] = A[j]
        C[A[j]] -= 1



n = int(input())
A = list(map(int, input().split()))

B = [0] * (n + 1)
CountingSort(A, B, max(A) + 1)

print(*B[1:])


Measured memory_bytes: 229492
from functools import lru_cache
N = int(input())
# A * B <= N - 1はいくつありますか？
count = 0
# A ∈ {1, 2, ..., N-1}
for A in range(1, N):
    # B <= (N - 1) // A
    count += (N - 1) // A
print(count)

Measured memory_bytes: 9560
#include <iostream>

using namespace std;

int num_comp = 0;
const int MAX = 500000;
int L[MAX/2 + 2];
int R[MAX/2 + 2];
const int SENTINEL = 2000000000;


// Merge
void Merge(int A[], int left, int mid, int right)
{
	int n1 = mid - left;
	int n2 = right - mid;
	for (int i = 0; i < n1; i++)
		L[i] = A[left + i];
	for (int i = 0; i < n2; i++)
		R[i] = A[mid + i];
	L[n1] = SENTINEL;
	R[n2] = SENTINEL;

	int i = 0;
	int j = 0;
	for (int k = left; k < right; k++) {
		num_comp++;
		if (L[i] <= R[j]) {
			A[k] = L[i];
			i++;
		}
		else {
			A[k] = R[j];
			j++;
		}
	}
}

// Merge sort
void Mergesort(int A[], int left, int right)
{
	if (left + 1 < right) {
		int mid = (left + right) / 2;
		Mergesort(A, left, mid);
		Mergesort(A, mid, right);
		Merge(A, left, mid, right);	
	}

}

// MAIN FUNCTION
int main(int argc, char** argv)
{
	// Input
	int A[MAX];
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> A[i];

	// Merge sort
	Mergesort(A, 0, n);

	// Print all elements
	for (int i = 0; i < n; i++) {
		if (i)
			cout << " ";
		cout << A[i];
	}
	cout << endl;
	cout << num_comp << endl;

	return 0;
}


Measured memory_bytes: 6960
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define mod 1000000007
int par[20005],ran[20005],sz[20005];
void init(){ for(int i=0;i<20005;i++) par[i] = i,sz[i ] = 1; }
int find(int x){ if(x == par[x]) return x; else return par[x] = find(par[x]); }
void unite(int x,int y){
	x = find(x); y = find(y); if(x==y) return;
	if(ran[x] < ran[y]){
		par[x] = y;
		sz[y]+=sz[x];
	}
	else{
		par[y] = x; sz[x]+=sz[y];
		if(ran[x] == ran[y]) ran[x]++;
	}
}
bool same(int x,int y){ return find(x)==find(y); }
int n,m;
char f[105][105];
int cnt[5],C[26];
int main(){
	cin>>n>>m;
	rep(i,n) scanf("%s",f[i]);
	init();
	rep(i,n)rep(j,m)C[f[i][j]-'a']++;
	rep(i,n){
		rep(j,m){
			if(j >= m-1-j) break;
			unite(i*m+j,i*m+m-1-j);
		}
	}
	rep(j,m){
		rep(i,n){
			if(i >= n-1-i) break;
			unite(i*m+j,(n-1-i)*m+j);
		}
	}
	vector<int>vec;
	rep(i,n)rep(j,m){
		if(find(i*m+j) != i*m+j) continue;
		cnt[sz[i*m+j]]++;//cout<<sz[i*m+j]<<endl;
	}
	bool ok = 1;
	for(int i=0;i<26;i++){
		if(C[i]%2 == 1){
			if(!cnt[1]){
				ok = 0; break;
			}
			cnt[1]--; C[i]--;
		}
		while(cnt[4] && C[i]>=4){
			cnt[4]--; C[i]-=4;
		}
		while(cnt[2] && C[i]>=2){
			cnt[2]--; C[i]-=2;
		}
		if(C[i]){
			ok=0; break;
		}
	}
	puts(ok?"Yes":"No");
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<fstream>
using namespace std;
#define ll long long int 
#define endl '\n'
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()

 
typedef vector<ll>   vi;
 
 
int main()
{
ll i;
string s;
cin>>s;
for(i=0;i<s.size();i++){
	if(s[i]=='7')
	{
		cout<<"Yes";
		return 0;
	}
}
cout<<"No";
return 0; 	

return 0; 
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
#define limit int(1e5 + 99)
ll wei[ limit ], val[ limit ];
ll dp[ 199 ][ limit ];
 
int main() {
	ll n, w;
	scanf("%lld%lld", &n, &w);
 
	for(ll i = 0; i < n; i++) {
		scanf("%lld%lld", &wei[ i ], &val[ i ]);
	}

        /*
	for(int i = 0; i < n; i++) {
		for(int j = w; j >= wei[ i ]; j--) {
			//printf("%i ? %i\n", dp[ j ], dp[ j - wei[ i ] ] + val[ i ]);
			dp[ j ] = max(dp[ j ], dp[ j - wei[ i ] ] + val[ i ]);
		}
	}*/

	for(int i = wei[ 0 ]; i <= w; i++) dp[ 0 ][ i ] = val[ 0 ];

	for(int i = 1; i < n; i++) {
		for(int j = 0; j <= w; j++) {
			if(j - wei[ i ] >= 0) dp[ i ][ j ] = max(dp[ i - 1 ][ j ], dp[ i - 1 ][ j - wei[ i ] ] + val[ i ]); 
			else dp[ i ][ j ] = dp[ i - 1 ][ j ];
		}
	}

	printf("%lld ", dp[ n - 1 ][ w ]);
}

Measured memory_bytes: 82176
import sys
def input(): return sys.stdin.readline().rstrip()
def prime_fact(m):
    pf={}
    for i in range(2,int(m**0.5)+1):
        while m%i==0:
            pf[i]=pf.get(i,0)+1
            m//=i
    if m>1:pf[m]=1
    return pf
def main():
    n,p=map(int,input().split())
    p_dict=prime_fact(p)
    ans=1
    for pp in p_dict.items():
        ans*=pp[0]**(pp[1]//n)
    print(ans)


if __name__=='__main__':
    main()

Measured memory_bytes: 38512
#include "bits/stdc++.h"
#define deb(x){cerr <<#x<<" = "<<(x)<<'\n';}

using namespace std;

int main(){
    int n;
    cin >> n;
    long long k = 0, tot = 0;
    map<long long , int>hs;
    hs[0] = 1;
    for(int i = 0; i<n; i++){
        int elm;
        cin >> elm;
        k +=elm;
        tot += hs[k];
        hs[k]++;
    }
    cout << tot << endl;
  return 0;
}




Measured memory_bytes: 12800
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#include <numeric>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[4] = {-1, 0, 1, 0};
ll dy[4] = {0, 1, 0, -1};

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


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

using namespace std;

int main(void){
	int m,n;
	
	while(cin >> m >> n){
		if(!(m|n)) break;
		int lb=0,ub=1500000;
		int maxi = 0;
		vector<int> books(n);
		for(int i=0;i<n;i++){
			cin >> books[i];
			maxi = max(maxi, books[i]);
		}
		while(ub - lb > 1){
			int mid = (lb + ub) / 2;
			int count=1;
			int tmp=0;
			for(int i=0;i<n;i++){
				if(tmp + books[i] <= mid){
					tmp += books[i];
				}else{
					tmp = books[i];
					count++;
				}
			}
			if(count <= m && mid >= maxi){
				ub = mid;
			}else{
				lb = mid;
			}
		}
		cout << ub << endl;
	}
}

Measured memory_bytes: 0
// 単一始点最短経路 ( ダイクストラ法 : 優先度付きキュー )
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>

#include<queue>

using namespace std;

static const int MAX = 10000;
static const int INFTY = (1 <<20);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n;

// 重み付き有向グラフの隣接リスト表現
// first : 頂点No. second : 入力される辺の重み
vector< pair<int, int> > adj[MAX];

int Dijkstra()
{
    int u;
    int d[MAX], p[MAX], color[MAX];

    // 優先度付きキュー : first : 最短距離 second : 頂点No.
    priority_queue< pair<int, int> > PQ;

    for(int i = 0; i < n; i++)
    {
        d[i] = INFTY;
        p[i] = -1;
        color[i] = WHITE;
    }

    // 初期値の設定
    d[0] = 0;
    PQ.push( make_pair(0, 0) );
    color[0] = GRAY;

    while( !PQ.empty() )
    {
        pair<int, int> f = PQ.top();
        PQ.pop();

        // 次に移動するべき頂点
        u = f.second;;
        // 訪問完了
        color[u] = BLACK;

        // 最小値を取り出し, それが最短で無ければ無視
        if( d[u] < f.first * (-1) )
        {
            continue;
        }

        for(int j = 0; j < adj[u].size(); j++)
        {
            // 隣接リストから要素を取得する
            int v = adj[u][j].first;

            if( color[v] != BLACK )
            {
                // u → v の経路の中で, vのコストが最小のものが見つかれば更新する
                if( d[v] > d[u] + adj[u][j].second )
                {
                    // コストの記録
                    d[v] = d[u] + adj[u][j].second;
                    // 頂点 v の親を記録する
                    p[v] = u;
                    // 訪問状態の記録
                    color[v] = GRAY;

                    // キューに要素を入れる
                    // priority_queue はデフォルトで大きい値を優先するため, -1を掛ける
                    PQ.push( make_pair( d[v] * (-1), v ) );
                }
            }
        }
    }

    // 結果の表示
    for(int i = 0; i < n; i++)
    {
        cout << i << " " << ( d[i] == INFTY ? -1 : d[i] ) << endl;
    }

    return 0;
}

int main(void)
{

    int k, c, u, v;

    cin >> n;

    for(int i = 0; i < n; i++)
    {
        cin >> u >> k;

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

            adj[u].push_back( make_pair(v, c) );
        }
    }

    Dijkstra();

    return 0;

}



Measured memory_bytes: 8092
#!/mnt/c/Users/moiki/bash/env/bin/python
N = int(input())
A = list(map(int, input().split()))

ans = 0
l = 0
r = 0
sumrange = 0
bitcount = 0
sumxor = 0

# while not ( r <= N-1 and l <= r) :
while   r <= N-1:
    # print("l,: ", l, "r: ", r)
    # r proceeds
    # while A[r] & bitcount == 0:
    while r <= N-1 and A[r] & bitcount == 0 : # sumrange == sumxor:
        sumrange += A[r]
        bitcount ^= A[r]
        length = r - l + 1
        ans += length # (length+1)*length // 2
        r += 1

    while l <= r:
        bitcount ^= A[l]
        sumrange -= A[l]
        l += 1
        if bitcount == sumrange:
            break
print(ans)
    
    

    
            




Measured memory_bytes: 77900
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
 
#define Rep(i, n) for (int i = 1; i <= n; i ++)
#define Rep0(i, n) for (int i = 0; i <= n; i ++)
#define RepG(i, x) for (int i = head[x]; i; i = edge[i].next)
#define v edge[i].to
#define mp(a, b) make_pair(a, b)
 
using namespace std;

const int N = 300100;

struct Seg{ int l, r;} s[N];
bool cmp(Seg a, Seg b) { return a.r - a.l < b.r - b.l;}

int tg[N];
void modify(int x, int l, int r, int a, int b)
{
	if (a <= l && r <= b){ tg[x] ++; return; }
	int mid = (l + r) >> 1;
	if (a <= mid) modify(x << 1, l, mid, a, b);
	if (b > mid) modify(x << 1 | 1, mid + 1, r, a, b);
}
int query(int x, int l, int r, int a)
{
	if (l == r) return tg[x];
	int ret = tg[x], mid = (l + r) >> 1;
	if (a <= mid) ret += query(x << 1, l, mid, a);
	else ret += query(x << 1 | 1, mid + 1, r, a);
	return ret;
}

int main()
{
	int n, m;
	scanf("%d%d", &m, &n);
	Rep(i, m) scanf("%d%d", &s[i].l, &s[i].r);
	
	sort(s + 1, s + 1 + m, cmp);
	
	int t = 1;
	Rep(i, n) {
		while (t <= m && s[t].r - s[t].l + 1 <= i) {
			modify(1, 1, n, s[t].l, s[t].r);
			t ++;
		}
		int ans = m - t + 1;
		for (int j = i; j <= n; j += i) ans += query(1, 1, n, j);
		
		printf("%d\n", ans); 
	}
	
	return 0;
}

Measured memory_bytes: 4224
import java.util.Scanner;

class Main{
 public static void main(String args[]){
  Scanner sc=new Scanner(System.in);
   
  int N=sc.nextInt();
  if(N>=15){
   System.out.println(800*N-200*(N/15));
  }else{
   System.out.println(800*N);
  }
 }
}

Measured memory_bytes: 21716
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
using namespace std;
int main()
{
  ios::sync_with_stdio(false);
  long n,w;
  cin>>n>>w;
  vector<long> dp(100001,w+1);
  dp[0]=0;
  for(int i=0;i<n;i++)
  {
    long we,va;
    cin>>we>>va;
    for(int j=(i+1)*1000;j>=va;j--)
    {
      if(min(dp[j],dp[j-va]+we)<=w)dp[j]=min(dp[j],dp[j-va]+we);
    }

  }
  int res=0;
  for(int i=100000;i>-1;i--)
  {
    if(dp[i]!=w+1){res=i;break;}
  }
  cout<<res;
  return 0;

}

Measured memory_bytes: 1024
#include <cstdio>
typedef long long ll; 
ll pos[100005], cnt[100005], ans; 
void work(int l, int r, int s)
{
	if (pos[r] < s)
	{
		ans += s - pos[l]; 
		return; 
	}
	if (pos[l] > s)
	{
		ans += pos[r] - s; 
		return; 
	}
	ans += pos[r] - pos[l];
	if (cnt[l] >= cnt[r])
	{
		while (l < r && cnt[l] >= cnt[r])
			cnt[l] += cnt[r--]; 
	}
	else
	{
		while (l < r && cnt[l] < cnt[r])
			cnt[r] += cnt[l++]; 
	}
	work(l, r, s); 
}
int main()
{
	// freopen("AGC023-D.in", "r", stdin); 
	int n, s; 
	scanf("%d%d", &n, &s); 
	for (int i = 0; i < n; i++)
		scanf("%lld%lld", pos + i, cnt + i); 
	work(0, n - 1, s); 
	printf("%lld\n", ans);
	return 0; 
}


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

bool isVisited[1000];
bool isEndOfSearch[1000];
bool isClose;
vector<vector<int> > vertexes;

void search(int n);

int main() {

	int v, e;

	cin >> v >> e;

	for (int i = 0; i < v; ++i)
		vertexes.push_back(vector<int>());

	for (int i = 0; i < e; ++i) {

		int s, t;
		cin >> s >> t;

		vertexes[s].push_back(t);

	}


	

	for (int i = 0; i < v; ++i) {
		if (vertexes[i].size() != 0 && isClose == false && isEndOfSearch[i] == false)
			search(i);
	}

	if (isClose == true)
		cout << 1 << endl;
	else
		cout << 0 << endl;

	return 0;
}

void search(int n) {

	isVisited[n] = true;
	isEndOfSearch[n] = true;

	for (int i = 0; i < vertexes[n].size(); ++i) {
		if (isVisited[vertexes[n][i]] == true || isClose == true) {
			isClose = true;
			// cout << n << " " << vertexes[n][i] << " back" << endl;
			return;
		}
		if(isEndOfSearch[vertexes[n][i]] == false)
			search(vertexes[n][i]);
	}

	isVisited[n] = false;

}


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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

#define pb push_back
#define INF 999999999
#define MOD 1000000007
#define sp ' '


//typedef
typedef long long ll;
typedef pair<int, int> pint;
typedef pair<long, long> pll;
typedef map<int, int> mint;
typedef set<int> sint;
typedef vector<int> vint;
typedef vector<char> vchr;
typedef vector<long long> vll;
typedef vector<string> vstr;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll a, ll b, ll c){ll ans=1; rep(i, b){ans=ans*a%c;} return ans;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T>
void dpp(T n){cerr << n << endl;}
template<typename T>
void vpp(T a){rep(i,a.size()){cout << a[i] << endl;}}
template<typename T>
void vdp(T a){rep(i,a.size()){cerr << a[i] << endl;}}

const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int ddx[8] = {1,0,-1,0,1,-1,-1,1};
const int ddy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;

    if(n == 1){
        ppp("Hello World");
        return 0;
    }
    else{
        int a, b;
        cin >> a >> b;
        ppp(a+b);
        return 0;
    }
    

}


Measured memory_bytes: 256
import queue
def main():
    n, x, y = map(int, input().split())
    x -= 1
    y -= 1
    ans = [0]*n
    t = [[i+1, i-1] for i in range(n)]
    t[x].append(y)
    t[y].append(x)
    for i in range(n):
        for j in range(i+1, n):
            if j <= x:
                ans[j-i] += 1
            elif j <= y:
                buf = min(j-i, abs(i-x) + 1 + (y-j))
                ans[buf] += 1
            else:
                buf = min(y-i, abs(x-i)+1)
                ans[buf + (j-y)] += 1
    for i in range(1, n):
        print(ans[i])
if __name__ == "__main__":
    main()

Measured memory_bytes: 4592
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

vector<int> dfs(int m,int a,int b){
    /* cout << "call m,a,b = " << bitset<5>(m) << " " << bitset<5>(a) << " " << bitset<5>(b) << endl; */
    if(__builtin_popcount(m) == 1){
        vector<int> ret{a,b};
        /* cout << "return " << ret << endl; */
        return ret;
    }
    int x = (a^b)&m;
    x=x&-x;     // maskの中でaとbが異なるbitの最右bit
    int m2 = m^x;
    /* cout << "m2 = " << bitset<5>(m2) << endl; */
    // mask(m2)の範囲ではa,bは経ってるbitの偶奇が等しい
    // cはm2の範囲でaと1bitだけ異なる
    int c = a ^ (m2 & -m2);
    auto l = dfs(m2,a,c);
    auto r = dfs(m2,c^x,b);
    for(auto rr : r) l.emplace_back(rr);
    return l;
}

int main(){
    int n,a,b;
    cin >> n >> a >> b;

    if(__builtin_popcount(a)%2 == __builtin_popcount(b)%2){
        cout << "NO" << endl;
        return 0;
    }


    auto res = dfs((1<<n)-1,a,b);
    cout << "YES" << endl;
    for(int i=0;i<res.size();i++){
        cout << res[i] << " ";
    }
    cout << endl;
}


Measured memory_bytes: 1648