akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}

int main(){
    string s;
    cin >> s;
    ll N = s.size();
    string S="";
    rep(i,N-1){
        if(s.substr(i,2) == "BC"){
            S.push_back('D');
            i++;
        }else{
            S.push_back(s[i]);
        }
    }
    ll M = S.size();
    ll ans = 0;
    ll cnt = 0;
    rep(i,M){
        if(S[M-1-i] == 'D'){
            cnt++;
        }else if(S[M-1-i] == 'A'){
            ans += cnt;
        }else{
            cnt = 0;
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 3904
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
using namespace std;
typedef long long int ll;

vector<int> g[100100];
int ans=0;
int n,k;

int dfs(int s,int p){
	int mx=0;
	for(int t:g[s]){
		mx=max(mx,dfs(t,s));
	}
	if(mx+1==k){
		if(p!=0)ans++;
		return 0;
	}
	else return mx+1;
}

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cin >> n >> k;
	for(int i=0;i<n;i++){
		int x; cin >> x;
		x--;
		if(i==0){
			if(x!=0)ans++;
		}
		else g[x].push_back(i);
	}
	dfs(0,0);
	cout << ans << endl;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll N;

int main() {
    cin >> N;
    vector<P> red(N);
    vector<P> blue(N);

    rep(i, N) {
        ll a, b;
        cin >> a >> b;
        red[i] = P(a, b);    
    }
    sort(red.begin(), red.end());

    rep(i, N) {
        ll c, d;
        cin >> c >> d;
        blue[i] = P(c, d);    
    }
    sort(blue.begin(), blue.end());

    ll cnt = 0;
    for (ll i = 0; i < blue.size(); i++) {

        ll red_idx = -1;
        ll red_y = -1;
        for (ll j = 0; j < red.size(); j++) {
            if (blue[i].first > red[j].first && blue[i].second > red[j].second) {
                if (red_y < red[j].second) {
                    red_y = red[j].second;
                    red_idx = j;
                }
            }
        } 

        // cout << red_idx << endl;
        if (red_idx != -1) {
            red.erase(red.begin() + red_idx);
            cnt++;
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
#define ll long long
const double EPS = 1e-10;

int main(){
	int n,h,w;
	cin>>n>>h>>w;
	cout<<(n-h+1)*(n-w+1)<<endl;
}


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

int main() {
	int s1, h, m, s2;
	
	cin >> s1;
	
	m = s1/60;
	s2 = s1%60;
	h = m/60;
	m = m%60;

	cout << h << ":" << m << ":" << s2 << endl;
	return 0;
}


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

int main() {
	ios_base::sync_with_stdio( false );

	int N, K;
	cin >> N >> K;

	int kind = 0;
	vector<int> A( N+1 );
	for( int i = 0; i < N; ++i ) {
		int x;
		cin >> x;

		if( A[x] == 0 ) {
			kind += 1;
		}

		A[x] += 1;
	}

	if( kind-K <= 0 ) {
		cout << "0\n";
	}
	else {
		sort( A.begin(), A.end() );

		int result = 0;
		auto it = lower_bound( A.begin(), A.end(), 1 );

		for( int i = 0; i < kind-K; ++i ) {
			result += *it++;
		}

		cout << result << endl;
	}

	return 0;
}


Measured memory_bytes: 1024
/* Generated by powerful Codeforces Tool
 * You can download the binary file in here https://github.com/xalanq/cf-tool (Windows, macOS, Linux)
 * Author: alireza_kaviani
 * Time: 2020-09-02 12:56:06
**/
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

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

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define sep                         ' '
#define endl                        '\n'
#define SZ(x)                       ll(x.size())

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 1e6 + 10;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

int n , A[MAXN] , B[MAXN] , par[MAXN] , sz[MAXN];
vector<int> v1 , v2;

int Find(int v){
	return (par[v] == -1 ? v : par[v] = Find(par[v]));
}

void Union(int v , int u){
	v = Find(v) , u = Find(u);
	if(v == u)	return;
	if(sz[v] < sz[u])	swap(v , u);
	par[u] = v;
	sz[v] += sz[u];
}

int main() {
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	fill(par , par + MAXN , -1);
	fill(sz , sz + MAXN , 1);

	cin >> n;
	for(int i = 0 ; i < n ; i++){
		cin >> A[i];
		A[n] ^= A[i];
		v1.push_back(A[i]);
	}
	v1.push_back(A[n]);
	for(int i = 0 ; i < n ; i++){
		cin >> B[i];
		B[n] ^= B[i];
		v2.push_back(B[i]);
	}
	v2.push_back(B[n]);
	sort(all(v1));
	sort(all(v2));
	if(v1 != v2)	return cout << -1 << endl , 0;
	int ans = -1;
	vector<int> vec;
	for(int i = 0 ; i <= n ; i++){
		A[i] = lower_bound(all(v1) , A[i]) - v1.begin();
		B[i] = lower_bound(all(v1) , B[i]) - v1.begin();
		if(A[i] != B[i] || i == n){
			if(i != n){
				Union(A[i] , B[i]) , ans++;
				//cout << i << endl;
			}
			vec.push_back(A[i]);
			vec.push_back(B[i]);
		}
	}
	if(ans == -1)	return cout << 0 << endl , 0;
	sort(all(vec));
	vec.resize(unique(all(vec)) - vec.begin());
	for(int i : vec){
		if(Find(i) == i)	ans++;
	}
	cout << ans << endl;

    return 0;
}
/*

*/

Measured memory_bytes: 13676
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)

ll f(ll n)
{
    if ((n + 1) % 4 == 0) return 0;
    if ((n + 1) % 4 == 1) return n;
    if ((n + 1) % 4 == 2) return 1;
    if ((n + 1) % 4 == 3) return n + 1;
}

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

    if (A == 0) cout << f(B) << endl;
    else cout << (f(A - 1) ^ f(B)) << endl;
}

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



int main ()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int toggle = 1;
    while (1)
    {
        if (toggle)
        {
            toggle ^= 1;
            c -= b;
            if (c<=0)
            {
                cout << "Yes" << endl;
                return 0;
            }
            continue;
        }

        else
        {
            toggle ^= 1;
            a -= d;
            if (a<=0)
            {
                cout << "No" << endl;
                return 0;
            }
            continue;

        }
        
    }
    


    return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int n, d, A;
struct az
{
	int x;
	int h;
}q[200005];

int l[200005];
long long f[200005];
long long sum[200005];

bool cmp(az a, az b)
{
	return a.x < b.x;
}
int main()
{
	scanf("%d%d%d",&n,&d,&A);
	for(int i=1;i<=n;++i)
	    scanf("%d%d",&q[i].x,&q[i].h);
	sort(q+1,q+1+n,cmp);
	int s=1;
    for(int i=1;i<=n;++i)
    {
    	while(s<n && q[s+1].x-q[i].x <= 2*d) ++s;
    	l[i]=s;
    }
	long long ans=0;
	for(int i=1;i<=n;++i)
	{
		sum[i]=sum[i-1]+f[i];
		double p=q[i].h - sum[i] *A;
		//cout<<p<<" "<<i<<endl;
		if (p > 0) 
		{
			f[i] += ceil(p/A);
			f[l[i]+1] -=ceil(p/A);
			sum[i] += ceil(p/A);
			ans+=ceil(p/A);
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

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

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

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

    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using ll = long long;
using P = pair<int, int>;
using MATRIX = vector< vector<ll> >;

int main() {
  int N, L;
  cin >> N >> L;
  int ans = (2 * L + N - 1) * N / 2;
  if(L > 0) {
    cout << ans - L << endl;
    return 0;
  }
  if(N + L - 1 < 0) {
    cout << ans - (L + N - 1) << endl;
    return 0;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define HAIRETU(N,A) for(int i=0;i<N;i++) cin >>A[i]
using namespace std;

int main(){
    int N,A[100]={};
    cin >> N;
    HAIRETU(N, A);
    sort(A, A+100,greater<int>());
    
    int Asum=0,Bsum=0;
    for (int i = 0; i < N; i++) {
        if(i % 2 == 0) Asum += A[i];
        else Bsum += A[i];
    }
    
    
    cout << Asum - Bsum << endl;
    return 0;
}



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

int main(void)
{
	vector <int> a;
	int b;
	
	for (int i = 0; i < 10; i++){
		scanf("%d", &b);
		a.push_back(b);
	}
	sort(a.begin(), a.end());
	printf("%d\n%d\n%d\n", a[9], a[8], a[7]);
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int main(void){
    int n,t,count;
    while (cin >> n){
        count = 0;
        for (int i = 0; i < 10; i++){
            for (int j = 0; j < 10; j++){
                for (int k = 0; k < 10; k++){
                    t = n - (i + j + k);
                    if(0 <= t && t < 10)   count++;
                }
            }
        }
        cout << count << endl;
    }
}


Measured memory_bytes: 3080
#include <stdio.h>
int main(void){
    int n;
    scanf("%d",&n);
    int a[n],b[n];
    for(int i=0;i<n;i++){
        scanf("%d",a+i);
        b[a[i]-1]=i+1;
    }
    for(int i=0;i<n;i++)printf("%d ",b[i]);
    printf("\n");
    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
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; }
ll mod= 1e9 + 7;


int main(){
  int n;
  cin >>n;
  ll a[n];
  rep(i,n)cin >> a[i];
  sort(a,a+n);
  reverse(a,a+n);
  queue<ll> g;
  ll ans=0;
  rep(i,n){
    if(i==0){g.push(a[i]);}
    else{
      ans+=g.front();
      g.pop();
      g.push(a[i]);
      g.push(a[i]);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 6640
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

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

  if (a <= 0 && b >= 0) {
    cout << "Zero" << endl;
  } else if (a > 0) {
    cout << "Positive" << endl;
  } else { // b < 0
    const ll diff = b - a + 1;
    cout << (diff % 2 == 0 ? "Positive" : "Negative") << endl;
  }
  return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

int dp[110000][13];

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

    string S;
    cin >> S;
    int len = S.size();
    reverse(S.begin(), S.end());

    if (S[0] == '?') {
        for (int i = 0; i < 10; i++) {
            dp[0][i] = 1;
        }
    } else {
        int index = S[0] - '0';
        dp[0][index] = 1;
    }

    int num = 1;
    for (int i = 1; i < len; i++) {
        num *= 10;
        num %= 13;

        if (S[i] == '?') {
            for (int j = 0; j < 10; j++) {
                for (int k = 0; k < 13; k++) {
                    int index = (k + j * num) % 13;
                    dp[i][index] += dp[i - 1][k];
                    dp[i][index] %= MOD;
                }
            }
        } else {
            for (int k = 0; k < 13; k++) {
                int j = (S[i] - '0');
                int index = (k + j * num) % 13;
                dp[i][index] += dp[i - 1][k];
                dp[i][index] %= MOD;
            }
        }
    }

    cout << dp[len - 1][5] << endl;

    return 0;
}


Measured memory_bytes: 5504
import sys
from collections import deque
from collections import defaultdict
import math
sys.setrecursionlimit(20000000)
#input = sys.stdin.readline

n,m = map(int,input().split())
a = []
for i in range(m):
        a.append(list(map(int,input().split())))
p = list(map(int,input().split()))
ans = 0
for i in range(1<<n):
        on = [0]*n
        for j in range(n):
                if i& 1<<j:
                        on[j] = 1
        for j in range(m):
                check = 0
                for k in range(1,a[j][0]+1):
                        check += on[a[j][k]-1]
                check %=2
                if check != p[j]:
                        break
        else:
                ans += 1
print(ans)


Measured memory_bytes: 42352
#include<bits/stdc++.h>
using namespace std;
int n,m,t,p;
int a,b,c,d;
int field[2000][2000]={};
int main(){
  while(1){
    cin >> n >> m >> t >> p;
    if(n==0 && m==0 && t==0 && p==0) break;
    int x_0=0,y_0=0,x_max=n-1,y_max=m-1;
    for(int i=0;i<2000;i++){
      for(int j=0;j<2000;j++){
        field[i][j]=0;
      }
    }
    for(int i=x_0;i<=x_max;i++){
      for(int j=y_0;j<=y_max;j++){
        field[i][j]=1;
      }
    }
    for(int T=0;T<t;T++){
      int c,d;
      cin >> c >> d;
      if(c==1){
        int k=1;
        /*for(int i=x_max-d;i>=x_0;i--){
          for(int j=y_0;j<=y_max;j++){
            field[i+k][j]+=field[i][j];
            field[i][j]=0;
          }
          k+=2;
        }//caution
        //x_max=max(x_max,x_0+k);
        int tmp=x_0;
        x_0=x_max-d+1;
        x_max=max(x_max,2*x_max-2*d-tmp+1);
        //for(int s=0;s<=4;s++) cout << field[s][0] << " ";
        //cout << endl;
        //cout << "x_max " << x_max << "x0" << x_0 << " " << "y0" << y_0 << endl;*/
        for(int i=x_0+d-1;i>=x_0;i--){
          for(int j=y_0;j<=y_max;j++){
            field[i+k][j]+=field[i][j];
            field[i][j]=0;
          }
          k+=2;
        }//caution
        int tmp=x_0;
        x_0+=d;
        x_max=max(x_max,tmp+2*d-1);
      }
      else{
        int k=1;
        for(int j=y_0+d-1;j>=y_0;j--){
          for(int i=x_0;i<=x_max;i++){
            field[i][j+k]+=field[i][j];
            field[i][j]=0;
          }
          k+=2;
        }//caution
        int tmp=y_0;
        y_0+=d;
        y_max=max(y_max,tmp+2*d-1);
      }
    }
    for(int i=0;i<p;i++){
    int q,w;
    cin >> q >> w;
    cout << field[x_0+q][y_0+w] << endl;
  }
//a=y_max,b=y_0,c=x_max,d=x_0;
}
/*for(int j=a;j>=b;j--){
  for(int i=d;i<=c;i++){
    cout << field[i][j] << " ";
  }
  cout << endl;
}
cout << field[d+3][b+4] << endl;*/
return 0;
}



Measured memory_bytes: 18720
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        l: usize,
    }
    let mut r = 0usize;
    let mut pow_ = 1;
    while pow_ <= l as i64 {
        pow_ *= 2;
        r += 1;
    }
    let mut g = vec![vec![]; r];
    let mut cnt = 0;
    for i in 0..r - 1 {
        g[i].push((i + 1, 0));
        g[i].push((i + 1, 1 << i));
        cnt += 2;
    }

    let mut l_ = 1 << (r - 1);
    for t in (0..r - 1).rev() {
        if l >> t & 1 == 1 {
            g[t].push((r - 1, l_));
            cnt += 1;
            l_ += 1 << t;
        }
    }

    println!("{} {}", r, cnt);
    for i in 0..r {
        for &(j, len_) in &g[i] {
            println!("{} {} {}", i + 1, j + 1, len_)
        }
    }
}


Measured memory_bytes: 4352
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int N,ans=0;

int main(){
    cin>>N;
    rep(i,N){
        if(i+1<10)ans++;
        else{
            if(i+1<100)continue;
            else{
                if(i+1<1000)ans++;
                else{
                    if(i+1<10000)continue;
                    else{
                        if(i+1<100000)ans++;
                        else continue;
                    }
                }
            }
        }
    }
    out(ans);
    
    
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
def main():
    N, W = map(int, input().split())
    L = [list(map(int, input().split())) for i in range(N)]
    #もらうDP i+1が i番目を検討した結果を示す
    V = [[0]*(W+1) for i in range(N+1)]

    for i in range(N):
        w, v = L[i]
        for s in range(W+1):
            if s-w >=0:
                #選んだあとの価値
                V[i+1][s] = max(V[i+1][s], V[i][s-w] + v)
            # 選ばないときと比較
            V[i+1][s] = max(V[i+1][s], V[i][s])
    print(V[N][W])

if __name__ == '__main__':
    main()

Measured memory_bytes: 147692
using System;

namespace kekW
{
    internal static class Program
    {
        private static void Main()
        {
            var nbrs = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            var x = nbrs[0];
            var y = nbrs[1];
            int res = 0;

            while(x != y)
            {
                if(x < y)
                {
                    if (-x - y > x - y && -x <= y)
                    {
                        x = -x;
                        res++;
                    }
                    else if(x < 0 && y > 0)
                    {
                        int temp = y - x - y * 2;
                        x += temp;
                        res += temp;
                    }
                    else
                    {
                        int temp = y - x;
                        x += temp;
                        res += temp;
                    }
                }
                else
                {
                    if (-x >= y && x < 0 || -x == y || Math.Abs(y) - x <= 0)
                    {
                        x = -x;
                        res++;
                    }
                    else
                    {
                        int temp = Math.Abs(y) - x;
                        x += temp;
                        res += temp;
                    }
                }
            }

            Console.WriteLine(res);
        }
    }
}

Measured memory_bytes: 17768
#include <iostream>
#include <string>
#include <cstring>
#include <iomanip>
#include <algorithm>
#include <cmath>
using namespace std;

int main()
{
    int a,b,c,d;
    while (cin>> a >> b >> c >> d)
    {
        if (abs(c-a)<=d)cout << "Yes" <<endl;
        else if (abs(a-b)<=d&&abs(b-c)<=d)cout << "Yes" <<endl;
        else cout << "No" <<endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
char s1[maxn], s2[maxn];
int dp[maxn][26];
typedef long long ll;
int main() {
	scanf("%s%s", s1 + 1, s2 + 1);
	memset(dp, -1, sizeof(dp)); 
	int n = strlen(s1 + 1);
	int m = strlen(s2 + 1);
	for (int i = n; i >= 1; i--) {
		for (int j = 0; j < 26; j++) {
			dp[i][j] = dp[i + 1][j];
		}
		dp[i][s1[i] - 'a'] = i;
	}
	ll ans = 0;
	int start = 1;
	int flag = 0;
	for (int i = 1; i <= m; i++) {
		if (dp[start][s2[i] - 'a'] != -1) {
			ans += dp[start][s2[i] - 'a'] - start + 1;
			if (dp[start][s2[i] - 'a'] == n) {
				start = 1;
			} else {
				start = dp[start][s2[i] - 'a'] + 1;
			}
			
		} else if (dp[1][s2[i] - 'a'] != -1){
			ans += n - start + 1;
			ans += dp[1][s2[i] - 'a'];
			if (dp[1][s2[i] - 'a'] == n) {
				start = 1;
			} else {
				start = dp[1][s2[i] - 'a'] + 1;
			}
			
		} else {
			flag = 1; break;
		}
	}
	if (!flag) {
		printf("%lld\n", ans);
	} else {
		printf("-1\n");
	}
	return 0;
}

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

int main() {
  int N = 0, count = 0;
  cin >> N;
  int array[N];
  bool flg = true;
  
  for(int i = 0; i < N; i++){
    cin >> array[i];
  }
  
  while(flg){
    for(int i = 0; i < N; i++){
      if(array[i] % 2 == 0){
        array[i] /= 2;
      }
      else{
        flg = false;
        break;
      }
    }
    
    if(flg){
      count++;
    }
  }
  
  cout << count << endl;
}


Measured memory_bytes: 256
def gcd_core(a, b):
    if b == 0:
        return a
    else:
        return gcd_core(b, a % b)


def gcd(arr):
    g = gcd_core(arr[0], arr[1])
    for i in range(2, len(arr)):
        g = gcd_core(g, arr[i])
    return g

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

ma = 0
ct = 0
for a in arr:
    if ma <= a:
        ma = a
        ct +=1

print(ct)










Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S=sc.next();
        final String a="CODEFESTIVAL2016";
        int count = 0;
        for(int i=0;i<16;i++){
            if(S.charAt(i)!=a.charAt(i)){
                count++;
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 9680
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
int a,b,c;
  cin >> a >>b >>c;
  int d = a*100 + b*10+c;
  if (d %4 == 0) cout <<"YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// copy ...
typedef long long ll;
const int N = 3054, mod = 1000000007, iv2 = (mod + 1) / 2;
int n, q;
int a[N], f[N][N];
ll PowerMod(ll a, int n, ll c = 1) {for (; n; n >>= 1, a = a * a % mod) if (n & 1) c = c * a % mod; return c;}
inline int half(int x) {return x = (x >> 1) + (-(x & 1) & (iv2 - mod)), x + (x >> 31 & mod);}
int main() {
	int i, j, u, v; ll I = 0;
	scanf("%d%d", &n, &q);
	for (i = 1; i <= n; ++i) scanf("%d", a + i);
	for (i = 1; i <= n; ++i)
		for (j = 1; j <= n; ++j)
			f[i][j] = a[i] > a[j];
	for (i = 0; i < q; ++i) {
		scanf("%d%d", &u, &v), f[u][v] = f[v][u] = half(f[u][v] + f[v][u]);
		for (j = 1; j <= n; ++j) if (j != u && j != v)
			f[u][j] = f[v][j] = half(f[u][j] + f[v][j]),
			f[j][u] = f[j][v] = half(f[j][u] + f[j][v]);
	}
	for (i = 1; i <= n; ++i) I += std::accumulate(f[i] + i, f[i] + (n + 1), 0ll);
	printf("%d\n", (int)PowerMod(2, q, I % mod));
	return 0;
}

Measured memory_bytes: 39608
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

main() {
    int64_t n;
    cin >> n;

    int64_t prev = -1;
    for (auto i : irange(0L, n)) {
        int64_t h;
        cin >> h;

        if (h < prev) {
            cout << "No" << endl;
            return 0;
        } else if (h == prev) {
            continue;
        } else {
            prev = h - 1;
        }
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
const int maxn = 300010;

int op(int a, int b)
{
  return max(a, b);
}

int e()
{
  return 0;
}

int main()
{
  int n, k;
  cin >> n >> k;
  int res = 0;
  atcoder::segtree<int, op, e> seg(maxn);
  for (int i = 0; i < n; i++)
  {
    int a;
    cin >> a;
    int tmp = seg.prod(max(0, a - k), min(maxn, a + k + 1)) + 1;
    res = max(res, tmp);
    seg.set(a, tmp);
  }
  cout << res << endl;
}

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

int main(){
  string s,t;
  cin>> s >> t;
  
  int n=s.size();
  unordered_map<char,set<int>> m;
  for (int i=0; i<n; i++) m[s[i]].insert(i+1);
  
  int64_t count=0;
  int p=0;
  bool pos=true;
  for (auto c: t){
    if (!m.count(c)){
      pos=false;
      break;
    }
    if (*rbegin(m[c]) <= p){
      p=*begin(m[c]);
      count++;
    }
    else p=*m[c].upper_bound(p); //多分ここ
  }
  
  int64_t ans=-1;
  if (pos) ans=n*count+p;
  cout<< ans <<endl;
}

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

using namespace std;

int main(int, char**) {
        string b = "ABC";
        string r = "ARC";
        string s;
        cin >> s;
        if (s==b) {
                cout << r << endl;
        } else {
                cout << b << endl;
        }
        return 0;
}


Measured memory_bytes: 3600
def solve():
    X, Y = map(int, input().split())

    for n_cranes in range(X+1):
        n_turtles = X - n_cranes

        if n_cranes * 4 + n_turtles * 2 == Y:
            return 'Yes'

    return 'No'


def main():
    print(solve())


if __name__ == "__main__":
    main()


Measured memory_bytes: 9160
import sys
from collections import Counter

readline = sys.stdin.readline
n = int(readline())
xy = [list(map(int, readline().split())) for _ in range(n)]

d = []
for i in range(n-1):
    for j in range(i+1, n):
        p = xy[i][0] - xy[j][0]
        q = xy[i][1] - xy[j][1]
        d.append((p, q))
        d.append((-p, -q))

if n > 1:
    ans = n - max(Counter(d).values())
else:
    ans = 1

print(ans)


Measured memory_bytes: 3828
import std.stdio;
import std.algorithm;
import std.conv;
import std.math;
import std.string;

void main() {
    auto n = readln.chomp.to!(ulong);
    auto t = readln.split.to!(ulong[]);
    sort(t);

    foreach (i, e; t) {
        if (e != i + i % 2 && n % 2 == 1) {
            0.writeln;
            return;
        }
        if (e != i + !(i % 2) && n % 2 == 0) {
            0.writeln;
            return;
        }
    }
    ulong ans = 1;
    foreach(i; 0..n / 2)
        ans = (ans * 2) % 1000000007;
    ans.writeln;
}


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

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

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

    // 後ろから解くかわりにすべての文字列を「左右反転」する
    reverse(S.begin(), S.end());
    for (int i = 0; i < 4; ++i) reverse(divide[i].begin(), divide[i].end());

    // 端から切っていく
    bool can = true;
    for (int i = 0; i < S.size();) {
        bool can2 = false; // 4 個の文字列たちどれかで divide できるか
        for (int j = 0; j < 4; ++j) {
            string d = divide[j];
            if (S.substr(i, d.size()) == d) { // d で divide できるか
                can2 = true;
                i += d.size(); // divide できたら i を進める
                break;
            }
        }
        if (!can2) { // divide できなかったら
            can = false;
            break;
        }
    }

    if (can) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 3760
// D - Patisserie ABC
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define up(i,s,e,d) for(int i=(s);i<(e);i+=(d))

int main(){
	int N,M; cin>>N>>M;
	vector<ll> X(N),Y(N),Z(N), S(N);
	rp(i, 0, N) cin>>X[i]>>Y[i]>>Z[i];
	ll ans = 0;
	up(x,-1,2,2) up(y,-1,2,2) up(z,-1,2,2){
		rp(i, 0, N) S[i] = X[i]*x + Y[i]*y + Z[i]*z;
		sort(S.rbegin(), S.rend());
		ll s = 0; rp(i, 0, M) s += S[i];
		ans = max(ans, s);
	}
	cout<< ans <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,i,l=0,r=0,cnt=0;
	cin>>n;
	int ara[n];
	for(i=0;i<n;i++){
		cin>>ara[i];
	}
	while(1){
		l=0;
		for(i=0;i<n;i++){
			if(ara[i]!=0&&(l==0||i==0)){
				l=i;
				break;
			}
		}
		if(i==n){
			break;
		}
		for(i=l;i<n;i++){
			if(ara[i]==0){
				break;
			}
			ara[i]--;
		}
		cnt++;

	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define inf 20021225
#define ll long long
#define mdn 1000000007
using namespace std;

int f[4100][4100],inv2;
int fac[8100],inv[8100];
int n,a[200010],b[200010];

int ksm(int bs,int mi)
{
	int ans=1;
	while(mi)
	{
		if(mi&1)	ans=(ll)ans*bs%mdn;
		bs=(ll)bs*bs%mdn; mi>>=1;
	}
	return ans;
}

int C(int x,int y)
{
	if(x<y)	return 0;
	return (ll) fac[x] * inv[x-y] %mdn *inv[y]%mdn;
}
bool vis[4100][4100];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)	scanf("%d%d",&a[i],&b[i]),f[2001-a[i]][2001-b[i]]+=1;
	fac[0]=inv[0]=1; inv2=ksm(2,mdn-2);
	for(int i=1;i<=8001;i++)	fac[i]=(ll)fac[i-1]*i%mdn;
	inv[8001]=ksm(fac[8001],mdn-2);
	for(int i=8000;i;i--)	inv[i]=(ll)inv[i+1]*(i+1)%mdn;
	for(int i=1;i<=4001;i++)
		for(int j=1;j<=4001;j++)
			f[i][j]+=f[i-1][j]+f[i][j-1],f[i][j]%=mdn;
	int mns=0,add=0;
	for(int i=1;i<=n;i++)
		mns = ((ll)mns + C(2*(a[i]+b[i]),2*a[i]))%mdn , add = ((ll)add + f[2001+a[i]][2001+b[i]])%mdn;
	//printf("%d %d %d\n",a[i],b[i],f[2001+a[i]][2001+b[i]]);
	add -= mns; if(add<0)	add+=mdn;
	//printf("%d\n",mns);
	printf("%d\n",(ll)add*inv2%mdn);
	return 0;
}

Measured memory_bytes: 65920
#include <iostream>
#include <string>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;

int main(){
	/*input*/
	int a, b;	cin >> a >> b;
	string s;	cin >> s;
	/*calculation*/
	bool flag[3] = {false};	//true:Yes false:No
	rep(i, a + b + 1){
		if(i >= 0 && i < a){
			if(s[i] - '0' >= 0 && s[i] - '0' <= 9)flag[0] = true;
		}else if(i == a){
			if(s[i] == '-')flag[1] = true;
		}else{
			if(s[i] - '0' >= 0 && s[i] - '0' <= 9)flag[2] = true;
		}
	}
	/*output*/
	if(flag[0] && flag[1] && flag[2]){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}


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

int main() {
  char a,b;
  cin >> a >> b;
  if (a > b) {
    cout << ">" << endl;
  } else if (a < b) {
    cout << "<" << endl;
  } else {
    cout << "=" << endl;
  }
  
}

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

class Program
{
    static void Main()
    {
        var seq = Console.ReadLine().Split().Select(int.Parse).OrderBy(x => x).ToArray();
        if (seq[0] == 5 && seq[1] == 5 && seq[2] == 7)
        {
            Console.WriteLine("YES");
        }
        else
        {
            Console.WriteLine("NO");
        }
    }
}

Measured memory_bytes: 13396
#include<iostream>
using namespace std;
typedef long long ll;
ll f(ll a,ll b){
    ll c=a^b;
    return c;
}
void Solve(){
    ll n,m;
    cin>>n>>m;
    ll res=m-n+1;
    int tmp=res%4;
    if(m==n) cout<<m<<endl;
    else if(tmp==0){
        if(n%2==0&&m%2==1) cout<<0<<endl;
        else cout<<f(1,f(n,m))<<endl;
    }
    else if(tmp==1){
        if(n%2==0&&m%2==0) cout<<m<<endl;
        else cout<<n<<endl;
    }
    else if(tmp==2){
        if(n%2==0&&m%2==1) cout<<1<<endl;
        else cout<<f(n,m)<<endl;
    }
    else if(tmp==3){
        if(n%2==0&&m%2==0) cout<<f(1,m)<<endl;
        else cout<<f(1,n)<<endl; 
    }
}
int main(){
    Solve();
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main(){
  int n,a,f,ans=0;
  cin>>n;
  while(n--){
    cin>>a;
    f=0;
    for(int i=2;i*i<=a;i++)
      if(!(a%i))f=1;
    if(!f)ans++;
  }
  cout<<ans<<endl;
  return 0;
}

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

int main() {
  int A, B;
  cin >> A >> B;
  if (13 <= A)
    cout << B << endl;
  else if (5 >= A)
    cout << 0 << endl;
  else if (6 <= A <= 12)
    cout << B / 2 << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import fractions

N = int(input().rstrip())
A = [0] + list(map(int, input().rstrip().split())) + [0]

L = [0] * (N + 2)
R = [0] * (N + 2)

for i in range(0, N):
    L[i + 1] = fractions.gcd(L[i], A[i + 1])

for i in range(N, 0, -1):
    R[i] = fractions.gcd(R[i + 1], A[i])

print(max(fractions.gcd(L[i], R[i + 2]) for i in range(0, N)))

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


int main() {
    char x, y, ans;
    cin >> x >> y;

    if ( x < y ) {
        ans = '<';
    }
    else if ( x > y ) {
        ans = '>';
    }
    else {
        ans = '=';
    }

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



Measured memory_bytes: 888
using System;
using System.Collections.Generic;
using System.Windows;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    public class Program
    {
        static void Main(string[] args)
        {
            var n = Read().ToLong();
            var dic = new Dictionary<string, long>();
            for (int i = 0; i < n; i++)
            {
                var s = Read();
                if (!dic.ContainsKey(s))
                {
                    dic.Add(s, 1);
                }
            }
            WriteRead(dic.Count);
        }

        public static string Read()
        {
            return Console.ReadLine();
        }

        public static string[] ReadSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        public static void WriteRead(object str)
        {
            Console.WriteLine(str);
            Read();
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
        }

        private static bool ChangeMin<T>(ref T a, T b) where T : IComparable
        {
            if (a.CompareTo(b) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }

        private static bool ChangekMax<T>(ref T a, T b) where T : IComparable
        {
            if (b.CompareTo(a) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }
    }
}


public static class Extentions
{
    public static int ToInt32(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static long ToLong(this object obj)
    {
        return long.Parse(obj.ToString());
    }

    public static decimal ToDecimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double ToDouble(this object obj)
    {
        return double.Parse(obj.ToString());
    }

    public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key) where T2 : struct
    {
        T2 value;
        if (d.TryGetValue(key, out value))
        {
            return value;
        }
        return new T2();
    }
}



Measured memory_bytes: 45456
#include <math.h>

#include <algorithm>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;

int main() {
  ll a;
  long double b;
  cin >> a >> b;
  long double ans = floor(a * b);
  cout << (ll)ans;
  return 0;
}


Measured memory_bytes: 3732
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <limits>
#include <math.h>
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define RREP(i,n) for(int i=(n)-1; i>=0; --i)
#define SREP(i,s,n) for(int i=(s), i##_len=(n); i<i##_len; ++i)


using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    if (b == 1) return 1;
    T r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

bool comp(pair<ll, ll> a, pair<ll, ll> b) {
    return (a.first*a.first + a.second*a.second) > (b.first*b.first + b.second*b.second);
}

struct UnionFind {
    vector<int> par;
    vector<int> rank;
    
    UnionFind(int n = 1) {
        init(n);
    }
    
    void init(int n = 1) {
        par.resize(n); rank.resize(n);
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            rank[i] = 0;
        }
    }
    
    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        return true;
    }
};

#define MOD (1000000007)


int main(int argc, const char * argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N;
    cin >> N;
    vector<pair<ll, ll>> p(N);
    REP(i, N) {
        cin >> p[i].first;
        p[i].second = i;
    }
    sort(p.begin(), p.end());
    vector<ll> A(N), B(N);
    A[0] = p[0].second;
    SREP(i, 1, N) {
        if (p[i-1].second < p[i].second) {
            A[i] = A[i-1]+ p[i].second - p[i-1].second + 1;
            B[i] = p[i].second - A[i];
        } else {
            B[i] = B[i-1]+ p[i].second - p[i-1].second - 1;
            A[i] = p[i].second - B[i];
        }
    }
    
    REP(i, N) {
        cout << A[i] - A[0] + 1 << " ";
    }
    cout << endl;
    REP(i, N) {
        cout << B[i] - B[N-1] + 1 << " ";
    }
    cout << endl;
}


Measured memory_bytes: 1280
n = gets.split.map(&:to_i)
ary = gets.split.map(&:to_i)
ary_new = []
ary.each_with_index do |a, index|
  if(index % 2 == 0)
    ary_new.push(a)
  end
end
ans = ary_new.delete_if { |n| n.even? }
puts ans.size

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

using namespace std;

#define vi vector<int>
#define pb push_back
#define ll long long
#define qi queue<int>
#define vll vector<long long>
#define si set<int>
#define mi map<int,int>
#define mod %
#define pow ^
#define frt(i,a,b) for(int i=a;i<b;i++)
#define fre(i,a,b) for(int i=a;i<=b;i++)
#define pair_int pair<int,int>
#define pair_ll pair<ll,ll>
#define pq priority_queue
#define N 200007


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

   int n;
   cin >> n;
   int a[n+1];
   int b[n+1];
   int c[n+1];

   for (int i = 0; i < n; ++i)
   {
   	   cin >> a[i+1];
   	   cin >> b[i+1];
   	   cin >> c[i+1];
   }

   int dp[n+1][3];
   dp[1][1] = a[1];
   dp[1][2] = b[1];
   dp[1][3] = c[1];

   for(int i=2;i<=n;i++)
   {
   	  dp[i][1] = max(dp[i-1][2],dp[i-1][3]) + a[i];
   	  dp[i][2] = max(dp[i-1][1],dp[i-1][3]) + b[i];
   	  dp[i][3] = max(dp[i-1][1],dp[i-1][2]) + c[i];
   }

   cout << max(max(dp[n][1],dp[n][2]),dp[n][3]) << endl; 
   return 0;
}


  


Measured memory_bytes: 2560
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
    int arr[3];
    scanf("%d%d%d",&arr[0],&arr[1],&arr[2]);
    sort(arr,arr+3);
    if(arr[2]==arr[0]+arr[1])
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) for (auto i = mp.begin(); i != mp.end(); ++i) { cout << i->first <<":"<<i->second << endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    sort(ALL(s));
    if(s[0]==s[1]&&s[1]!=s[2]&&s[2]==s[3]){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

    return  0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
const (
	GRAY = iota
	BROWN
	GREEN
	SKYBLUE
	BLUE
	YELLOW
	ORANGE
	RED
	FREE
)

func main() {
	defer stdout.Flush()

	N := readInt()
	m := make(map[int]bool)
	var nrFree int
	for i := 0; i < N; i++ {
		c := readInt()
		switch {
		case c < 400:
			m[GRAY] = true
		case c < 800:
			m[BROWN] = true
		case c < 1200:
			m[GREEN] = true
		case c < 1600:
			m[SKYBLUE] = true
		case c < 2000:
			m[BLUE] = true
		case c < 2400:
			m[YELLOW] = true
		case c < 2800:
			m[ORANGE] = true
		case c < 3200:
			m[RED] = true
		default:
			nrFree++
		}
	}
	min := maxInt(1, len(m))
	max := len(m) + nrFree
	println(min, max)

}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long int
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;

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

    ll p[n],x,ans=0;
    for(ll i=0;i<n;i++)
    	{
    		cin>>x;
    		x--;
    		p[x]=i;
    	}
    
  multiset<ll> s;
  s.insert(-1);
  s.insert(-1);
  s.insert(n);
  s.insert(n);

  for(ll i=n-1;i>=0;i--)
  {
  	s.insert(p[i]);
    auto it=s.find(p[i]);

    it--;
   ll a=*(it);
    it--;
    ll b=*(it);
    it++;
    it++;
    it++;
    ll x=*(it);
    it++;
    ll y=*(it);

  	ans=ans+((a-b)*(x-p[i]) +(p[i]-a)*(y-x))*(i+1);
  }
  cout<<ans<<endl;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long

int main() {
    fastio;
    int n;
    cin >> n;
    double* a = new double[n];

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

    sort(a, a + n);
    double ans = (a[0]+a[1])/2;

    for(int i = 2; i < n; ++i) {
        ans = (ans + a[i]) / 2;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <tuple>
#include <vector>

using namespace std;

int A[2][101] = {0};

int main() {
    int N;

    cin >> N;

    for (int i = 0; i < N; i++) {
        cin >> A[0][i];
    }
    for (int i = 0; i < N; i++) {
        cin >> A[1][i];
    }

    int sum;
    int max = 0;
    for (int i = 0; i < N; i++) {
        sum = 0;
        for (int j = 0; j <= i; j++) {
            sum += A[0][j];
        }
        for (int j = i; j < N; j++) {
            sum += A[1][j];
        }
        if (sum > max) {
            max = sum;
        }
    }

    cout << max << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<bitset>
#include<sstream>
#include<cmath>

int main(){
	int N, K;

	std::cin >> N >> K;

	if(K*2-1<=N) std::cout << "YES" << std::endl;
	else std::cout << "NO" << std::endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD=1000000007;

int main() {
    ll X; cin>>X;
    ll count=1;
    ll ct=0;
    for(ll i=1;i<=X;i++){
        ct++;
        if(i==X)break;
        if(ct == count){
            count++;
            ct=0;
        }
    }
    cout<<count;
    return 0;
}

Measured memory_bytes: 256