akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string.h>

using namespace std;
int cntWord(char* word) {
    int cnt = 0;
    while(word[cnt] != '\0') {
        cnt++;
    }
    return cnt;
}
int main() {
    int N;
    cin >> N;
    bool flag = false;
    char word[N][20];
    for(int i = 0; i < N; i++) {
        cin >> word[i];
        if(i != 0) {
            int cnt = cntWord(word[i-1]);
            // cout << word[i][0] << word[i-1][cnt-1] << endl;
            if(word[i][0] != word[i-1][cnt-1]) {
                flag = true;
            }
            for(int j = 0; j < i; j++) {
                if(i == j) continue;
                // for(int k = 0; k < 20; k++) {
                    // cout << word[i][k] << word[j][k] << endl;
                    // if(word[i][k] == word[j][k]) flag = true;
                    if(strcmp(word[i], word[j]) == 0) flag = true;
                    // if(word[i][k] == '\0' || word[j][k] == '\0') break;
                // }
            }
        }
    }
    // for(int i = 0; i < N; i++) {
    //     cout << word[i] << endl;
    // }
    flag ? cout << "No" << endl : cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
// Problem : E - Dist Max
// Contest : AtCoder - AtCoder Beginner Contest 178
// URL : https://atcoder.jp/contests/abc178/tasks/abc178_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// $%U%$
// Mere bas ka nahi hai
// still i'm trying
// apna time aayega
//
//        .--------------.  
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |  
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'                          		  
//
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll power(ll x,ll y,ll m){if(y==0)return 1;ll p=power(x,y/2,m)%m;p=(p*p)%m;return (y%2==0)?p:(x*p)%m;}
ll nCr(ll n,ll r,ll m){if(r>n)return 0;ll a=1,b=1,i;for(i=0;i<r;i++){a=(a*n)%m;--n;}while(r){b=(b*r)%m;--r;}return (a*power(b,m-2,m))%m;}
#define Test int t;cin>>t;while(t--)
#define endl '\n'
void solve()
{
	int n;
	cin >> n;
	vector<ll> x(n),y(n);
	for(int i=0;i<n;++i)
	cin >> x[i] >> y[i];
	ll ans=0;
	vector<vector<ll>> v(4,vector<ll>(n));
	int t=0;
	for(ll i=-1;i<=1;i+=2)
	{
		for(ll j=-1;j<=1;j+=2)
		{
			for(int k=0;k<n;++k)
			{
				v[t][k]=i*x[k]+j*y[k];
			}
			t++;
		}
	}
	t=0;
	for(ll i=-1;i<=1;i+=2)
	{
		for(ll j=-1;j<=1;j+=2)
		{
			ll mn=v[t][0];
			for(int k=0;k<n;++k)
			{
				ans=max(ans,v[t][k]-mn);
				mn=min(mn,v[t][k]);
			}
			t++;
		}
	}
	cout << ans << endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//Test
	solve();
	return 0;
}


Measured memory_bytes: 14280
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;
typedef int64_t i64;

const i32 mod = 1000000007;

i32 mod_pow (i32 r, i32 n) {
  i32 t = 1;
  i32 s = r;
  while (n > 0) {
    if (n & 1) t = (i64) t * s % mod;
    s = (i64) s * s % mod;
    n >>= 1;
  }
  return t;
}

i32 inv (i32 a) {
  return mod_pow (a, mod - 2);
}

i32 *fact = NULL;
i32 *iFact = NULL;
void init_fact (const i32 n) {
  fact = (i32 *) calloc (n + 1, sizeof (i32));
  fact[0] = 1;
  for (i32 i = 1; i <= n; ++i) {
    fact[i] = (i64) i * fact[i - 1] % mod;
  }
  iFact = (i32 *) calloc (n + 1, sizeof (i32));
  iFact[n] = inv (fact[n]);
  for (i32 i = n - 1; i >= 0; --i) {
    iFact[i] = (i64) (i + 1) * iFact[i + 1] % mod;
  }
}

i32 comb (i32 n, i32 k) {
  if (!(0 <= k && k <= n)) return 0;
  return (i64) fact[n] * iFact[k] % mod * iFact[n - k] % mod;
}

#define ALLOC(size,type) ((type*)calloc((size),sizeof(type)))
#define SORT(a,num,cmp) qsort((a),(num),sizeof(*(a)),cmp)

typedef struct point {
  i32 r, c;
} point;

int cmp (const void *a, const void *b) {
  const point *p = a;
  const point *q = b;
  i32 d = p->r - q->r;
  if (d != 0) return d < 0 ? -1 : 1;
  d = p->c - q->c;
  return d == 0 ? 0 : d < 0 ? -1 : 1;
}

void run (void) {
  i32 h, w, n;
  scanf ("%" SCNi32 "%" SCNi32 "%" SCNi32, &h, &w, &n);
  h--; w--;
  point *p = ALLOC (n + 1, point);
  for (i32 i = 0; i < n; ++i) {
    i32 r, c;
    scanf ("%" SCNi32 "%" SCNi32, &r, &c);
    r--; c--;
    p[i] = (point) {r, c};
  }
  p[n] = (point) {h, w};
  SORT (p, n + 1, cmp);
  init_fact (h + w);
  i32 *dp = ALLOC (n + 1, i32);
  for (i32 i = 0; i <= n; ++i) {
    i32 x = p[i].r;
    i32 y = p[i].c;
    i32 way = comb (x + y, x);
    for (i32 j = 0; j < i; ++j) {
      if (!(p[j].r <= x && p[j].c <= y)) continue;
      way = (way + (i64) mod * mod - (i64) dp[j] * comb (x - p[j].r + y - p[j].c, x - p[j].r)) % mod;
    }
    dp[i] = way;
  }
  printf ("%" PRIi32 "\n", dp[n]);
}

int main (void) {
  run();
  return 0;
}


Measured memory_bytes: 1792
import sys
from itertools import combinations, product
n, m, q = [int(i) for i in sys.stdin.readline().split()]
ls = []
for i in range(q):
    a, b, c, d = [int(i) for i in sys.stdin.readline().split()]
    a -= 1
    b -= 1
    ls.append([a, b, c, d])

def check_ls(ls, A):
    cnt = 0
    for a, b, c, d in ls:
        if A[b] - A[a] == c:
            cnt += d
    return cnt

_best = 0
res = []

def dfs(last, cur):
    flg = len(cur) < n - 1
    for i in range(last, 1+m):
        if flg:
            dfs(i, cur + [i])
        else:
            res.append(cur + [i])

dfs(1, [])
for i in res:
    i = [int(j) for j in i]
    _best = max(_best, check_ls(ls, i))
print(_best)

Measured memory_bytes: 94380
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int ct = 0, cx = 0, cy = 0;
  bool isok = true;
  for (int i = 0; i < N; i++) {
    int t, x, y;
    cin >> t >> x >> y;
    int dist = abs(x - cx) + abs(y - cy), dt = t - ct;
    isok &= dist <= dt;
    isok &= !((dist ^ dt) & 1);
    ct = t, cx = x, cy = y;
  }
  cout << (isok ? "Yes" : "No") << '\n';
  return 0;
}


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

