akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
    int A,B,C,X;

    if (scanf("%d %d %d", &A, &B, &X) < 3)
    {
        exit(1);
    }

    C = A + B;

    if (1 <= A && A <= 100 && 1 <= B && B <= 100 && 1 <= X && X <= 200)
    {
        if(A <= X && X <= C){
            printf("YES\n");
        }else{
            printf("NO\n");
        }
    }
    return 0;
}

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

#define int long long
#define fi first
#define se second
#define pb push_back
#define ins insert
#define er erase

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;

const int oo = 1e18 + 7, mod = 1e9 + 7;

int n;
long double cur = 100;

signed main(){
	ios_base::sync_with_stdio(0);
	cin >> n;
	for(int i = 1; i <= 4000; i++){
		int tmp = cur/100;
		cur += tmp;
		if(cur >= n){
			//cout << cur << "\n";
			cout << i;
			return 0;
		}
	}
}

/*
TEST HERE
INPUT #1
103
OUTPUT #1
3
INPUT #2
1000000000000000000
OUTPUT #2
3760
INPUT #3
1333333333
OUTPUT #3
1706
*/


Measured memory_bytes: 3644
#include <stdio.h>
#include <queue>
using namespace std;

void hukasa(int,int,int);

int map[102][102];		//数値変換した果樹園のマップ
int ty[4] = {1,-1,0,0},tx[4] = {0,0,1,-1};	//四方向の移動量

int main()
{
	char in[101];			//入力文字列
	int y,x;				//果樹園の大きさh,w
	int i,j,r;				//ループ用変数
	int temp;				//作業用

	scanf("%d%d",&y,&x);
	
	while(y != 0 && x != 0){
		//初期化
		for(i = 0; i <= y+1; i++){
			map[0][i] = 0;
			map[x+1][i] = 0;
		}
		for(i = 0; i <= x+1; i++){
			map[i][0] = 0;
			map[i][y+1] = 0;
		}
		
		//入力
		for(j = 1; j <= y; j++){
			scanf("%s",in);
			//マップの数値化
			//しなくてもいいけど私はこうした方が分かり易いのでやる
			for(i = 1; i <= x; i++){
				if(in[i-1] == '#'){
					map[i][j] = -1;
				}
				else if(in[i-1] == '*'){
					map[i][j] = -2;
				}
				else if(in[i-1] == '@'){
					map[i][j] = -3;
				}
			}
		}
		
		//連続した部分の探索
		int c = 0;	//c:連続した区間の数
		for(j = 1; j <= y; j++){
			for(i = 1; i <= x; i++){
				if(map[i][j] < 0){
					//printf("現在地:%d,%d\n",i,j);
					c++;
					hukasa(i,j,map[i][j]);
				}
			}
		}
		
		/*デバッグ用出力:mapの出力
		for(i = 0; i <= y+1; i++){
			for(j = 0; j <= x+1; j++){
				printf("%2d",map[j][i]);
			}
			printf("\n");
		}*/

		printf("%d\n",c);


		scanf("%d%d",&y,&x);
	}

	return 0;
}

//深さ優先探索関数
//nx:現在地のx座標  ny:現在地のy座標  c:果実の種類
void hukasa(int nx,int ny,int c)
{
	int i,j;

	//現在地は探索済みなので
	//マップを壁に変えて重複して探索しないようにする
	map[nx][ny] = 0;

	//4方向を調べる
	for(i = 0; i < 4; i++){
		//もし果実の種類が同じなら移動
		if(map[nx + tx[i]][ny + ty[i]] == c){
			hukasa(nx + tx[i],ny + ty[i],c);
		}
	}

	return;
}

Measured memory_bytes: 1540
#include <algorithm>
#include <cstdio>
#include <vector>
#define pb push_back
std::vector<int> adj_r[200005], adj_b[200005];
int pa[200005], dep[200005], ans;
void init(int u, int fa = -1)
{
	pa[u] = fa;
	for (int v : adj_b[u])
	{
		if (v != fa)
		{
			dep[v] = dep[u] + 1;
			init(v, u);
		}
	}
}
inline bool chk(int u, int v)
{
	if (dep[u] < dep[v])
		std::swap(u, v);
	for (int i = 0; i < 2 && u != v; i++)
	{
		if (dep[u] < dep[v])
			v = pa[v];
		else
			u = pa[u];
	}
	return u == v;
}
void dfs(int u, int len = 0, int fa = -1)
{
	ans = std::max(ans, dep[u]);
	if (dep[u] <= len)
		return;
	for (int v : adj_r[u])
	{
		if (v == fa)
			continue;
		if (!chk(u, v))
			throw false;
		dfs(v, len + 1, u);
	}
}
int main()
{
	int n, x, y;
	scanf("%d%d%d", &n, &x, &y);
	for (int i = 1; i < n; i++)
	{
		int u, v;
		scanf("%d%d", &u, &v);
		adj_r[--u].pb(--v);
		adj_r[v].pb(u);
	}
	for (int i = 1; i < n; i++)
	{
		int u, v;
		scanf("%d%d", &u, &v);
		adj_b[--u].pb(--v);
		adj_b[v].pb(u);
	}
	init(--y);
	try
	{
		dfs(--x);
		printf("%d\n", ans << 1);
	}
	catch (...)
	{
		puts("-1");
	}
	return 0;
}


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

bool check(const string& S) {
  if (S.size() % 2 == 1) {
    return false;
  }
  string head = S.substr(0, S.size() / 2);
  string tail = S.substr(S.size() / 2);
  return head == tail;
}

