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

typedef long long ll;

const int mod = 1000000007;
const int Maxn = 200005;

int n;
char str[Maxn];
int res = 1;

int main()
{
    scanf("%d", &n);
    scanf("%s", str);
    int cur = 0;
    for (int i = 0; i < 2 * n; i++)
        if (str[i] == 'W')
            if (cur % 2 == 0) { res = ll(res) * cur % mod; cur--; }
            else cur++;
        else if (str[i] == 'B')
            if (cur % 2 == 0) cur++;
            else { res = ll(res) * cur % mod; cur--; }
    if (cur != 0) res = 0;
    for (int i = 2; i <= n; i++)
        res = ll(res) * i % mod;
    printf("%d\n", res);
    return 0;
}


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

int solve(int);

int solve(int n){
	if (n == 4 || n == 6 || n == 9 || n == 11){
		return 0;	
	}else if (n == 2){
		return 1;	
	}else{
		return 2;
	}
}

int main(){
	int x,y;
	cin >> x >> y;
	if (solve(x) == solve(y)){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;	
	}
	return 0;
}

Measured memory_bytes: 256
def degit_sum(n):
    if len(str(n)) < 2:
        return n
    s = list(str(n))
    s = [int(e) for e in s]
    return sum(s)

N = int(input())
degit = len(str(N))
if N % pow(10,degit-1) == 0 and N >= 10:
    degit -= 1
A = pow(10,degit-1)
B = N - A
ans = degit_sum(A) + degit_sum(B)
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

#define INF 1000000000009

vector<vector<long long>> dist;
vector<vector<long long>> car_dist;

int main()
{
	int n,m,l;
	cin >> n >> m >> l;

	dist=vector<vector<long long>>(n,vector<long long>(n,INF));
	car_dist=vector<vector<long long>>(n,vector<long long>(n,INF));

	for(int i=0;i<m;i++)
	{
		int a,b,c;
		cin >> a >> b >> c;
		a--;b--;
		dist[a][b]=c;
		dist[b][a]=c;
		if(c<=l)
		{
			car_dist[a][b]=1;
			car_dist[b][a]=1;
		}
	}

	for(int k=0;k<n;k++)
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
			{
				long long tmp=dist[i][k]+dist[k][j];
				if(tmp<dist[i][j])
					dist[i][j]=tmp;

				if(dist[i][j]<=l)
					car_dist[i][j]=1;
			}
	
	
	for(int k=0;k<n;k++)
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
			{
				long long tmp=car_dist[i][k]+car_dist[k][j];
				if(tmp<car_dist[i][j])
					car_dist[i][j]=tmp;
			}
	
		
	int q;
	cin >> q;
	for(int Q=0;Q<q;Q++)
	{
		int s,t;
		cin >> s >> t;
		s--;t--;


		if(car_dist[s][t]>=INF)
			cout << -1 << endl;
		else
			cout << car_dist[s][t]-1 << endl;

	}
}


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

const int _ = 4003; vector < int > nxt[_]; int N , K;
int dfs(int x , int p , int l){
	int cnt = x <= N;
	if(l < K) for(auto t : nxt[x]) if(t != p) cnt += dfs(t , x , l + 1);
	return cnt;
}

int main(){
	cin >> N >> K;
	for(int p , q , i = 1 ; i < N ; ++i){
		cin >> p >> q; nxt[p].push_back(N + i); nxt[q].push_back(N + i);
		nxt[N + i].push_back(p); nxt[N + i].push_back(q);
	}

	int mx = 0;
	if(K & 1) for(int i = N + 1 ; i < 2 * N ; ++i) mx = max(mx , dfs(i , 0 , 0));
	else for(int i = 1 ; i <= N ; ++i) mx = max(mx , dfs(i , 0 , 0));
	cout << N - mx;
	return 0;
}


Measured memory_bytes: 640
a,b,c=map(str,input().split())
a,c=int(a),int(c)
while not b=='?':
    if b=='+':
        print(a+c)
    elif b=='-':
        print(a-c)
    elif b=='*':
        print(a*c)
    elif b=='/':
        print(int(a/c))
    a,b,c=map(str,input().split())
    a,c=int(a),int(c)


Measured memory_bytes: 5600
#include<bits/stdc++.h>
#define sf1(n) scanf("%d",&n)
#define sf2(n,q) scanf("%d %d",&n,&q)
#define f first
#define ss second
#define pb push_back
#define lli long long
#define mem(ar,false) memset(ar,false,sizeof(ar))
#define mpr make_pair
#define endl "\n"
#define mod 1000000007
#define inf 9000000000000000000LL
using namespace std;

lli ar[105][5];
lli dp[100005];


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli n,w;
    cin >> n >> w ;

    lli sum=0;
    for(int i=1; i<=n; i++)
    {
        cin >> ar[i][1] >> ar[i][2];
        sum += ar[i][2];
    }

    for(int i=1; i<=sum; i++)
        dp[i] = inf;

    for(int i=1; i<=n; i++)
    {
        for(int j=sum-ar[i][2]; j>=0; j--)
        {
            dp[j+ar[i][2]] = min(dp[j+ar[i][2]],ar[i][1]+dp[j]);
        }
    }

    lli ans =0;
    for(int i=0; i<=sum; i++)
    {
        if(dp[i]<=w)
            ans = i;
    }
    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 4388
