akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
	static class Bracket {
		int diff;
		int bottom;
		public Bracket(int diff, int bottom) {
			this.diff = diff;
			this.bottom = bottom;
		}
		
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		ArrayList<Bracket> list1 = new ArrayList<>();
		ArrayList<Bracket> list2 = new ArrayList<>();
		for(int i=0; i<N; i++) {
			char[] c = sc.next().toCharArray();
			int cur = 0;
			int bottom = 0;
			for(int j=0; j<c.length; j++) {
				if(c[j]=='(') {
					cur++;
				} else {
					cur--;
					bottom = Math.min(bottom, cur);
				}
			}
			if(cur>=0)
				list1.add(new Bracket(cur, bottom));
			else
				list2.add(new Bracket(cur, bottom));
		}
		
		Collections.sort(list1, new Comparator<Bracket>() {
			public int compare(Bracket b1, Bracket b2) {
				return - Integer.compare(b1.bottom, b2.bottom);
			}
		});
		
		int pos = 0;

		for(Bracket b : list1) {
			if(pos + b.bottom < 0) {
				System.out.println("No");
				sc.close();
				return;
			}
			pos += b.diff;
		}
		
		Collections.sort(list2, new Comparator<Bracket>() {
			public int compare(Bracket b1, Bracket b2) {
				return Integer.compare(b1.bottom-b1.diff, b2.bottom-b2.diff);
			}
		});
		
		for(Bracket b : list2) {
			if(pos + b.bottom < 0) {
				System.out.println("No");
				sc.close();
				return;
			}
			pos += b.diff;
		}
		
		System.out.println(pos==0 ? "Yes" : "No");

		sc.close();
	}

}


Measured memory_bytes: 85128
from sys import stdin

def main():
    moji = input()

    s = 0
    for m in moji:
        s += int(m)


    if s == 0:
        print("Yes")
        exit()

    if s % 9:
        print("No")
    else:
        print("Yes")
    

if __name__ == "__main__":
    main()

Measured memory_bytes: 9288
#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 rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = LLONG_MAX;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
int main() {
    ll a,b;cin >> a >> b;
    if((a+b)%2==0) cout << (a+b)/2;
    else puts("IMPOSSIBLE");
    return 0;
}

Measured memory_bytes: 3616
package main

import (
	"fmt"
	"math"
)

func main() {
	var total, ave float64
	var n int
	fmt.Scan(&n)
	xlist := make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&xlist[i])
		total += xlist[i]
	}
	ave = total / float64(n)
	hasu := ave - math.Trunc(ave)
	if hasu > 0.5 {
		ave = math.Ceil(ave)
	} else {
		ave = math.Trunc(ave)
	}

	var ans float64
	for _, x := range xlist {
		ans += math.Pow((x - ave), 2)
	}

	fmt.Printf("%d\n", int(ans))
}


Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<queue>
using namespace std;

struct Node
{
    int data,priority;
    Node *l,*r;
};

void rightRotate(Node *&p)
{
    Node *s=p->l;
    p->l=s->r;
    s->r=p;
    p=s;
}

void leftRotate(Node *&p)
{
    Node *s=p->r;
    p->r=s->l;
    s->l=p;
    p=s;
}

void insert_point(Node *&p,int x,int y)
{
    if(p==NULL)
    {
        p=(Node *)malloc(sizeof(Node));
        p->data=x;
        p->priority=y;
        p->l=p->r=NULL;
        return;
    }
    if(x < p->data)
    {
        insert_point(p->l,x,y);
        if(p->priority < p->l->priority)
            rightRotate(p);
    }
    else
    {
        insert_point(p->r,x,y);
        if(p->priority < p->r->priority)
            leftRotate(p);
    }
}

bool find_point(const Node *p,int x)
{
    if(p==NULL)
        return false;
    if(p->data==x)
        return true;
    else if(x<=p->data)
        return find_point(p->l,x);
    else
        return find_point(p->r,x);
}
void delete_assist(Node *&p)
{
    if(p->l==NULL &&p->r==NULL)
        p=NULL;
    else if(p->l==NULL)
        leftRotate(p),delete_assist(p->l);
    else if(p->r==NULL)
        rightRotate(p),delete_assist(p->r);
    else
    {
        if(p->l->priority > p->r->priority)
            rightRotate(p),delete_assist(p->r);
        else
            leftRotate(p),delete_assist(p->l);
    }
}

bool delete_point(Node *&p,int x)
{
    if(p==NULL)
        return false;
    if(p->data==x)
    {
        delete_assist(p);
        return true;
    }
    else if(x<=p->data)
        return delete_point(p->l,x);
    else
        return delete_point(p->r,x);
}

void inorder(Node *p)
{
    if(p!=NULL)
    {
        inorder(p->l);
        printf(" %d",p->data);
        //printf(" %d",p->priority);
        inorder(p->r);
    }
}

void preorder(Node *p)
{
    if(p!=NULL)
    {
        printf(" %d",p->data);
        //printf(" %d",p->priority);
        preorder(p->l);
        preorder(p->r);
    }
}