int main() {
  string S;
  cin >> S;
  do {
    S.pop_back();
  } while (!check(S));
  cout << S.size() << endl;
}


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

int main()
{
  string s,t;
  cin >> s;
  cin >> t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end(),greater<int>());
  if(s < t) cout << "Yes" <<endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)
	ans := 0
	if strings.Contains(s, "RRR") {
		ans = 3
	} else if strings.Contains(s, "RR") {
		ans = 2
	} else if strings.Contains(s, "R") {
		ans = 1
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1836
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
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 gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}



int main(void)
{
    ll n,m;
    cin >> n >> m;
    vector<ll> a(m);
    vector<ll> range(m+1);
    ll mod = 1e9+7;

    REP(i,m){
        cin >> a[i];
    }

    if(m != 0){
        range[0] = a[0] - 1;
        range[m] = n - a[m-1] -1;
    }
    else{
        range[0] = n;
    }


    REP(i,m-1){
        if(a[i+1]-a[i] == 1){
            cout << 0 << endl;
            return 0;
        }
    }
    FOR(i,1,m){
        range[i] = a[i] - a[i-1] - 2;
    }

    ll max = *max_element(all(range));

    vector<ll> mod_kaijo(max + 1);
    mod_kaijo[0] = 1;

    FOR(i,1,max+1){
        mod_kaijo[i] = ((i%mod) * mod_kaijo[i-1])%mod;
    }

    ll ans = 1;
    REP(i,range.size()){
        ll sum = 0;
        for(ll j = 0;j <= range[i]/2;j++){
            sum = (sum + (mod_kaijo[range[i]-j]*modinv((mod_kaijo[range[i]-2*j]*mod_kaijo[j])%mod,mod))%mod)%mod;
        }
        ans = (ans * sum)%mod;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#pragma GCC optimize(2)
#include <bits/stdc++.h>

using namespace std;
 
typedef long long ll;
typedef pair<int,int> pii;

 
#define MP make_pair
#define INF 0x3f3f3f3f
#define closeSync ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, a, n) for (int i=(a); i<=(n); i++)
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>void debug_out(Head H, Tail... T) { cerr << " " << to_string(H);    debug_out(T...);}
 
set<pii> s;
set<pii> t;
int main()
{closeSync;
#ifdef DEBUG
	//freopen("C:/Users/86159/Desktop/input.txt", "r", stdin);
	//freopen("C:/Users/86159/Desktop/output.txt", "w", stdout);
#endif
	//clock_t c1 = clock();
	int h,w;
	cin>>h>>w;
	rep (i,1,w)
	{
		s.insert(MP(i,0));	
		t.insert(MP(0,i));
	}
	rep (i,1,h)
	{
		int a,b;
		cin>>a>>b;
		auto l = s.lower_bound(MP(a,-1));
		auto r = s.upper_bound(MP(b,INF));
		int d = w;   // d代表右移几步 , b 代表右移后离左边的距离
 		while (l!=r)
		{
			auto [x, y] = *l;
			//debug(x,y);
			d = min(d,(b + 1) - (x - y));
			//debug(d,(b + 1) - (x - y));
			l = s.erase(l);
			t.erase(MP(y,x));
		}
		if ( d < w && b < w)
		{
			//debug(b,d);
			s.insert(MP(b + 1,d)),t.insert(MP(d,b + 1));
		}
		int ans = -1;
		if (!t.empty())
			ans = i  + t.begin()->first;
		cout<<ans<<endl;
	}	
	//cerr << "Time:" << clock() - c1 << "ms" <<endl;
    return 0;
}

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

#define ll long long
#define vi vector<long long>
#define r(i, a) for(int i=0; i<a; i++)
#define re(i, a, b) for(int i=a; i<b; i++)
#define inp(a,b) cin>>a>>b
#define in(a) cin>>t
#define pb push_back
#define mod 1000000007
#define ma unordered_map<long long>
//
//class node{
//    public:
//    ll data;
//    node *left;
//    node *right;
//    node (ll val){
//        data=val;
//        left = right = NULL;
//    }
//    
//};
//
//node *insert(ll val, node *root){
//    if(root==NULL){
//        return new node(val);
//    }
//    else if(val>root->data){
//        root->right = insert(val, root->right); 
//    }
//    else if(val<=root->data){
//        root->left = insert(val, root->left);
//    }
//}
//
//void inorder(node *root){
//    if(root!=NULL){
//        inorder(root->left);
//        cout<<root->data<<" ";
//        inorder(root->right);
//    }
//}
//
//
//ll findheight(node *root){
//    if(root==NULL)
//        return 0;
//    ll l=0,r=0;
//    if(root->left!=NULL) l=findheight(root->left);
//    if(root->right!=NULL) r=findheight(root->right);
//    return max(l,r)+1;
//}

//ll n;








void func(){ 
    ll n;
    cin>>n;
    cout<<n+(n*n)+(n*n*n)<<endl;

}

int main(){

ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);

//sieve();

//int t;
//cin >> t;
//for(ll i=1; i<=t; i++)
//{
    
    func();
//    cout<<endl;
//cout<<func()<<endl;

//if(func())
//    cout<<"Yes"<< endl;
//else
//    cout <<"No"<<endl; 
//cout<<"Case:"<<i<<" "<<     <<endl;
//}
return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define endl '\n'

using namespace std;

int n, m, d, x;
map<int, int> f;

int main() {
    ios_base::sync_with_stdio(0);
    
    cin >> n >> m;

    for(int i=0; i < m; ++i) {
        cin >> d;
        for(int i=0; i < d; ++i) {
            cin >> x;
            f[x] = 1;
        }
    }

    cout << (n - f.size()) << endl;

    return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define REVERSE(a) reverse(ALL(a))
#define MOD 1000000007
using namespace std;
typedef long long ll;
//vector<vector<int>> vec(i, vector<int>(j));

vector<int> input(int N) {
    vector<int> vec(N);
    for (int i = 0; i < N; i++) {
        cin >> vec.at(i);
    }
    return vec;
}

void Main() {
    ll n;
    int max;
    bool flag=true;
    map<ll,int> sq;
    cin >> n;
    for (int i = 0; i < 31630; i++)
    {
        ll cnt=i*i;
        sq[cnt]=i;
    }
    while (flag)
    {
        if(sq.count(n)){
            cout <<n<<endl;
            flag=false;
        }else{
            n--;
            continue;
        }
    }
    
}

int main() {
	Main();
	return 0;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define range(i,l,h) for(int i=l;i<h;i++)
#define endl '\n'
#define I INT_MAX
#define L INT_MIN
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vi vector<int>
using namespace std;
using std::ios;
constexpr int MOD=1e9+7;
constexpr int mod=998244353;

int main()
{
  fastio;

  string s,t;
  cin>>s>>t;

  int c=0;
  for(int i=0;i<s.size();i++)
  {
    if(s[i]!=t[i])c++;
  }
  cout<<c;

}


Measured memory_bytes: 3796
# -*- coding: utf-8 -*-

## Library

import sys
from fractions import gcd
import math
from math import ceil,floor
import collections

## input

# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]

N = int(input())
D = [int(input()) for _ in range(N)]

## Logic

print(len(set(D)))



Measured memory_bytes: 63980
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define REP(i,n,m) for(int i = (n); i < (m); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

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


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

	int n, x; cin >> n >> x;
	vector<int> a(n); rep(i,n) cin>>a[i];
	
	ll ans = 0;
	rep(i, n-1) {
	  if (a[i]+a[i+1] > x) {
			int d = a[i] + a[i + 1] - x;
		  a[i+1] -= d; 
			ans += (ll) d;
		}
		chmax(a[i+1], 0);
	}

	cout << ans << endl;
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vi v(n);
	REP(i, n)cin >> v[i];
	int p = -1;
	vi a;
	vi ans;
	REP(i, n) {
		if (v[i] == 2)ans.push_back(i);
		if (v[i] == -2)a.push_back(i);
		if (v[i] == -1 && p == -1)p = i;
	
	}
	if (a.size() % 2 == 1) {
		if (p != -1) {
			REP(i, a.size())ans.push_back(a[i]);
			ans.push_back(p);
		}
		else {
			REP(i, a.size() - 1)ans.push_back(a[i]);
		}
	}
	else {
		REP(i, a.size())ans.push_back(a[i]);
	}
	sort(ALL(ans));
	cout << ans.size() << endl;
	REP(i, ans.size()) {
		cout << ans[i]+1 << endl;
	}
	
}



Measured memory_bytes: 3224
#define _USE_MATH_DEFINES 
#include <iomanip> 
#include <cmath>  
#include<iostream>
#include <fstream>
#include<vector>
#include<algorithm>
#include<bitset>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl

ll N, K, ans = 4 * 1000000000000000000 + 10;
ll x[55], y[55], Psum[55][55];
map<ll, ll> Pmap;//Pmap[x]=y

ll calcPsum(ll x1, ll x2, ll y1, ll y2) {
	if (x1 == 0 && y1 == 0) return Psum[x2][y2];
	else if (x1 == 0) return Psum[x2][y2] - Psum[x2][y1 - 1];
	else if (y1 == 0) return Psum[x2][y2] - Psum[x1 - 1][y2];
	else return Psum[x2][y2] - Psum[x2][y1 - 1] - Psum[x1 - 1][y2] + Psum[x1 - 1][y1 - 1];
}

void buildPsum() {
	repi(i, 0, N) {
		repi(j, 0, N) {
			if (i == 0 && j == 0);
			else if (i == 0) Psum[i][j] = Psum[i][j - 1];
			else if (j == 0) Psum[i][j] = Psum[i - 1][j];
			else Psum[i][j] = Psum[i][j - 1] + Psum[i - 1][j] - Psum[i - 1][j - 1];
			if (Pmap[x[i]] == y[j]) Psum[i][j]++;
		}
	}
}

int main() {
	cin >> N >> K;
	repi(i, 0, N) {
		ll p, q;
		cin >> p >> q;
		x[i] = p, y[i] = q;
		Pmap[p] = q;
	}
	sort(x, x + N);
	sort(y, y + N);

	buildPsum();

	repi(x1, 0, N) {
		repi(x2, x1 + 1, N) {
			repi(y1, 0, N) {
				repi(y2, y1 + 1, N) {
					if (calcPsum(x1, x2, y1, y2) == K) ans = min(ans, (x[x2] - x[x1])*(y[y2] - y[y1]));
				}
			}
		}
	}

	wrln(ans);

	return 0;
}

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

int main() {
    int n;cin>>n;
    int a;
    map<int,int> m;
    for (int i=0;i<n;i++) {
        cin>>a;
        m[a]++;
    }
    int mx=0;
    for (int i=0;i<=100000;i++)
        mx=max(mx,m[i-1]+m[i]+m[i+1]);
    cout<<mx<<endl;
    return 0;
}

Measured memory_bytes: 4992
X, Y, A, B, C = map(int, input().split())
AA = list(map(int, input().split()))
BB = list(map(int, input().split()))
CC = list(map(int, input().split()))
a = sorted(AA, reverse=True)
b = sorted(BB, reverse=True)
c = sorted(CC, reverse=True)

if X < A:
  del a[X:]

if Y < B:
  del b[Y:]

NEW = a + b + c
NEWnew = sorted(NEW, reverse=True)
del NEWnew[X+Y:]
K = sum(NEWnew)
print(K)

  



Measured memory_bytes: 23728
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

vector <vector <int> > G;
int total = 1;
int N, M, ans = 0, freq[15];

void bkt(int node) {
    if(total == N) {
        ++ans;
    }
    else {
        freq[node] = 1;

        for(unsigned int z = 0; z < G[node].size(); ++z) {
            if(freq[G[node][z]] == 0) {
                ++total;
                bkt(G[node][z]);
                --total;
            }
        }

        freq[node] = 0;
    }
}

int main() {
   // #ifndef ONLINE_JUDGE
   // freopen("input.txt","r",stdin);
   // #endif // ONLINE_JUDGE

    cin >> N >> M;

    G.resize(N + 2);

    int x, y;
    for(int i = 1; i <= M; ++i) {
        cin >> x >> y;

        G[x].push_back(y);
        G[y].push_back(x);
    }

    bkt(1);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int i, H, heap[251];

    scanf("%d", &H);
    for (i = 1; i <= H; i++)
        scanf("%d", heap + i);
    
    for (i = 1; i <= H; i++) {
        printf("node %d: key = %d, ", i, heap[i]);
        if (i > 1)
            printf("parent key = %d, ", heap[i / 2]);
        if (i * 2 <= H)
            printf("left key = %d, ", heap[i * 2]);
        if (i * 2 + 1 <= H)
            printf("right key = %d, ", heap[i * 2 + 1]);
        putchar('\n');
    }

    return 0;
}


Measured memory_bytes: 2112
#include<stdio.h>
int main(void){
  int A,B; scanf("%d%d",&A,&B);
  if(A<=5){
    printf("0\n");
  }else if(A<=12){
    printf("%d\n",B/2);
  }else{
    printf("%d\n",B);
  }
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<algorithm>

int main(void){
	const int N_MAX=100000;
	int n,m;
	bool field[N_MAX]={};
	int amount[N_MAX];
	for(int lp=0;lp<N_MAX;lp++){
		amount[lp]=1;
	}
	field[0]=true;
	int m1,m2;
	std::cin >>n>>m;
	for(int lp=0;lp<m;lp++){
		std::cin >>m1>>m2;
		m1--; m2--;
		if(field[m1]){
			field[m2]=true;
		}
		amount[m1]--; amount[m2]++;
		if(amount[m1]==0) field[m1]=false;
	}
	int answer=0;
	for(int lp=0;lp<n;lp++){
		if(field[lp]&&amount[lp]>=1) answer++;
	}
	std::cout <<answer<<std::endl;
	return 0;
}


Measured memory_bytes: 896
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()

using namespace std;

int N, K;
char S[100100];
vector<int> v;

signed main()
{
	cin >> N >> K;
	cin >> S;

	char prev = S[0];
	int cnt = 1;
	for (int i = 1; i < N; i++)
	{
		if (S[i] != prev)
		{
			v.push_back(cnt);
			prev = S[i];
			cnt = 1;
		}
		else
		{
			cnt++;
		}
	}
	v.push_back(cnt);

	int ans = 0;
	for (int n : v)
	{
		ans += (n - 1);
	}

	int size = (int)v.size();
	if (size / 2 <= K)
	{
		ans = N - 1;
	}
	else
	{
		ans += (K * 2);
	}

	cout << ans << endl;
}



Measured memory_bytes: 1528
# -*- coding: utf-8 -*-

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)


def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        lines.append(input())
        (n, m) = [int(e) for e in lines[0].split(' ')]
        lines.append(input())
        for _ in range(m):
            lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]
        (n, m) = [int(e) for e in lines[0].split(' ')]

    h_list = [int(e) for e in lines[1].split(' ')]
    ab_list = []
    for i in range(2, m+2):
        ab_list.append([int(e) for e in lines[i].split(' ')])
        
    return (n, m, h_list, ab_list)


def solve(n, m, h_list, ab_list):


    bad_tower = set()
    for j in range(m):

        ab = ab_list[j]
        if h_list[ab[0]-1] <= h_list[ab[1]-1]:
            bad_tower.add(ab[0])
        
        if h_list[ab[1]-1] <= h_list[ab[0]-1]:
            bad_tower.add(ab[1])

        if debug:
            log("j=%d, bad_tower=%s" % (j, bad_tower))
    
    result = n - len(bad_tower)

    return  result


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

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

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int32 N, M;
	cin >> N >> M;
	vector<PII> a(N, {1, 0});
	REP(i, M){
		int32 A;
		cin >> A;
		a[A]={0, 0};
	}
	while(a.size() > 1){
		vector<PII> na(a.size()/2);
		for(int32 i = 0;i < a.size();i+=2){
			na[i/2] = {a[i].fs+a[i+1].fs, a[i].sc+a[i+1].sc};
			if(a[i].fs && a[i+1].fs)
				na[i/2].sc++;
		}
		a = na;
	}
	cout << a[0].sc << endl;
}



Measured memory_bytes: 3176
#include <bits/stdc++.h>
 using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
 int main(){
  int n,ans;
   cin>>n;
   ans=n;
   
   while(1){
     bool flag=true;
   for(int i=2;i<ans-1;i++){
     if(ans%i==0){
     flag=false;
       break;
     }
    }
    if(flag) break;
     ans++;
   }
   cout<<ans<<endl;
}

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

const int inf = 1e9;
const ll linf = 1e18;

ll C(int n, int k)
{
    ll res = 1;
    for (int i = 0; i < k; i++) res *= (n - i);
    for (int i = 1; i <= k; i++) res /= i;
    return res;
}

int pow(int n, int k)
{
    int res = 1;
    for (int i = 0; i < k; i++) res *= n;
    return res;
}

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

    string n; cin >> n;
    int K; cin >> K;
    const int len = n.length();

    ll dp[len + 1][K + 1][2] = {};
    dp[0][0][0] = 1;
    for (int i = 0; i < len; i++) {
        for (int j = 0; j <= K; j++) {
            for (int k = 0; k < 2; k++) {
                int nxt = n[i] - '0';
                for (int num = 0; num <= 9; num++) {
                    if (k == 0 && num > nxt) continue;

                    int ni = i + 1;
                    int nj = (num ? j + 1 : j);
                    int nk = (k == 0 && num == nxt ? 0 : 1);

                    if (nj > K) continue;

                    dp[ni][nj][nk] += dp[i][j][k];
                }
            }
        }
    }

    cout << dp[len][K][0] + dp[len][K][1] << endl;
    return 0;
}

Measured memory_bytes: 256
N = list(map(int, list(input())))
L = len(N)
K = int(input())
 
dp = [[[0] * (K+1) for j in range(2)] for i in range(L+1)]
dp[0][0][0] = 1
 
for i in range(L):
    ni = N[i]
    if ni == 0:
        for j in range(K):
            dp[i+1][1][j+1] += dp[i][1][j] * 9
        for j in range(K+1):
            dp[i+1][0][j] += dp[i][0][j]
    else:
        for j in range(K+1):
            dp[i+1][1][j] += dp[i][0][j]
        for j in range(K):
            dp[i+1][1][j+1] += (dp[i][0][j] * (ni-1) + dp[i][1][j] * 9)
            dp[i+1][0][j+1] += dp[i][0][j]
 
    for j in range(K+1):
        dp[i+1][1][j] += dp[i][1][j]
 
print(dp[L][0][K]+dp[L][1][K])

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

int main() {
  int n; cin >> n;
  int arr[n],dp[n];
  for (int i=0; i<n; i++) cin >> arr[i];
  dp[0] = 0;
  dp[1] = abs(arr[1] - arr[0]);
  for (int i=2; i<n; i++) {
    dp[i] = min(dp[i-2] + abs(arr[i]-arr[i-2]), dp[i-1] + abs(arr[i]-arr[i-1]));
  }
  cout << dp[n-1] << endl;
}

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

#include <algorithm>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return (t * t) % mod;
    } else {
        return (modpow(m, n - 1) * m) % mod;
    }
}