use std::io;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let d:i32 = buf.trim().parse().ok().unwrap();
	print!("Christmas");
	for i in 0..(25 - d) {
		print!(" Eve");
	}
	println!("");
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(n); i++)
using veci = vector<int>;
using veci = vector<int>;
using veci = vector<int>;
using veci = vector<int>;
using G = vector<vector<int>>;
using ll = long long;
int INF = 10101010;
int a[4][3][10];
int main(){
   int n;
   cin >> n;
   rep(i, n){
       int b, f, r, v;
       cin >> b >> f >> r >> v; b--; f--; r--;
       a[b][f][r] += v;
   }
   rep(i, 4){
       rep(j, 3){
            rep(k, 10){
                cout << " " << a[i][j][k];
               }
               cout << endl;
           }
           if (i != 3){
             rep(i, 20){
               cout << '#';
               if (i == 19) cout << endl;
           }
       }
   }
}


Measured memory_bytes: 3072
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


class PriorityQueue:
    def __init__(self, l=[]):
        self.__q = l
        heapq.heapify(self.__q)
        return

    def push(self, n):
        heapq.heappush(self.__q, n)
        return

    def pop(self):
        return heapq.heappop(self.__q)


sys.setrecursionlimit(1000000)
MOD = int(1e09) + 7
INF = int(1e30)


def main():
    # sys.stdin = open("Sample.txt")
    N, K = Scanner.map_int()
    X = [0] * N
    Y = [0] * N
    for i in range(N):
        x, y = Scanner.map_int()
        X[i] = x
        Y[i] = y
    sx = sorted(X)
    sy = sorted(Y)
    ans = INF
    for l in range(N-1):
        for r in range(l+1, N):
            for b in range(N-1):
                for t in range(b+1, N):
                    left = sx[l]
                    right = sx[r]
                    bottom = sy[b]
                    top = sy[t]
                    cnt = 0
                    for i in range(N):
                        if left <= X[i] <= right and bottom <= Y[i] <= top:
                            cnt += 1
                    if cnt >= K:
                        ans = min(ans, (right-left)*(top-bottom))
    print(ans)
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 47704
#include <iostream>

using namespace std;
using ll = long long;

ll gcd(ll A, ll B) {
  ll d;
  while ((d = A % B)) {
    A = B;
    B = d;
  }
  return B;
}

int main() {
  ll A, B, C, D, G, N;
  cin >> A >> B >> C >> D;
  G = C * D / gcd(C, D);
  N = B - A + 1 - B / C + (A - 1) / C - B / D + (A - 1) / D + B / G -
      (A - 1) / G;
  cout << N << endl;
}


Measured memory_bytes: 256
N = gets.to_i
As, Bs, Cs = readlines.map{|l| l.split.map(&:to_i)}

puts As.inject(0){|s, i| s + Bs[i - 1]} + As.each_cons(2).select{|i, j| j == i + 1}.inject(0){|s, (i, j)| s + Cs[i - 1]}

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#include <unordered_map>
#define int long long int
#define double long double
#define endl "\n"
#define PI 3.141592653589793238462643383279502884
#define sp(x)   setprecision(x)
#define ceil(a,b)   (a+(b-1))/b
#define LCM(a,b)    (a*b)/__gcd(a,b)
#define all(v)  v.begin(),v.end()
#define alls(s,v)  s.begin(),s.end(),v
#define gena(arr,n,nxt)  generate(arr,arr+n, nxt)
#define genv(v,nxt)  generate(v.begin(),v.end(), nxt)
#define base ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define exit return 0;
#define is(x) cout << #x << " = " << x << endl;
using namespace std;
const int N=500000;
bool prime[N];
void sieve(){
    memset(prime, true, sizeof(prime));
    for (int p=2; p*p<100000000; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<100000; i += p)
                prime[i] = false;
        }
    }
}
int nxt(){int x;cin >> x;return x;}
int32_t main(){
    base
    int a=nxt(),b=nxt(),h=nxt();
    cout<<((a+b)*h)/2;
    exit
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

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

       
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var n = Read();
            var a = n / 100;
            var b = (n - a * 100) / 10;
            var c = n - a * 100 - b * 10;
            if (a == 7 || b == 7 || c == 7) Console.WriteLine("Yes");
            else Console.WriteLine("No"); 









            Console.Out.Flush();
        }
    }
}


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