int main()
{
    int i,m,x,y;
    char st[20];
    Node *tree=NULL;
    cin>>m;
    for(i=1;i<=m;i++)
    {
        scanf("%s",st);
        switch (st[0])
        {
        case 'i' :
            scanf("%d%d\n",&x,&y);
            insert_point(tree,x,y);
            break;
        case 'f' :
            scanf("%d\n",&x);
            if(find_point(tree,x))
                cout<<"yes"<<endl;
            else
                cout<<"no"<<endl;
            break;
        case 'd' :
            scanf("%d\n",&x);
            delete_point(tree,x);

            break;
        default:
            inorder(tree);
            cout<<endl;
            preorder(tree);
            cout<<endl;
        }
    }
    return 0;
}



Measured memory_bytes: 9488
n,m,k = map(int,input().split())
a_list = list(map(int,input().split()))
b_list = list(map(int,input().split()))

from itertools import accumulate
sum_a_list = list(accumulate([0] + a_list))
sum_b_list = list(accumulate([0] + b_list))

ans = 0
b_idx = m
for a_idx in range(n+1):
    if sum_a_list[a_idx] > k:
        continue
 
    while sum_a_list[a_idx] + sum_b_list[b_idx] > k:
        b_idx -= 1
    
    ans = max(ans, a_idx + b_idx)
        
print(ans)