void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)

signed main() {
    long long n, m, ans = 0;
    cin >> n >> m;
    vector<long long> as(m);
    vector<long long> bs(m);
    vector<long long> ansv(m);
    ans = n * (n - 1) / 2;
    REP(i, m) {
        cin >> as[i] >> bs[i];
        as[i] -= 1;
        bs[i] -= 1;
    }
    reverse(as.begin(), as.end());
    reverse(bs.begin(), bs.end());
    vector<long long> parent(n, -1);
    vector<long long> size(n, 1);
    ansv[0] = ans;
    REP(i, m - 1) {
        long long k = as[i];
        while (parent[k] != -1) {
            k = parent[k];
        }
        long long l = bs[i];
        while (parent[l] != -1) {
            l = parent[l];
        }
        if (l != k) {
            if (size[k] <= size[l]) {
                swap(k, l);
            }
            parent[l] = k;
            ans -= size[l] * size[k];
            ansv[i + 1] = ans;
            size[k] += size[l];
        }else{
            ansv[i + 1] = ansv[i]; 
        }
    }
    reverse(ansv.begin(), ansv.end());
    REP(i, m) { cout << ansv[i] << endl; }
}

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

int gcd(int a, int b) {
	return (b == 0 ? a : gcd(b, a % b));
}

