akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]
#![allow(dead_code)]

use std::thread;
use std::io::{ self, Read };
use std::fmt;
use std::iter::Iterator;
use std::cmp::*;
use std::collections::*;
use std::str::*;

#[derive(Default)]
struct Input {
    buf: Vec<String>
}

impl Input {
    fn new() -> Input {
        Input { buf: Vec::new() }
    }

    fn read<T: FromStr>(&mut self) -> T 
    where <T as FromStr>::Err: fmt::Debug {
        self.next().unwrap().parse::<T>().unwrap()
    }

    fn read_2<T: FromStr, U: FromStr>(&mut self) -> (T, U)
    where <T as FromStr>::Err: fmt::Debug,
          <U as FromStr>::Err: fmt::Debug {
        (self.read(), self.read())
    }

    fn read_bytes(&mut self) -> Vec<u8> {
        self.next().unwrap().into_bytes()
    }

    fn read_n<T: FromStr>(&mut self, n: usize) -> Vec<T>
    where <T as FromStr>::Err: fmt::Debug {
        let mut v = Vec::new();
        for _ in 0..n { v.push(self.read::<T>()); }
        v
    }
}

impl Iterator for Input {
    type Item = String;
    fn next(&mut self) -> Option<String> {
        while self.buf.is_empty() {
            let mut s = String::new();
            let _res = io::stdin().read_line(&mut s);
            self.buf = s.split_whitespace().map(|s| s.to_owned()).collect::<Vec<_>>();
            self.buf.reverse();
        }
        self.buf.pop()
    }
}

fn f(a: usize, s: &[u8]) -> bool {
    for (i, c) in s.iter().enumerate() {
        if i == a {
            if *c != b'-' { return false; }
        } else {
            if *c < b'0' || b'9' < *c { return false; }
        }
    }
    true
}