long long int f(const long long int x){
    const int m = log2(x)+1;
    long long int res = 0;
    for(int i = 1; i <= m; ++i){
        long long int n = 1LL<<i;
        long long int c = ((x+1)/n)*(n/2);
        c += max(0LL, ((x+1)%n)-(n/2));

        if(c & 1) res += n>>1;
    }

    return res;
}

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

    long long int ans = f(A-1)^f(B);
    cout << ans << endl;
}

Measured memory_bytes: 384
A, B, N = map(int, input().split())


# S = input()
# X1_list = [int(input()) for i in range(N)]
# X2_list = [list(map(int,input().split())) for i in range(N)]
def solve(i):
    a = int(A * i / B)
    b = A * int(i / B)
    return a - b


print(solve(min(N, B - 1)))

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

int main() {
  int N, A, X;
  cin >> N;
  cin >> A;
  X = N % 1000;
  if (A >= X) {
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
//Author ::  ABHINAV3010 ::

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define fast ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
typedef long long ll;
typedef pair<ll,ll> p;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    new_data_set;
ll mod=1000000007;
ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
typedef long double ld;
ll power(ll x, ll y, ll p=mod)
{ll res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1;x = (x*x) % p;}return res;}
int main()
{
fast;
ll x;
cin>>x;
ll cnt=0;
ll val=100.0;
while(true)
{
    if(val>=x)
    {
        break;
    }
    val=val+0.01*val;
    cnt++;
}
cout<<cnt<<endl;
return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <set>
#include <string>

using namespace std;

int main() {
    int n;  string s; int q;    cin >> n >> s >> q;
    vector<set<int> > st(26);
    for (int i = 0; i < n; i++) {
        st[s[i]-'a'].insert(i);
    }

    vector<int> ans;
    for (int i = 0; i < q; i++) {
        int m;  cin >> m;

        if (m == 1) {
            int j;  char c; cin >> j >> c;
            j--;
            for (int k = 0; k < 26; k++) {
                if (st[k].find(j) != st[k].end())
                    st[k].erase(j);
            }
            st[c-'a'].insert(j);
        }
        else {
            int l, r;   cin >> l >> r;  l--, r--;
            int tmp = 0;
            for (int j = 0; j < 26; j++) {
                auto ite = st[j].lower_bound(l);
                if (ite != st[j].end() && *ite <= r)
                    tmp++;
            }
            ans.push_back(tmp);
        }
    }

    for (auto x: ans)
        cout << x << endl;

    return 0;
}

Measured memory_bytes: 27460
#include <bits/stdc++.h>
using namespace std ;
inline int Readin() {
	register int K = 0 , F = 1 ; register char C = getchar() ;
	while( C < '0' or C > '9' ) F = C == '-' ? -1 : 1 , C = getchar() ;
	while( C <= '9' and C >= '0' ) K = ( K << 1 ) + ( K << 3 ) + C - '0' , C = getchar() ;
	return F * K ;
}
const int MaxN = 100000 + 5 ;
int N , A[MaxN] , K ;
inline int Min( int A , int B ) {
	return A < B ? A : B ;
}
int main() {
	N = Readin() ;
	K = Readin() ;
	for(register int i = 0 ; ++i <= N ; A[i] = Readin() ) ;
	sort( A + 1 , A + 1 + N ) ;
	int Ans = 1000000000 ;
	for(register int i = K ; i <= N ; Ans = Min( Ans , A[i] - A[i-K+1] ) , ++i ) ;
	return not printf( "%d\n" , Ans ) ;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;

class F
{
	static int[] Read() => Console.ReadLine().Split().Select(int.Parse).ToArray();
	static void Main()
	{
		var z = Read();
		int h = z[0], w = z[1];
		var a = new int[h].Select(_ => Console.ReadLine()).ToArray();

		int sv = h + w, ev = sv + 1;
		var s = (i: 0, j: 0);
		var t = (i: 0, j: 0);

		var dag = new List<long[]>();
		for (int i = 0; i < h; i++)
			for (int j = 0; j < w; j++)
				if (a[i][j] == 'o')
				{
					dag.Add(new[] { i, h + j, 1L });
					dag.Add(new[] { h + j, i, 1L });
				}
				else if (a[i][j] == 'S')
				{
					s = (i, j);
					dag.Add(new[] { sv, i, 1L << 60 });
					dag.Add(new[] { sv, h + j, 1L << 60 });
				}
				else if (a[i][j] == 'T')
				{
					t = (i, j);
					dag.Add(new[] { i, ev, 1L << 60 });
					dag.Add(new[] { h + j, ev, 1L << 60 });
				}

		Console.WriteLine(s.i == t.i || s.j == t.j ? -1 : MaxFlow(ev, sv, ev, dag.ToArray()));
	}

	static long MaxFlow(int n, int sv, int ev, long[][] dag)
	{
		var map = Array.ConvertAll(new int[n + 1], _ => new List<long[]>());
		foreach (var e in dag)
		{
			map[e[0]].Add(new[] { e[1], e[2], map[e[1]].Count });
			map[e[1]].Add(new[] { e[0], 0, map[e[0]].Count - 1 });
		}

		long Bfs()
		{
			var from = new long[n + 1][];
			var u = new bool[n + 1];
			var minFlow = Enumerable.Repeat(long.MaxValue, n + 1).ToArray();
			var q = new Queue<long>();
			q.Enqueue(sv);

			while (q.TryDequeue(out var v))
			{
				if (v == ev) break;
				foreach (var e in map[v])
				{
					if (u[e[0]] || e[1] == 0) continue;
					from[e[0]] = e;
					u[e[0]] = true;
					minFlow[e[0]] = Math.Min(minFlow[v], e[1]);
					q.Enqueue(e[0]);
				}
			}

			if (from[ev] == null) return 0;
			long tv = ev;
			while (true)
			{
				from[tv][1] -= minFlow[ev];
				var rev = map[from[tv][0]][(int)from[tv][2]];
				rev[1] += minFlow[ev];
				if ((tv = rev[0]) == sv) break;
			}
			return minFlow[ev];
		}

		long M = 0, t;
		while ((t = Bfs()) > 0) M += t;
		return M;
	}
}


Measured memory_bytes: 33692
fun main(args: Array<String>) {
    abc062c()
}

fun abc062c() {
    val (h, w) = readLine()!!.split(" ").map { it.toLong() }

    // h or wが3の倍数の場合は直線に三分割
    if (h % 3L == 0L || w % 3L == 0L) {
        println(0)
        return
    }

    val minDiffOfAll = Math.min(calcAnswer(h, w), calcAnswer(w, h))

    println(minDiffOfAll)
}

private fun calcAnswer(h: Long, w: Long): Long {
    return (1 until h).map {
        val piece1 = it * w
        val remainHeight = h - it
        // 横の字に切るパターン
        val pieceH = (remainHeight / 2) * w
        val pieceHLarger = if (remainHeight % 2L == 0L) pieceH else (remainHeight / 2 + 1) * w
        val maxPieceH = Math.max(piece1, pieceHLarger)
        val minPieceH = Math.min(piece1, pieceH)
        val diffH = maxPieceH - minPieceH
        // 横/Tの字に切るパターン
        val pieceV = remainHeight * (w / 2)
        val pieceVLarger = if (w % 2L == 0L) pieceV else remainHeight * (w / 2 + 1)
        val maxPieceV = Math.max(piece1, pieceVLarger)
        val minPieceV = Math.min(piece1, pieceV)
        val diffV = maxPieceV - minPieceV

        Math.min(diffH, diffV)
    }.min()!!
}


Measured memory_bytes: 40828
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
const int INF=1e9;
struct edge{
    int to,cost;
    edge(int a,int b):to(a),cost(b){}
    edge(){}
};
struct data{
    int At,cost;
    bool flag;
    data(int a,int b,bool f):At(a),cost(b),flag(f){}
    data(){}
    bool operator>(const data &d)const{
        return cost>d.cost;
    }
};
int main(){
    int n,m;
    while(cin>>n>>m,n||m){
        vector<vector<edge> >V(n);
        vector<vector<int> >D(2,vector<int>(n,INF));
        for(int i=0;i<m;i++){
            int a,b,c;
            cin>>a>>b>>c;
            a--;b--;
            V[a].push_back(edge(b,c));
            V[b].push_back(edge(a,c));
        }
        priority_queue<data,vector<data>,greater<data> >Q;
        Q.push(data(0,0,false));
        while(!Q.empty()){
            data ins=Q.top();Q.pop();
            int At=ins.At,cost=ins.cost;bool flag=ins.flag;
            int cnv=(flag)?1:0;
            if(D[cnv][At]<cost)continue;
            D[cnv][At]=cost;

            for(int i=0;i<V[At].size();i++){
                edge e=V[At][i];
                Q.push(data(e.to,cost+e.cost,flag));
                if(!flag){
                    for(int j=0;j<V[e.to].size();j++){
                        edge _e=V[e.to][j];
                        if(_e.to==At)continue;
                        Q.push(data(_e.to,cost,true));
                    }
                }
            }
        }
        cout<<min(D[0][n-1],D[1][n-1])<<endl;

    }
    return 0;
}

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

#define pb push_back
#define mp make_pair
#define f first
#define s second

using namespace std;

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


int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;

    vector<vi> a(n, vi(3));
    for(int i=0; i < n; i++){
        for(int j=0; j < 3; j++){
            cin >> a[i][j];
        }
    }
    
    vector<vi> dp(n, vi(3, -1));
    
    for(int i=0; i < 3; i++){
        dp[0][i] = a[0][i];
    }

    for(int i=1; i < n; i++){
        for(int j=0; j < 3; j++){
            for(int k=0; k < 3; k++){

                if(j == k) continue;
                dp[i][k] = max(dp[i][k], dp[i-1][j] + a[i][k]);

            }
        }
    }

    cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2])) << endl;


    return 0;
}