int main() {
	int N, K;
	cin >> N >> K;
	int GCD, MAX;
	cin >> GCD;
	MAX = GCD;
	bool ans = true;
	for (int i = 1; i < N; i++) {
		int A;
		cin >> A;
		if (GCD > 1) GCD = gcd(A, GCD);
		MAX = max(MAX, A);
	}
	if (MAX < K) ans = false;
	if (ans && K % GCD != 0) ans = false;
	cout << (ans ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    char s[10];
    int point = 0, mojisu, i, count = 0;
    scanf("%s", s);

    for (i = 0; s[i] != '\0'; i++)
    {}

    mojisu = i;

    if (s[0] == 'A' )
    {
        point += 1;
        for (i = 2; i < (mojisu - 1); i++)
        {
            if (s[i] == 'C')
            {
                count++;
            }
        }
        if (count == 1)
        {
            point += 1;
            count = 0;
            for (i = 0; i < 10; i++)
            {
                if(s[i] >= 'a' && s[i] <= 'z')
                {
                    count++;
                }
            }
            if (count == mojisu - 2)
            {
                point += 1;
            }
        }
    }
    if (point == 3)
    {
        printf("AC\n");
    }
    else if(point != 3)
    {
        printf("WA\n");
    }
    return (0);
}


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

const int maxn = 10000 + 3;
int ans[maxn];

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

    for (int x = 1; x <= 100; ++x) {
        for (int y = 1; y <= 100; ++y) {
            for (int z = 1; z <= 100; ++z) {
                int t = x * x + y * y + z * z + x * y + y * z + z * x;
                if (t < maxn)
                    ans[t]++;
            }
        }
    }

    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i)
        cout << ans[i] << '\n';

    return 0;
}


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