fn run() {
    let mut ip = Input::new();
    let a: usize = ip.read();
    let _b: usize = ip.read();
    let s = ip.read_bytes();
    if f(a, &s) {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let _ = thread::Builder::new()
        .stack_size(10 * 1024 * 1024)
        .spawn(run).unwrap()
        .join();
}

Measured memory_bytes: 8572
#include<bits/stdc++.h>
using namespace std;
int n,m;
struct node{
	int p,y,num,rank;
}a[100100];
bool cmp(node x,node y){
	if(x.p==y.p){
		return x.y<y.y;
	}
	return x.p<y.p;
}
bool cmpp(node x,node y){
	return x.num<y.num;
}
void print(int x){
	int p=a[x].p,r=a[x].rank;
	if(p>=100000) cout<<p;
	if(p<100000 && p>=10000) cout<<"0"<<p;
	if(p<10000  && p>=1000) cout<<"00"<<p;
	if(p<1000   && p>=100) cout<<"000"<<p;
	if(p<100    && p>=10) cout<<"0000"<<p;
	if(p<10) cout<<"00000"<<p;
	if(r>=100000) cout<<r<<endl;
	if(r<100000 && r>=10000) cout<<"0"<<r<<endl;
	if(r<10000  && r>=1000) cout<<"00"<<r<<endl;
	if(r<1000   && r>=100) cout<<"000"<<r<<endl;
	if(r<100    && r>=10) cout<<"0000"<<r<<endl;
	if(r<10) cout<<"00000"<<r<<endl;
}
int main(){
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		cin>>a[i].p>>a[i].y;
		a[i].num=i;
	}
	sort(a+1,a+m+1,cmp);
	for(int i=1;i<=m;i++){
		if(a[i].p!=a[i-1].p) a[i].rank=1;
		else a[i].rank=a[i-1].rank+1;
	}
	sort(a+1,a+m+1,cmpp);
	for(int i=1;i<=m;i++){
		print(i);
	}
	return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    // Your code here!
    ll n,m,sum=0;
    cin>>n>>m;
    vector<ll>a(n);
    rep(0,i,n){
        cin>>a[i];
        sum+=a[i];
    }
    double s=1.*sum/(4.*m);
    sort(a.rbegin(),a.rend());
    rep(0,i,m){
        if(s>a[i]){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
}

Measured memory_bytes: 256
x = int(input())
while x != 0:
    y = 1000 - x
    a = y//500
    b = (y-500*a)//100
    c = (y-(500*a+100*b))//50
    d = (y-(500*a+100*b+50*c))//10
    e = (y-(500*a+100*b+50*c+10*d))//5
    f = (y-(500*a+100*b+50*c+10*d+5*e))//1
    g = a+b+c+d+e+f
    print(g)
    x = int(input())


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


using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const int  INF = 1 << 29;
const ll INFL = 1LL << 60;
const ll mod = 998244353;


int main() {

	int h, w;
	cin >> h >> w;
	VVC v(h, VC(w));
	REP(i, h)REP(j, w)cin >> v[i][j];


	VVI ans(h, VI(w, INF));
	ans[0][0] = 0;

	queue<pair<int, pair<int, int>>> q;
	q.push({ 0,{0,0} });

	VVB b(100, VB(100, false));


	int an = INF;

	while (!q.empty()) {
		int i = q.front().first;
		int j = q.front().second.first;
		int cnt = q.front().second.second;

		q.pop();

		if (i == h - 1 && j == w - 1) {
			an = min(an, cnt);

			continue;
		}

		if (i != h - 1) {
			if (v[i][j] != v[i + 1][j]) {
				ans[i + 1][j] = min(ans[i + 1][j], ans[i][j] + 1);
			}
			else {
				ans[i + 1][j] = min(ans[i + 1][j], ans[i][j]);
			}

			if (!b[i + 1][j])q.push({ i + 1,{j,cnt} });
			b[i + 1][j] = true;
		}
		if (j != w - 1) {
			if (v[i][j] != v[i][j+1]) {
				ans[i][j+1] = min(ans[i][j+1], ans[i][j] + 1);
			}
			else {
				ans[i][j + 1] = min(ans[i][j + 1], ans[i][j]);
			}
			if (!b[i][j + 1])q.push({ i,{j + 1,cnt } });
			b[i][j + 1] = true;
		}
	}

	int a = (ans[h - 1][w - 1] + 1) / 2;
	if (v[0][0] == '#'&&v[h - 1][w - 1] == '#')a++;

	cout << a << endl;


}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const double pi = acos(-1);

int main() {
    ll h, w;
    cin >> h >> w;
    
    vector<string> board(h);
    rep(i, h) {
        cin >> board[i];
    }
    
    vvl L(h, vl(w));  // L[i][j] : (i,j)の左側の障害物のないマスの連続している個数
    rep(i, h) {
        for(ll j = 1; j < w; j++) {
            if(board[i][j-1] == '#') {
                L[i][j] = 0;
            }
            else {
                L[i][j] = L[i][j-1] + 1;
            }
        }
    }

    vvl R(h, vl(w));  // R[i][j] : (i,j)の右側の障害物のないマスの連続している個数
    rep(i, h) {
        for(ll j = w-2; j >= 0; j--) {
            if(board[i][j+1] == '#') {
                R[i][j] = 0;
            }
            else {
                R[i][j] = R[i][j+1] + 1;
            }
        }
    }

    vvl U(h, vl(w));  // U[i][j] : (i,j)の上側の障害物のないマスの連続している個数
    for(ll i = 1; i < h; i++) {
        rep(j, w) {
            if(board[i-1][j] == '#') {
                U[i][j] = 0;
            }
            else {
                U[i][j] = U[i-1][j] + 1;
            }
        }
    }

    vvl D(h, vl(w));  // D[i][j] : (i,j)の下側の障害物のないマスの連続している個数
    for(ll i = h-2; i >= 0; i--) {
        rep(j, w) {
            if(board[i+1][j] == '#') {
                D[i][j] = 0;
            }
            else {
                D[i][j] = D[i+1][j] + 1;
            }
        }
    }

    ll ans = 0;
    rep(i, h) {
        rep(j, w) {
            if(board[i][j] == '#') {
                continue;
            }
            chmax(ans, L[i][j] + R[i][j] + U[i][j] + D[i][j] + 1);
        }
    }

    out(ans);
    re0;
}

Measured memory_bytes: 131328
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
      }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
// typedef
typedef complex<double> Point;
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;

const int MAX = 300000;
int a[MAX], rui[MAX];
signed main(){
  int n, X;
  scanf("%lld%lld", &n, &X);
  rrep(i,n)scanf("%lld", &a[i]);
  rrep(i,n)rui[i] = rui[i-1]+a[i];
  int ans = INF;
  rrep(K,n){
    int sum = 0, c = 5, d = K;
    sum += c*(rui[n]-rui[n-d]);
    sum += X*(K+n);
    int now = n-d;
    while(now > 0){
      int r = now, l = max(0LL, now-d);
      sum += c*(rui[r]-rui[l]);
      c += 2;now -= d;
      if(INF < sum)sum = INF;
    }
    chmin(ans, sum);
  }
  printf("%lld\n", ans);
	return 0;
}










Measured memory_bytes: 3840
n=int(input())
a_box=list(map(int,input().split()))
b_box=list(map(int,input().split()))
c_box=list(map(int,input().split()))

count=0
number=-10
for i in a_box:
    i=i-1
    count +=b_box[i]
    if number+1==i:
        count +=c_box[number]
    number=i

print(count)

Measured memory_bytes: 38256
from bisect import bisect_left
import sys
if sys.version_info[0:2] >= (3, 3):
    from collections.abc import Sequence
else:
    from collections import Sequence


class LazySequence(Sequence):
    def __init__(self, f, n):
        self.f = f
        self.n = n

    def __len__(self):
        return self.n

    def __getitem__(self, i):
        if not (0 <= i < self.n):
            raise IndexError
        return self.f(i)


N, Q = map(int, input().split())
A = [int(s) for s in input().split()]
X = []
for _ in range(Q):
    X.append(int(input()))

# A.sort()
s = [0] * (N + 1)
for i in range(1, N + 1):
    s[i] = s[i - 1] + A[i - 1]
t = [0, A[0]] + [0] * (N - 1)
for i in range(2, N + 1):
    t[i] = t[i - 2] + A[i - 1]


def index_left(x, i):
    val = 2 * x - A[i]
    return bisect_left(A, val)


def nankaime(x, i):
    """requires x <= A[i]"""
    return i - index_left(x, i) + 1


def npi(x, i):
    return nankaime(x, i) + i


def index_right(x, istart):
    ls = LazySequence(lambda i: npi(x, i + istart), N - istart)
    return istart + bisect_left(ls, N) - 1


def getans(x):
    istart = bisect_left(A, x)
    if istart == N:
        return t[N]
    j = index_right(x, istart)
    turn = N - 1 - j
    i = j - turn + 1
    return s[N] - s[j + 1] + (t[i] if i > 0 else 0)


for i in range(Q):
    print(getans(X[i]))


Measured memory_bytes: 100588
s = input()

def comb(x):
    return x * (x-1) // 2

left, right = 0, 0
ans = 0
pre = '<'
for c in s:
    if pre == '>' and c == '<':
        ans += comb(min(left, right)) + comb(max(left, right)+1)
        left, right = 1, 0
    elif c == '<':
        left += 1
    else:
        right += 1
    pre = c
ans += comb(min(left, right)) + comb(max(left, right) + 1)
print(ans)

Measured memory_bytes: 4116
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset

using namespace std;

int main() {

	int a,b,c, sum, n, flag = 0, m, count = 0;

	cin >> a >> b >> c ;

	n = b + c;

	if (n < a) {
		cout << 0 << endl;
	}
	else {
		cout << n - a << endl;
	}

	return 0;
}


Measured memory_bytes: 256
from collections import deque
k=int(input())
nums=[1,2,3,4,5,6,7,8,9]
lst=deque()
for j in nums:
  d=deque()
  d.append(j)
  while len(d)<10**5:
    num=d.popleft()
    lst.append(num)
    s=str(num)
    l=len(s)
    t=int(s[l-1])
    if 1<=t<=8:
      d.append(s+str(t-1))
      d.append(s+str(t))
      d.append(s+str(t+1))
    if t==0:
      d.append(s+str(0))
      d.append(s+str(1))
    if t==9:
      d.append(s+str(8))
      d.append(s+str(9))

Lst=list(lst)
Lst=list(map(int,Lst))
Lst.sort()
print(Lst[k-1])
    
    
      
   


Measured memory_bytes: 167368
#include <stdio.h>

int main(void){
    int S;
    scanf("%d",&S);
    int h = S/3600;
    int m = (S-h*3600)/60;
    int s = S-h*3600-m*60;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}


Measured memory_bytes: 2116
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<limits.h>

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define revrep(i,begin,end) for(int i=begin; i>end; i--)
#define lld long long int

typedef struct node{
    lld x, y, z;
}node;

int _x, _y, _z;

int cmpAsc(const void* a, const void* b){
    if(_x == 0){_x = -1;}
    if(_y == 0){_y = -1;}
    if(_z == 0){_z = -1;}
    lld x1 = ((node*)a)->x, x2 = ((node*)b)->x;
    lld y1 = ((node*)a)->y, y2 = ((node*)b)->y;
    lld z1 = ((node*)a)->z, z2 = ((node*)b)->z;
    lld sum1 = _x*x1 + _y*y1 + _z*z1;
    lld sum2 = _x*x2 + _y*y2 + _z*z2;
    if(sum1 > sum2){
        return 1;
    }
    if(sum1 < sum2){
        return -1;
    }
    return 0;
}

int main(){
    int n, m;
    scanf("%d %d", &n, &m);
    node a[n];
    rep(i, 0, n){
        lld x, y, z;
        scanf("%lld %lld %lld", &x, &y, &z);
        a[i].x = x;
        a[i].y = y;
        a[i].z = z;
    }
    lld ans = 0;
    rep(i, 0, 2){
        rep(j, 0, 2){
            rep(k, 0, 2){
                _x = i; _y = j; _z = k;
                qsort(a, n, sizeof(node), cmpAsc);
                lld buf_x = 0, buf_y = 0, buf_z = 0;
                rep(l, 0, m){
                    buf_x += a[l].x;
                    buf_y += a[l].y;
                    buf_z += a[l].z;
                }
                if(buf_x < 0){buf_x *= -1;}
                if(buf_y < 0){buf_y *= -1;}
                if(buf_z < 0){buf_z *= -1;}
                lld buf = buf_x + buf_y + buf_z;
                if(ans < buf){
                    ans = buf;
                }
            }
        }
    }
    printf("%lld", ans);

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	static int MAX = 100;
	static int top;
	static int[] entry;
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		top = -1;
		entry = new int[MAX];
		String input;
		int a, b;
		while (cin.hasNext()) {
			input = cin.next();
			if (input.charAt(0) == '+') {
				a = pop();
				b = pop();
				push(a + b);
			} else if (input.charAt(0) == '-') {
				b = pop();
				a = pop();
				push(a - b);
			} else if (input.charAt(0) == '*') {
				a = pop();
				b = pop();
				push(a * b);
			} else {
				push(Integer.parseInt(input));
			}
		}
		System.out.println(pop());
	}
	static void push(int x) {
		top++;
		entry[top] = x;
	}
	static int pop() {
		top--;
		return entry[top + 1];
	}
}