int main(){
  int N, M;
  cin >> N >> M;
  
  vector<int> H(N);
  
  for(int i=0; i < N; i++) cin >> H[i];
  vector<vector<int>> G(100010);
  
  for(int i=0; i < M; i++){
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  int ans = 0;
  
  for(int i=0; i <N; i++){
    int max_val = 0;
    for(auto &e: G[i]){
       max_val = max(max_val, H[e]);
    }
    if(max_val < H[i]) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 8740
S = input()
a = ['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']

for i in S:
    if i in a:
        a.remove(i)
#print(a)
print(a[0] if len(a)!=0 else 'None')

Measured memory_bytes: 9164
/*
digu_J - Digvijay Janartha
NIT Hamirpur - INDIA
 
***********************IN COLABRATION WITH -----AJrockstar   :)*********************
*/
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
 
using namespace std;
using namespace __gnu_pbds;
 
//template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
//template<typename T> using MinPriorityQueue = priority_queue <T, vector <T>, greater <T>>;
 
typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef complex<double> com;
 
#define eb emplace_back
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define loop(x,n) for(ll x = 0; x < n; x++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
 
const ll LINF = LLONG_MAX, SZ = 1e3, MOD = 1e9 + 7, N = 1e5 + 5, M = 1e3 + 5, LG = 21;
const int INF = INT_MAX;
const db PI = acos(-1), EPS = 1e-6;
//mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
 
 
int main() {
	
    fast_io();
    ll i,j,t,n,p,k,q,o,ca=0,cb=0,x,y,s;
    
    cin>>n>>k;
    char a[n][k];
    ll dp[n+1][k+1],m;
    for(i=0;i<n;i++)
    {
    	for(j=0;j<k;j++)
    	{
    		cin>>a[i][j];
		}
	}
	
	for(i=0;i<k;i++)
	dp[0][i]=1;
	
	for(i=0;i<n;i++)
	dp[i][0]=1;
	
	for(i=0;i<n;i++)
    {
    	for(j=0;j<k;j++)
    	{
    		if(a[i][j]=='#')
    		dp[i][j]=0;
		}
	}
	
	for(i=0;i<k;i++)
	{
		if(a[0][i]=='#')
		{
			for(j=i;j<k;j++)
			dp[0][j]=0;
			break;
		}
		
	}
	
	
	for(i=0;i<n;i++)
	{
		if(a[i][0]=='#')
		{
			for(j=i;j<n;j++)
			dp[j][0]=0;
			break;
		}
		
	}
	
	for(i=1;i<n;i++)
	{
		for(j=1;j<k;j++)
		{
			if(a[i][j]!='#')
			{
				dp[i][j]=(dp[i-1][j]+dp[i][j-1])%MOD;
			}
		}
	}
	
	cout<<dp[n-1][k-1];
    return 0;
}
 
 

Measured memory_bytes: 9088
#include "bits/stdc++.h"
using namespace std;
int n, k;
const int mod = 1000000000 + 7;
int mem[2][2222][2222];

int dp(int shit, int cur, int left) {
	if(cur < 1) return 0;
	if(cur == 1 && ((n - 1 - left) == k-1)) {
		return 1;
	}
	if(mem[shit][cur][left] != -1) {
		return mem[shit][cur][left];
	}
	long long ans = 0;
	ans += dp(0, cur - 1, left);
	if(left && !shit) {
		ans += dp(0, cur, left - 1);
	}
	ans += dp(1, cur - 1, left + 1);
	ans %= mod;
	return mem[shit][cur][left] = ans;
} 

int main(int argc, char const *argv[])
{
	cin >> n >> k;
	memset(mem, -1, sizeof mem);
	long long ans = dp(0, n, 0);
	for(int i = 1; i < (n-k); i++) {
		ans *= 2;
		ans %= mod;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 38912
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;

int main() {
	double x[3] = { .0 }, y[3] = { .0 }, sum = .0, z, a, b ,c;
	char t;

	cin >> x[0] >> t >> y[0] >> x[1] >> t >> y[1];
	while (cin >> x[2]) {
		cin >> t >> y[2];
		a = hypot(x[1] - x[0], y[1] - y[0]);
		b = hypot(x[2] - x[1], y[2] - y[1]);
		c = hypot(x[0] - x[2], y[0] - y[2]);
		z = (a + b + c) / 2;
		sum += sqrt(z * (z - a) * (z - b) * (z - c));
		x[1] = x[2], y[1] = y[2];
	}
	printf("%.6lf\n", sum);
	return 0;
}

Measured memory_bytes: 3256
# -*- coding: utf-8 -*-
"""
Created on Sun May 10 20:54:33 2020

@author: Kanaru Sato
"""

n,k = list(map(int,input().split()))
_ = list(map(int,input().split()))
np = [0]+_

cp = 1
dic = {"1":0}
kaisu = 0

while True:
    kaisu += 1
    cp = np[cp]
    if cp in dic:
        break
    else:
        dic[cp] = kaisu

loopstart = cp
looplength = kaisu-dic[loopstart]

if k <= dic[loopstart]:
    ans = [i for i, v in dic.items() if v == k]
    print(ans[0])
else:
    k = k-dic[loopstart]
    k = k%looplength
    ans = [i for i, v in dic.items() if v == dic[loopstart]+k]
    print(ans[0])

Measured memory_bytes: 40220
n,k,q = map(int,input().split())
a_list = [int(input()) for nesya in range(q)]
hoge_list = [0]*n
for a in a_list:
  s = a-1
  hoge_list[s] += 1
for hoge in hoge_list:
  if hoge > q-k:
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 8636
#include <iostream>
#include <cmath>
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = 0; i < (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
#define ECHO(v) cout << v << endl;

int main(void)
{
  int N, T;
  int num;
  int prev = 0;
  int sum = 0;
  cin >> N >> T;
  REP(i, N)
  {
    cin >> num;
    sum += min(T, num - prev);
    prev = num;
  }
  sum += T;
  ECHO(sum);
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	a := readInt()
	b := readInt()
	c := readInt()

	println(minInt(b/a, c))
}

// -----------------------------------------------------------------------------

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 640
#include <array>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

int main()
{
    int N;
    cin >> N;
    vector<pair<int, int> > X(N);
    REP(i, N)
    {
        cin >> X[i].first;
        X[i].second = i;
    }
    sort(X.begin(), X.end());
    int ans[N];
    REP(i, N)
    {
        if((i + 1) <= N / 2)
        {
            ans[X[i].second] = X[(N + 1) / 2].first;
        }
        else
        {
            ans[X[i].second] = X[(N + 1) / 2 - 1].first;
        }
    }
    REP(i, N)
    {
        cout << ans[i] << endl;;
    }
    return 0;
}


Measured memory_bytes: 4480
// #define _GLIBCXX_DEBUG
// #pragma GCC optimize("Ofast")
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <bits/stdc++.h>
// #include <atcoder/all>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define reps(i, s, n) for (int i = s; i < (int)(n); ++i)
using namespace std;
using ll = long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
constexpr int INF = 1e9 + 7;
constexpr ll LINF = 1LL << 60;

void solve() {
    int n;
    cin >> n;
    int ans = 0;
    ans += n / 500 * 1000;
    n %= 500;
    ans += n / 5 * 5;
    cout << ans << "\n";
}
int main() {
    cin.tie(nullptr);
    // ios_base::sync_with_stdio(false);
    // cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, t;
  cin >> s >> t;
  int ans = 1000;
  
  for(int i = 0; i < s.size(); i++) {
	if(i + t.size() > s.size()) break;
    int cnt = 0;
    for(int j = 0; j < t.size(); j++) {
      if(s[i+j] != t[j]) cnt++;
    }
    ans = min (ans, cnt);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N = int(rl())
    S = [rl().rstrip() for _ in range(N)]
    
    ans = 0
    for b in range(N):
        flg = True
        for i in range(N):
            for j in range(N):
                ii = (i + b) % N
                jj = (j + b) % N
                if S[i][jj] != S[j][ii]:
                    flg = False
                    break
            if not flg:
                break
        ans += flg
    ans *= N
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 39792
#include<bits/stdc++.h>
#include<string>
#define pii pair<int, int>
#define mp make_pair
#define ll long long
#define ld long double
#define pb push_back
#define S second
#define F first
using namespace std;



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

	
	ll n, d;
	cin >> n >> d;
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		ll k, l;
		cin >> k >> l;
		if (l * l + k * k <= d * d) cnt++;
	}

	cout << cnt << '\n';

}

Measured memory_bytes: 3652
n = gets.to_i
a = gets.split(' ').map(&:to_i)
m = gets.to_i
b = gets.split(' ').map(&:to_i)
cnt = 0
a.uniq.each do |i|
  b.uniq.each do |ii|
    cnt += 1 if i == ii
  end
end
puts cnt

Measured memory_bytes: 12732
#include <iostream>
using namespace std;
int main(void){
    int len, ind = 0;
    string s, ans = "";
    cin >> s;
    len = s.length();
    for(int i=0;i<len;i++){
        if(s[i] == 'B' && ind > 0){
            ans = ans.substr(0, --ind);
        }
        if(s[i] == '0' || s[i] == '1'){
            ans += s[i];
            ind++;
        }
    }
    cout << ans << endl;
    
}


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

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

#define vi vector<int>
#define pb push_back
#define mp make_pair

typedef long long ll;

int main() {
//    ifstream in("a_in.txt");
//    cin.rdbuf(in.rdbuf());

    int n,m,pp;
    while(cin >>n >> m>>pp,n){
        int p = pp;
        int a[110] = {};
        p = 100-p;
//        int m[110] = {};
        rep(i,n) cin >> a[i];
        int sum = 0;
        rep(i,n) sum += a[i];
        m--;
//        cout << p << " : " << sum*100 << " : " << a[m] << endl;
        if(a[m] ==0) cout << 0 << endl;
        else cout << int(p*sum/a[m])  << endl;

    }
    return 0;
}


Measured memory_bytes: 2996
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;typedef vector<ll> vll;
#define fill(a) memset(a, 0, sizeof (a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0; i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define unq(v) sort(all(v)),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define getpos(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define _ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ff first
#define ss second
#define pb push_back
#define sz(x) (int)x.size()

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int maxn = 2000100;
const ll inf = ll(1e18)+1;

int main(){
        _ios;
        ll n,k;
        cin>>n>>k;
        vll num(n);
        for(int i = 0; i<n;i++){
            cin>>num[i];
        }
        sort(all(num));
        ll left = -inf, right = inf;
        while(left+1< right){
            ll mid = (left+right)/2;
            ll cnt = 0;
            rep(i,n){
                ll temp = num[i];
                if(temp>0){
                    int l = -1,r=n;
                    while(l+1<r){
                        int c = (l+r)/2;
                        if(num[c]*temp<=mid)l=c;
                        else r = c;

                    }
                    cnt+=r;
                }
                else if(temp==0){
                    if(mid>=0)cnt+=n;
                }
                else {
                    int l = -1,r=n;
                    while(l+1<r){
                        int c = (l+r)/2;
                        if(num[c]*temp<=mid) r= c;
                        else l = c;
                    }
                    cnt+=n-r;
                }
                if(temp*temp<=mid)cnt--;
            }
            cnt/=2;
            if(cnt>=k)right = mid;
            else left = mid;
        }
        cout<<right<<endl;




return 0;
}






Measured memory_bytes: 1792
package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	as := make([]int, n)
	for i := range as {
		as[i] = -1
	}
	ss := make([]int, m)
	cs := make([]int, m)
	for i := 0; i < m; i++ {
		fmt.Scan(&ss[i], &cs[i])
	}
	for i := 0; i < m; i++ {
		s, c := ss[i], cs[i]
		s--
		if (as[s] != -1 && c != as[s]) || (s == 0 && c == 0 && n != 1) {
			fmt.Println(-1)
			return
		}
		as[s] = c
	}
	for i := range as {
		if as[i] == -1 {
			if i == 0 && n != 1 {
				fmt.Print(1)
			} else {
				fmt.Print(0)
			}
		} else {
			fmt.Print(as[i])
		}
	}
	fmt.Println()
}


Measured memory_bytes: 512
import sys
input = sys.stdin.readline

N = int(input())
A = list( map(int, input().split()) )
x = [0]*N
SUM = sum(A)
x[0] = SUM
for i in range(1, N, 2):
    x[0] -= 2*A[i]
for i in range(1, N):
    x[i] = 2*A[i-1]-x[i-1]
print(*x)

Measured memory_bytes: 60260
x=int(input())
if x in range(400,600):
    p=8
elif x in range(600,800):
    p=7
elif x in range(800,1000):
    p=6
elif x in range(1000,1200):
    p=5
elif x in range(1200,1400):
    p=4
elif x in range(1400,1600):
    p=3
elif x in range(1600,1800):
    p=2
elif x in range(1800,2000):
    p=1
print(p)

Measured memory_bytes: 61924
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

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

  int d = b-a;
  int t = d * (d+1) / 2;
  cout << t - b << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
res = 0
for i in range(N):
    diff = B[i] - A[i]
    if diff >= 0:
        if B[i] >= A[i] + A[i+1]:
            res += A[i] + A[i+1]
            A[i+1] = 0
        else:
            res += B[i]
            A[i+1] -= diff
    else:
        res += B[i]
print(res)



Measured memory_bytes: 18624
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)



int main(){

    int n,y;
    cin>>n>>y;
    int k;
    REP(i,n+1){
        REP(j,n-i+1){
            k = n - i - j;
            if(y==10000*i+5000*j+1000*k){
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;


    return 0;
}

Measured memory_bytes: 256
import sys
from sys import stdin

s = stdin.readline().rstrip()
n = len(s)
s = '|' + s + '|'
r = [0] * (n + 1)
l = [0] * (n + 1)

for i in range(1, n + 1):
    if s[i] == '<':
        l[i] = l[i - 1] + 1
    else:
        l[i] = 0
for i in range(n - 1, -1, -1):
    if s[i + 1] == '>':
        r[i] = r[i + 1] + 1
    else:
        r[i] = 0

ans = 0
for i in range(n + 1):
    ans += max(r[i], l[i])
# print(r, l)
print(ans)

Measured memory_bytes: 27188
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <set>
using namespace std;

int main(){
  const int n = getInt();
  int ans = 0;
  REP(i,n){
    const int l = getInt();
    const int r = getInt();
    ans += (r - l + 1);
  }
  printf("%d\n", ans);
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

const ll mod = 3;
const int N = 1e3 + 10, M = 1e6 + 10;
const ll INF = 1e18;
const int inf = 0x3f3f3f3f;
const double eps = 1e-8;

#define pi acos(-1)

int a[N];

int main()
{
    ll x, k, d;
    cin >> x >> k >> d;
    ll ans = INF;
    if (x >= 0)
    {
        ll num = x / d;
        if (num >= k)
            ans = min(ans, abs(x - k * d));
        if (x % d)
            num++;
        ll y, cnt;
        if (num <= k)
        {
            y = x - num * d;
            cnt = k - num;
            if (cnt & 1)
            {
                ans = abs(y + d);
            }
            else
            {
                ans = abs(y);
            }
        }
        if (num - 1 <= k && num)
        {
            num--;
            y = x - num * d;
            cnt = k - num;
            if (cnt & 1)
            {
                ans = min(ans, abs(y - d));
            }
            else
            {
                ans = min(ans, abs(y));
            }
        }
    }
    else
    {
        x = abs(x);
        ll num = x / d;
        if (num >= k)
            ans = min(ans, abs(-x + k * d));
        if (x % d)
            num++;
        ll y, cnt;
        if (num <= k)
        {
            y = -x + num * d;
            cnt = k - num;
            if (cnt & 1)
            {
                ans = abs(y - d);
            }
            else
            {
                ans = abs(y);
            }
        }
        if (num - 1 <= k && num)
        {
            num--;
            y = -x + num * d;
            cnt = k - num;
            if (cnt & 1)
            {
                ans = min(ans, abs(y + d));
            }
            else
            {
                ans = min(ans, abs(y));
            }
        }
    }
    cout << ans << endl;
    return 0;
}
/*

*/

Measured memory_bytes: 3672
#include <iostream>
using namespace std;
int a1,a2;
int gcd,lcm;

int GCD(int a,int b){
    int i = 2;
    int minimum = min(a,b);
    if (minimum == 0){
        i = 0;
    }
    else if (minimum == 1){
        i = 1;
    }
    else {
        for (i = 1; i <= minimum; i++) {
            if (a % (minimum - i + 1) == 0 & b % (minimum - i + 1) == 0) {
                i = minimum - i + 1;
                break;
            }
        }
    }
    return i;
}

int main(){
    while(cin >> a1 >> a2) {
        gcd = GCD(a1,a2);
        if (gcd == 0){
            lcm = 0;
        }
        else{
            lcm = a1/gcd*a2;
        }
        cout << gcd << " " << lcm << endl;
    }
}

Measured memory_bytes: 3004
#include <iostream>
using namespace std;
void roll(int *dice, int *old, int *rollInfo)
{
    for(int i = 0; i < 6; ++i)
    { dice[i] = old[rollInfo[i]-1]; }
}
int main()
{
    int Sroll[6] = { 5, 1, 3, 4, 6, 2}, Eroll[6] = {4, 2, 1, 6, 5, 3}; 
    int Wroll[6] = {3, 2, 6, 1, 5, 4}, Nroll[6] = {2, 6, 3, 4, 1, 5};
    int dice[6], a;
    string directs;
    for(int i = 0; i < 6; ++i)
    { cin >> dice[i]; }
    cin >> directs;
    
    for(int s = 0; s < directs.size(); ++s)
    {
        int old[6] = {dice[0], dice[1], dice[2], dice[3], dice[4], dice[5]};
        if(directs[s] ==  'S') { roll(dice, old, Sroll); }
        else if(directs[s] == 'E') { roll(dice, old, Eroll); }
        else if(directs[s] == 'W') { roll(dice, old, Wroll); }
        else if(directs[s] == 'N') { roll(dice, old, Nroll); }
    }
    cout << dice[0] << endl;
    return 0;
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    string s;
    cin >> s;
    string res = "Yes";
    rep(i,ceil(s.size()/2.0)){
        if(s.at(i) != s.at(s.size()-1-i)){
            res = "No";
        }
    }
    string harf = s.substr(0,s.size()/2);
    rep(i,ceil(harf.size()/2.0)){
        if(harf.at(i) != harf.at(harf.size()-1-i)){
            res = "No";
        }
    }
    string remain = s.substr((s.size()+3)/2-1,s.size()-1);
    rep(i,ceil(remain.size()/2.0)){
        if(remain.at(i) != remain.at(remain.size()-1-i)){
            res = "No";
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);

        final int l = scanner.nextInt();
        final int r = scanner.nextInt();

        final List<Integer> mods = new ArrayList<>();
        for (int i = l; i <= Math.min(r, l + 2019); i++) {
            mods.add(i % 2019);
        }

        int min = Integer.MAX_VALUE;
        for (int i = 0; i < mods.size(); i++) {
            for (int j = i + 1; j < mods.size(); j++) {
                min = Math.min(min, (mods.get(i) * mods.get(j)) % 2019);
            }
        }

        System.out.println(min);
    }
}

Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef pair<ll,ll> pr;
typedef vector<ll> vc;
typedef unordered_map<ll,ll> umap;
#define pb emplace_back
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
const ll max_n = 1e5+5;
const ll inf = 1e17;

int main() {
    // your code goes here
    ll n, k, h[max_n], dp[max_n];
    cin >> n >> k;
    rep(i,1,n) cin >> h[i];
    dp[1] = 0;
    rep(i,2,k){
    	dp[i] = inf;
    	rep(j,1,i-1) chmin(dp[i],dp[j]+abs(h[i]-h[j]));
    }
    rep(i,k+1,n){
    	dp[i] = inf;
    	rep(j,i-k,i-1) chmin(dp[i],dp[j]+abs(h[i]-h[j]));
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<iostream>
#include<cstdlib>
int MOD = 1e9 + 7;
using namespace std;

int N,M;
int main (){
    cin >> N >> M;
    long long int x = 1;
    long long int y = 1;
    int ans ;
    if ( abs(N - M) >= 2) {
        cout << 0 << endl;
        return 0;
    }
    else {
        for(int i=0; i<min(M,N); i++){
            x = x * (N - i) % MOD;
            y = y * (M - i) % MOD;
            ans = x * y % MOD;
        }
    }
    if( N == M ) cout << ans * 2 % MOD << endl;
    else cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
// Sequence Growing Hard
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#define N 500
using namespace std;

int n, K, Mod;
int c[N][N], f[N][N], sum[N][N];

int main() {
#ifdef whyqx
    freopen("work.in", "r", stdin);
    freopen("work.out", "w", stdout);
#endif

    cin >> n >> K >> Mod;
    
    for (int i = 0; i <= n; ++i)
        for (int j = c[i][0] = 1; j <= i; ++j)
            c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % Mod;

    for (int i = 0; i <= K; ++i)
        f[1][i] = 1, sum[1][i] = K - i + 1;

    for (int i = 2; i <= n + 1; ++i) {
        for (int j = 0; j <= K; ++j)
            for (int a = 1; a < i; ++a)
                f[i][j] = (f[i][j] + 1ll * f[i - a][j] * c[i - 2][a - 1] % Mod * sum[a][j + 1]) % Mod;
        for (int j = K; j >= 0; --j)
            sum[i][j] = (sum[i][j + 1] + f[i][j]) % Mod;
    }

    cout << f[n + 1][0] << endl;

    return 0;
}


Measured memory_bytes: 2048
#include<iostream>
#include<algorithm>
using namespace std;
//Dinic O(EV^2)
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<limits>
template<typename T>
struct MF{
	vector<vector<pair<pair<int,int>,T> > >G;
	vector<int>level,iter;
	MF(int n_=0):G(n_),level(n_),iter(n_){}
	void add_edge(int from,int to,T cap)
	{
		G[from].push_back(make_pair(
			make_pair(to,G[to].size()),cap
		));
		G[to].push_back(make_pair(
			make_pair(from,G[from].size()-1),0
		));
	}
	T dfs(int u,int t,T f)
	{
		if(u==t)return f;
		for(;iter[u]<G[u].size();iter[u]++)
		{
			pair<pair<int,int>,T>&e=G[u][iter[u]];
			if(e.second>0&&level[u]<level[e.first.first])
			{
				T d=dfs(e.first.first,t,min(f,e.second));
				if(d>0)
				{
					e.second-=d;
					G[e.first.first][e.first.second].second+=d;
					return d;
				}
			}
		}
		return 0;
	}
	T max_flow(int s,int t)
	{
		T ret=0;
		for(;;)
		{
			fill(level.begin(),level.end(),-1);
			queue<int>P;
			level[s]=0;
			P.push(s);
			while(!P.empty())
			{
				int u=P.front();P.pop();
				for(pair<pair<int,int>,T>&e:G[u])
				{
					if(e.second>0&&level[e.first.first]<0)
					{
						level[e.first.first]=level[u]+1;
						P.push(e.first.first);
					}
				}
			}
			if(level[t]<0)return ret;
			fill(iter.begin(),iter.end(),0);
			for(T f;(f=dfs(s,t,numeric_limits<T>::max()))>0;)ret+=f;
		}
	}
};
int n,m;
string u;
main()
{
	cin>>n>>m>>u;
	MF<long long>mf(n+2);
	for(int i=0;i<n;i++)
	{
		long long a;cin>>a;
		if(u[i]=='L')
		{
			mf.add_edge(0,i+1,0);
			mf.add_edge(i+1,n+1,a);
		}
		else
		{
			mf.add_edge(0,i+1,a);
			mf.add_edge(i+1,n+1,0);
		}
	}
	for(int i=0;i<m;i++)
	{
		int s,t;
		long long b;
		cin>>s>>t>>b;
		if(s<t)mf.add_edge(s,t,b);
		else mf.add_edge(t,s,b);
	}
	cout<<mf.max_flow(0,n+1)<<endl;
}



Measured memory_bytes: 3292
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <math.h>

using namespace std;

const int maxn = 100000 + 50;

int coor[maxn];
int N, scost;

int work(int x)
{
	int res = scost;
	int y = x + 1, z = x - 1;
	if (x == N)
		y = 0;

	res -= abs(coor[z] - coor[x]);
	res -= abs(coor[x] - coor[y]);
	res += abs(coor[z] - coor[y]);
	return res;
}

int main()
{

	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> N;
	for (int i = 1; i <= N; i++)
		cin >> coor[i];

	for (int i = 1; i <= N; i++)
		scost += abs(coor[i] - coor[i - 1]);
	scost += abs(coor[N]);

	for (int i = 1; i <= N; i++)
	{
		int res = work(i);
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;




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

    int N;
    cin>>N;
    int ans=0;
    map<pair<int,int>,int> m;
    for(int i=1;i<=N;i++){
        int a=i;
        int b=i%10;
        while(a>=10){
            a/=10;
        }
        m[make_pair(a,b)]++;
    }

    for(int i=1;i<=9;i++){
        for(int j=i;j<=9;j++){
            if(i!=j) ans+=m[make_pair(i,j)]*m[make_pair(j,i)]*2;
            else ans+=m[make_pair(i,j)]*m[make_pair(j,i)];
        }
    }
    cout << ans << endl;






}


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

int main(){
    int l,r,d;
    cin >> l >> r >> d;
    int ans = 0;
    for(int i = l; i < r + 1; i++){
        if(i % d == 0) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

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

int main() {
  int n; cin >> n;
  int itm[n]; rep(i,n) cin >> itm[i];
  int min = 0;
  int ans = 0;
  rep(i,n) {
    if (itm[i] > min) min = itm[i];
    if (itm[i] >= min) ans++; 
  }
  cout << ans << endl;
}


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

using namespace std;

int main(){
    long N;
    cin>>N;
    bool f = false;
    for(int i=1; i<=9; ++i){
        int a = N%i;
        if(a==0 && N/i == N*1.0/i && N/i<=9){
            cout<<"Yes"<<endl;
            f = true;
            break;
        }
    }
    if(f==false){
        cout<<"No"<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int n;
    cin >> n;
    vector<int> t(n),v(n);
    int sumT = 0;
    for(int i = 0; i < n; i++) cin >> t[i], sumT += t[i];
    for(int i = 0; i < n; i++) cin >> v[i];
    vector<ld> a(sumT*2+1, 1e9);
    int nowt = 0;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < sumT*2+1; j++) {
            if(nowt*2 <= j && j <= (nowt+t[i])*2) {
                chmin(a[j], (ld)v[i]);
            } else if (j < nowt*2) {
                ld tt = (nowt*2-j)*0.5+v[i];
                chmin(a[j], tt);
            } else {
                ld tt = (j-(nowt+t[i])*2)*0.5+v[i];
                chmin(a[j], tt);
            }
        }
        nowt += t[i];
    }
    for(int i = 0; i < sumT*2+1; i++) {
        if(i <= sumT) {
            chmin(a[i], (ld)i*0.5);
        }else {
            chmin(a[i], sumT-(ld)i*0.5);
        }
    }
    ld ans = 0;
    for(int i = 0; i < sumT*2; i++) {
        ans += (a[i]+a[i+1])*0.25;
    }
    cout << fixed << setprecision(20) << ans << endl;
}

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

const int mod = 1e9 + 7; 
const int MaxN = 4e2 + 5; 

int n, c; 
int l[MaxN], r[MaxN]; 
int f[MaxN][MaxN], pw[MaxN][MaxN]; 

inline void add(int &x, const int &y)
{
	x += y; 
	(x >= mod) ? (x -= mod) : 0; 
}

int main()
{
//	freopen("candy.in", "r", stdin); 
//	freopen("candy.out", "w", stdout); 
	
	scanf("%d%d", &n, &c); 
	for (int i = 1; i <= n; ++i)
		scanf("%d", l + i); 
	for (int i = 1; i <= n; ++i)
		scanf("%d", r + i); 
	
	for (int i = 1; i <= n; ++i)
		for (int j = l[i]; j <= r[i]; ++j)
		{
			int now = 1; 
			for (int k = 0; k <= c; ++k)
			{
				add(pw[i][k], now); 
				now = 1LL * now * j % mod; 
			}
		}
	
	f[0][0] = 1; 
	for (int i = 1; i <= n; ++i)
		for (int j = 0; j <= c; ++j)
			for (int k = 0; k <= j; ++k)
				f[i][j] = (f[i][j] + 1LL * f[i - 1][j - k] * pw[i][k]) % mod; 
	
	printf("%d\n", f[n][c]); 
	
	fclose(stdin); 
	fclose(stdout); 
	return 0; 
}

Measured memory_bytes: 1536
#include                        <bits/stdc++.h>
#include                        <ext/pb_ds/assoc_container.hpp>
#define lb                      lower_bound
#define ub                      upper_bound
#define fe(x)                   *(x.begin())
#define le(x)                   *(x.rbegin())
#define pb                      push_back
#define load(node,n)            bool operator < (const node &n) const
#define fbo(x)                  find_by_order(x)
#define ook(x)                  order_of_key(x)
#define all(x)                  (x).begin(),(x).end()
#define FOR(i,n)                for(int i = 1; i<=n; i++)
#define REP(i,n)                for(int i = 0; i<n;  i++)
#define TT                      int TC;  scanf("%d",&TC);  while(TC--)
#define read                    freopen("input.txt","r",stdin)
#define write                   freopen("output.txt","w",stdout)
#define set(x)                  tree<x,null_type,less<x>,rb_tree_tag,tree_order_statistics_node_update>
using                           namespace __gnu_pbds;
using                           namespace std;
typedef                         long long ll;
typedef                         pair<ll,ll> pll;
typedef                         pair<int,int> pii;



#define mx 200004
vector<int> v[mx];


main(){
//read;


int n;
cin>>n;
for(int i = 2; i<=n; i++){
    int x;
    cin>>x;
//    v[i].pb(x);
    v[x].pb(i);
}
for(int i = 1; i<=n; i++)
    cout<<v[i].size()<<endl;


return 0;
}


Measured memory_bytes: 14572