using namespace std;

int main (void) {
    int N;
    cin >> N;
    vector<int> A(N);
    for ( int i = 0; i < N; i++ )
        cin >> A.at(i);

    int ans = 0;
    for ( int i = 0; i < N; i++ ) {
        for ( int j = i+1; j < N; j++ ) {
            ans = max(abs(A.at(i) - A.at(j)), ans);
        }
    }

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



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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,k,c=0;
    cin>>n>>k;
    while(n--){
        ll a;
        cin>>a;
        if(a>=k){
            c++;
        }
    }
    cout<<c;
	return 0;
}

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

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

	int ans = 0;
	for (int i=0; i<a.size(); i++)
		if (a[i] != b[i])
			ans++;

	cout<<ans<<"\n";

	return 0;
}

Measured memory_bytes: 3896
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
	
#define roop(i, start, end) for(int i=start;i<end;i++)
	
using namespace std;
using ll = long long int;
using ull = unsigned long long;
	
float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}
	
int main() {
    ll a, b, k;
    cin >> a >> b >> k;
    if (a >= k) {
        cout << (a - k) << " " << b << endl;
    } else {
        if ( b - (k - a) >= 0) {
            cout << 0 << " " << b - (k - a) << endl;
        } else {
            cout << 0 << " " << 0 << endl;
        }
    }
	return 0;
}