Measured memory_bytes: 26280
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s1 = scan.next();
		String s2 = scan.next();
		String s3 = scan.next();
		System.out.println(s1.substring(0, 1).toUpperCase() + s2.substring(0, 1).toUpperCase() + s3.substring(0, 1).toUpperCase());
		scan.close();

	}

}


Measured memory_bytes: 22100
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,i;
  cin>>n;
  int A[n];
  for(i=0;i<n;i++)
  {
    cin>>A[i];
  }
  int max1,max2,B[n];
  for(int i=0;i<n;i++)
  {
    B[i]=A[i];
  }
  sort(B,B+n);
  max1=B[n-1];
  max2=B[n-2];
  for(i=0;i<n;i++)
  {
    if(A[i]==max1)
    cout<<max2<<'\n';
    else 
    cout<<max1<<'\n';
  }
  return 0;
}

Measured memory_bytes: 3200
#include <vector>
#include <queue>
#include <iostream>

int DFS_MaxDist(std::vector<std::vector<int>> &connection, int vertexCount, int start)
{
    const int NotChecked = -1;
    int result = NotChecked;

    std::vector<int> dist(vertexCount, NotChecked);
    std::queue<int> que;

    dist[start] = 0;
    que.push(start);

    while (!que.empty())
    {
        int v = que.front();
        que.pop();

        for (int nv : connection[v])
        {
            if (dist[nv] != NotChecked)
                continue;

            dist[nv] = dist[v] + 1;
            que.push(nv);

            if (result < dist[nv])
                result = dist[nv];
        }
    }

    return result;
}

int ToLinerMapIndex(int x, int y, int w)
{
    return y * w + x;
}

