akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define MAXN (100010)

int n, k;
int l[MAXN], r[MAXN];
bool has[MAXN];
std::vector<int> mat[MAXN];

bool union_seg(int &lu, int &ru, int lv, int rv, int odd, bool &mark){
	if(!mark){
		lu = lv;
		ru = rv;
		mark = true;
	}
	else{
		lu = std::max(lu, lv);
		ru = std::min(ru, rv);
	}
	if(lu > ru || lu == ru && (lu & 1) != odd) return false;
	return true;
}

bool dfs1(int u, int fa, int odd){
	if(has[u] && (l[u] & 1) != odd){
		return false;
	}
	for(auto v : mat[u]){
		if(v == fa) continue;
		if(!dfs1(v, u, !odd)){
			return false;
		}
		if(!union_seg(l[u], r[u], l[v] - 1, r[v] + 1, odd, has[u])){
			return false;
		}
	}
	if(!has[u]){
		l[u] = - 1e9;
		r[u] =   1e9;
	}
	return true;
}

bool inseg(int x, int l, int r){
	return l <= x && x <= r;
}

bool dfs2(int u, int fa){
	for(auto v : mat[u]){
		if(v == fa) continue;
		if(inseg(l[u] + 1, l[v], r[v])){
			l[v] = l[u] + 1;
			if(!dfs2(v, u)){
				return false;
			}
		}
		else if(inseg(l[u] - 1, l[v], r[v])){
			l[v] = l[u] - 1;
			if(!dfs2(v, u)){
				return false;
			}
		}
		else{
			return false;
		}
	}
	return true;
}

int main(){
	scanf("%d", &n);
	for(int i = 1; i < n; ++ i){
		int u, v;
		scanf("%d%d", &u, &v);
		mat[u].push_back(v);
		mat[v].push_back(u);
	}
	scanf("%d", &k);
	for(int i = 1; i <= k; ++ i){
		int v, p;
		scanf("%d%d", &v, &p);
		l[v] = r[v] = p;
		has[v] = true;
	}
	int root;
	for(root = 1; !has[root]; ++ root);
	if(!dfs1(root, 0, l[root] & 1)){
		return printf("No\n"), 0;
	}/*
	if(!dfs2(root, 0)){
	    return printf("No\n"), 0;
	}*/
	dfs2(root, 0);
	printf("Yes\n");
	for(int i = 1; i <= n; ++ i){
		printf("%d\n", l[i]);
	}
	return 0;
}

Measured memory_bytes: 15104
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <unordered_map>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <memory>
#include <iomanip>
#include <type_traits>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
constexpr long long MOD = 1e9 + 7;
constexpr long long MAX = 1000000;

//long long MOD = 998244353;
constexpr ll INF = 1e17;
constexpr double PI = 3.141592653589793;
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; }

ll h, w;
vector<ll> dx = { -1, 0, 1, 0 };
vector<ll> dy = { 0, -1, 0, 1 };


bool isInField(ll x, ll y) {
    bool f = x >= 0 && x < w && y >= 0 && y < h;
    return f;
}

bool compare_first(pair<ll, ll> x, pair<ll, ll> y)
{
    if (x.first != y.first) {
        return x.first < y.first;
    }
    else {
        return x.second < y.second;
    }
}

bool compare_second(pair<ll, ll> x, pair<ll, ll> y)
{
    if (x.second != y.second) {
        return x.second < y.second;
    }
    else {
        return x.first < y.first;
    }
}

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

    ll n, k;
    cin >> n >> k;
    vector<ll> p(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> p[i];
    }

    vector<double> expectation(1010);
    expectation[0] = 0.0;
    expectation[1] = 1.0;
    for (ll i = 2; i < 1010; i++)
    {
        expectation[i] = (expectation[i - 1] * (double)(i - 1) + (double)i) / (double)i;
    }

    vector<double> cumexpectaion(n + 10);
    for (ll i = 0; i < n; i++)
    {
        cumexpectaion[i + 1] += cumexpectaion[i] + expectation[p[i]];
    }

    double max = -1.0;
    for (ll i = 0; i <= n - k; i++)
    {
        double candidate = cumexpectaion[i + k] - cumexpectaion[i];
        if (max < candidate) {
            max = candidate;
        }
    }

    cout << setprecision(9) << max << "\n";

    return 0;
}