Measured memory_bytes: 256
import numpy as np
N, D = map(int, input().split())
K = []
for i in range(N):
    K.append([int(x) for x in input().split()])

answer = 0
for i in range(N):
    for j in range(N-i-1):
        j = N - j - 1
        B = 0
        A = []
        S = K[j]
        T = K[i]
        for l in range(D):
            A.append(S[l]-T[l])
        for k in range(D):
            B += (A[k])**2
        C = np.sqrt(B)
        CC = np.floor(C)
        if C == CC:
            answer += 1
        
print(answer)

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

using namespace std;

int main() {
	int l;
	cin >> l;
	int n = 0, m = -1;
	for (; l >= 1 << n; n++)
		if (l & 1 << n) m++;
	m += (n - 1) * 2;
	cout << n << ' ' << m << '\n';
	for (int i = 1; l > 1; i++) {
		if (l & 1)
			cout << i << ' ' << n << ' ' << l - 1 << '\n';
		l >>= 1;
		for (int j = 0; j < 2; j++)
			cout << i << ' ' << i + 1 << ' ' << j * l << '\n';
	}
	cout << flush;
	return 0;
}


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

int N, M;
int pos[100010];
int cnt[100010];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> M;
  fill_n((int*)cnt, 100010, 1);
  pos[0] = 1;
  for (int i = 0; i < M; i++) {
    int x, y;
    cin >> x >> y;
    x--; y--;
    cnt[x]--;
    cnt[y]++;
    if (pos[x]) {
      if (cnt[x] == 0) pos[x] = 0;
      pos[y] = 1;
    }
  }  
  cout << accumulate(pos, pos + N, 0) << endl;

  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
 int main(){
	long long int a = 0, b = 0, c = 0, count = 0, ans = 0, n = 0,h=0,l=0,d=0,e=0,f=0,g=0;
	string s;
	cin >> n >> a >> b;
	if (a >= b) { 
		c = a - b;
		h = a;
		l = b;
	}
	else {
		c = b - a; 
		h = b;
		l = a;
	}
		if (c % 2 == 0)cout << c / 2 << endl;
		else if(h-1==l) {
			d = n - l;
			e = h-1;
			ans = min(d, e);
			cout << ans << endl;
		}
		else {
			d = n - h + 1;
			f = c / 2 + d;
			e = l;
			g = c / 2 + e;
			ans = min(f, g);
			cout << ans << endl;
		}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, P1a, P1b, P2a, P2b;
  cin >> N;
  
  P1a = N % 1000;
  P1b = P1a % 111;
  
  P2a =  N / 10;
  P2b = P2a % 111;
  
  
	if (P1b == 0 || P2b == 0) {
		cout << "Yes" << endl;
    }
  else {
      cout << "No" << endl;
  } 
}

Measured memory_bytes: 3564
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

//二項係数（nCk mod.p;1<=k<=n<=1e7,pは素数）
struct Combination{
    const int MOD = 1000000007;
    vector<ll> fac,finv,inv;
    Combination(const int MAX):fac(MAX),finv(MAX),inv(MAX){
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < MAX; i++){
            fac[i] = fac[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
    }
    long long comb(int n, int k){
        if (n < k) return 0;
        if (n < 0 || k < 0) return 0;
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
    }
};

long long mod(long long val, long long m) {
  long long res = val % m;
  if (res < 0) res += m;
  return res;
}

int main(){
    ll n;cin >> n;
    vector<int> a(n+1);
    rep(i,n+1)cin >> a[i];
    vector<int> bkt(n+1);
    ll d = 0,ridx=0;
    rep(i,n+1){
        if(bkt[a[i]]==1){
            d = a[i];
            ridx=i;
            break;
        }
        bkt[a[i]]++;
    }
    ll l_cnt=0,r_cnt=n-ridx;
    for(int i=0;a[i]!=d;i++)l_cnt++;
    Combination C(200000);
    cout << n << endl;
    for(int i=2;i<=n;i++){
        cout << mod(C.comb(n+1,i)-C.comb(l_cnt+r_cnt,i-1),1e9+7) << endl;
    }
    cout << 1 << endl;
    return 0;
}

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

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define all(v) v.begin(), v.end()
#define F first
#define S second


typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

const ll MOD = 1e9+7;

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