int main()
{
    int H, W;
    std::cin >> H >> W;

    int nodeCount = H * W;

    std::vector<std::vector<char>> S(H, std::vector<char>(W));
    std::vector<std::vector<int>> connection(nodeCount);

    for (int i=0; i<H; ++i)
    {
        for (int j=0; j<W; ++j)
        {
            std::cin >> S[i][j];
        }
    }

    for (int i=0; i<H; ++i)
    {
        for (int j=0; j<W; ++j)
        {
            // i,j が道だったら上下左右と繋がる可能性がある
            if (S[i][j] == '#')
                continue;

            // 下とつながってるか
            if (i < H-1 && S[i+1][j] != '#')
            {
                int from = ToLinerMapIndex(j, i, W);
                int to = ToLinerMapIndex(j, i+1, W);
                connection[from].emplace_back(to);
                connection[to].emplace_back(from);
            }
            // 右とつながっているか
            if (j < W-1 && S[i][j+1] != '#')
            {
                int from = ToLinerMapIndex(j, i, W);
                int to = ToLinerMapIndex(j+1, i, W);
                connection[from].emplace_back(to);
                connection[to].emplace_back(from);
            }
        }
    }

    int maxDist = -1;
    for (int i=0; i<H; ++i)
    {
        for (int j=0; j<W; ++j)
        {
            if (S[i][j] == '#')
                continue;

            auto dist = DFS_MaxDist(connection, nodeCount, ToLinerMapIndex(j, i, W));
            if (maxDist < dist)
                maxDist = dist;
        }
    }
    std::cout << maxDist;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#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(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

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

const int MOD = 1e9+7;
const int INF = 1e9;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,K;cin>>N>>K;
    vector<ll> h(N);
    rep(i,N)cin>>h[i];
    ll dp[N];
    rep(i,N+1)dp[i] = INF;
    dp[0] = 0;
    rep(i,N){
        rep1(k,K+1){
            if(i+k<N){
                dp[i+k] = min(dp[i+k], dp[i] + abs(h[i+k]-h[i]));
            } 
        }
    }
    cout<<dp[N-1]<<endl;
}

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

int pow2(int n) {
  int ans = 1;
  for(int i = 0; i < n; ++i) {
    ans *= 2;
  }
  return ans;
}

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

  int ans = (1900 * M + 100 * (N - M)) * pow2(M);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
 int a[3][10][4] = { {0} };
 int i, j, k;
 int n;
 int b, f, r, v; 
 
 scanf("%d", &n);
 for(i=0; i<n; i++){
 scanf("%d%d%d%d", &b, &f, &r, &v);

 a[f-1][r-1][b-1] += v;
 }
 
 for(k=0; k<4; k++){
 for(i=0; i<3; i++){
 for(j=0; j<10; j++){
 if(a[i][j][k] == 0){
 printf(" 0");
 }else{
 printf(" %d", a[i][j][k]);
 }
 }
 printf("\n");
 }
 if(k != 3){
 printf("####################\n");
 }
 }
 
 return 0;
 }
 
 


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

/*==============変数宣言==============*/
int N;
const int M = 26;
int n;
int m = M;
const int def = 1000000;

int c[30];
int s[400][30];

void input(){
	scanf("%d", &N);
	n = N;

	for(int i = 0;i < M;i++) scanf("%d", &c[i]);

	for(int i = 0;i < N;i++)
		for(int j = 0;j < M;j++)
			scanf("%d", &s[i][j]);
	
	return;
}

/*================関数================*/
struct RandomNumberGenerator {
  mt19937 mt;

  RandomNumberGenerator() : mt(chrono::steady_clock::now().time_since_epoch().count()) {}

  int operator()(int a, int b) { // [a, b)
    uniform_int_distribution< int > dist(a, b - 1);
    return dist(mt);
  }

  int operator()(int b) { // [0, b)
    return (*this)(0, b);
  }
};

struct Timer {
  chrono::high_resolution_clock::time_point st;

  Timer() { reset(); }

  void reset() {
    st = chrono::high_resolution_clock::now();
  }

  chrono::milliseconds::rep get() {
    auto ed = chrono::high_resolution_clock::now();
    return chrono::duration_cast< chrono::milliseconds >(ed - st).count();
  }
};

Timer timer;
RandomNumberGenerator rnd;
/*====================================*/



void init(){
	input();
	return;
}


void output(short ans[]){
	for(int i = 0;i < n;i++){
		printf("%d\n", ans[i]+1);
	}
}

int sum(int i){
	return (i*(i+1))/2;
}

int getScore(short a[]){
	int last[30] = {};
	int ans = 0;
	for(int i = 0;i < n;i++){
		ans += s[i][a[i]]; 
		ans -= c[a[i]] * sum(i-last[a[i]]);
		last[a[i]] = i+1;
	}
	for(int j = 0;j < m;j++){
		ans -= c[j] * sum(n-last[j]);
	}
	return ans;
}