Measured memory_bytes: 3456
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . ___
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         ·ð×æ±£ÓÓ       ÓÀÎÞBUG
*/
#include<map>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<set>
#include<cmath>
#include<fstream>
#include<assert.h>
#include<queue>
#include<deque>
#include<stack>
#include<list>
#include<string.h>
#define mp make_pair
#define md ((l+r)>>1)
using namespace std;
const int INF=1e9;
inline int pt(int a[],int l,int r){
	int p,i,j;
	p=a[l];
	i=l;
	j=r+1;
	for(;;){
		while(a[++i]<p) if(i>=r) break;
		while(a[--j]>p) if(j<=l) break;
		if(i>=j) break;
		else swap(a[i],a[j]);
	}
	if(j==l) return j;
	swap(a[l],a[j]);
	return j;
}
inline void q_sort(int a[],int l,int r){
	int q;
	if(r>l){
		q=pt(a,l,r);
		q_sort(a,l,q-1);
		q_sort(a,q+1,r);
	}
}
int main(){
	long long a,b,c,x,y,i,j,t,v,w,f,ans=1234567891123;
	cin>>a>>b>>c>>x>>y;
	t=c*2;
	v=a+b;
	if(t<v){
		w=min(x,y);
		ans=w*2*c;
		if(x>w){
			ans+=min((x-w)*a,(x-w)*c*2);
			cout<<ans<<endl;
			return 0;
		}else{
			ans+=min((y-w)*b,(y-w)*c*2);
			cout<<ans<<endl;
			return 0;
		}
	}else if(t==v){
		w=min(x,y);
		ans=w*(a+b);
		if(x>w){
			ans+=min((x-w)*a,(x-w)*c*2);
		}else ans+=min((y-w)*b,(y-w)*c*2);
		cout<<ans<<endl;
		return 0;
	}else{
		w=min(x,y);
		ans=w*(a+b);
		if(x>w){
			ans+=min((x-w)*a,(x-w)*c*2);
		}else ans+=min((y-w)*b,(y-w)*c*2);
		cout<<ans<<endl;
		return 0;
	} 
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using std::cin;
using std::cerr;
using std::cout;
using std::endl;
using std::make_pair;
using std::pair;
using std::stack;
using std::string;
using std::unordered_set;
using std::vector;

int main(int argc, char* argv[]) {
  int a, b, c;
  cin >> a >> b >> c;
  if ((a == b && b != c) ||
      (a == c && a != b) ||
      (b == c && a != b)) {
    cout << "Yes";
  } else {
    cout << "No";
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    string S,T;
    cin>>S>>T;
    
    int ans=0;
    for(int i=0;i<S.length();i++){
        if(S.at(i) != T.at(i)) ans++;
        
    }
    cout<<ans<<endl;
   
    
}


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

int main(){
  int A, B, C;
  cin >> A >> B >> C;
  
  int count = 0;
  if(A==7) count++;
  if(B==7) count++;
  if(C==7) count++;
  
  if(count==1) cout << "YES" << endl;
  else cout << "NO" << endl;
  
  return 0;
}

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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)

int main(void)
{
	li a, b;
	cin >> a >> b;
	stringstream ss;
	ss << a << b;
	li x = atoi(ss.str().c_str());
	li xr = sqrt(x);
	cout << (xr * xr == x ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 256
a, n = map(int, input().split())
b = list(map(str, input().split()))
c = str(a)
while True:
    check = True
    for i in range(len(c)):
        if c[i] in b:
            c = str(int(c) + 1)
            check = False
            break
    if check:
        print(c)
        break

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
// const lint MOD = 998244353;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}

int gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

int main (){
	ll x,y;cin>>x>>y;
	int count = 0;
	ll n = x;
	while(true){
		if (n > y) break;
		n *= 2;
		count++;
	} 
	cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printve(vector<T>& v) {int n = sz(v); REP(i, n) cerr << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    string s;
    cin >> s;
    int n = sz(s);
    bool ok = true;
    REP(i, n / 2) {
        if (s[i] != s[n - 1 - i]) {
            ok = false;
            break;
        }
    }
    if (!ok) {
        cout << "No" << endl;
        return;
    }
    int m = (n - 1) / 2;
    REP(i, m / 2) {
        if (s[i] != s[m - 1 - i]) {
            ok = false;
            break;
        }
    }
    if (!ok) {
        cout << "No" << endl;
        return;
    }
    int l = (n + 3) / 2;
    FOR(i, l, (l + n) / 2) {
        if (s[i] != s[n - 1 - i]) {
            ok = false;
            break;
        }
    }
    if (!ok) {
        cout << "No" << endl;
        return;
    }
    cout << "Yes" << endl;
}


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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, K; cin >> N >> K;
    int V[N]; rep(i, N) cin >> V[i];
    int ans = 0;
    for(int i = 1; i <= min(N, K); i++){
        //i個取り出す
        int rem_op = K-i; //rem_op回戻すことができる
        int left_lim = i-1; //A[0]~A[left_lim]まで左から取り出す
        int right_lim = N; //A[N-1]~A[right_lim]まで右から取り出す
        while(left_lim >= 0){
            vector<int> res;
            int acc = 0;
            for(int j = 0; j <= left_lim; j++){
                acc += V[j];
                res.push_back(V[j]);
            }
            for(int j = N-1; j >= right_lim; j--){
                acc += V[j];
                res.push_back(V[j]);
            }
            sort(res.begin(), res.end());
            for(int j = 0; j < min(rem_op, (int) res.size()); j++){
                if(res[j] >= 0) break;
                acc -= res[j];
            }
            ans = max(ans, acc);
            left_lim--; right_lim--;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def max(a, b)
  a > b ? a : b
end
def min(a, b)
  a < b ? a : b
end

N = gets.to_i
a = gets.split.map(&:to_i)
dp = Array.new(N + 2){Array.new(N + 2, 0)}

1.upto(N + 1) do |len|
  (N + 1 - len).times do |i|
    j = i + len
    if (N - len) % 2 == 0
      dp[i][j] = max(dp[i + 1][j] + a[i], dp[i][j - 1] + a[j - 1])
    else
      dp[i][j] = min(dp[i + 1][j] - a[i], dp[i][j - 1] - a[j - 1])
    end
  end
end
puts dp[0][N]

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

typedef long long ll;
typedef pair<int,int> P;
ll const mod = 1e9+7;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    string k;
    int d;
    cin >> k >> d;
    int n = k.size();
    vector<vector<vector<ll>>> dp(2,vector<vector<ll>>(n+1,vector<ll>(d,0)));
    dp[1][0][0] = 1;
    for (int i = 0;i < n;++i) {
        int a = k[i]-'0';
        for (int j = 0;j < d;++j) dp[1][i+1][j] += dp[1][i][(j-a+d*10)%d];
        for (int j = 0;j < a;++j) for (int x = 0;x < d;++x)  dp[0][i+1][x] += dp[1][i][(x-j+d*10)%d];
        //if (i == 0) dp[0][1][0] = 0;
        for (int j = 0;j < d;++j) for (int x = 0;x < 10;++x) dp[0][i+1][j] += dp[0][i][(j-x+d*10)%d];
        for (int j = 0;j < d;++j) for (int x = 0;x < 2;++x) dp[x][i+1][j] %= mod;
    }
    cout << (dp[0][n][0]+dp[1][n][0]-1+mod)%mod << endl;
    return 0;
}

Measured memory_bytes: 24832
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<limits.h>
#define max(x,y)(x>y?x:y)

typedef struct{
    int x;
    int y;
}data_t;

typedef struct{
    int head;
    int tail;
    data_t data[200000];
}queue_t;

queue_t queue;
int h,w;
char map[20][21];
int dist[20][20];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

void init_queue() {queue.head = queue.tail = 0;}
void enqueue(data_t data) {queue.data[queue.tail++]=data;}
data_t dequeue() {return queue.data[queue.head++];}

int bfs(data_t start,data_t end)
{
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            dist[i][j]=-1;
        }
    }
    /*syokika*/
    init_queue();
    dist[start.y][start.x]=0;
    enqueue(start);

    /*queue ni atai ga aru aida kurikaesu*/
    while(queue.head!=queue.tail){
        data_t now=dequeue();
        data_t move;

        for(int i=0;i<4;i++){
            /*idousaki ga hannigai ka douka*/
            move.x=now.x+dx[i];
            move.y=now.y+dy[i];
            if(move.y<0||move.x<0||move.y>=h||move.x>=w)continue;
            if(dist[move.y][move.x]!=-1||map[move.y][move.x]=='#')continue;

            /*idousaki tosite mitomeru*/
            enqueue(move);
            /*dist ni kakikomu*/
            dist[move.y][move.x]=dist[now.y][now.x]+1;
        }
        /*end ni atai ga attara kaesu*/
        if(dist[end.y][end.x]!=-1) return dist[end.y][end.x];
    }
    return -1;
}


int main(void)
{
    scanf("%d %d",&h,&w);
    for(int i=0;i<h;i++){
        scanf("%s",map[i]);
    }
    int max=INT_MIN;

    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(map[i][j]=='#')continue;
            for(int ii=0;ii<h;ii++){
                for(int jj=0;jj<w;jj++){
                    if(map[ii][jj]=='#') continue;
                    if(i==ii&&j==jj)continue;
                    data_t start,end;
                    start.y=i;
                    start.x=j;
                    end.y=ii;
                    end.x=jj;
                   
                    max=max(bfs(start,end),max);
                }
            }
        }
    }
    printf("%d\n",max);
    return 0;
}

Measured memory_bytes: 128
{-# LANGUAGE TypeApplications #-}
module Main where
import qualified Data.ByteString.Char8         as BS
import qualified Data.ByteString.Lazy.Char8    as BSL
import qualified Data.ByteString.Builder       as BSB
import           Data.Char                      ( isSpace )
import           Data.List
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM
import           Data.HashMap.Strict            ( HashMap )
import qualified Data.HashMap.Strict           as HashMap


main :: IO ()
main = do
  n  <- readLn @Int
  as <- VU.unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  let xs = hist $ VU.toList $ VU.zipWith (-) (VU.enumFromN 1 n) as
  let ys = hist $ VU.toList $ VU.zipWith (+) (VU.enumFromN 1 n) as
  print $ sum $ HashMap.elems $ HashMap.intersectionWith (*) xs ys
-- create histogram from list
hist :: [Int] -> HashMap Int Int
hist xs = HashMap.fromListWith (+) $ zip xs $ repeat 1


Measured memory_bytes: 70804
#include<iostream>
using namespace std;
main(){
  int x,y,w,h,n,tx,ty,cnt;
  cin>>x;
  while(cin>>x>>y>>w>>h>>n){
    cnt=0;
    for(int i=0;i<n;i++){
      cin>>tx>>ty;
      if ( x<=tx && tx<=x+w && y <=ty && ty <=y+h)cnt++;
    }
    cout << cnt << endl;
  }
}

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

int main() {
    int N, M, X, Y;
    int x[100], y[100];
    int zl, zr;
    
    cin >> N >> M >> X >> Y;
    
    for (int i = 0; i < N; i++) {
        cin >> x[i];
    }
    
    for (int i = 0; i < M; i++) {
        cin >> y[i];
    }
    
    zl = X + 1;
    zr = Y;
    
    for (int i = 0; i < N; i++) {
        zl = max(zl, (x[i] + 1));
    }
    
    for (int i = 0; i < M; i++) {
        zr = min(zr, y[i]);
    }
    
    if (zl <= zr) {
        cout << "No War" << endl;
    }
    else {
        cout << "War" << endl;
    }
    
    return 0;
}

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

using namespace std;
int main() {
  string a, b, c;
  cin >> a >> b >> c;

  int r1 = stoi(a) + stoi(b + c);
  int r2 = stoi(a) + stoi(c + b);
  int r3 = stoi(b) + stoi(a + c);
  int r4 = stoi(b) + stoi(c + a);
  int r5 = stoi(c) + stoi(a + b);
  int r6 = stoi(c) + stoi(b + a);
  cout << max({r1, r2, r3, r4, r5, r6}) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

// ll m_lcm(vector<int> &a, int lv, int n){
// 	if(lv == 2){
// 		ll g = __gcd(a.at(lv-2), a.at(lv-1));
// 		ll l = a.at(lv-2) * a.at(lv-1);
// 		l /= g;
// 		return l;
// 	}else{
// 		ll lm = m_lcm(a, lv-1, n);
// 		ll g = __gcd(lm, (ll)a.at(lv-1));
// 		ll l = lm * a.at(lv-1);
// 		l /= g;
// 		return l;
// 	}
// }

int main(){
	ll n, m;
	cin >> n >> m;
	vector<ll> a(n);
	rep(snip_i, n) cin >> a.at(snip_i);
	int c;
	rep(i, n){
		if(i == 0){
			c = 0;
			ll temp = a.at(0);
			while(1){
				if(temp % 2 == 0){
					temp /= 2;
					c++;
				}else{
					break;
				}
			}
		}else{
			int ct = 0;
			ll temp = a.at(i);
			while(1){
				if(temp % 2 == 0){
					temp /= 2;
					ct++;
				}else{
					break;
				}
			}
			if(ct != c){
				cout << 0 << endl;
				return 0;
			}
		}
	}
	rep(i, n) a.at(i) /= 2;
	ll l = a.at(0);
	rep2(i, 1, n){
		ll g = __gcd(l, a.at(i));
		l /= g;
		l *= a.at(i);
	}
	// cerr << l << endl;
	ll ans = m / l - m / (2*l);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define mod 1000000007

const int sz=1e6+5;
ll inf=1e15;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t=1;
    // cin>>t;
    
    while(t--)
    {
        
        int n,W;
        cin>>n>>W;
        ll ar[n+1][2];
        for(int i=1;i<=n;i++)
            cin>>ar[i][0]>>ar[i][1];
        ll dp[n+1][W+1];
        for(int i=0;i<=n;i++)
        {
            for(int j=0;j<=W;j++)
                dp[i][j]=0;
        }
            
        // dp[0]=0;
        for(int i=1;i<=n;i++)
        {
            for(int wt=0;wt<=W;wt++)
            {
                dp[i][wt]=dp[i-1][wt];
                if(wt-ar[i][0]>=0)
                dp[i][wt]=max(dp[i-1][wt],dp[i-1][wt-ar[i][0]]+ar[i][1]);
            }
        }
        ll res=0;
        for(int i=0;i<=W;i++)
            res=max(res,dp[n][i]);
        cout<<res;
    }

    return 0;
}

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

int main()
{
    string s;
    cin >> s;
    bool flag = false;
    int sx,max;
    for(int i = 0;i < s.size();i++){
        if(s[i] == 'A' && flag == false){
            flag = true;
            sx = i;
        }
        if(flag && s[i] == 'Z'){
            max = i - sx + 1;
        }
    }
    cout << max << endl;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a,b;
		while(true){
			a = sc.nextInt();
			b = sc.nextInt();
			if(a==0&&b==0)break;
			for(int i=0;i<a;i++){
				for(int j=0;j<b;j++){
					if(i==0||j==0||i==a-1||j==b-1)System.out.print("#");
					else System.out.print(".");
				}
				System.out.print("\n");
			}
			System.out.print("\n");
		}
	}
}



Measured memory_bytes: 36572
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <assert.h>
using namespace std;

typedef long long ll;
#define REP(i,n) for (ll i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;

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

	ll ans = 1;
	REP(i,K) {
		if (ans < A) {
			ans++;
		} else {
			ll lcnt = K - i;
			if (lcnt >= 2) {
				ll gain = B - A;
				if (gain >= 2) {
					ans += (lcnt / 2) * gain;
					i += (lcnt / 2) * 2 - 1;
				} else {
					ans++;
				}
			} else {
				ans++;
			}
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main() {
	int n, t, a;
	float min, ans;
	cin >> n >> t >> a;
	int h[n];
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	min = abs(a - (t - h[0] * 0.006));
	ans = 1;
	for (int i = 0; i < n; i++) {
		if (min > abs(a - (t - h[i] * 0.006))) {
			min = abs(a - (t - h[i] * 0.006));
			ans = i + 1;
		} 
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
H,W,N=map(int,input().split())
Sr,Sc=map(int,input().split())
S=input()
T=input()

wr=Sc
wl=Sc
hu=Sr
hd=Sr


ans='YES'
for i in range(N):
    if S[i]=='R':
        wr+=1
    elif S[i]=='L':
        wl-=1
    elif S[i]=='U':
        hu-=1
    elif S[i]=='D':
        hd+=1
    if wr>W or wl<1 or hu<1 or hd>H:
        ans='NO'
        break

    if T[i]=='R':
        wl = min(W,wl+1)
    elif T[i]=='L':
        wr = max(1,wr-1)
    elif T[i]=='U':
        hd= max(1,hd-1)
    elif T[i]=='D':
        hu=min(H,hu+1)

print(ans)

Measured memory_bytes: 3888
function main()
  N=parse(Int,readline())
  A=sort(map(x->parse(Int,x),split(readline())))
  p=t=0
  for a=A
    if p*3<p+a
      t=1
    else
      t+=1
    end
    p+=a
  end
  println(t)
end
main()

Measured memory_bytes: 133252
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int A = sc.nextInt();
    
    while(N >= 500){
      N -= 500;
    }
    
    if(A >= N){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
    
  }
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)

typedef long long ll;
typedef pair<int, int> P;

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

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

    vector<int> A(N);
    rep(i, N) cin >> A[i];

    bool ans = false;
    rep(i, N) {
        if (A[i] % 2) ans = true;
    }

    if (ans) {
        puts("first");
    } else {
        puts("second");
    }
}

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

int N,W;
int v[110],w[110];
int dp[110][10010]={0};//dp[i][j]:i番目の数で重さj以内の時の価値の最大値

int main(){
    cin>>N>>W;
    for(int i=0; i<N; i++)cin>>v[i]>>w[i];
    
    //dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i])(j-w[i]>=0)
    for(int i=0; i<N; i++){
        for(int j=0; j<=W; j++){
            if(j-w[i]>=0)dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);
            else dp[i+1][j]=dp[i][j];
        }
    }
    
    cout<<dp[N][W]<<endl;
    
    return 0;
}


Measured memory_bytes: 6976
import math

a,b,h,m=map(int,input().split())

da=180*(h+m/60)/6
db=180*m/30
d=da-db

if da>=db:
  if d>=180:
    d=360-d
else:
  if -d>=180:
    d=360+d
  else:
    d=-d

d=math.pi*d/180
cos=math.cos(d)
answer2=a**2+b**2-2*a*b*cos

print(answer2**(1/2))

Measured memory_bytes: 62644
# https://atcoder.jp/contests/abc145/tasks/abc145_c

import sys
sys.setrecursionlimit(12345678)
import itertools
import math
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def main():
    n = int(input())
    nl = [i for i in range(n)]

    xy = []
    for _ in range(n):
        x, y = map(int, input().split())
        xy.append((x, y))

    total = 0
    routes = list(itertools.permutations(nl))
    for route in routes:
        # print(route)
        distance = 0
        for i in range(1, len(route)):
            src_x = xy[route[i-1]][0]
            src_y = xy[route[i-1]][1]
            dst_x = xy[route[i]][0]
            dst_y = xy[route[i]][1]
            distance += math.sqrt((dst_x - src_x) * (dst_x - src_x) + (dst_y - src_y) * (dst_y - src_y))

        total += distance
    # print(len(routes))
    print(total / len(routes))


if __name__ == '__main__':
    main()


Measured memory_bytes: 46960
n = int(input())
p = list(map(int,input().split()))
lists = []
for i in range(1,len(p)-1):
    if p[i-1] < p[i] < p[i+1]:
        lists.append(p[i])
    elif p[i-1] > p[i] > p[i+1]:
        lists.append(p[i])
print(len(lists))

Measured memory_bytes: 3064
import java.util.Scanner;
import java.util.Arrays;

public class Main {
    public static void main(String args[]){
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        long sum = 0;
        int dis[] = new int[n];
        boolean flag = true;
        
        for(int i = 0; i < n; i++){
            dis[i] = stdIn.nextInt();
        }
        
        if(dis[0] == 0){
            Arrays.sort(dis);
            long num = 0;
            
            if(n > 1){
                if(dis[1] == 0){
                    flag = false;
                }
            }else{
                flag = false;
            }
            
            boolean flafla = true;
            
            if(flag){
                int index = 0;
                for(int i = 1; i < n; i++){
                    if(dis[i] == 1){
                        num++;
                    }else{
                        index = i;
                        break;
                    }
                    
                    if(i == n - 1){
                        flafla = false;
                    }
                }
                
                sum = 1;
                long num2 = num;
                
                if(flafla){
                    for(int i = index; i < n; i++){
                        if(dis[i - 1] == dis[i]){
                            sum = (sum * num) % 998244353;
                            //System.out.println(num + " " +sum + " ue");
                            num2++;
                        }else if(dis[i - 1] + 1 == dis[i]){
                            num = num2;
                            sum = (sum * num) % 998244353;
                            //System.out.println(num + " " +sum + " shita");
                            num2 = 1;
                        }else{
                            sum = 0;
                        }
                    }
                }
                System.out.println(sum);
            }else{
                System.out.println(0);
            }
            
            
        }else{
            System.out.println(0);
        }
        
    }
}


Measured memory_bytes: 50848
#include<bits/stdc++.h>
#define li long long  int
#define pb push_back
using namespace std;
int main(){
 li n , count1=0 ,t;
 cin>>n;
 while(n){
        t=n;
    li count =0;
    while(t){
        t=t/10;
        count++;
    }
    if(count%2!=0){
        count1++;
    }
    n--;
 }
cout<<count1<<endl;



}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

LL N;
deque<int> deq[2];
vector<int> ans;

void OutBin(LL k) {
  rrep(i, 64) {
    printf("%01lld", k >> i &1);
  }
  puts("");
}

int main() {
  scanf("%lld", &N);
  
  int num_char = 0;
  bool first = true;
  N++;
  rrep(i, 62) {
    if (!first) {
      int a = ++num_char;
      rep(i, 2) deq[i].eb(a);
    }

    if (N >> i & 1) {
      if (!first) {
        int a = ++num_char;
        deq[0].push_front(a);
        deq[1].push_back(a);
      }
      first = false;
    }
  }
  /*while (1) {
    OutBin(N);
    bool found = false;
    rreps(i, 6, 62) {
      if (i%2 == 0) continue;
      if (N >> i) {
        int p = (i-1)/2;
        int a = ++num_char;
        int b = ++num_char;
        rep(j, p) ans.eb(a);
        rep(j, p) ans.eb(b);
        rep(j, p) ans.eb(a);
        rep(j, p) ans.eb(b);
        assert(p > 0);
        LL sub = 1LL << i;
        sub -= 1LL << (p+1);
        sub -= 1;
        assert(sub > 0);
        N -= sub;
        found = true;
        break;
      }
    }

    if (!found) break;
  }*/

  /*while (N > 0) {
    bool found = false;
    OutBin(N);
    rrep(i, 62) {
      //cout << "i: " << i << "and N: " << N << endl;
      LL pw = 1LL << i;
      if (N%pw == pw-1 || (N >> i & 1)) {
        int p = i+1;
        int a = ++num_char;
        rep(j, p) ans.eb(a);
        LL sub = pw;
        sub -= 1;
        assert(sub > 0);
        N -= sub;
        found = true;
        break;
      }
    }
    assert(found);
  }*/

  //cout << "N: " << N << endl;
  rep(i, 2) ans.insert(ans.end(), all(deq[i]));
  //cout << "num_char: " << num_char << endl;
  //cout << "ans.size(): " << ans.size() << endl;
  assert(num_char <= 100);

  int M = ans.size();
  assert(M <= 200);
  
  printf("%d\n", M);
  rep(i, M) {
    int v = ans[i];
    printf("%d%c", v, " \n"[i == M-1]);
  }
}


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

using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n); i > 0; i--)
#define all(n) n.begin(), n.end()
#define print(n) cout << n << endl

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

    if(a%k == 0 || b/k - a/k > 0) print("OK");
    else print("NG");

    return 0;
}

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