	int n; cin >> n;
	vi v(n), dp(n, 0);
	for(auto& p: v) cin >> p;

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

	for(int i = 2; i < n; i++)
		dp[i] = min(dp[i-1] + abs(v[i]-v[i-1]),
			        dp[i-2] + abs(v[i]-v[i-2]));

	cout << dp[n-1] << '\n';

	return 0;
}

Measured memory_bytes: 1024
//By Tushar Gautam
#pragma GCC optimize ("-O2")
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define memreset(a) memset(a,0,sizeof(a))
#define testcase(t) int t;cin>>t;while(t--)
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define leadzero(a) __builtin_clz(a) // count leading zeroes
#define trailzero(a) __builtin_ctz(a) // count trailing zeroes
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)
#define ln "\n"
#define dbgarr(v,s,e) cerr<<#v<<" = "; forsn(i,s,e) cerr<<v[i]<<", "; cerr<<endl
#define inputfile freopen("input.txt", "r", stdin)
#define outputfile freopen("output.txt", "w", stdout)
#define dbg(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) { cerr<<endl; }
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << "\t"; err(++it, args...);
}
template<typename T1,typename T2>
ostream& operator <<(ostream& c,pair<T1,T2> &v){
	c<<"("<<v.fi<<","<<v.se<<")"; return c;
}
template <template <class...> class TT, class ...T>
ostream& operator<<(ostream& out,TT<T...>& c){
    out<<"{ ";
    forstl(x,c) out<<x<<" ";
    out<<"}"; return out;
}
typedef long long int  ll;
typedef long double  ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<int> v32; 
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
const int LIM = 1e5+5, MOD = 1e9+7;
int t,n,m,k,x,y;
v64 a,cum;
vv64 dp;
int main(){
	fastio;
	cin>>n; ll pre=0; cum.pb(pre);
	a.resize(n);
	dp.assign(n,v64(n,0));
	forn(i,n) cin>>a[i],pre+=a[i],cum.pb(pre),dp[i][i]=0;
	forsn(l,1,n){
		forn(i,n-l){
			int j=i+l;
			auto &x =dp[i][j];
			x=1e18;
			forsn(k,i,j){
				x=min(x,dp[i][k]+dp[k+1][j]);
			}
			x+=cum[j+1]-cum[i];
		}
	}
	cout<<dp[0][n-1]<<ln;
	return 0;
}

Measured memory_bytes: 1536
import * as fs from "fs"
const NUMBER_MIN = Math.ceil(Number.MIN_SAFE_INTEGER / 2)

const process = (n: number, a: number[], b: number[], c: number[]): string => {
  let lastEat = NUMBER_MIN
  let res = 0

  for (let i = 0; i < n; i++) {
    const ryouri = a[i]
    const manzoku = b[ryouri - 1]
    res += manzoku
    if (lastEat + 1 === ryouri - 1) {
      res += c[ryouri - 2]
    }
    lastEat = ryouri - 1
  }

  return "" + res
}