Measured memory_bytes: 11264
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};

typedef struct node * Node;

Node root;

Node treeMinimum(Node x){


}

Node treeMaximum(Node x){


}

Node treeSearch(Node u, int k){
  if(u==NIL||k==u->key) return u;
  if(k<u->key) return treeSearch(u->left,k);
  else return treeSearch(u->right,k);

}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key<x->key) x=x->left;
    else x=x->right;
  }

    z->parent=y;

    if(y==NIL) root=z;
    else if(z->key<y->key) y->left=z;
    else y->right=z;

}

void inorder(Node u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
  
}

void preorder(Node u){
  if(u==NIL) return;

  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 20476
/*
    Vishal Raj 
    IIT Kharagpur
*/

#include <bits/stdc++.h>

using namespace std;

#define li long long int

int main() {
    li n; cin>>n;
    li k; cin>>k;
    vector<li> dp(n,LLONG_MAX);
    dp[0] = 0;
    vector<li> h(n,0); 
    for( int i = 0; i < n; i++ ) cin>>h[i];
    for( int i = 1; i < n ; i++ ) {
        for( int j = i-1; j >= max(0ll,i-k) ; j-- ) {
            dp[i] = min(dp[i],dp[j]+abs(h[i]-h[j]));
        }
    }
    cout<<dp.back()<<"\n";
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    ll n;
    cin >> n;
    
    ll cnt = n/2;
    if(n&1)cnt++;

    printf("%f",double(cnt)/double(n));
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <queue>
#include <algorithm>
#define R register
#define IN inline
#define W while
#define gc getchar()
#define MX 200500
template <class T>
IN void in(T &x)
{
	x = 0; R char c = gc;
	for (; !isdigit(c); c = gc);
	for (;  isdigit(c); c = gc)
	x = (x << 1) + (x << 3) + c - 48;
}
int n, m, low, hig, rcnt, ans;
int buf[MX];
struct INFO {int l, r;} dat[MX];
IN bool operator < (const INFO &x, const INFO &y) {return x.l == y.l ? x.r > y.r : x.l < y.l;}
std::priority_queue <int, std::vector <int>, std::greater <int> > pq;
int main(void)
{
	in(n), in(m);
	low = 1, hig = m;
	for (R int i = 1; i <= n; ++i) in(dat[i].l), in(dat[i].r);
	std::sort(dat + 1, dat + 1 + n);
	for (R int i = 1; i <= n; ++i)
	{
		pq.push(dat[i].r);
		if (low <= dat[i].l) ++low;
		else
		{
			buf[++rcnt] = pq.top();
			pq.pop();
		}
	}
	std::sort(buf + 1, buf + 1 + rcnt);
	for (R int i = rcnt; i; --i)
	{
		if (hig >= buf[i] && hig >= low) --hig;
		else ++ans;
	}
	printf("%d", ans);
}

Measured memory_bytes: 3192
import sys
n = int(input())
mark = [[[],[]]for _ in range(n+1)]
color = [0 for _ in range(n+1)]
done = set()
for i in range(n-1):
    a,b,c = map(int,sys.stdin.readline().split())
    if c&1:
        mark[a][1].append(b)
        mark[b][1].append(a)
    else:
        mark[a][0].append(b)
        mark[b][0].append(a)
run = [1]
temp = []
while(len(run))>0:
    next = run.pop(0)
    done.add(next)
    # print('NEXT:',next)
    if color[next]==0:
        for v in mark[next][1]:
            if v not in done:
                color[v]=1
                temp.append(v)
        for v in mark[next][0]:
            if v not in done:
                temp.append(v)
    else:
        for v in mark[next][0]:
            if v not in done:
                color[v] = 1
                temp.append(v)
        for v in mark[next][1]:
            if v not in done:
                temp.append(v)
    if len(run)==0:
        run=run+temp
        temp=[]
    # print('Then',color)
for i in range(1,n+1):
    sys.stdout.write(str(color[i])+'\n')

Measured memory_bytes: 45724
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>

#define rep(i, n) REP(i, 0, n)
#define REP(i, a, n) for(int i = a ; i < (int)n ; i++)
#define INF 1e9
#define MAX_N 100001

using namespace std;

struct Card{
  char c;
  int num;
};

int n;
Card A[100001], B[100001];
int comp;
Card l[MAX_N/2+2];
Card r[MAX_N/2+2];

void merge(int left, int right, int mid){
  rep(i, mid-left){
    l[i] = B[left + i];
  }
  rep(i, right-mid){
    r[i] = B[mid + i];
  }

  l[mid-left].num = r[right-mid].num = INF;
  
  int left_idx, right_idx;
  left_idx = right_idx = 0;
  REP(i,left,right){
    comp++;
    if(l[left_idx].num <= r[right_idx].num){
      B[i] = l[left_idx];
      left_idx++;
    }else{
      B[i] = r[right_idx];
      right_idx++;
    }
  }
}

void mergeSort(int left, int right){
  if(right - left > 1){
    int mid = (right + left)/2;
    mergeSort(left, mid);     // ???
    mergeSort(mid, right);    // ???
    merge(left, right, mid);  // ?????????
  }
}

int partition(int p, int r){
  int i;
  i = p-1;
  REP(j, p, r){
    if(A[j].num <= A[r].num){
      i++;
      swap(A[i], A[j]);
    }
  }
  swap(A[i+1], A[r]);
  
  return i+1;
}

void quickSort(int p, int r){
  if(r - p > 0){
    int ret = partition(p, r);
    quickSort(p, ret-1);
    quickSort(ret+1, r);
  }
}

bool compare(Card l, Card r){
  return (l.num <= r.num);
}

signed main(){

  cin >> n;
  rep(i, n){
    cin >> A[i].c >> A[i].num;    
    B[i].c = A[i].c;
    B[i].num = A[i].num;
  }
  
  quickSort(0, n-1);
  mergeSort(0, n);

  bool flag = false;
  rep(i, n){
    if(A[i].c != B[i].c) flag = true;
  }
  
  if(flag) cout << "Not stable" << endl;
  else cout << "Stable" << endl;

  rep(i, n){
    cout << A[i].c << " " << A[i].num << endl;
  }

}

Measured memory_bytes: 5420
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
    int x=0,f=1;char c=getchar();
    while(c<'0' || c>'9'){if(c=='-') f=0;c=getchar();}
    while(c>='0' && c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
    return f?x:-x;
}
int n,a[110],s1,s2;
char ch;
int main()
{
    n=read();
    for(int i=1;i<=n;i++) a[i]=read();
    sort(a+1,a+n+1,greater<int>());
    for(int i=1;i<=n;i++)
    {
        if(i&1) s1+=a[i];
        else s2+=a[i];
    }
    printf("%d",s1-s2);
    return 0;
}


Measured memory_bytes: 256
N = int(input())
W = list(map(int,input().split()))
array = [abs(W[0]-sum(W[1:]))]
diff = 0
for i in range(1,N-1):
    diff = abs(sum(W[:i+1])- sum(W[i+1:]))
    array.append(diff)

print(min(array))

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

#define fori(i,a,b)    for(int i=a;i<=b;i++)
#define ford(i,a,b)   for(int i=a;i>=b;i--)
#define all(a)        a.begin(), a.end()
#define in(c,x)       ((c).find(x) != (c).end())
#define isp(c,x)      (find(all(c),x) != (c).end())
#define pb             push_back
#define ppb            pop_back
#define sz(x)          (int)x.size()
#define fill(a,v)      memset(a, v, sizeof a)
#define fs first
#define sc second
#define ub upper_bound
#define lb lower_bound
#define en '\n'

typedef long long int lli;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long int> vlli;
typedef pair< int, int > pii;
typedef pair< lli, lli > plli;
typedef list<int> li;
typedef map<int, int> mi;
typedef map<lli, lli> mlli;
lli gcd(lli a,lli b){return (!b)?a:gcd(b,a%b);}
int t = 1; int ti;



const int N = 1e5 + 5;
int dp[N], a[105];


void solve(){
    int n, k; cin>>n>>k;

    int y = N;

    fori(i, 1, n){
        cin>>a[i];
        y = min(a[i], y);
    }    

    // cout<<y;

    fori(i, 0, y-1){
        dp[i] = 1; 
    }

    fori(i, y, k){
        int fg = 0;

        fori(j, 1, n){
            if(i-a[j] >= 0){
                fg |= dp[i-a[j]];
            }
        }

        if(fg == 1)
        dp[i] = 0;

        else {
            dp[i] = 1;
        }
    }

    cout<<(!dp[k]? "First":"Second");
}
//THINK OF SPECIAL CASES, ARRAY LIMITS, LLI vs INT, 1LL

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

    // cin>>t;

    // for(ti= 1; ti <= t; ti++)
    solve();

//    cout<<"\nTHINK OF SPECIAL CASES, ARRAY LIMITS, LLI vs INT, 1LL";
}

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

using namespace std;

int h,w,n;
int d[1009][1009];
int dp[1009][1009];
int main(){
while(1){
	scanf("%d%d%d",&h,&w,&n);
if(h == 0)break;
	for(int i = 1;i <= h;i++){
		for(int j = 1;j <= w;j++){
			scanf("%d",&d[i][j]);
			dp[i][j] = 0;
		}
	}

	dp[1][1] = n-1;

	for(int i = 1;i <= h;i++){
		for(int j = 1;j <= w;j++){
			if(dp[i][j] % 2 == 0){
				dp[i+1][j] += dp[i][j]/2;
				dp[i][j+1] += dp[i][j]/2;
			}else{
				if(d[i][j] == 0){
					dp[i+1][j] += (dp[i][j]+1)/2;
					dp[i][j+1] += dp[i][j]/2;
				}else{
					dp[i][j+1] += (dp[i][j]+1)/2;
					dp[i+1][j] += dp[i][j] / 2;
				}
			}
		}
	}

	for(int i = 1;i <= h;i++){
		for(int j = 1;j <= w;j++){
			if(dp[i][j] % 2 == 0)continue;
			if(d[i][j] == 0)d[i][j] = 1;
			else d[i][j] = 0;
		}
	}
	
	int x = 1,y = 1;
	while(x <= w && y <= h){
		if(d[y][x] == 0)y++;
		else x++;
	}
	printf("%d %d\n",y,x);
}
	return 0;
}


Measured memory_bytes: 9112
import sys
inputs = sys.stdin.readlines()
n = int(inputs[0])
L = list(map(int, inputs[1].split()))
A = sorted(L)
 
ans = 0
for i in range(n-1, 0, -1):
    l, r = 0, i-1
    while l < r:
        if A[i] < A[l] + A[r]:
            ans += r-l
            r -= 1
        else:
            l += 1

print(ans)

Measured memory_bytes: 3188
use std::str::FromStr;
use std::io::*;
use std::collections::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(&mut i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: &mut R, o: &mut W) {
    let mut i = AtRead::from(i);

    let (n, m) = i.read2::<usize, usize>();
    let mut lrds = Vec::new();
    for _ in 0..m {
        let (l, r, d) = i.read3::<usize, usize, isize>();
        lrds.push((l - 1, r - 1, d));
    }
    let r = if solve(n, &lrds) { "Yes" } else { "No" };
    writeln!(o, "{}", r).unwrap();
}
fn solve(n: usize, lrds: &[(usize, usize, isize)]) -> bool {
    let mut m = HashMap::new();
    for &lrd in lrds {
        insert(&mut m, lrd);
    }
    let mut x = vec![None; n];
    let mut q = Vec::new();
    while let Some(&k) = m.keys().next() {
        q.push(k);
        x[k] = Some(0);
        while let Some(l) = q.pop() {
            let rds = m.remove(&l).unwrap();
            let xl = x[l].unwrap();
            for &(r, d) in &rds {
                let xr_e = xl + d;
                if let Some(xr) = x[r] {
                    if xr != xr_e {
                        return false;
                    }
                } else {
                    x[r] = Some(xr_e);
                    q.push(r);
                }
            }
        }
    }
    true
}
fn insert(m: &mut HashMap<usize, Vec<(usize, isize)>>, (l, r, d): (usize, usize, isize)) {
    m.entry(l).or_insert(Vec::new()).push((r, d));
    m.entry(r).or_insert(Vec::new()).push((l, -d));
}

struct AtRead<'a, R: BufRead + 'a> {
    r: &'a mut R,
    s: String,
}

macro_rules! fn_read {
        {$f:ident($($v:ident: $t:ident),*)} => {
            fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.next().split(' ');
                $(
                    let $v = next(i);
                )*
                ($($v),*)
            }
        };
    }