#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second

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

const int MOD = 1e9 + 7;
const int INF = 1e9 + 5;
const int MAXN = 1e5+13;
const ll LINF = LLONG_MAX;
ll powmod (ll a,ll b) {ll res=1;a%=MOD; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}

int main() {
	faster;

	int n;

	cin >> n;
	vi arr(n+1);

	for(int i = 0; i < n-1; ++i){
		int x;

		cin >> x;
		arr[x]++;
	}

	for(int i = 1; i <= n; ++i)
		cout << arr[i] << "\n";

	return 0;
}

// READ
// THINK
// CODE
// DEBUG
// AC


Measured memory_bytes: 3992
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

fn main() {
    input! {
        h: usize,
        w: usize,
        c: [chars; h],
    }
    //let mut l: Vec<Vec<char>> = vec![vec!['i'; w]; h * 2];
    for i in 0..h*2 {
        for j in 0..w {
            //let x = i / 2;
            //l[i][j] = c[x][j];
            print!("{}", c[i / 2][j]);
        }
        println!("");
    }
    /*
    for i in 0..l.len() {
        for j in 0..l[i].len() {
            print!("{}", l[i][j]);
        }
        println!("");
    }
    */
}

Measured memory_bytes: 4352
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int dp[20000];

int main()
{
 long long n,m;
 scanf("%lld %lld",&n,&m);
 long long x,ara1[n+5];
 long long a,b;
 a=b=0;
 int ia,ib;
 for(int i=1;i<=n;i++)
 {

     scanf("%lld %lld",&x,&ara1[i]);

     if(a<x )
     {
         a=x;
         ia=i;
     }




 }
    bool fl=0;


sort(ara1+1,ara1+n+1);
     int ans=0;

     for(int i=n;i>=1;i--)
     {

         if(ara1[i]>=a)
         {
             ans++;
             m-=ara1[i];
             if(m<=0)
             {
                 cout <<ans<<endl;
                 return 0;
             }

         }
     }

         


  
             ans+=(m/a);
            if(m%a)
            ans++;


         
         cout <<ans<<endl;



}


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