int main(){
	init();

	short now[365];
	short ans[365]; 

	for(int i = 0;i < n;i++){
		ans[i] = now[i] = rnd(26); 
	}

	int ans_score = getScore(ans);

	int fin = 1800;
	const double C = fin*500.0;

	int now_time = 0;
	int AS = ans_score;
	short ANS[365];
	int cnt = 0;
	while((now_time = timer.get()) < fin){
		int idx = rnd(365);
		int old = now[idx];
		int nxt = rnd(26);
		if(now[idx] == nxt) continue;
		now[idx] = nxt;
		int now_score = getScore(now);

		double r = rnd(100000)/100000.0;

		double line = (fin-now_time)/C; 

		if(ans_score <= now_score || line > r){
			ans[idx] = nxt;
			ans_score = now_score;
			if(AS < ans_score){
				memcpy(ANS, ans, sizeof(ans));
				AS = ans_score;
				//cerr << AS << endl;
			}
		}else{
			now[idx] = old; 
		}

		cnt++;
		if(cnt == 50000){
			cnt = 0;
			if(now_score != AS){
				memcpy(now, ANS, sizeof(ANS));
				memcpy(ans, ANS, sizeof(ANS));
				ans_score = AS;
			}
		}
	}


	memcpy(now, ANS, sizeof(ANS));

	int idx = 0; 
	int nxt = 0;
	fin = 1990;
	while((now_time = timer.get()) < fin){
		int old = now[idx];
		now[idx] = nxt;
		int now_score = getScore(now);

		if(AS < now_score){
			ANS[idx] = nxt;
			AS = now_score;
			//cerr << " " << AS << endl;
		}else{
			now[idx] = old; 
		}
		nxt++;
		if(nxt == m){
			nxt = 0;
			idx++;
			if(idx == n) idx = 0;
		}
	}
	output(ANS);

	return 0;
}


Measured memory_bytes: 3752
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;

int main() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    tx -= sx;
    ty -= sy;

    for (int i = 0; i < tx; i++) cout << 'R';
    for (int i = 0; i < ty; i++) cout << 'U';
    for (int i = 0; i < tx; i++) cout << 'L';
    for (int i = 0; i < ty; i++) cout << 'D';
    cout << 'D';
    for (int i = 0; i <= tx; i++) cout << 'R';
    for (int i = 0; i <= ty; i++) cout << 'U';
    cout << 'L';
    cout << 'U';
    for (int i = 0; i <= tx; i++) cout << 'L';
    for (int i = 0; i <= ty; i++) cout << 'D';
    cout << 'R';
    cout << endl;

    return 0;
}

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

namespace ABC138A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = CIN.Int();
            string s = CIN.String();
         
            Console.WriteLine(a >= 3200 ? s : "red");
        }
    }

    internal static class CIN
    {
        public static string String()
        {
            return Console.ReadLine();
        }

        public static int Int()
        {
            return int.Parse(Console.ReadLine());
        }

        public static int[] IntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        public static long Long()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] LongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] DoubleArray()
        {
            return Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
        }
    }
}

Measured memory_bytes: 11092
#include<iostream>
#include<vector>

int main()
{
int N,K,Q; std::cin >> N >> K >> Q;
std::vector<int> A(Q);
std::vector<int>P(N, K);
for(int i = 0; i < Q; ++i)
{
std::cin >> A[i];A[i]-=1;
P[A[i]] += 1;
}

for(int i = 0; i < N; ++i)
{
if(P[i]  - Q > 0)
{
std::cout << "Yes" << '\n';
//std::cout << i << "  " << P[i] << '\n';
}
else
{
std::cout << "No" << '\n';
}
}

}


Measured memory_bytes: 1408
n = int(input())
def calc(n):
    bool1 = False
    bool2 = False
    bool3 = False
    for i in range(n):
        d1, d2 = (int(x) for x in input().split())
        if d1 == d2:
            if bool2 == True:
                bool3 = True
            if bool1 ==True:
                bool2 = True
            if bool1 == False:
                bool1 = True
        else:
            bool1 = False
            bool2 = False
    return bool3
if calc(n):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 62340
#include <iostream>
using namespace std;
string s;
int len, last[26], a[26], ans;
int main()
{
    cin >> s;
    len = ans = s.length();
    for (int i = 0; i < len; ++i) {
        a[s[i] - 'a'] = max(a[s[i] - 'a'], i - last[s[i] - 'a']);
        last[s[i] - 'a'] = i + 1;
    }
    for (int i = 0; i < 26; ++i) {
        a[i] = max(a[i], len - last[i]);
        ans = min(ans, a[i]);
    }
    cout << ans << endl;
    return 0;
}

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


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

Measured memory_bytes: 3076
use proconio::*;
use std::cmp::*;
use std::collections::*;
use std::ops::Bound::*;

#[fastout]
fn run() {
    input! {
        n: usize,
        a: [usize; n],
        b: [usize; n],
    }
    let mut range = vec![(n, 0); n + 1];
    for (i, a) in a.iter().enumerate() {
        let po = &mut range[*a];
        po.0 = min(po.0, i);
        po.1 = i;
    }
    let mut set = (0..n).collect::<BTreeSet<_>>();
    for (i, &b) in b.iter().enumerate() {
        let (x, y) = range[b];
        if x == n {
            continue;
        }
        if x >= i {
            let mut del = vec![];
            for &v in set.range((Included(&(x - i)), Included(&(y - i)))) {
                del.push(v);
            }
            for v in del {
                set.remove(&v);
            }
        } else {
            let mut del = vec![];
            for &v in set.range((Included(&(n + x - i)), Included(&(n + y - i)))) {
                del.push(v);
            }
            if y >= i {
                for &v in set.range((Included(&0), Included(&(y - i)))) {
                    del.push(v);
                }
            }
            for v in del {
                set.remove(&v);
            }
        }
    }
    if let Some(&k) = set.iter().next() {
        println!("Yes");
        for (i, b) in b.iter().cycle().skip(n - k).take(n).enumerate() {
            if i > 0 {
                print!(" ");
            }
            print!("{}", b);
        }
        println!();
    } else {
        println!("No");
    }
}

fn main() {
    run();
}