impl<'a, R: BufRead + 'a> AtRead<'a, R> {
    fn from(r: &'a mut R) -> Self {
        AtRead {
            r: r,
            s: String::new(),
        }
    }
    fn next(&mut self) -> &str {
        self.s.clear();
        self.r.read_line(&mut self.s).unwrap();
        self.s.trim()
    }

    fn_read! { read2(v1: T1, v2: T2) }
    fn_read! { read3(v1: T1, v2: T2, v3: T3) }
}

fn next<'a, T: FromStr, I: std::iter::Iterator<Item = &'a str>>(i: &mut I) -> T {
    i.next().unwrap().parse().ok().unwrap()
}


Measured memory_bytes: 28872
#include <iostream>
#include <complex>
using namespace std;
const double EPS = 1e-10;
typedef complex<double> P;

bool ior1(double x, double y, double z)
{
  return x < y + EPS && y < z + EPS;
}

bool ior(P a1, P a2, P b1, P b2)
{
  bool res;
  if (a1.real() < b1.real())
    res = ior1(a1.real(), b1.real(), a2.real());
  else
    res = ior1(b1.real(), a1.real(), b2.real());
  if (res) {
    if (a1.imag() < b1.imag())
      return ior1(a1.imag(), b1.imag(), a2.imag());
    else
      return ior1(b1.imag(), a1.imag(), b2.imag());
  }
  return false;
}