const int mod = 1e9 + 7;
const int MN = 3010;

int N, M;
int dp1[MN][MN], dp2[MN][MN];

int main() {
    cin >> N >> M;
    N--; M--;

    for(int i = 0; i <= N; i++) dp1[0][i] = dp2[0][i] = 1;
    for(int i = 1; i <= M; i++) {
        for(int j = 0; j <= N; j++) {
            if(j) {
                dp1[i][j] += dp1[i - 1][j - 1];
                dp1[i][j] %= mod;
            }
            if(j != N) {
                dp1[i][j] += dp1[i - 1][j + 1];
                dp1[i][j] %= mod;
            }
            dp1[i][j] += 2LL * dp1[i - 1][j] % mod;
            dp1[i][j] %= mod;

            if(j > 1) {
                dp2[i][j] += dp2[i - 1][j - 1];
                dp2[i][j] %= mod;
            }
            if(j != N) {
                dp2[i][j] += dp2[i - 1][j + 1];
                dp2[i][j] %= mod;
            }
            if(j) {
                dp2[i][j] += 2LL * dp2[i - 1][j] % mod;
                dp2[i][j] %= mod;
            }
        }
    }

    int ans = 0;
    for(int i = 0; i <= M; i++) {
        ans += 1LL * dp1[M - i][0] * dp2[i][0] % mod;
        ans %= mod;
    }
    printf("%d", 4LL * ans % mod);
}