Measured memory_bytes: 15788
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define RFOR(it,c) for(__typeof((c).rbegin()) it=(c).rbegin(); it!=(c).rend(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

int N;
ll a[100005];
ll v[100005];


int main(){
  cin >> N;

  map<ll,pair<ll,ll> > memo;
  rep(i,N){
    cin >> a[i];
    if(memo.count(a[i]) == 0){
      memo[a[i]] = make_pair(i,1);
    }else{
      pair<ll,ll> x = memo[a[i]];
      x.second++;
      memo[a[i]] = x;
    }
  }

  vector<ll> rev;
  FOR(it,memo){
    rev.push_back(it->first);
  }
  reverse(ALLOF(rev));
  
  rep(i,rev.size()){
    ll x = rev[i];
    pair<ll,ll> z = memo[rev[i]];
    ll mn = z.first;
    ll y = z.second;
    if(i+1<rev.size()){
      x = rev[i] - rev[i+1];

      pair<ll,ll> pr = memo[rev[i+1]];
      pr.first = min(pr.first, mn);
      pr.second += y;
      memo[rev[i+1]] = pr;
    }
    v[mn] += x*y;
  }
  rep(i,N){
    cout << v[i] << endl;
  }
  
  return 0;
}



Measured memory_bytes: 9848
N, K = map(int, input().split())
abs_g = [(i, j) for i in range(1, N) for j in range(i + 1, N + 1)][::-1]

if len(abs_g) - (N - 1) < K:
    print(-1)
    exit()

print(len(abs_g) - K)
[print(i, j) for i, j in abs_g[K:]]


Measured memory_bytes: 9580
P,S=print,sorted
n,k,*t=map(int,open(i:=0).read().split())
l=S([a-1,a<1<exit(P(-1)),i:=i+1]for a in t)[::-1]
*_,r=zip(*l)
while k:
 *_,b=r;k-=1
 for t in S(l)[::-1]:
  if t[2]-b:t[t[0]<1<exit(P(-1))]-=1;r+=t[2],
P(len(r),*r)

Measured memory_bytes: 9456
#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep1(i,n) for(long long i=1;i<=(long long)(n);i++)
#define all(v) v.begin(),v.end()
#define Sort(v) sort(all(v))
#define Reverse(v) reverse(all(v))
#define Rsort(v) sort(all(v),greater)
#define pub(v) push_back(v)
#define pob(v) pop_back(v)
typedef long long ll;
typedef vector<ll> vel;
typedef vector<vector<ll>> vel2d;
typedef string str;
typedef pair<ll,ll> pal;
typedef vector<str> ves;


int main() {
  vel a(3); rep0(i,3){cin>>a[i];}
  ll sum=0;
  rep0(i,3){sum+=a[i];}
  if(sum<=21){cout<<"win"<<endl;}
  else{cout<<"bust"<<endl;}
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main
{
    public static void main(String args[])
        {
            Scanner s = new Scanner(System.in);
            int days = s.nextInt(); 
            int arr[][] = new int[days][3];
            for(int i=0;i<days;i++)
                {
                    for(int j=0;j<3;j++)
                        {
                            arr[i][j] = s.nextInt();
                        }
                }
            solver(arr,days);
        }
    private static void solver(int arr[][],int days)
        {
            int max = Integer.MIN_VALUE;
            for(int i=0;i<days;i++)
                {
                    for(int j=0;j<3;j++)
                        {
                            if(i==0)
                                {
                                    max = Math.max(arr[i][j],max);
                                    continue;
                                }
                            else
                                {
                                    arr[i][j] = helper(arr,i-1,j)+arr[i][j];
                                }
                            max = Math.max(arr[i][j],max);
                        }
                }
            System.out.println(max);
        }
    private static int helper(int arr[][],int row,int col)
        {
            int max = Integer.MIN_VALUE;
            for(int i=0;i<arr[0].length;i++)
                {
                   if(i!=col) max = Math.max(arr[row][i],max);
                }
            return max;
        }
}

Measured memory_bytes: 63084
#include<stdio.h>
int main(void){
    int i,j,k=1,cards[4][14]={0},n,b;
    char a;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf(" %c %d",&a,&b);
        if(a=='S')cards[0][b]=1;
        if(a=='H')cards[1][b]=1;
        if(a=='C')cards[2][b]=1;
        if(a=='D')cards[3][b]=1;
    }
    for(j=0;j<4;j++){
        for(k=1;k<14;k++){
            if(cards[j][k]==0){
                if(j==0)printf("S %d\n",k);
                if(j==1)printf("H %d\n",k);
                if(j==2)printf("C %d\n",k);
                if(j==3)printf("D %d\n",k);
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1816
// AOJ Vol.5 0500: Card Game

#include<stdio.h>

int main(){
	
	int i;
	int n;
	int A, B;
	int sumA;
	int sumB;
	
	while(1){
		
		sumA = 0; sumB = 0;
		
		scanf("%d", &n);
		if(n == 0) return 0;
		for(i = 0; i < n; i++){
			scanf("%d%d", &A, &B);
			if(A > B) sumA += A + B;
			else if(A < B) sumB += A + B;
			else{ sumA += A; sumB += B; }
		}
		printf("%d %d\n", sumA, sumB);
	}
	
	return 0;
}


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

int main(){
  int n,b,f,r,v;
  cin >> n;
  int house[4][3][10];
  REP(i,4){
    REP(j,3){
      REP(k,10){
        house[i][j][k]=0;
      }
    }
  }
  REP(i,n){
    cin >> b >> f >> r >> v;
    house[b-1][f-1][r-1]=house[b-1][f-1][r-1]+v;
    if(house[b-1][f-1][r-1]>10)
      house[b-1][f-1][r-1]=9;
  }
  REP(i,4){
    REP(j,3){
      REP(k,10){
        cout <<" "<< house[i][j][k];
      }
      cout << endl;
    }
    if(i!=3)
    cout << "####################" <<endl;
  }
}

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

using namespace std;

int a[110];
bool dp[100100];
int n, k;

int main(){
    cin >> n >> k;
    for(int i = 0; i < n; i++) cin >> a[i];
    memset(dp, false, sizeof(dp));
    for(int i = 0; i <= k; i++){
        for(int j = 0; j < n; j++){
            if(i - a[j] >= 0 && !dp[i - a[j]]) dp[i] = true;
        }
    }
    cout << (dp[k] ? "First\n" : "Second\n");
}

Measured memory_bytes: 384
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;
const int MOD = 1000000007;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }



int main()
{
	string s;
	cin >> s;
	char last = s.back();
	int ans = 0;

	while (!s.empty())
	{
		if (s.back() != last)
		{
			++ans;
		}

		last = s.back();
		s.pop_back();
	}

	cout << ans << endl;
}


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

int main() {
    uint64_t N, M;
    std::cin >> N >> M;

    const uint64_t all = N * M;

    uint64_t ans = 0;
    if (N == 1) {
        if (M == 1) {
            ans = 1;
        } else {
            ans = all - 2;
        }
    } else if (M == 1) {
        if (N == 1) {
            ans = 1;
        } else {
            ans = all - 2;
        }
    } else {
        ans = (N - 2) * (M - 2);
    }

    std::printf("%lu\n", ans);

    return 0;
}


Measured memory_bytes: 256
A, B = gets.chomp.split

a1, a2 = A[0..1], A[0..2]
b1, b2 = B[0..1], B[0..2]
a = a2.to_i
a += 1 if A > a2 + a1.reverse
b = b2.to_i
b += 1 if B >= b2 + b1.reverse
ans = b - a

puts ans


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

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

int main() {
    string s; cin >> s;
    int n = s.size();
    vector<ll> v(2019, 0);
    ll e = 1, cur = 0;
    v[cur]++;
    for(int i = 0; i < n; i++){
        cur = (cur + (s[n - 1 - i] - '0') * e) % 2019;
        e = (e * 10) % 2019;
        v[cur]++;
    }
    ll ans = 0;
    for(int i = 0; i < v.size(); i++){
        ans += v[i] * (v[i] - 1) / 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3668
s = input()
if s == "SUN":
  print(7)
elif s == "MON":
  print(6)
elif s == "TUE":
  print(5)
elif s == "WED":
  print(4)
elif s == "THU":
  print(3)
elif s == "FRI":
  print(2)
elif s == "SAT":
  print(1)


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

int main(){
	int n;
	int ac=0;
	int wa=0;
	int tle=0;
	int re=0;
	cin>>n;
	rep(i,n){
		string s;
		cin>>s;
		if(s=="AC")ac++;
		else if(s=="WA")wa++;
		else if(s=="TLE")tle++;
		else if(s=="RE")re++;
	}

	printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n",ac,wa,tle,re);

	return 0;
}

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

using namespace std;

using ll = long long;

const ll INF = 1000000000000000LL;

ll a[5005];
vector<int> g[5005];
vector< array<ll, 2> > dp[5005];

void dfs(int cur, int par) {
    dp[cur].push_back({a[cur], (a[cur] < 0)});
    for (int nex : g[cur]) {
        if (nex == par) continue;
        dfs(nex, cur);

        vector< array<ll, 2> > ndp(dp[nex].size() + dp[cur].size(), {INF, INF});
        for (int i = 0; i < dp[cur].size(); i++) {
            for (int j = 0; j < dp[nex].size(); j++) {
                ndp[i + j][0] = min(ndp[i + j][0], dp[cur][i][0] + dp[nex][j][0]);
                ndp[i + j][1] = min(ndp[i + j][1], dp[cur][i][1] + dp[nex][j][1]);

                if (dp[nex][j][0] < 0 || dp[nex][j][1] == 0) {
                    ndp[i + j + 1][0] = min(ndp[i + j + 1][0], dp[cur][i][0]);
                    ndp[i + j + 1][1] = min(ndp[i + j + 1][1], dp[cur][i][1]);
                }
            }
        }
        dp[cur] = move(ndp);
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];

    for (int i = 1; i < n; i++) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    dfs(0, -1);

    for (int i = 0; i < dp[0].size(); i++) {
        if (dp[0][i][0] < 0 || dp[0][i][1] == 0) {
            cout << i << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 163840
#[allow(unused_imports)]
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::{Chars, Usize1};
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused)]
const ALPHA_SMALL: [char; 26] = [
    'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
    't', 'u', 'v', 'w', 'x', 'y', 'z',
];
#[allow(unused)]
const ALPHA: [char; 26] = [
    'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
    'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
];

fn main() {
    input!(N: usize);
    input!(A: [Usize1; N - 1]);
    let mut B = vec![0; N];
    for &a in &A {
        B[a] += 1;
    }
    for &b in &B {
        println!("{}", b);
    }
}


Measured memory_bytes: 5440
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
	ll n;cin>>n;
	vector<ll> a(n);
	ll val=0;
	for(ll i=0;i<n;i++){
		cin>>a[i];
		val=val^a[i];
	}
	//cout<<val<<" ";
	for(int i=0;i<n;i++){
		cout<<(val^a[i])<<" ";
	
	}
	cout<<"\n";
	
	
	
	
	
	return 0;
}

Measured memory_bytes: 4772
#include <stdio.h>

int main(void)
{
        int a, b, c, temp;
        scanf("%d %d %d", &a, &b, &c);

        if (b > c) {
                temp = b;
                b = c;
                c = temp;
        }
        if (a > b) {
                temp = a;
                a = b;
                b = temp;
        }
        if (b > c) {
                temp = b;
                b = c;
                c = temp;
        }

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

        return 0;
}

Measured memory_bytes: 2696
import sys
N = int(input())

if N == 3:
    print('2 5 63')
    sys.exit()
if N == 4:
    print('2 5 20 63')
    sys.exit()

if N == 5:
    print('2 3 6 4 9')
    sys.exit()

if N == 20000:
    for i in range(5000):
        Tmp1 = 6 * i + 2
        Tmp2 = 6 * i + 3
        Tmp3 = 6 * i + 4
        Tmp4 = 6 * (i + 1)
        print('%d %d %d %d' %(Tmp1,Tmp2,Tmp3,Tmp4), end='')
        if Tmp4 == 30000:
            break
        else:
            print(' ', end='')
    
    print()
    sys.exit()


S = '2 3 6 4 9'

N -= 5

print(S, end='')

if N == 1:
    print(' 12')
    sys.exit()

for i in range(5001):
    
    Tmp1 = 6 * i + 8
    Tmp2 = 6 * i + 10
    if Tmp2 > 30000:
        break
    
    print(' %d %d' %(Tmp1, Tmp2) , end='')
    N -= 2
    if N == 0:
        print()
        sys.exit()
    elif N == 1:
        print(' 12')
        sys.exit()
        
for i in range(5001):
    
    Tmp1 = 12 * i + 15
    Tmp2 = 12 * i + 21
    if Tmp2 > 30000:
        break
    
    print(' %d %d' %(Tmp1, Tmp2), end='')
    N -= 2
    if N == 0:
        print()
        sys.exit()
    elif N == 1:
        print(' 12')
        sys.exit()   

for i in range(N):
    
    Tmp1 = 6 * (i + 3)
    if Tmp1 > 30000:
        break
    
    print(' %d' %(Tmp1) , end='')


print()



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

int main(){
	int N = 0;
	for(int i = 0; i < 4; i++){
		int a;
		cin >> a;
		N += a;
	}
	cout << N / 60 << endl;
	cout << N % 60 << endl;
	return 0;
}


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

int main(){
    int x , y;
    cin >> x >> y;
    int val1 = y - 2*x;
    int val2 = 4*x - y;
    if(val1 >= 0 && val2 >= 0 && val1%2 == 0 && val2%2 == 0)
        cout<<"Yes\n";
    else
        cout<<"No\n";
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std; 
#define all(c) c.begin(),c.end()
#define REP(i,a,b) for(int i=a;i<=b;++i)
#define tr(container,it) \
for(auto it=container.begin();it!=container.end();++it)
typedef long long ll ; 
typedef vector<int> vi;
#define mod 1000000007 
//bool good(ll d){
   
   
//}
int main()
{
   ios::sync_with_stdio(0);
   // cin.tie(0);
   int n;
   cin>>n;
   vi v(n+1);
   REP(i,1,n)
   cin>>v[i];
   vector<int>dp(n+1);
   dp[0]=0;
   dp[1]=0;
   for(int i=2;i<=n;++i){
       if(i-2>=1)
      
       dp[i]=min(dp[i-1]+abs(v[i]-v[i-1]),dp[i-2]+abs(v[i]-v[i-2]));
       else
       dp[i]=dp[i-1]+abs(v[i]-v[i-1]);
      

   }
   cout<<dp[n];
 
   



    return 0;
}

Measured memory_bytes: 3920
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }
    

    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        int S = 0;
        for (int i = 0; i < 2; i++)
        {
            S = Math.Max(S, cin.nextInt() * cin.nextInt());
        }
        Console.WriteLine(S);
    }




}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 11092
N, M = [int(i) for i in input().split()]
inputs = [[int(i) for i in input().split()] for _ in range(N)]
ordered = sorted(inputs, key=lambda x: x[0])

count = 0
money = 0
for ab in ordered:
    a = ab[0]
    b = ab[1]
    if M >= count + b:
        count += b
        money += b * a
    else:
        c = (M - count)
        count += c
        money += c * a
        break

print(money)


Measured memory_bytes: 23524
#include <iostream>
using namespace std;
int main(void){
    int N;
    cin >> N;
    long long H[N];

    for(int i = 0; i < N ;i++){
        cin >> H[i];
    }
    
    
    int max = 0;
    int memo = 0;
    for(int i = 0; i < N ;i++){
        if(H[i]>=H[i+1])memo++;
        else{
            if(max<memo)max=memo;
            memo = 0;
            
        }
    }
    cout << max << endl;
    
}



Measured memory_bytes: 1024
/*  ex5_3
    Graku   */
#include<stdio.h>

int main(void) {
    int height, width;
    scanf("%d %d", &height, &width);
    char matrix[height][width];
    for (int row = 0; row < height; ++row) {
        for (int col = 0; col < width; ++col) {
            scanf(" %c", &matrix[row][col]); //don't read "\n"
        }
    }

    int blank_rows[height], blank_cols[width]; //blank -> 0, not blank -> 1
    for (int row = 0; row < height; ++row) { //find blank rows
        int flag = 0;
        for (int col = 0; col < width; ++col) {
            if ('#' == matrix[row][col]) { //not blank
                flag = 1;
                break;
            }
        }
        blank_rows[row] = flag;
    }
    for (int col = 0; col < width; ++col) { //find blank columns
        int flag = 0;
        for (int row = 0; row < height; ++row) {
            if ('#' == matrix[row][col]) { //not blank
                flag = 1;
                break;
            }
        }
        blank_cols[col] = flag;
    }

    for (int row = 0; row < height; row++) {
        if (blank_rows[row]) { //if row is not blank
            for (int col = 0; col < width; ++col) {
                if (blank_cols[col]) { //if column is not blank
                    printf("%c", matrix[row][col]);
                }
            }
            printf("\n");
        }
    }

    return 0;
}

Measured memory_bytes: 128