int main(int argc, char **argv)
{
  double xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2;
  while (cin >> xa1 >> ya1 >> xa2 >> ya2 >> xb1 >> yb1 >> xb2 >> yb2) {
    if (ior(P(xa1, ya1), P(xa2, ya2), P(xb1, yb1), P(xb2, yb2)))
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}

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

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define sizeOf(A) (sizeof(A))/(sizeof(A[0]))
#define odd(x) ((x) % (2))
#define fastio ios_base::sync_with_stdio(false), cin.tie(0);
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
const ll MOD = 1e9 + 7;

int main() {
    fastio;

    int a, b, c;
    cin >> a >> b >> c;
    if (a == b) {
        cout << c << "\n";
    } else if (a == c) {
        cout << b << "\n";
    } else {
        cout << a << "\n";
    }
    return 0;
}


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

using namespace std;
const int N = 5e3 + 5;
int dp[N], p[N], x[N];
vector <int> g[N];

void dfs(int v) {
    if (g[v].empty()) {dp[v] = x[v]; return ;}
    vector <int> vec;
    bitset <N> bt = 0;
    int res = 0;
    for (int u : g[v]) {
        dfs(u);
        if (x[u] < dp[u] - x[u]) res += x[u];
        else res += dp[u] - x[u];
        vec.push_back(abs(2 * x[u] - dp[u]));
        dp[v] += dp[u];
    }
    bt[res] = 1;
    for (int i : vec) bt |= bt<<i;
    for (int i = x[v]; i >= 0; i--) if (bt[i] == 1) {
        dp[v] += x[v] - i;
        return ;
    }
    cout << "IMPOSSIBLE\n";
    exit(0);
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n; cin >> n;
    for (int i = 2; i <= n; i++) cin >> p[i], g[p[i]].push_back(i);
    for (int i = 1; i <= n; i++) cin >> x[i];
    dfs(1);
    cout << "POSSIBLE\n";

    return 0;
}


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

using namespace std;

#define sz(x) (int) x.size()
#define all(a) a.begin(), a.end()

const int MAXN = 5050;
const int mod = (int) 1e9 + 7;

long long binpow(long long x, long long p) {
  long long res = 1;
  while (p) {
    if (p & 1) {
      res = (res * x) % mod;
      p--;
    } else {
      x = (x * x) % mod;
      p /= 2;
    }
  }
  return res % mod;
}

long long inv(long long x) {
  return binpow(x, mod - 2) % mod;
}

int n;
string s;
long long dp[MAXN][MAXN];

int main() {

    scanf("%d\n", &n);
    getline(cin, s);

    dp[0][0] = 1;
    for (int i = 0; i < n; i++)
        for (int j = 0; j <= i; j++) {
            dp[i + 1][j + 1] = (dp[i + 1][j + 1] + 2ll * dp[i][j]) % mod;
            dp[i + 1][max(j - 1, 0)] = (dp[i + 1][max(j - 1, 0)] + dp[i][j]) % mod;
        }

    long long ans = dp[n][sz(s)] * inv(binpow(2, sz(s))) % mod;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 197248
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

const Inf = 1 << 60

func main() {
	A, B, Q := ReadInt(), ReadInt(), ReadInt()
	s, t := ReadInts(A), ReadInts(B)
	sort.Ints(s)
	sort.Ints(t)
	s = append([]int{-Inf}, s...)
	t = append([]int{-Inf}, t...)
	s = append(s, Inf)
	t = append(t, Inf)
	for q := 0; q < Q; q++ {
		x := ReadInt()
		rsIdx := sort.Search(len(s), func(i int) bool {
			return x <= s[i]
		})
		rtIdx := sort.Search(len(t), func(i int) bool {
			return x <= t[i]
		})
		ans := Inf
		for _, a := range s[rsIdx-1 : rsIdx+1] {
			for _, b := range t[rtIdx-1 : rtIdx+1] {
				ans = Min(ans, Abs(a-x)+Abs(b-a))
				ans = Min(ans, Abs(b-x)+Abs(b-a))
			}
		}
		fmt.Println(ans)
	}
}

func Abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func Min(xs ...int) int {
	min := xs[0]
	for _, x := range xs[1:] {
		if min > x {
			min = x
		}
	}
	return min
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


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

using namespace std;

const int MOD = 1e9 + 7;

void solver() {
	int H, W, K;
	cin >> H >> W >> K;

	vector< string > g(H);

	for(int i = 0; i < H; ++i)
		cin >> g[i];

	int ans = 0;

	for(int i = 0; i < (1 << H); ++i) {
		for(int j = 0; j < (1 << W); ++j) {
			
			int blacks = 0;
			
			for(int k = 0; k < H; ++k) {
				for(int l = 0; l < W; ++l) {
					if (i & (1 << k)) continue;
					if (j & (1 << l)) continue;
					blacks += (g[k][l] == '#');
				}
			}

			ans += (blacks == K);
		}
	}

	cout << ans << '\n';
}

int main() {

	ios_base :: sync_with_stdio(0); cin.tie(NULL);

	int t;
	//cin >> t;
	t = 1;

	while(t--)
		solver();

	return 0;
}


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

int main(){
    long long int a,b,c,K;
    cin >> a>>b>>c>>K;
    if(a < K){
        if(a+b < K){
            cout << a - K+a+b;
        }else{
            cout << a;
        }
    }else{
        cout << K;
    }

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    string S;
    cin >> S;
    int ans = 0;
    for(int i = 0; i < S.size() - 1; i++) {
        if(S[i] == S[i + 1]) {
            ans++;
            if(S[i + 1] == '0') {
                S[i + 1] = '1';
            } else {
                S[i + 1] = '0';
            }
        }
    }
    cout << ans << endl;
}


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

int main(){
    int x;
    cin >> x;
    int res=x;
    bool flg=true;
    vector<int> prime;
    prime.push_back(2);
    if(x==2){
        cout << 2 << endl;
    }else{
        for(int i=3; i<x; i++){ // エラトステネスの篩
            flg=true;
            for(int j=2; j<i; j++){
                if(i%j == 0){
                    flg = false;
                    break;
                }
            }
            if(flg){
                prime.push_back(i);
            }
        }
        while(true){
            flg = true;
            for(int i=0; i<prime.size(); i++){
                if(x%prime.at(i) == 0){
                    flg = false;
                    break;
                }
            }
            if(flg){
                cout << x << endl;
                break;
            }else{
                x++;
            }
        }
    }
    return 0;
}


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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int h,w, ch,cw, dh, dw;
	cin >>h >>w >>ch >>cw >>dh >>dw;
	vector<string> ba(h);
	rep(i, h) cin >>ba[i];
	ch--;cw--;dh--;dw--;
	
	const int dr[]={0,1,0,-1,0};
	typedef tuple<ll, int, int> pli;
	const ll INF = 1e18;
	priority_queue< pli, vector<pli>, greater<pli> > que;
	vector<VL> d(h, VL(w, INF));
	d[ch][cw] = 0;
	que.emplace(0, ch, cw);
	while(!que.empty()){
		auto [cost, cy, cx ] = que.top(); que.pop();
		if(d[cy][cx] < cost) continue;

		rep(i, 4){
			int ny = cy+dr[i], nx=cx+dr[i+1];
			if(ny<0 || ny>=h || nx<0 || nx>=w || ba[ny][nx] !='.') continue;
			ll ncst = d[cy][cx];
			if(d[ny][nx]> ncst){
				d[ny][nx] = ncst; que.emplace(ncst, ny, nx);
			}
		}
		rep2(yy, -2,3) rep2(xx, -2,3){
			int ny = cy+yy, nx=cx+xx;
			if(ny<0 || ny>=h || nx<0 || nx>=w || ba[ny][nx] !='.') continue;
			ll ncst = d[cy][cx] + 1;
			if(d[ny][nx] > ncst){
				d[ny][nx] = ncst; que.emplace(ncst, ny, nx);
			}
		}
	}

	ll ans = d[dh][dw];
	cout << (ans!=INF? ans: -1) <<"\n";
	
	//for(auto xl: d){for(auto x :xl) cerr<<setw(3)<<x<<" ";dbg();}

	return 0;
}



Measured memory_bytes: 12516
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	ll a,b,c,d;
	cin >> a >> b >> c >> d;
	auto lcm = [&](ll x,ll y){
		return x*y/__gcd(x,y);
	};
	auto f = [&](ll x){
		return x - x/c - x/d + x/lcm(c,d);
	};
	cout << f(b) - f(a-1) << endl;
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));

            return;
        }

        public void Solve(ConsoleInput cin)
        {

            var N = cin.ReadInt;
            var H = cin.ReadIntArray(N);

            for (int i = N - 1; i > 0; i--) {
                if (H[i] < H[i - 1]) {
                    H[i - 1]--;
                    if (H[i] < H[i - 1]) {
                        Console.WriteLine("No");
                        return;
                    }
                }
            }
            Console.WriteLine("Yes");
            return;
        }
    }

    public static class Extensions
    {
        public static string Reverse(this string sourse)
        {
            char[] chrAry = sourse.ToCharArray();
            Array.Reverse(chrAry);
            return new string(chrAry);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


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

int main() {
    double w,h,x,y;
    cin >> w >> h >> x >> y;

    printf("%.10f ", w*h/2);

    if (w/2==x && h/2==y) {
        printf("1\n");
    }
    else {
        printf("0\n");
    }
    return 0;
}

Measured memory_bytes: 3792
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;
#define rep2(x,from,to) for(int x = (from); x < (to); ++(x))
#define rep(x,to) rep2(x,0,to)
bool isGoal(int n, int m, int s, int t, string bar, int c) {
	s--,t--;
	if(c != -1) {
		bar[c] = '1';
	}
	rep(i,m) {
		rep(j,n-1) {
			if(bar[i *(n-1) + j] == '1') {
				if(s == j) s = j + 1;
				else if(s == j + 1) s = j;
			}
		}
	}
	if(s == t) return true;
	return false;
}
int main() {
	int n, m, s, t;
	string str;
	while(cin >> n && n) {
		cin >> s >> t >> m;
		string bar;
		rep(i,m) {
			cin >> str;
			bar += str;
		}
		if(isGoal(n,m,s,t,bar,-1)) {
			cout << 0 << endl;
			continue;
		}
		bool f = 0;
		rep(i,m) {
			rep(j,n-1) {
				if(j==0 && bar[i*(n-1)+1] == '0') {
					if(isGoal(n,m,s,t,bar,i*(n-1))) {
						cout << i+1 << " " << j+1 << endl;
						f = 1;
						break;
					}
				} else if(j == n-2 && bar[i*(n-1)+n-3] == '0') {
					if(isGoal(n,m,s,t,bar,i*(n-1)+n-2)) {
						cout << i+1 << " " << j+1 << endl;
						f = 1;
						break;
					}
				} else if((j != 0 || j != n-2) && bar[i*(n-1)+j-1] == '0' && bar[i*(n-1)+j+1] == '0') {
					if(isGoal(n,m,s,t,bar,i*(n-1)+j)) {
						cout << i+1 << " " << j+1 << endl;
						f = 1;
						break;				
					}
				}
			}
			if(f) break;
		}
		if(!f) cout << 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
#include <tuple>
#include <list>
#include <deque>
#include <stack>
#include <complex>
#include <functional>
#include <regex>
#include <map>
#include <numeric>

using namespace std;

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

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

using ll = long long;
using ld = long double;
using ull = unsigned long long;

int N, Q;

// G[node_no][edge_no]
vector<vector<int>> G;
vector<int> C;

void solve(int node, int cnt, int prev) {
  C[node] += cnt;
  for (auto next : G[node]) {
    if (next == prev) continue;
    solve(next, C[node], node);
  }
}

int main(void) {
  cin >> N >> Q;
  G.resize(N);
  C.assign(N, 0);
  rep(i, N - 1) {
    int a, b; cin >> a >> b;
    G[a-1].push_back(b-1);
    G[b-1].push_back(a-1);
  }
  rep(i, Q) {
    int p, x; cin >> p >> x;
    C[p-1] += x;
  }
  solve(0, 0, -1);
  rep(i, N) {
    if (i) cout << " ";
    cout << C[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 23552
n, k = map(int,input().split())
r,s,p = map(int,input().split())
t = list(input())
dp = [0] * n #勝ったら1
ans = 0
for i in range(k):
    if t[i] == 'r':
        ans += p 
    elif t[i] == 's':
        ans += r 
    else:
        ans += s 
    dp[i] = 1
for i in range(k, n):
    if t[i] == 'r':
        if t[i - k] == t[i] and dp[i - k] == 1:
            continue
        else:
            dp[i] = 1
            ans += p 
            
    elif t[i] == 's':
        if t[i - k] == t[i] and dp[i - k] == 1:
            continue
        else:
            dp[i] = 1 
            ans += r 
    else:
        if t[i - k] == t[i] and dp[i - k] == 1:
            continue
        else:
            dp[i] = 1
            ans += s 

print(ans)
        


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

int main() {
  int N,Z=0;
  cin>>N;
  map<string,int> p;
  vector<string> a;
  for(int i=0;i<N;i++){
    string S;
    cin>>S;
    if(p.count(S)){
      p.at(S)++;
    }
    else{
      p[S]=1;
      a.push_back(S);
    }
  }
  for(int i=0;i<a.size();i++){
    if(p.at(a.at(i))%2==1){
      Z++;
    }
  }
  cout<<Z<<endl;
}

Measured memory_bytes: 13300
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int h, w, n; cin >> h >> w >> n;
	vector<int>a(n);
	rep(i, n)cin >> a[i];
	vector<vector<int>>res(h, vector<int>(w, 0));
	int x = 0, y = 0;
	rep(i, n) {
		rep(j, a[i]) {
			res[x][y] = i + 1; y++;
			if (y == w) {
				x++; y = 0;
			}
		}
	}
	rep(i, h) {
		if (i & 1) {
			reverse(res[i].begin(), res[i].end());
		}
	}
	rep(i, h) {
		rep(j, w) {
			cout << res[i][j];
			if (j != w - 1)cout << " ";
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 512
function main(input) {
  input = input.trim().split("\n").map(n => Number(n));
  let result = 0;
  let max = 0;
  for (let i = 0; i < 5; i++) {
    const num = input[i];
    const remain = num%10;
    if (remain === 0) {
      result += num;
    } else {
      result += num + 10 - remain;
      if (max < 10 - remain) max = 10 - remain;
    }
  }
  result -= max;
  console.log(result);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 11468