Measured memory_bytes: 70912
n=int(input())
a=list(map(int,input().split()))
from collections import Counter
ac=Counter(a)
v=sorted(ac.items(),reverse=1)
ans=[]
ans1=[]

for i in range(len(ac)):
  if v[i][1]>=2:
    ans.append(v[i][0])
  if v[i][1]>=4:
    ans1.append(v[i][0])
if len(ans)>=2:
  if len(ans1)>=1:
      print(max(ans[0]*ans[1],ans1[0]**2))
  else:
      print(ans[0]*ans[1])
else:
  if len(ans1)>=1:
      print(max(0,ans1[0]**2))
  else:
      print(0)

Measured memory_bytes: 26120
n = int(input())

h = list(map(int, input().split()))
h[0] -= 1
for i in range(1, n):
    if h[i - 1] < h[i]:
        h[i] -= 1
    elif h[i - 1] == h[i]:
        pass
    else:
        print("No")
        break
else:
    print("Yes")

Measured memory_bytes: 20672
/* 
		BURN OUT
	*/	  
		#include <bits/stdc++.h>
		using namespace std;
			     
		#define ll long long int
		#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
			     
		#define mp make_pair
		#define pb push_back
		#define ld long double
		#define F first
		#define S second
		const ll N =(1e6);  
		const ll mod = (1e9+7);

	int main(){
	fast;
	int n , m;
	cin >> n ;
	ll arr[n];
	for(int i = 0 ; i < n ; i++){
		cin >> arr[i];
	}
	ll sum = 0;
	for(int i = 0 ; i < n ; i ++){
		for(int j = i+1 ;j < n ; j ++)
		{
			sum+=arr[i]*arr[j];
		}
	}
	
	cout<<sum;
	}

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