Measured memory_bytes: 49004
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vvl = vector<vector<ll>>;
using vl  = vector<ll>;
using vvi = vector<vector<int>>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define acc_io cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(ll i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
#define DBG(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
const ll MOD = 1000000007;
const double PI = acos(-1);  
//name[i]   -> vl  name(i)
//name[i][j]-> vvl name(i,vl(j))
//or-> ||
//map<int,int>mp

int n,m;
int ans;
//string s;
signed main(){
	acc_io;
	cin>>n>>m;
	vi TO[100005];
	rep(i,0,m){
		int a,b;
		cin>>a>>b;
		a--;b--;
		TO[a].pb(b);
		TO[b].pb(a);
	}
	queue<int> q;
	q.push(0);
	vi pre(n,-1);
	vi cnt(n);
	while(!q.empty()){
		int v=q.front();q.pop();
		for(auto u:TO[v]){
			if(pre[u]>=0) continue;
			pre[u]=v;
			cnt[u]=cnt[v]+1;
			q.push(u);
		}
	}
	cout<<"Yes"<<endl;
	rep(i,1,n){
		ans=pre[i]+1;
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 10688
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <utility>
#include <cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)


int n, A[114514];
int partition(int p, int r){
	int tmp;
	int x = A[r];
	int i = p - 1;
	for(int j = p; j < r ; j++){
		if( A[j] <= x){
			i = i + 1;
			tmp = A[i];
			A[i] = A[j];
			A[j] = tmp;
		}
	}
	tmp = A[i+1];
	A[i+1]=A[r];
	A[r] = tmp;
	return i + 1;
}

int main(){
	int i, q;

	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d", &A[i]);
	}

	q = partition(0 , n - 1);

	for(int i = 0; i < n; i++){
		if(i) printf(" ");
		if(i == q){
			printf("[");
		}
		printf("%d", A[i]);
		if ( i == q ) printf("]");
	}
	printf("\n");

	return 0;


}


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

typedef struct ICPC{
	int AC;
	int TIME;
	int No;
	int WA[20];
}S;

int M, T, P, R;

int huga(S a, S b){
	if(a.AC > b.AC) return 1;
	else if(a.AC == b.AC){
		if(a.TIME > b.TIME) return 2;
		else if(a.TIME == b.TIME){
			if(a.No > b.No) return 3;
		}
	}
	return false;
}

void Sort(S a[]){
	int v, j;
	S temp;
	for(int i = 2; i <= T; i++){
		j = i-1;
		temp = a[i];
		while(j >= 1 && huga(temp,a[j])){
			a[j+1] = a[j];
			j--;
		}
		a[j+1] = temp;
	}
}

int main(){

	while(1){
		S a[100] = {};
		cin>>M>>T>>P>>R;
		if(!M&&!T&&!P&&!P)break;
		for(int i = 1; i <= T; i++)a[i].No = i;
		for(int i = 1,m,t,p,j; i <= R; i++){
			cin>>m>>t>>p>>j;
			if(!j){a[t].AC++;a[t].TIME -= m + a[t].WA[p]*20;}
			else a[t].WA[p]++;
		}
		Sort(a);
		for(int i = 1; i <= T; i++){
			if(i==1)cout<<a[i].No;
			else{
				if(huga(a[i-1],a[i]) == 3) cout<<'='<<a[i].No;
				else cout<<','<<a[i].No;
			}
		}cout<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 3096
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use std::cmp::*;
use std::collections::*;
use std::mem::*;

fn main() {
    let (r, w, e) = (std::io::stdin(), std::io::stdout(), std::io::stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());

    let n: usize = io.read();
    let v = io.readn::<i64>(n);
    let c = io.readn::<i64>(n);
    io.writeln(
        v.iter()
            .enumerate()
            .map(|(i, &x)| x - c[i])
            .filter(|&x| x > 0)
            .fold(0, |sum, x| sum + x),
    );
}

static MOD: i64 = 1000000007;
// IO
use std::io::*;
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
    fn debug3<S: std::fmt::Debug, T: std::fmt::Debug, U: std::fmt::Debug>(
        &mut self,
        val1: S,
        val2: T,
        val3: U,
    ) {
        writeln!(
            self.Error,
            "(debug3) {:?} -> {:?} -> {:?}",
            val1, val2, val3
        );
    }
}


Measured memory_bytes: 4352
#!/usr/bin/env python3
import sys


def solve(A: int, B: int):
    if B == 1:
        print(0)
        return
    t = A
    ans = 1
    while True:
        if t >= B:
            print(ans)
            break
        t += A-1
        ans += 1
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 61960
#include <bits/stdc++.h>
using namespace std;
#define M ((int)1e9+7)
int main() {
    // your code goes here
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    long long ans=0,sum=0;
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
    	cin>>a[i];
    	ans+=(a[i]*sum)%M;
    	ans%=M;
    	sum+=a[i];sum%=M;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 4396
import java.util.Scanner;
class Main {
  public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);
    int a = stdIn.nextInt();
    int b = stdIn.nextInt();
    int c = stdIn.nextInt();

    if((a < c && c < b) || (b < c && c < a)) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

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

int main(){
  int N, T;
  cin >> N >> T;
  int t[N];
  rep(i, N)
    cin >> t[i];
  //入力終了

  long long ans = 0;

  //スイッチを押す間隔dよりTの方が長ければ，dを加算していく
  //逆にT < dならば，T秒間水が出っぱ
  rep(i, N-1){
    int d = t[i+1] - t[i];
    ans += min(d, T);
  }
  
  //最後は普通にT秒追加とみなせる
  ans += T;

  //解答
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4392
#入力受け取り
N, M=map(int, input().split())
A=list(map(int, input().split()))

#Aを昇順でソート
A.sort()

#総投票数Sを求めておく
#A[-M]が得票数M番目の商品の得票数
S=sum(A)

if A[-M]>=S/(4*M): #A[-M]がS/(4*M)以上であれば人気商品を最低M個選べる('Yes')
    print('Yes')
else: #S/(4*M)未満であれば選べる人気商品はM個未満となる('No')
    print('No')

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}
template<typename T>
ll FindErase(vector<T> &v,T tar){
  ll cnt = 0;
  for(auto it = v.begin(); it != v.end();){
    if(*it == tar){
      it = v.erase(it);
      ++cnt;
    }
    else{
      ++it;
    }
  }
  return cnt;
}

template<typename T>
bool SuffixErase(vector<T> &v,size_t suf){
  if(suf > v.size()) return false;
  for(auto it = v.begin(); it != v.end();){
    if(distance(v.begin(),it) == suf){
      v.erase(it);
      return true;
    }
    else{
      ++it;
    }
  }
  return false;
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

template<typename T>
bool check(T a,T b,T c){
  if(a.se != b.se || b.se != c.se){
    return false;
  }
  if(a.fi +1 == b.fi && a.fi +2 == c.fi){
    return true;
  }
  else if(a.fi == b.fi && b.fi == c.fi) return true;
  return false;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  rep(i,n){
    vector<pair<ll,char>> v(9);
    rep(j,9){
      cin >> v[j].fi;
    }
    rep(j,9){
      cin >> v[j].se;
    }
    sort(all(v));
    bool f = 0;
    do{
      if(check(v[0],v[1],v[2]) && check(v[3],v[4],v[5]) && check(v[6],v[7],v[8])){
        cout << 1 << endl;
        f = 1;
        break;
      }
    }while(next_permutation(all(v)));
    if(!f)
      cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 3040
INF = 1.0 / 0.0

def used_edges(sink, pre_node)
  ans = []
  p = pre_node[sink]
  while p != nil
    v, i = p
    ans << $edges[v][i]
    p = pre_node[v]
  end
  return ans
end

def min_cost_flow(source, sink, required_flow)
  res = 0
  while required_flow > 0
    dist = Array.new($n){INF}
    dist[source] = 0
    pre_node = Array.new($n){nil}

    loop do
      updated = false
      $n.times{|v|
        next if dist[v] == INF
        $edges[v].each_with_index{|edge, i|
          capacity, target, cost = edge[0..2]
          new_dist = dist[v] + cost
          if capacity > 0 &&  dist[target] > new_dist
            dist[target] = new_dist
            pre_node[target] = [v, i]
            updated = true
          end
        }
      }
      break if not updated
    end
    return -1 if dist[sink] == INF

    path = used_edges(sink, pre_node)
    aug = required_flow
    path.each{|e|
      aug = e[0] if aug > e[0]
    }

    required_flow -= aug

    res += aug * dist[sink]
    path.each{|e|
      target,idx = e[1], e[3]
      e[0] -= aug
      $edges[target][idx][0] += aug
    }
  end
  return res
end

$n, m, f = gets.split.map(&:to_i)
$edges = Array.new($n){[]}

m.times{|i|
  s, t, c, d = gets.split.map(&:to_i)
  ls = $edges[s].size
  lt = $edges[t].size
  $edges[s] << [c, t, d, lt]
  $edges[t] << [0, s,-d, ls]
}

puts min_cost_flow(0, $n-1, f)

Measured memory_bytes: 8908
#include<iostream>
#include<cstdlib>
#include<cmath>
using namespace std;
#define G 9.8
int main(){
	double v;
	while(cin>>v){
		v = pow(v,2);
		v = v/(2*G) + 5;
		v /= 5;
		cout<<((int)v+1)<<endl;	
	}
	return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
typedef pair<int,int> P;
#define mod 1000000007

int main(){
    vector<vector<char>> m(3,vector<char>(3));
    rep(i,3){
        rep(j,3){
            cin >> m[i][j];
        }
    }
    cout << m[0][0]<<m[1][1] << m[2][2] <<endl;
    return 0;
}

Measured memory_bytes: 256
// In the name of GOD
 
#include <bits/stdc++.h>
#define ll long long
#define pp pair <int, int>
using namespace std;
const ll N = 1e9, MOD =  998244353;

void solve() {
    int n;
    cin >> n;
    vector <int>a(n), b(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i] >> b[i];
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    int ans;
    if (n % 2 == 1) {
        ans = b[n/2] - a[n/2] + 1;
    }
    else {
        ans = (b[n/2 - 1] + b[n/2]) - (a[n/2] + a[n/2 - 1]) + 1;
    }
    cout << ans;
}

int main()  {
  ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    int tt = 1;
    // cin >> tt;
    for (int tc = 1; tc <= tt; ++tc) {
        solve();
    }
}                                  


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

int main(void) {
	using namespace std;
	int H, W;
	cin >> H >> W;
	vector<string> A;
	for(int i = 0; i < H; ++i) {
		string s;
		cin >> s;
		A.push_back(s);
	}
	for(int i = 0; i < H; ++i) {
		for(int j = 0; j < W; ++j) {
			for(int k = 0; k < H; ++k) {
				for(int l = 0; l < W; ++l) {
					if(A[i][j] == '#' && A[k][l] == '#' && k < i && j < l) {
						cout << "Impossible\n";
						return 0;
					}
				}
			}
		}
	}
	cout << "Possible\n";
	return 0;
}



Measured memory_bytes: 256
Base = gets.chomp

table = ["A","C","G","T"]

answers = []

Base.length.times do |i|
  tmp = ""
  (Base.length - i).times do |j|
    flag = false
    table.each do |b|
      if Base[i+j] == b
        tmp = tmp + Base[i+j]
        #p tmp
        flag = true
      end
    end
    answers.push(tmp)
    if flag == false
      break
    end
  end
end

ans = ""
answers.each do |v|
  if v.length > ans.length
    ans = v
  end
end

puts ans.length

Measured memory_bytes: 1788
/*================================================
# ~  file:ABC155_C.cpp
# ~~ date:2020-02-16
# ~~~author: SoMnus_L
#        |everybody finds love,in the end|
#   人の運命か,人の希望は悲しみにつづられているね
=================================================*/

#include <iostream>
#include <cstdio>
#include <cstring>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#define ll long long
const int N=1e6+10;
using namespace std;
typedef pair<int,int>PII;
int n;
int ans=-1;
map<string,int> a;
int main(){
 ios::sync_with_stdio(false);
 cin>>n;
 while(n--){
 string s;
 cin>>s;
 a[s]++;
 ans=max(ans,a[s]);
 }
 map<string,int>::iterator iter;
 for(iter=a.begin();iter!=a.end();iter++){
 if(iter->second==ans)  cout<<iter->first<<endl;
 }
  return 0;
}


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

int main() {
  int N, W;
  cin >> N >> W;
  vector<int>w(N);
  vector<long long>v(N);
  for (int i = 0; i < N; i++) {
    cin >> w.at(i) >> v.at(i);
  }
  vector<vector<long long>>dp(N+1,vector<long long>(W+1));
  for (int i = 0; i < N+1; i++) {
    for (int j = 0; j < W+1; j++) {
      dp.at(i).at(j) = 0;
    }
  }
  for (int i = 1; i < N+1; i++) {
    for (int j = 0; j < W+1; j++) {
      if (j >= w.at(i-1)) {
        dp.at(i).at(j) = max(dp.at(i-1).at(j), dp.at(i-1).at(j-w.at(i-1)) + v.at(i-1));
      }
      else {
        dp.at(i).at(j) = dp.at(i-1).at(j);
      }
    }
  }
  cout << dp.at(N).at(W);
}

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

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = Console.ReadLine().Split().Select(i => Convert.ToInt32(i)).ToArray();
            int add = input[0] + input[1];
            int sub = input[0] - input[1];
            int mul = input[0] * input[1];
            Console.WriteLine(Math.Max(Math.Max(add, sub), mul));
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n, m, l;
  cin >> n >> m >> l;
  vector <ll> c(n);
  vector <vector <ll>> v(n, vector <ll> (m));
  rep(i, n) {
    cin >> c.at(i);
    rep(j, m) {
      cin >> v.at(i).at(j);
    }
  }
  ll res = INF;
  for (auto tmp = 0; tmp < (1 << 12); tmp++) {
    bitset <12> s(tmp);
    ll cost = 0;
    vector <ll> u(m, 0);
    rep(i, n) {
      if (s.test(i)) {
        cost += c.at(i);
        rep(j, m) u.at(j) += v.at(i).at(j);
      }
    }
    bool flag = 1;
    rep(i, m) {
      if (u.at(i) < l) flag = 0;
    }
    if (flag) chmin(res, cost);
  }
  if (res == INF) {
    cout << -1 << endl;
  } else {
    cout << res << endl;
  }
}

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

class Program
{
    public static void Main()
    {
        int Q = int.Parse(Console.ReadLine().Split(' ')[1]);
        string S = Console.ReadLine();
        string[] o;
        int[] cf = new int[S.Length];
        int[] cb = new int[S.Length];

        for (int i = 1; i < S.Length; i++)
        {
            if (S[i - 1] == 'A' && S[i] == 'C')
                cb[i] = 1;
        }
        for (int i = 1; i < S.Length; i++) { 
            cb[i] += cb[i - 1];
        }

        for(int i = 0; i < Q; i++)
        {
            o = Console.ReadLine().Split(' ');
            int l = int.Parse(o[0]);
            int r = int.Parse(o[1]);
            l--;
            r--;
            Console.WriteLine(cb[r]- cb[l]);
        }
    }
}


Measured memory_bytes: 16716
#include <iostream>
#include <algorithm>

using namespace std;

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

Measured memory_bytes: 256
r, d, x=map(int, input().split())


a=r*x-d
b=r*a-d
c=r*(b-a)+b
d=r*(c-b)+c
f=r*(d-c)+d
g=r*(f-d)+f
h=r*(g-f)+g
i=r*(h-g)+h
j=r*(i-h)+i
k=r*(j-i)+j

v=[a,b,c,d,f,g,h,i,j,k]
for i in v:
    print(i)
  

Measured memory_bytes: 3064
n = gets.to_i
a = []
n.times { a << gets.to_i }
colors = []
a.each { |a|
  idx = colors.bsearch_index { |b| b < a } # それより小さいものがあるか
  if idx.nil? # なければ色を追加
    colors << a
  else
    colors[idx] = a # その場所をこの数字で置き換える（その色の一番大きい数字だけ残す）。
  end
}
p colors.size


Measured memory_bytes: 3764
/*ॐ नमो भगवते वासुदेवाय नमः*/
#include<bits/stdc++.h>
using namespace std;

#define int long long
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define allrev(x) (x).rbegin(), (x).rend()
#define pb push_back
#define pf push_front
#define fori(i, a, n) for(int i = a; i < n; ++i)
#define MAX(x) (*max_element(all(x)))
#define MIN(x) (*min_element(all(x)))
#define sortarr(a, n) sort(a, a + n)
#define sortvec(V) sort(all(V))

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

typedef unordered_map<int, int, custom_hash> u_map;
typedef unordered_set<int, int, custom_hash> u_set;
typedef vector<int> V;
typedef pair<int , int> pairi;
typedef set<int> seti;
typedef priority_queue<int> p_queue;
typedef deque<int> deqi;

const int MOD = 1e9+7;
const int INF = 1e9+8;
const double pi = 3.14159265359;

int binpow(int a, int b, int m) {
    a %= m;
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
int inverse(int x){
    return binpow(x, MOD - 2, MOD);
}

void solve()
{
    int D, T, S;
    cin >> D >> T >> S;
    int x = D/S;
    if(D % S)   x++;
    if(x > T)   cout << "No" << endl;
    else cout << "Yes" << endl;
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    solve();
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n ";
}

Measured memory_bytes: 3768
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s2,s3,s1;
    char c,a,b;
    cin>>s1;
    cin>>s2;
    cin>>s3;

    a=s1[0];
    b=s2[0];
    c=s3[0];
    a=a-32;
    b=b-32;
    c=c-32;

    cout<<a<<b<<c<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll i=0,i##_len=(n);i<i##_len;i++)
#define brep(i,a,b) for(ll i=(a),i##_len=(b);i<=i##_len;i++)
#define rrep(i,n) ll i=(n);ll now=-1;while(i--&&(now++||1))
#define Yes(n) cout<<((n)?Yes:No)
#define pb push_back
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vbl = vector<bool>;
using vint = vector<int>;
using vstr = vector<string>;
static inline void ignore_ret(int x) {x++;}
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(a>b){a=b;return 1;}return 0;}
template<class T> inline map<T,T> factorize(T n){map<T,T>r;for(T i=2;i*i<=n;i++){while(n%i== 0){r[i]++;n/=i;}}if(n!=1)r[n]=1;return r;}
template<class T> inline T gcd_vec(vector<T>v){T r=v[0];for(T i=1;i<v.size();i++)r=gcd(r,v[i]);return r;}
template<class T> inline T lcm_vec(vector<T>v){T r=v[0];for(T i=1;i<v.size();i++)r=lcm(r,v[i]);return r;}
template<class T> inline T factorial(T n){if(n==0)return 1;T r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> inline T nCr(T n,T k){if(n<k||n<0||k<0)return 0;T r=1;k=min(k,n-k);for(T i=n-k+1;i<=n;i++)r*=i;return r/factorial(k);}
template<class T> inline T dot_product(vector<T>u,vector<T>v){if(u.size()<v.size())return 0;T r=0;for(T i=0;i<u.size();i++)r+=u[i]*v[i];return r;}
template<class T> inline T sum(vector<T>v){return reduce(all(v),0LL);}

void solve(ll D) {
  cout << "Christmas";
  while (D < 25) {
    cout << " Eve";
    D++;
  }
  cout << endl;
}

int main() {
  ll D;
  ignore_ret(scanf("%lld",&D));
  solve(D);
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()

{

  char ch;

  scanf ("%c", &ch);

    if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u' ||
       ch=='A' || ch=='E' || ch=='I' || ch=='O' || ch=='U')
    {
        printf("vowel", ch);
    }
    else {
        printf("consonant", ch);
    }


  return 0;
}


Measured memory_bytes: 1672
a, b = map(int, input().split())
A = list(map(int, input().split()))
d = []
for i in range(len(A)):
  if i == len(A)-1:
    r = a-A[i]+A[0]
    d.append(r)
  else:
    d.append(A[i+1]-A[i])
print(a-max(d))

Measured memory_bytes: 26444
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<vector>
#include<cstdlib>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<sstream>
using namespace std;

int N;

int calc(int a, int b){
	int res = a - b;
	if( res < 0 ) res += N;
	if( res > (N-1)/2 ) return res = N - res;
	return res;
}

int main(){
	while(cin >> N, N){
		int cnt[10000] = {};
		vector<int> s;
		for(int i = 1; i < N; i++){
			s.push_back( (i*i)%N );
		}
		sort( s.begin(), s.end() );
		s.erase( unique( s.begin(), s.end() ), s.end() );
		for(int i = 0; i < s.size(); i++){
			for(int j = 0; j < s.size(); j++){
				if( s[i] == s[j] ) continue;
				cnt[ calc(s[i], s[j]) ]++;
			}
		}
		for(int i = 1; i <= (N-1)/2; i++) printf("%d\n", cnt[i]);
	}
	return 0;
}

Measured memory_bytes: 1348
n = int(input())
a_list = list(map(int, input().split()))

num_of_factor_2 = []

for i in range(len(a_list)):
    a_trial = 0
    while a_list[i] % 2 == 0:
        a_list[i] = a_list[i] / 2
        a_trial += 1
    num_of_factor_2.append(a_trial)
    
print(sum(num_of_factor_2))

Measured memory_bytes: 10132
N, M = map(int, input().split())

ac_list = [0] * (N+1)
wa_list = [0] * (N+1)
wa_cnt = 0
ac_cnt = 0

for _ in range(M):
  p, S = map(str, input().split())
  if S == 'AC':
    if ac_list[int(p)] == 0:
      ac_cnt += 1
      ac_list[int(p)] = 1
      wa_cnt += wa_list[int(p)]
    else:
      pass
  else:
    if ac_list[int(p)] == 0:
      wa_list[int(p)] += 1
    else:
      pass
    

print(ac_cnt, wa_cnt)
    

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


l, r = 0, n

print(0, flush=True)
re = input()
if re=="Vacant": exit()

for i in range(19):
    mid = (l+r)//2
    print(mid, flush=True)
    tmp = input()
    if tmp=="Vacant": exit()

    p = abs(l-mid)%2

    if (re!=tmp and p) or (re==tmp and p-1):
        l = mid
        re = tmp
    else:
        if abs(l-mid) in [1, n-1]:
            l = mid
            re = tmp
        else: r = mid


Measured memory_bytes: 3660
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define SZ(a) (int)((a).size())
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef double db;
typedef pair <int, int> Pii;
typedef pair <ll, int> Pli;
typedef unsigned long long ull;
const double eps = 1e-8;
const ll infll = 0x7fffffffffffffff;
const int mod = (int)(1e9) + 7;
const int inf = 0x7fffffff;
const int maxn = (int)(2e5) + 7;
const int maxm = 300;

int n;

int main() {

	scanf("%d", &n);
	printf("%d\n", (1000 - n % 1000) % 1000);

	return 0;
}

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

deque<int> d[2];
vector<int> e[200000];
int ans[200000];

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

	int H, W, N;
	cin >> H >> W >> N;
	for(int i = 0; i < N; i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		e[a].push_back(b);
	}

	for(int i = 0; i < W; i++) {
		d[i % 2].push_back(i);
	}

	for(int i = 0; i < H; i++) {
		for(int b : e[i]) {
			if(i % 2 == 0) {
				swap(d[0][b / 2], d[1][b / 2]);
			}
			else {
				swap(d[0][b / 2 + 1], d[1][b / 2]);
			}
		}

		swap(d[0], d[1]);
		if(i % 2) {
			d[0].push_front(d[1].front());
			d[1].pop_front();
			d[1].push_back(d[0].back());
			d[0].pop_back();
		}
	}


	for(int i = 0; i < W; i++) {
		if(i % 2 == 0) ans[d[0][i / 2]] = i;
		else ans[d[1][i / 2]] = i;
	}

	for(int i = 0; i < W; i++) {
		cout << ans[i] + 1 << endl;
	}
}

Measured memory_bytes: 13052
#define _USE_MATH_DEFINES
#define INF 100000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

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

static const double EPS = 1e-8;

const int tx[] = {0,1,0,-1};
const int ty[] = {-1,0,1,0};

int main(){

	double x,y;
	int n;
	int seq=1;
	
	while(~scanf("%d",&n)){
		if(n==0) break;
		vector<P> v;
		for(int i=0;i<n;i++){
			scanf("%lf %lf",&x,&y);
			v.push_back(P(x,y));
		}

		double S=0;
		for(int i=0;i<v.size();i++){
			int idx1 = i;
			int idx2 = (i+1) % v.size();
			S += 0.5*(v[idx2].first - v[idx1].first)*(v[idx1].second + v[idx2].second) + EPS;
		}

		printf("%d %.1lf\n",seq++,S);
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <iomanip>
#include <list>
#include <queue>
#include <stack>
#include <map>
#define modulus 1000000007
#define ll long long
using namespace std;

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

Measured memory_bytes: 3628
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define lld long double
#define REP(i,s,n) for(lli i=s;i<n;i++)
#define RREP(i,s,n) for(lli i=s;i>=n;i--)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

map<lli,map<string,lli>> memo;

bool ok(string last4){
	REP(i,0,4){
		string t=last4;
		if(DEBUG)cout<<"t="<<t<<endl;
		if(i!=0)swap(t[i],t[i-1]);
		if(t.find("AGC")!=string::npos)return false;
	}
	if(DEBUG)cout<<"unchi"<<endl;
	return true;
}
lli n;

lli func(lli now,string last3){
	if(DEBUG)cout<<"now="<<now<<" last3 = "<<last3<<endl;
	if(memo[now][last3])return memo[now][last3];
	if(now==n)return 1;
	string s = "AGCT";

	lli rtn = 0;
	REP(i,0,4){
		string next4 = last3+s[i];
		if(ok(next4))rtn += func(now+1,next4.substr(1));
	}
	rtn %= MOD;
	return memo[now][last3] = rtn;

}

signed main(){

	cin>>n;
	cout<<func(0,"TTT")<<endl;

	return 0;
}

Measured memory_bytes: 896
n, k = list(map(int, input().split()))
s = str(input())

num = s.replace('10', '1,0')
num = num.replace('01', '0,1').split(',')
num = list(map(len, num))

if s[0] == '0':
    num.insert(0, 0)
if s[-1] == '0':
    num.append(0)

left = 0
right = 2*k + 1
length = sum(num[left:right])
ans = length
for i in range(2, len(num)-k, 2):
    length -= sum(num[left:left+2])
    left = i
    right = i + 2*k + 1
    length += sum(num[right-2:right])
    ans = max(ans, length)
    
print(ans)

Measured memory_bytes: 5472
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <bitset>
#include <deque>
using namespace std;
using ll = long long;
using itn = int;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;

int main() {

    int n, a, b;
    cin >> n >> a >> b;

    cout << min(n*a, b) << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

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

using namespace std;

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

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

void inputVector(vector<int> &v, int &n) {rep(i,n){v.push_back(nextInt());}}
void inputVector(vector<double> &v, int &n) {rep(i,n){v.push_back(nextDouble());}}
void inputVector(vector<string> &v, int &n) {rep(i,n){v.push_back(nextString());}}

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

	bool c, f;
	c = false;
	rep(i, s.size()) {
		if (c && s[i] == 'F') {
			cout << "Yes" << endl;
			return 0;
		}
		if (s[i] == 'C') {
			c = true;
		}
	}

	cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
for _ in range(10000):
    n, x = map(int, input().split())

    if n == 0 and x == 0:
        break

    ans = 0

    for num1 in range(1, n + 1):
        if num1 * 3 >= x:
            break

        for num2 in range(num1 + 1, n + 1):
            num3 = x - num1 - num2
            if num2 >= num3:
                break
            if (num3) <= n:
                if num1 != num3 and num2 != num3:
                    ans += 1
    print(ans)



Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int n; cin >> n;
    vector<int> buka(n+1, 0);
    rep(i, n-1) {
        int a; cin >> a;
        buka[a]++;
    }
    rep1(i, n) cout << buka[i] << endl;
}


Measured memory_bytes: 4028
//FizzBuzz Sum

#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <map>
#include <stdio.h>
#include <string.h>
#include <initializer_list>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <queue>
#include <set>
using namespace std;
const int INF = 1 << 29;
int main ()
{
    int N;
    cin >> N;

    long long sum = 0;
    for (int i = 1; i <= N; i++) {
        if (i%3==0||i%5==0) {
            continue;
        }
        else {
            sum += i;
        }
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3188
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
 
#define sl(x) scanf("%ld", &x)
#define ss(x) scanf("%s", x)
#define pl(x) printf("%ld\n", x)
#define ps(x) printf("%s\n", x)
 
#define INF 100000000000
#define MOD 1000000007
 
#define MIN(a,b) (((a)<(b))?(a):(b))
#define MAX(a,b) (((a)>(b))?(a):(b))
 
int main() {
	long N, K;
	long ai, ao, at, aj, al, as, az;
	long i, j;
	long tmp;
	long ans = 0;
	long min_i, max_i;
	
	sl(ai); sl(ao); sl(at); sl(aj); sl(al); sl(as); sl(az);
	
	tmp = 0;
	if(ai % 2) tmp++;
	if(aj % 2) tmp++;
	if(al % 2) tmp++;
	
	if(tmp == 1 || ai == 0 || aj == 0 || al == 0) {
		ans += (ai % 2 ? ai - 1 : ai);
		ans += ao;
		ans += (aj % 2 ? aj - 1 : aj);
		ans += (al % 2 ? al - 1 : al);
	} else if(tmp == 2) {
		ans += 3;
		ai--; aj--; al--;
		ans += (ai % 2 ? ai - 1 : ai);
		ans += ao;
		ans += (aj % 2 ? aj - 1 : aj);
		ans += (al % 2 ? al - 1 : al);
	} else {
		ans += MIN(ai, MIN(aj, al)) * 3;
		ai -= (ans / 3);
		aj -= (ans / 3);
		al -= (ans / 3);
		ans += (ai % 2 ? ai - 1 : ai);
		ans += ao;
		ans += (aj % 2 ? aj - 1 : aj);
		ans += (al % 2 ? al - 1 : al);
	}
	
	pl(ans);
	
	return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class C { public static void Main() => (new Solver()).Solve(); }

public class Solver
{
	public void Solve()
	{
		long N = GetLong();
		long K = GetLong();
		var A = GetLongs(N);

		for(long i = 0; i < K; i++)
		{
			var B = new long[N];
			for(long j = 0; j < N; j++)
			{
				long l = Max(0, j - A[j]);
				long r = Min(j + A[j], N - 1);
				B[l]++;
				if(r + 1 < N)
					B[r + 1]--;
			}
			for(long j = 0; j < N - 1; j++)
				B[j + 1] += B[j];

			A = B;
			if(A.All(x => x == N))
				break;
		}
		WriteLine(string.Join(" ", A));
	}
}

public static class MyIO
{
	private static string[] args = new string[0];
	private static int cnt = 0;
	private static IEnumerable<string> getArgs(long N) => Range(0, N).Select(_ => getArg());
	private static string getArg()
	{
		if(cnt == args.Length) { args = Console.ReadLine().Split(); cnt = 0; }
		return args[cnt++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
	public static long[] GetLongs(long N) => getArgs(N).Select(long.Parse).ToArray();
	public static double[] GetDoubles(long N) => getArgs(N).Select(double.Parse).ToArray();
	public static decimal[] GetDecimals(long N) => getArgs(N).Select(decimal.Parse).ToArray();
	public static string[] GetStrings(long N) => getArgs(N).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) < 0) x = y; }
	public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) > 0)	x = y; }
	public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; }
	public static long rightShift(long x, long y) => (x >> (int)y);
	public static long leftShift(long x, long y) => (x << (int)y);
	public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
	public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
	public static long lcm(long x, long y) => (x / gcd(x,y)) * y;	
	public static IEnumerable<int> Range(long start, long count) => Enumerable.Range((int)start, (int)count);
	public static void Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}


Measured memory_bytes: 78560
def int_(num_str):
    return int(num_str) - 1


N, M = map(int, input().split())
ablist = [list(map(int_, input().split())) for _ in range(M)]
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
        self.group_count = n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        self.group_count -= 1

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
ans = 0
for i in range(M):
    uf = UnionFind(N)
    for j in range(M):
        if i != j:
            uf.union(*ablist[j])
    if uf.group_count >= 2:
        ans += 1
print(ans)


Measured memory_bytes: 3064
#include <stdio.h>

int main() {
  int a[4][3][10] = {0};
  int n, b, f, r, v;

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


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

int INF = 1001001001;

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


int main() {
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    vector<int> dp(110000, INF);
    dp[0] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 1; j <= k; j++) {
            chmin(dp[i+j], dp[i] + abs(h[i] - h[i+j]));
        }
    }
    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 3968