const Main = (input: string): string => {
  const aa: string[][] = input.split("\n").map((e) => e.split(" "))
  const na0: number[] = aa[0].map((e) => parseInt(e))
  const [n] = na0

  const res =
    process(
      n,
      aa[1].map((e) => parseInt(e)),
      aa[2].map((e) => parseInt(e)),
      aa[3].map((e) => parseInt(e))
    ) + ""
  console.log(res)
  return res
}
Main(fs.readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 7372
import java.util.Scanner;

public class Main{
	public static void main(String[] args)
	{
		Scanner sc =new Scanner(System.in);
		String S=sc.next();
		int ans=0;

		for(int i=0;i<S.length();i++){
			if(S.charAt(i)=='1') ans++;
		}
		
		System.out.println(ans);	
	}
	
}

Measured memory_bytes: 24020
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
// constexpr ll MOD = 998244353;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<int> par;
    
//     UnionFind(int N): par(N) {
//         for (int i=0;i<N;i++) par[i] = i;
//     }

//     int root(int x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//     }

//     bool same(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         return rx == ry;
//     }
// };

int main(void) {
    string S;
    cin >> S;
    bool flagl = false, flagr = false;
    int N = S.size();
    for (int i=0;i<N;i+=2) {
        if (S[i] == 'L') flagl = true;
    }
    for (int i=1;i<N;i+=2) {
        if (S[i] == 'R') flagr = true;
    }
    if (flagl || flagr) cout << "No" << endl;
    else cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main()
{
   int n,i,j,k=0,a[2][100000],m=0,t=0;
   scanf("%d",&n);
   for(i=0;i<2;i++)
    for(j=0;j<n;j++)
        scanf("%d",&a[i][j]);
   for(i=0;i<n;i++)
   {
       t=t+a[0][i];
       m=t;
       for(j=i;j<n;j++)
       {
           m=m+a[1][j];
       }
       if(m>k)
        k=m;
   }
    printf("%d\n",k);
    return 0;
}

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

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

    int tmp = n % 10;
    if(tmp == 3) cout << "bon" << endl;
    else if(tmp == 0 || tmp == 1 || tmp == 6 || tmp == 8) cout << "pon" <<endl;
    else cout << "hon" << endl;

}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define cl clear() ;
#define vl vector<ll>
#define sz size()
#define len length()
#define el endl;cout.flush()
#define be begin()
#define fi first
#define se second
#define br break
#define en end()
#define ro return 0
#define br break
#define eb emplace_back
#define con continue
#define ms(x) memset(x , 0, so x)
#define all(x) (x).be , (x).en
#define acc(x) accumulate((x).be , (x).en , 0ll)
#define forn(i,a,b) for(ll i=a;i<=b;++i)
#define rng_58 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
#define trace3(a,b,c) cerr <<"a is " << a << " b is " << b << " c is " << c << el;
#define trace4(a,b,c,d) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << el ;
#define trace5(a,b,c,d,e) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << el;
#define trace6(a,b,c,d,e,f) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << " f is " << f << el ;

int main()
{
    ios;
   set<ll> s ;
   ll a , b , c;
   cin >> a >> b >> c ;
   s.insert(a) ;
   s.insert(b) ;
   s.insert(c) ;
   cout << s.sz << el ;
   ro ;
}































Measured memory_bytes: 256
import numpy as np
words = lambda t : list(map(t, input().split()))

n,k =  words(int)
s = input()

stt = s[0]

cnts = []
cur = stt
lcnt = 0
for c in s:
    if c == cur:
        lcnt += 1
    else:
        cnts.append(lcnt)
        lcnt = 1
        if cur == '0':
            cur = '1'
        else:
            cur = '0'
cnts.append(lcnt)
zsum = 0
if stt == '0':
    sumstt = 1
    for i in range(min(k*2,len(cnts))):
        zsum += cnts[i]
else:
    sumstt = 0

#print(cnts)
sum = 0
#print("ss",sumstt, len(cnts),sumstt+(k*2+1))
for i in range(sumstt, min(len(cnts),sumstt+(k*2+1))):
    sum += cnts[i]

#print(zsum, sum)
maxsum = max(zsum,sum)

l = sumstt + 2
r = sumstt + k*2+1 + 2
#print("first lr",l,r)
while r <= len(cnts):
    sum = sum - cnts[l-2] - cnts[l-1] + cnts[r-2] + cnts[r-1]
    #print(l,r, sum)
    maxsum = max(maxsum, sum)
    l += 2
    r += 2

#print(l,r)
if s[-1] == '0' and r-2 < len(cnts):
    sum = sum - cnts[l-2] - cnts[l-1] + cnts[r-2]
    #print("last 0", l, r,sum)
    maxsum = max(maxsum, sum)

print(maxsum)


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

const long double PI = acos(-1);
constexpr long double EPS = 1e-15;
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;

//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

void solve() {
  int n,q;
  cin >> n >> q;
  pair<ll,pair<ll,ll>> p[n];
  ll ans[q];
  set<ll> st;
  REP(i,q) ans[i] = -1;
  REP(i,n) {
    cin >> p[i].se.fi >> p[i].se.se >> p[i].fi;
  }
  sort(p,p+n);
  ll d[q];
  map<ll,ll> mp;
  REP(i,q) {
    cin >> d[i];
    d[i] = -d[i];
    st.insert(d[i]);
    mp[d[i]] = i;
  }

  REP(i,n) {
    ll from = p[i].fi - p[i].se.se + 1;
    ll to = p[i].fi - p[i].se.fi;
    // cout << p[i].se.fi << " " << p[i].se.se << " " << p[i].fi << endl;
    // cout << from << " " << to << endl;
    set<ll>::iterator itr = st.lower_bound(from);
    vector<ll> v;
    while (itr != st.end() && (*itr) <= to) {
      // cout << " " << *itr << endl;
      v.pb(*itr);
      ans[mp[*itr]] = p[i].fi;
      itr++;
    }
    for (auto tmp: v) st.erase(tmp);
  }

  REP(i,q) cout << ans[i] << endl;
}

int main(int argc, char *argv[]){
  int case_num = 1;
  // while (1) if (solve()) break;
  if (argc > 1 && stoi(argv[1])) cin >> case_num;
  REP(case_no, case_num) {
    cerr << endl << "case " << case_no + 1 << endl;
    solve();
  }
  return 0;
}

Measured memory_bytes: 32140
H, W = map(int, input().split())
s = [input() for _ in range(H)]
dp = [[float('inf') for _ in range(W)] for _ in range(H)]
if s[0][0] == '#':
    dp[0][0] = 1
else:
    dp[0][0] = 0
dx = [0, 1]
dy = [1, 0]

for i in range(H):
    for j in range(W):
        for k in range(2):
            ni = i + dx[k]
            nj = j + dy[k]
            if ni >= H or nj >= W:
                continue
            add = 0
            # print(i, j, ni, nj)
            if s[i][j] == '.' and s[ni][nj] == '#': add += 1
            dp[ni][nj] = min(dp[ni][nj], dp[i][j] + add)

            # print(dp)
print(dp[H-1][W-1])

Measured memory_bytes: 9408
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
using vbvb = vector<vector<bool>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 1000000007;
const int inf = 1001001001;

int main(void) {
  int n,q;
  cin >> n >> q;
  string s ;
  cin >> s;
  vi a(n,0);
  rep(i,n-1){
    if(s[i]=='A' && s[i+1] == 'C'){
      a[i]++;
      a[i+1]++;
    }
  }
  vi sum(n+1);
  sum[0] = 0;
  rep(i,n) sum[i+1] = sum[i] + a[i];
  rep(i,q){
    int l,r;
    cin >> l >> r;
    l--;
    r--;
    int ans = sum[r+1] - sum[l];
    ans/=2;
    //if(i==1) cout << ans << endl;
    if(s[l]=='C' && s[r]=='A' && a[l] && a[r]) ans--;
    cout << ans << endl;
  }
    
    
}






Measured memory_bytes: 1792