#define x first
#define y second
#define all(x) begin(x), end(x)
typedef long long ll;

signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n, a, b;
	cin >> n >> a >> b;
	ll olda = a, oldb = b;
	ll add = 0;
	if (a > b)
		swap(a, b);
	if ((a - b) % 2) {
		add = a;
		b -= a;
		a = 1;
	}
	ll ans1 = add + (b - a) / 2;
	a = n - olda + 1;
	b = n - oldb + 1;
	add = 0;
	if (a > b)
		swap(a, b);
	if ((a - b) % 2) {
		add = a;
		b -= a;
		a = 1;
	}
	ll ans2 = add + (b - a) / 2;
	cout << min(ans1, ans2) << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a,b,m,n,j,i,p,o,hp,kp,q,w,e,r;
	scanf("%d %d",&a,&b);
	scanf("%d %d",&m,&n);
	scanf("%d %d %d %d",&j,&i,&p,&o);
	hp=(a*j)+(b*i);
	kp=(m*j)+(n*i);
	if(a>=10){
		a=a/10;
		q=a*p;
		hp=hp+q;
	}
	if(b>=10){
		b=b/20;
		w=b*o;
		hp=hp+w;
	}
	if(m>=10){
		m=m/10;
		e=m*p;
		kp=kp+e;
	}
	if(n>=10){
		n=n/20;
		r=n*o;
		kp=kp+r;
	}
	if(hp>kp){
		printf("hiroshi\n");
	}
	else if(hp<kp){
		printf("kenjiro\n");
	}
	else{
		printf("even\n");
	}
	return 0;
}


Measured memory_bytes: 2112
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
#define debug puts("wzpakking")
#define y1 ysghysgsygsh
using namespace std;
const int N=200005;
vector<int> e[N];
vector<int> vec[N];
int n,vis[N],ans[N];
void color(int x,int fa,int c){
	vec[c].PB(x);
	for (auto i:e[x])
		if (i!=fa) color(i,x,c^1);
}
int main(){
	scanf("%d",&n);
	For(i,1,n-1){
		int x,y;
		scanf("%d%d",&x,&y);
		e[x].PB(y); e[y].PB(x);
	} 
	color(1,0,0);
	if (vec[0].size()>vec[1].size())
		swap(vec[0],vec[1]);
	if (vec[0].size()<=n/3){
		int p=0;
		for (auto i:vec[0])
			ans[i]=(p+=3),vis[p]=1;
		p=1;
		for (auto i:vec[1]){
			for (;vis[p];++p);
			ans[i]=(p++);
		}
	}
	else{
		For(i,0,n/3) if (i*3+1<=n)
			ans[vec[0][i]]=i*3+1;
		For(i,0,n/3) if (i*3+2<=n)
			ans[vec[1][i]]=i*3+2;
		int p=0;
		For(i,1,n) if (!ans[i]) ans[i]=p+=3;
	}
	For(i,1,n) printf("%d ",ans[i]);
	puts("");
}
/*
按照和A的距离三染色
*/

Measured memory_bytes: 26356
<?php

    while(true){
        $mark = explode(" ", trim(fgets(STDIN)));
        
        if(array_sum($mark) == -3) exit;    
        
        if($mark[0] * $mark[1] < 0){
            echo "F"."\n";
            continue;
        }        
        
        $total = $mark[0] + $mark[1];
        
        switch (true) {
            case ($total >= 80):
                echo "A"."\n";
                break;
            case ($total >= 65):
                echo "B"."\n";
                break;
            case ($total >= 50):
                echo "C"."\n";
                break;
            case ($total >= 30):
                if($mark[2] >= 50){
                    echo "C"."\n";
                } else {
                    echo "D"."\n";
                }
                break;
            default:
                echo "F"."\n";
                break;
        } 
    }

Measured memory_bytes: 15216
#include <iostream>

using namespace std;
int a, b, c, mx;
int main()
{
	cin >> a >> b >> c;
	mx = max(max(a, b), c);
	if(a == 5 && b == 5 && c == 5){
		cout << "NO";
	}else if(a + b + c - mx == 10){
		cout << "YES";
	}else{
		cout << "NO";
	}
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ii=pair<ll,ll>;
using vi=vector<ll>;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (ll)1e18
#define all(x) (x).begin(),(x).end()
#define print(a); for(auto x:a)cout<<x<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
    ll n,x;cin>>n>>x;
    ll dp[x+1];mset(dp);
    for(int i=0;i<n;i++){
        ll a,b;cin>>a>>b;
        for(int j=x;j>=a;j--){
            dp[j]=max(dp[j],dp[j-a]+b);
        }
        //print(dp);
    }
    cout<<dp[x]<<"\n";
}



Measured memory_bytes: 1024
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    int s[n],t[n],chr=0,ans=0;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        chr+=a;
        s[i]=chr;
    }
    for(int i=0;i<n;i++){
        cin>>t[i];
    }
    chr=0;
    reverse(t,t+n);
    for(int i=0;i<n;i++){
        chr+=t[i];
        int p=s[n-i-1]+chr;
        ans=max(ans,p);
    }
    cout<<ans<<endl;
}


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

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

	vector<ll> d(s.size(), 0);
	for (int i = s.size() - 1; i >= 0; --i) {
		if (s[i] == 'W') { d[i] += 1; }
		if (i == s.size() - 1) { continue; }
		d[i] += d[i + 1];
	}

	ll res = 0;
	for (int i = 0; i < s.size(); ++i) {
		if (s[i] == 'B') {
			res += d[i];
		}
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 2180
//include
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath> 
#include <iomanip>
#include <math.h>
#include <utility>
#include <functional>
#include <cstdlib>
//using
using namespace std;
using vl = vector <long long>;
using vs = vector <string>;
using vc = vector <char>;
using ll= long long;
using vvl = vector<vector<ll> >;
//vector<vector<char> > hyou(N, vector<char>(N));
using vd = vector <double>;
//define
//#define int long long
#define rep(i,n) for(int i=0; i<n; i++)
#define print(n) cout<<n<<endl;
#define sortp(d) sort(d.begin(),d.end()) //1234
#define sortm(d) sort(d.rbegin(),d.rend()) //4321
//素数判定　O(√A) 
bool is_prime(int x){
 if(x<=1) return false;
 for(int i=2;i*i<=x;i++)
 if(x%i==0) return false;
 return true;
 }
/*順列生成
do {
  // 順列に対する処理
} while (next_permutation(配列変数.begin(), 配列変数.end()));*/

//絶対値　abs()
//文字→数字　'0' アルファベット→数字　'a'　'A'が65番,'a'が97番だわ
//型キャスト　char('a'+1)

//グローバル変数宣言
 ll p=0,q=0,r=0;

int main()
{
  ll a,b;
  cin>>a>>b;
  //a<=b
  if(a<=0&&b>=0)print("Zero")
  else if(a>0&&b>0)print("Positive")
  else{
  p=b-a+1;
  if(p%2==0)print("Positive")
  else print("Negative")
  }
}

Measured memory_bytes: 3608
using System;

class Tester
{
    static void Main(string[] args)
    {
        int y = 1;

        while(true)
        {
            string x = Console.ReadLine();
            int i = int.Parse(x);


            if (i == 0)
                break;

            Console.WriteLine("Case {0}: {1}",y++,i);
        }
    }
}


Measured memory_bytes: 9288
#pragma GCC optimize ("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
#define FORD(i, a, b) for (int i=(a); i>(b); i--)
#define PPC(x) __builtin_popcount(x)
#define MSB(x) (31 - __builtin_clz(x))
#define SZ(x) ((int)(x).size())
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define ithBit(m, i) ((m) >> (i) & 1)
#define ft first
#define sd second
#define kw(a) ((a) * (a))
#ifdef DEBUG
#include "debug.h"
#else
#define dbg(...) 0
#endif
using namespace std;

const int maxN = 100000000;

int T[maxN];

void solve()
{
	int n, res = 0;
	scanf ("%d", &n);
	FOR(i, 1, n+1)
	{
		scanf ("%d", T+i);
		res += (T[i] & i) & 1;
	}
	printf("%d\n", res);
}

int main()
{		
	int t = 1;
	//scanf ("%d", &t);
	while (t--)
		solve();
	return 0;
}


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

int main(void)
{
	string num;
	cin>>num;
	int len=num.length();
	for(int i=0;i<len;++i){
		if(num.at(i)=='7'){
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<string>
#include<queue>
#include<map>
#include<vector>
#include<ctime>

#define ll long long
#define R register
#define IL inline
#define Rf(a,b,c) for(R int (a)=(b);(a)<=(c);++(a))
#define Tf(a,b,c) for(R int (a)=(b);(a)>=(c);--(a))
#define MP make_pair
#define PA pair<int,int>
#define MES(a,b) memset((a),(b),sizeof((a)))
#define MEC(a,b) memcpy((a),(b),sizeof((b)))
#define D double

using namespace std;

const int N=1e5+5;

int n,m,h[N],d[N],ans;

IL int read() {
    int x=0,f=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x*=10;x+=(ch-'0');ch=getchar();}
    return x*f;
}
IL void write(int x) {
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}

signed main()
{
	n=read();m=read();
	Rf(i,1,n) h[i]=read();
	Rf(i,1,m) {
		R int a=read(),b=read();
		if(h[a]>=h[b]) d[b]++;
		if(h[a]<=h[b]) d[a]++;
	}
	Rf(i,1,n) if(!d[i]) ans++;
	write(ans);
    return 0;
}


Measured memory_bytes: 4412