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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h, w, k;
	cin >> h >> w >> k;
	vector<string> v(h);
	REP(i, h)cin >> v[i];
	int sx, sy;
	REP(i, h) {
		REP(j, w) {
			if (v[i][j] == 'S') {
				sy = i; sx = j;
			}
		}
	}
	vvi depth(h, vi(w, INF));
	queue<pii> q;
	q.push({ sx,sy });
	depth[sy][sx] = 0;
	while (!q.empty()) {
		int x = q.front().first, y = q.front().second;
		q.pop();
		if (x != 0 && depth[y][x - 1] == INF&&v[y][x-1]!='#') {
			q.push({ x - 1,y });
			depth[y][x - 1] = depth[y][x] + 1;
		}
		if (y != 0 && depth[y - 1][x] == INF&&v[y-1][x]!='#') {
			q.push({ x ,y - 1 });
			depth[y - 1][x] = depth[y][x] + 1;
		}

		if (x != w - 1 && depth[y][x + 1] == INF&&v[y][x+1]!='#') {
			q.push({ x + 1,y });
			depth[y][x + 1] = depth[y][x] + 1;
		}

		if (y != h - 1 && depth[y + 1][x] == INF&&v[y+1][x]!='#') {
			q.push({ x,y + 1 });
			depth[y + 1][x] = depth[y][x] + 1;
		}
	}
	int dist = INF;
	REP(i, h) {
		REP(j, w) {
			if (depth[i][j] <= k) {
				dist = min(dist, min(i, min(j, min(h - i - 1, w - j - 1))));
			}
		}
	}
	cout << (dist + k - 1) / k+1 << endl;
	return 0;
}


Measured memory_bytes: 3456
import heapq
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
candidates = []
for i in range(X):
    candidates.append(-1 * p[i])
for i in range(Y):
    candidates.append(-1 * q[i])
for i in range(C):
    candidates.append(-1 * r[i])
heapq.heapify(candidates)
ans = 0
for _ in range(X + Y):
    val = heapq.heappop(candidates)
    ans += val
print(-ans)

Measured memory_bytes: 28832
#include <iostream>
using namespace std;
int a[100000];
int main()
{
    int n=0;
    int b=0; 
    cin>>n;
    for (int i=1;i<=n;i++){
        cin>>b;
        a[b]++;
    }
    int mx=0;
    for (int i=1;i<=99999;i++)
        if (a[i-1]+a[i]+a[i+1]>mx) mx=a[i-1]+a[i]+a[i+1];
    cout<<mx<<endl;
    system ("pause");
    return 0;
}

Measured memory_bytes: 1008
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}

ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 1000000000;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};



ll N, M;
vector<ll> pos(100010, INFL);
bool l = 1;
vector<queue<pair<ll, ll>>> G(100010);
bool visited[100010];

inline void dfs(ll now, ll from){
  visited[now] = 1;
  while(!G[now].empty()){
    if(l == 0) break;
    ll next = G[now].front().first;
    ll cost = G[now].front().second;
    G[now].pop();
    if(pos[next] != INFL && pos[next] != pos[now] + cost){
      l = 0;
      break;
    }else{
      pos[next] = pos[now] + cost;
      dfs(next, now);
    }
  }
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N >> M;
  rep(i, M){
    ll L, R, D; cin >> L >> R >> D;
    L--, R--;
    G[L].push({R, D});
    G[R].push({L, -D});
  }
  rep(i, N){
    if(l == 0) break;
    if(visited[i] == 1) continue;
    dfs(i, -1);
  }
  if(l){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

}


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

int main(){

    int a, b;
    string s;
    scanf("%d%d", &a, &b);
    cin>>s;
    int sz=s.length();
    string sub1="", sub2="";
    if(s[0]=='-'||s[sz-1]=='-'){
        puts("No");
        return 0;
    }

    int cnt=0;
    for(int i=0; i<sz; ++i){
        if(s[i]=='-')
            ++cnt;
    }
    if(cnt!=1){
        puts("No");
        return 0;
    }

    for(int i=0; i<sz; ++i){
        if(s[i]=='-'){
            sub1=s.substr(0, i), sub2=s.substr(i+1, (sz-i)-1);
            break;
        }
    }

    if(sub1.length()==a&&sub2.length()==b)
        puts("Yes");
    else
        puts("No");






    return 0;
}


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

#define MOD 1000000007
typedef long long ll;

typedef pair<ll, ll> P;
typedef vector<vector<P>> Graph;

const int Nmax=200010;
vector<int> dist(Nmax, MOD);
bool f = true;

void aaa(Graph &node, int N){
	for(int i=0;i < node[N].size();i++){
		P p = node[N][i];
		ll next = p.first;
		
		if(dist[next] == MOD){
			dist[next] = dist[N] + p.second;
			aaa(node, next);
		}else{
			if(dist[next] != dist[N] + p.second){
				f = false;
				return;
			}
		}
	}
	return;
}
		
int main() {
	int N,M;
	cin >> N >> M;
	ll L,R,D;
	Graph nodes(N);
	for(int i=0;i < M;i++){
		cin >> L >> R >> D;
		nodes[--L].push_back(P(--R, D));
		nodes[R].push_back(P(L, -D));
	}
	
	for(int i=0;i < N;i++){
		if(dist[i] == MOD){
			dist[i] = 0;
			aaa(nodes, i);
		}
	}
	
	if(f) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 16512
use proconio::input;

fn main() {
    input! {
        n: usize,
        xy: [(i64, i64); n],
    }

    let st: Vec<_> = xy.iter().map(|&(x, y)| (x + y, x - y)).collect();

    let s: Vec<_> = st.iter().map(|&(s, _t)| s).collect();
    let t: Vec<_> = st.iter().map(|&(_s, t)| t).collect();

    let smin = s.iter().min().unwrap();
    let smax = s.iter().max().unwrap();
    let tmin = t.iter().min().unwrap();
    let tmax = t.iter().max().unwrap();

    let res = (smax - smin).max(tmax - tmin);
    println!("{}", res);
}


Measured memory_bytes: 15320
#include <stdio.h>

void insertionSort(int *, int);
void printArray(int* array, int n);
int main(void){
// Here your code !

	// TODO ?????????????????????????????????????????????
	int input[100];
	int numOfInput;
	int i;

	scanf("%d", &numOfInput);

	for(i = 0; i < numOfInput; i++){
		scanf("%d", &input[i]);
	}
	
	printArray(input, numOfInput);

	insertionSort(input, numOfInput);
	
	return 0;
}

void insertionSort(int* array, int n){
    int i, j, v;
	for(i = 1; i <= n - 1; i++){
		v = array[i];
		j = i - 1;
		while (j >= 0 && array[j] > v){
			array[j+1] = array[j];
			j--;
		}
		array[j+1] = v;
		
		printArray(array, n);
	}
}

void printArray(int* array, int n){
    int i;
	for(i = 0; i < n ; i++){
		printf("%d", array[i]);
		if(i < n - 1){
			printf(" ");
		}
		else{
			printf("\n");
		}
	}
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N, K;
	cin >> N >> K;
	vector<int> A(N);
	for (auto& x : A) cin >> x;

	vector<long long> a;
	for (int i = 0; i < N; ++ i) {
		long long sum = 0;
		for (int j = i; j < N; ++ j) {
			sum += A[j];
			a.push_back(sum);
		}
	}

	long long r = 0;
	for (int i = 50; i >= 0; -- i) {
		int cnt = 0;
		for (auto x : a) if ((x>>i)&1) ++ cnt;
		if (cnt >= K) {
			r |= 1LL<<i;
			vector<long long> b;
			for (auto x : a) if ((x>>i)&1) b.push_back(x);
			a.swap(b);
		}
	}
	cout << r << endl;
}


Measured memory_bytes: 6260
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    vector<int> S;
    ll M = 100005;
    vector<bool> prime(M, true);
    prime[1] = false;
    for (ll i = 2; i*i < M; i++) {
        if(prime[i] == false) continue;
        ll j = 2 * i;
        while(j < M){
            prime[j] = false;
            j += i;
        }
    }

    for (int i = 3; i < M; i+=2) {
        if(prime[i] && prime[(i+1)/2]){
            S.push_back(i);
        }
    }

    int Q;
    cin >> Q;
    int l, r;
    int ans;
    for (ll i = 0; i < Q; i++) {
        cin >> l >> r;
        ans = lower_bound(ALL(S), r+1) - lower_bound(ALL(S), l);
        printf("%d\n", ans);
    }

}

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

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

    for(int i=A; i<=B; i++){
        if(i<=B && i<A+K){
            cout << i << endl;
        }else if(i>=A && i>B-K){
            cout << i << endl;            
        }
    }

    return 0;
}


Measured memory_bytes: 256
import java.io.*
import java.util.*
import kotlin.math.*
//WRONG
fun main(){
	val f = BufferedReader(InputStreamReader(System.`in`))

	val n = f.readLine().toInt()

	val array = f.readLine().split(" ").map{it.toLong()}.toLongArray()

	val dp = LongArray(n){1000L}

	for(k in 0 until n){
		if(k > 0) dp[k] = max(dp[k],dp[k-1])
		val stocks = dp[k]/array[k]
		val remainder = dp[k]%array[k]

		for(j in k+1 until n){
			dp[j] = max(dp[j],stocks*array[j]+remainder)
		}
	}

	println(dp[n-1])
}


Measured memory_bytes: 36364
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int N = int.Parse(str[0]);
		int K = int.Parse(str[1]);
		int[]P = new int[N];
		long[]C = new long[N];
		string[] str2 = Console.ReadLine().Split();
		string[] str3 = Console.ReadLine().Split();
		for(var i=0;i<N;i++){
			P[i] = int.Parse(str2[i])-1;
			C[i] = long.Parse(str3[i]);
		}
		int[]T = new int[N];
		long[]D = new long[N];
		long[]M = new long[N];
		for(var i=0;i<N;i++){
			int p1 = i;
			int c1 = 0;
			long s1 = 0;
			while(true){
              	//Console.Error.WriteLine(p1+" "+s1);
				p1 = P[p1];
				s1 += C[p1];
				M[i] = Math.Max(M[i],s1);
				c1++;
				if(p1==i){
					T[p1] = c1;
					D[p1] = s1;
					break;
				}
			}
		}
		long ans = 0;
		for(var i=0;i<N;i++){
			int c1a = K/T[i];
			long sum1 = c1a * D[i];
			long m1 = 0;
          	if(c1a > 0){
              	m1 = Math.Max(M[i],Math.Max(m1,(c1a-1)*D[i]+M[i]));
            }
          	//Console.Error.WriteLine(m1+" "+M[i]);
			int k1 = K - c1a*T[i];
			int p1 = i;
            //Console.Error.WriteLine(m1+" "+sum1+" "+k1);
			while(k1>0){
				p1 = P[p1];
				sum1 += C[p1];
				m1 = Math.Max(m1,sum1);
				k1--;
			}
			if(m1 > ans){
				ans = m1;
			}
		}
		long maxx = -1000000007;
      	for(var i=0;i<N;i++){
          	maxx = Math.Max(C[i],maxx);
        }
      	if(maxx < 0){
          	ans = maxx;
        }
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 19520
import sys,math
from collections import deque,defaultdict
import operator as op
from functools import reduce

I=sys.stdin.readline

def ii():
	return int(I().strip())
def li():
	return list(map(int,I().strip().split()))
def mi():
	return map(int,I().strip().split())
def ncr(n, r):
    r = min(r, n-r)
    numer = reduce(op.mul, range(n, n-r, -1), 1)
    denom = reduce(op.mul, range(1, r+1), 1)
    return numer // denom


def main():
	n=ii()
	s=I().strip()
	i=0
	j=n-1
	cnt=0
	while i<j:
		if s[i]=="R":
			i+=1
		if s[j]=="W":
			j-=1
		if s[i]=="W" and s[j]=="R":
			cnt+=1
			i+=1
			j-=1
	print(cnt)






		










		


		










		






if __name__ == '__main__':
	main()

Measured memory_bytes: 9788
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n;
    std::cin >> n;
    std::vector<int> b(n + 1);
    for (int i = 0; i < n; i++) {
        int in;
        std::cin >> in;
        b[in] = i;
    }

    i64 ret = 0;
    std::multiset<int> v { -1, -1, n, n };
    for (i64 i = n; i > 0; i--) {
        auto d = v.upper_bound(b[i]), f = std::next(d), s = std::prev(d), a = std::prev(s);
        ret += i * (*f - *d) * (b[i] - *s) + i * (*d - b[i]) * (*s - *a);
        v.insert(b[i]);
    }

    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 5376
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=1000000;
const int MAXM=500000;
const int MAXFAC=3*MAXM+MAXN-1;
const int MOD=998244353;

int inv[MAXFAC+1];
int fac[MAXFAC+1];
int ifac[MAXFAC+1];
//int p2[MAXFAC+1];
int choose(int n,int k) { assert(n>=0&&n<=MAXFAC); if(k<0||k>n) return 0; return (ll)fac[n]*ifac[k]%MOD*ifac[n-k]%MOD; }

int n,m;

int solve() {
	inv[1]=1; FORE(i,2,MAXFAC) inv[i]=(ll)(MOD-MOD/i)*inv[MOD%i]%MOD;
	fac[0]=1; FORE(i,1,MAXFAC) fac[i]=(ll)fac[i-1]*i%MOD;
	ifac[0]=1; FORE(i,1,MAXFAC) ifac[i]=(ll)ifac[i-1]*inv[i]%MOD;
	//p2[0]=1; FORE(i,1,MAXFAC) p2[i]=(ll)p2[i-1]*2%MOD;

	int all=choose(3*m+n-1,n-1);
	int sub=(ll)n*choose(m-1+n-1,n-1)%MOD;
	int ret=all-sub; if(ret<0) ret+=MOD;

	REPE(nodd,n) {
		if(nodd<=m) continue;
		if((3*m-nodd)%2!=0) continue;
		//printf("nodd=%d\n",nodd);
		int v1=choose(n,nodd),v2=choose((3*m-nodd)/2+n-1,n-1);
		int cur=(ll)v1*v2%MOD;
		ret-=cur; if(ret<0) ret+=MOD;
	}
	//printf("all=%d sub=%d ret=%d\n",all,sub,ret);
	return ret;
}

int solvestupid() {
	set<vector<int>> seen;
	if(m==1) REP(i,n) REP(j,n) if(j!=i) { vector<int> cur(n,0); cur[i]+=2,cur[j]+=1; seen.insert(cur); }
	if(m==2) REP(i,n) REP(j,n) if(j!=i) REP(ii,n) REP(jj,n) if(jj!=ii) { vector<int> cur(n,0); cur[i]+=2,cur[j]+=1,cur[ii]+=2,cur[jj]+=1; seen.insert(cur); }
	if(m==3) REP(i,n) REP(j,n) if(j!=i) REP(ii,n) REP(jj,n) if(jj!=ii) REP(iii,n) REP(jjj,n) if(jjj!=iii) { vector<int> cur(n,0); cur[i]+=2,cur[j]+=1,cur[ii]+=2,cur[jj]+=1,cur[iii]+=2,cur[jjj]+=1; seen.insert(cur); }
	return SZ(seen);
}

void run() {
	scanf("%d%d",&n,&m);
	printf("%d\n",solve());
	//if(m<=3) printf("%d\n",solvestupid());
}

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


Measured memory_bytes: 29568
# import itertools
# import math


def solve(N, K, H):
    H.sort(reverse=True)
    if N <= K:
        return 0

    for i in range(K):
        H[i] = 0
    return sum(H)


# N = int(input())
# S = input()
N, K = map(int, input().split())
H = list(map(int, input().split()))

# P = []
# S = []
# for i in range(N):
#     pp, ss  = map(int, input().split())
#     P.append(pp)
#     S.append(ss)

print(solve(N, K, H))


Measured memory_bytes: 26180
#include <bits/stdc++.h>
using namespace std;
 
int mod = 1e9 + 7;
 
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	int n, k;
	cin >> n >> k;
	int h[n];
	for (int i = 0; i < n; i++) cin >> h[i];
	
	int dp[n];
	dp[0] = 0;
	for (int i = 1; i < n; i++) {
		dp[i] = 1e9;
		for (int j = 1; j <= min(i, k); j++) dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
	}
	cout << dp[n - 1];
}

Measured memory_bytes: 4360
import java.util.*;

class Main {
    public static void main(String... args) {
        int H = IN.nextInt();
		int W = IN.nextInt();
		int[][] G = new int[H][W + 1];
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				G[i][j] = IN.nextInt() % 2;
			}
		}
	//	puts(Arrays.deepToString(G));
		List<int[]> log = new ArrayList<>();
        for (int i = 0; i < H - 1; i++) {
			for (int j = 0; j < W; j++) {
                if (G[i][j] == 1) {
					if (G[i][j + 1] == 1) {
						G[i][j + 1] = 0;
						log.add(createL(i, j, i, j + 1));
					} else {
						if (G[i + 1][j] == 1) {
						    G[i + 1][j] = 0;
					    } else {
						    G[i + 1][j] = 1;
						}
					    log.add(createL(i, j, i + 1, j));
					}
				}
			}
		}
		for (int j = 0; j < W - 1; j++) {
			if (G[H - 1][j] == 1) {
				if (G[H - 1][j + 1] == 1) {
					G[H - 1][j + 1] = 0;
				} else {
					G[H - 1][j + 1] = 1;
				}
				log.add(createL(H - 1, j, H - 1, j + 1));
			}
		}
        puts(log.size());
		for (int[] x: log) {
			puts(join(x, " "));
		}

	}
    static int[] createL(int a, int b, int c, int d) {
		int[] x = {a + 1, b + 1, c + 1, d + 1};
		return x;
	}


	static String join(int[] a, String s) {
		StringBuilder v = new StringBuilder();
		for (int i = 0; i < a.length - 1; i ++) {
			v.append(a[i]);
			v.append(s);
		}
		return v.append(a[a.length - 1]).toString();
	}
    static final Scanner IN = new Scanner(System.in);
    static <T> void puts(T arg) { System.out.println(arg); }
}



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

int main(){
    int n;
    cin >> n;
    vector<int> a(n,0), ans(n,0);
    for(int i=1; i<n; i++){
        cin >> a[i];
    }
    for(int i=1; i<n; i++){
        ans[a[i] - 1]++;
    }
    for(int i=0; i<n; i++){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 4780
#include <bits/stdc++.h>
using namespace std;
long n, k, t, ans=0;
vector<long> a(200000);
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> k;
    for (long i=0; i<n; i++)
        cin >> t, a[t]++;
    sort(a.begin(), a.end(), [](long a, long b){return a > b;});
    for (long i=0; i<k; i++)
        ans += a[i];
    cout << n - ans << endl;
}

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

using namespace std;

int main()
{
  int N; cin >> N;
  int a[101];
  for(int i = 0; i < N; i++) cin >> a[i];
  int ans = 1<<25;
  int s = *min_element(a, a + N), t = *max_element(a, a + N);
  for(int i = s; i <= t; i++) {
    int sum = 0;
    for(int j = 0; j < N; j++) sum += (i-a[j])*(i-a[j]);
    ans = min(ans, sum);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
signed main()
{
    int n, m;
    cin >> n >> m;

    vector<int> s(m), c(m);
    rep(i, m) cin >> s[i] >> c[i];
    

    int H = 1, L = 1;
    rep(i, n-1) L *= 10;
    H = L * 10;
    for (int i = 0; i < H; i++){
        bool ok = true;

        string str = to_string(i);
        if (str.size() != n) {
            continue;
        } 

        rep(j, m){
            if (str[s[j] - 1] != '0' + c[j]) {
                ok =false;
                break;
            }
        }

        if (ok) {
            put(i);
            return 0;
        }
    }

    put(-1);
    
    return 0;
}

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



int main() {
  ll N;
  cin >> N;
  vector<ll> h(N);
  rep(i,N)
  {
    cin>>h.at(i);
  }
  vector<ll> ans(N);//最短コスト
  ans.at(0)=0;
  ans.at(1)=abs(h.at(1)-h.at(0));
  rep(i,N-2)
  {
    ans.at(i+2)=min(ans.at(i)+abs(h.at(i+2)-h.at(i)),
                    ans.at(i+1)+abs(h.at(i+2)-h.at(i+1)));
  }
  cout<<ans.at(N-1)<<endl;
  return 0;
}

Measured memory_bytes: 1792
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#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 reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
const int INF=1e9+7;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)                    cerr<<#x<<": "<<x<<endl
#define trace2(x, y)                 cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)                 cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)             cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)         cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f)     cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}



int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin >> n;
    ll ans=inf;
    for(ll i=1; i*i<=n; i++){
        if(n%i==0){
            ans=min(ans,i+n/i -2);
        }
    }
    ans=min(ans,1+n-2);
    cout << ans;
    return 0;
}
/* The judge is never wrong! Your code is buggy
   Look for:
 * * Read the problem carefully.
 * * Don't forget to sort(), mod, ll!!!!
 * * Initial value = +/- infinity instead of zero!!!
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */


Measured memory_bytes: 256
import collections
import heapq


class Dijkstra:
    def __init__(self):
        self.e = collections.defaultdict(list)

    def add(self, u, v, d):
        self.e[u].append([v, d])
        self.e[v].append([u, d])

    def delete(self, u, v):
        self.e[u] = [_ for _ in self.e[u] if _[0] != v]
        self.e[v] = [_ for _ in self.e[v] if _[0] != u]

    def search(self, s):
        """
        :param s: 始点
        :return: 始点から各点までの最短経路
        """
        d = collections.defaultdict(lambda: float('inf'))
        d[s] = 0
        q = []
        heapq.heappush(q, (0, s))
        v = collections.defaultdict(bool)
        while len(q):
            k, u = heapq.heappop(q)
            if v[u]:
                continue
            v[u] = True

            for uv, ud in self.e[u]:
                if v[uv]:
                    continue
                vd = k + ud
                if d[uv] > vd:
                    d[uv] = vd
                    heapq.heappush(q, (vd, uv))

        return d

N,M,S = map(int,input().split())
train = [list(map(int,input().split())) for i in range(M)]
change = [list(map(int,input().split())) for i in range(N)]

if S > 2500:
    S = 2500

G = Dijkstra()

for u,v,a,b in train:
    for i in range(a,2501):
        G.e[(u,i)].append([(v,i-a),b])
        G.e[(v,i)].append([(u,i-a),b])
for i in range(1,N+1):
    for j in range(2501-change[i-1][0]):
        G.e[(i,j)].append([(i,j+change[i-1][0]),change[i-1][1]])

A = G.search((1,S))

for i in range(2,N+1):
    print(min(A[(i,j)] for j in range(2501)))

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

using namespace std;

int main()
{
	int a,b,c,d,hi,lo;
	cin>>a>>b>>c>>d;
	hi = min(b,d);
	lo = max(a,c);
	cout<<max(0,hi-lo)<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>

using namespace std;



int main() {
	int a, b, k;
	cin >> a >> b >> k;
	vector<int> v;
	for (int i = 1; i <= min(a, b); i++) {
		if (a % i == 0 && b % i == 0) {
			v.push_back(i);
		}
	}
	reverse(v.begin(), v.end());
	cout << v.at(k - 1) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

struct Point {
    double x, y;
};

void Koch_Curve(int n, Point a, Point b) {
    if (n==0) return;
    else {
        Point s, t, u;
        double th = M_PI * 60.0 / 180.0;

        s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
        s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
        t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
        t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
        u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
        u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

        Koch_Curve(n-1, a, s);
        printf("%.8f %.8f\n", s.x, s.y);
        Koch_Curve(n-1, s, u);
        printf("%.8f %.8f\n", u.x, u.y);
        Koch_Curve(n-1, u, t);
        printf("%.8f %.8f\n", t.x, t.y);
        Koch_Curve(n-1, t, b);
    }
}

int main() {
    Point a, b;
    int n;

    scanf("%d", &n);

    a.x = 0;
    a.y = 0;
    b.x = 100;
    b.y = 0;

    printf("%.8f %.8f\n", a.x, a.y);
    Koch_Curve(n, a, b);
    printf("%.8f %.8f\n", b.x, b.y);

    return 0;
}




Measured memory_bytes: 2740
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000001

typedef struct p{
    char cap;
    int num;
}P;

void merge(P a[], int left, int mid, int right){
    P l[mid-left+1], r[right-mid+1];
    l[mid-left].num = INF;
    r[right-mid].num = INF;
    for(int i = 0; i < mid - left; i++) l[i] = a[left + i];
    for(int i = 0; i < right - mid; i++) r[i] = a[mid + i];
    int j = 0, k = 0;
    for(int i = left; i < right; i++){
        l[j].num <= r[k].num ? a[i] = l[j++] : a[i] = r[k++];
    }
}

void mergeSort(P a[], int left, int right){
    if(left + 1 < right){
        int mid = (left + right) / 2;
        mergeSort(a, left, mid);
        mergeSort(a, mid, right);
        merge(a, left, mid, right);
    }
}

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

void quicksort(P a[], int p, int r){
    if(p < r){
        int q = partition(a,p,r);
        quicksort(a,p,q-1);
        quicksort(a, q+1, r);
    }
}

int main(){
    bool flag = true;
    int n; cin >> n;
    P card1[n], card2[n];
    for(int i = 0; i < n; i++)
        cin >> card1[i].cap >> card1[i].num;
    
    memcpy(card2, card1, sizeof(card1));

    quicksort(card1, 0, n-1);
    mergeSort(card2, 0, n);

    for(int i = 0; i < n; i++){
        if(card1[i].cap != card2[i].cap ||
            card1[i].num != card2[i].num){
            flag = false;
            break;
        }
    }

    flag ? cout << "Stable" << endl: cout << "Not stable" << endl;
    for(int i = 0; i < n; i++)
        cout << card1[i].cap << " " << card1[i].num << endl;

    return 0;
}


Measured memory_bytes: 5460
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    REP(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    REP(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

int main()
{
    string S;
    cin >> S;
    int Q = inputValue();
    bool inv = false;
    string pre = "";
    REP(i, Q){
        int q = inputValue();
        if(q == 1){
            inv = !inv;
        }else{
            int F = inputValue();
            string C;
            cin >> C;
            if((!inv && F==1) || (inv && F==2)){
                pre += C;
            }else{
                S += C;
            }
        }
    }
    reverse(pre.begin(), pre.end());
    S = pre + S;
    if(inv){
        reverse(S.begin(), S.end());
    }

    cout << S << endl;
}


Measured memory_bytes: 1180
import sys
sys.setrecursionlimit(100000)

def ins(): return input().split()
def ii(): return int(input())
def iil(): return list(map(int, ins()))
def lin(): return list(input())
def iin(): return map(int, ins())

a,b,c = iin()
if c-a-b>0 and 4*a*b<(c-a-b)**2:
    print('Yes')
else:
    print('No')

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

ll v[3004];
ll dp[3005][3005];

ll solve(ll i, ll j) {
	if (i > j)
		return 0;
	if (dp[i][j] != -1)
		return dp[i][j];
	return dp[i][j] = max(v[i] + min(solve(i + 2, j), solve(i + 1, j - 1)), v[j] + min(solve(i + 1, j - 1), solve(i, j - 2)));
}

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

	memset(dp, -1, sizeof(dp));
	ll n;
	cin >> n;
	ll sum = 0;
	for (ll i = 0; i < n; i++)
		cin >> v[i], sum += v[i];
	ll res = solve(0, n - 1);
	ll dif = sum - res;
	cout << res - dif;

	return 0;
}



Measured memory_bytes: 74296
#include <iomanip>
#include <iostream>
using namespace std;
int main(void) {
  int r, c;
  cin >> r >> c;
  int x[r + 1][c + 1];
  for(int i = 0; i < r; i++) {
    int s = 0;
    for(int j = 0; j < c; j++) {
      cin >> x[i][j];
      cout << x[i][j] << " ";
      s += x[i][j];
    }
    cout << s << endl;
    x[i][c] = s;
  }
  for(int j = 0; j < c + 1; j++) {
    int s = 0;
    for(int i = 0; i < r; i++) {
      s += x[i][j];
    }
    x[r][j] = s;
  }
  for(int j = 0; j < c; j++)
    cout << x[r][j] << " ";
  cout << x[r][c] << endl;

  return 0;
}



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

void solve(std::string S, std::string T, long long A, long long B, std::string U)
{
    if (S == U)
        A--;
    else {
        B--;
    }
    cout << A << " " << B << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    std::string U;
    std::cin >> U;
    solve(S, T, A, B, U);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <string>
#include <cmath>
#include <math.h>
using namespace std;
 
int main() {
	string str;
	int n;
	cin >> n;
	int x[n], y[n];
	for(int i=0; i<n; i++){
		cin >> x[i];
	}
	for(int i=0; i<n; i++){
		cin >> y[i];
	}
	double d1=0.0,d2=0.0,d3=0.0,dinf=0.0;
	for(int i=0; i<n; i++){
		d1 +=fabs(x[i]-y[i]);
	}
	printf("%.6f\n", d1);
	for(int i=0; i<n; i++){
		d2 += pow(fabs(x[i]-y[i]),2);
	}
	d2 = pow(d2,1.0/2.0);
	printf("%.6f\n", d2);
	for(int i=0; i<n; i++){
		d3 += pow(fabs(x[i]-y[i]),3);
	}
	d3 = pow(d3,1.0/3.0);
	printf("%lf\n", d3);
	for(int i=0; i<n; i++){
		if(dinf < fabs(x[i]-y[i])) dinf = fabs(x[i]-y[i]);
	}
	printf("%lf\n", dinf);
	return 0;
}


Measured memory_bytes: 3360
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bs binary_search
#define pb push_back
#define F first 
#define S second 
#define M 1000000007
#define lc "\n"
ll power(ll x,ll y,ll p)  
{  
    ll res=1; 
    x=x%p; 
    while(y>0)  
    {  
        if(y&1) res=(res*x)%p;  
        x=(x*x)%p;  
    }  
    return res;  
} 
int main() 
{
    fastio
    ll n,a=0; cin>>n;
    a+=1000*(n/500); n=n%500;
    a+=5*(n/5); 
    cout<<a;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <unistd.h>
using namespace std;
#define nl cout<<"\n"
#define pb push_back
#define S second
#define F first
long double pi =3.14159265358979323846264338327950L;
typedef long long int ll;

int main(){
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//~ freopen("input.txt", "r", stdin); 
    //~ freopen("output.txt", "w", stdout); 
	long double a,b,h,m;
	cin>>a>>b>>h>>m;
	long double ang1= pi*2.0*((long double)h/12.0+((long double)m/60.0)/12.0-(long double)m/60.0);
	//cout<<ang1<<" "<<ang2<<" "<<diff<<endl;
	long double ans= sqrt(a*a+b*b-2*a*b*cosl(ang1));
	cout.precision(20);
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

int main()
{
  string code[] = {".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
  int len[] = {5, 3, 3, 3, 3, 3, 4, 3, 4};
  
  int N;
  cin >> N;
  while(N--){
    string s;
    cin >> s;
    char c = '#';
    int idx = 0;
    for(int i = 0; i < s.size(); i++){
      if(s[i] == '0'){
	if(c != '#') cout << c;
	c = '#';
	idx = 0;
      } else {
	c = code[s[i]-'0'-1][idx];
	idx = (idx + 1) % len[s[i]-'0'-1];
      }
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
#include<tr1/unordered_map>
#define pb push_back
#define pii pair<int,int>
#define SZ(x) (int)x.size()
#ifdef __linux__
#define getchar getchar_unlocked
#endif
#define mem(a,b) memset(a,b,sizeof(a))
#define  For(i,a,b) for(int i=a,i##E=b;i<=i##E;++i)
#define rFor(i,a,b) for(int i=a,i##E=b;i>=i##E;--i)
typedef long long LL;
using namespace std;
const int N=100010;
const int inf=0x3f3f3f3f;
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
template<typename T>inline void read(T &x)
{
	x=0;int _f(0);char ch=getchar();
	while(!isdigit(ch))_f|=(ch=='-'),ch=getchar();
	while( isdigit(ch))x=x*10+ch-'0',ch=getchar();
	x=_f?-x:x;
}
inline void file()
{
#ifdef ztzshiwo
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
}
int n,ans,a[N];
int main()
{
	file();
	read(n);
	For(i,1,n)read(a[i]);
	sort(a+1,a+n+1);
	int cnt=0;
	For(i,1,n)
	{
		cnt++;
		if(a[i]!=a[i+1])
		{
			if(cnt>=a[i])
				ans+=cnt-a[i];
			else
				ans+=cnt;
			cnt=0;
		}
	}
	printf("%d\n",ans);
	return 0;
}


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

int main() {
    //ABC129_B
    int N;
    cin >> N;
    vector<int> omori(N);
    for(int i = 0;i<N;i++){
        cin >> omori.at(i);
    }

    int ans = 99999;
    int count;
    int omosaF = 0;
    int omosaS = 0;

    for(int j = 0;j<N;j++){
      	omosaF = 0;
      	omosaS = 0;
        for(int k = 0;k <= j;k++){
            omosaF = omori.at(k) + omosaF;
        }
        for(int l = j+1;l < N;l++){
            if(l == N){
                break;
            }
            else{
                omosaS = omori.at(l) + omosaS;
            }
        }
      
      	//cout << omosaF << " " << omosaS << endl;
        if(omosaF >= omosaS){
            count = omosaF - omosaS;
            if(ans >= count){
                ans = count;
            }
        }
        else{
            count = omosaS - omosaF;
            if(ans >= count){
                ans = count;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>

void view(const std::vector<T> &v)
{
#ifndef ONLINE_JUDGE
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
#endif
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

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

    cout << (x >= 30 ? "Yes" : "No") << endl;

    return 0;
}

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


signed main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    cout << fixed << setprecision(20);

    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ll ans = 1e9;
    for(int i=-100;i<=100;i++){
        ll ret = 0;
        for(int j=0;j<n;j++){
            ret += (a[j] - i) * (a[j] - i);
        }
        ans = min(ans,ret);
    }
    cout << ans<< endl;
}

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


int main(){
  int N;
  cin >> N;
  vector<ll> a(N), b(N);
  rep(i,N) cin >> a[i];
  rep(i,N) cin >> b[i];

  ll ac = 0;
  ll bc = 0;
  
  rep(i,N){
    if(a[i] == b[i]) continue;
    if(a[i] < b[i]){
      ll diff = b[i] - a[i];
      if(diff%2 == 0){
        ac += diff/2;
      }else{
        bc++;
        diff++;
        ac += diff/2;
      }
    }else{
      ll diff = a[i] - b[i];
      bc += diff;
    }
  }

  if(ac>=bc) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


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

long long K, A, B;

int main() {
    while (cin >> K >> A >> B) {
        if (B - A <= 1) {
            cout << K + 1 << endl;
        }
        else {
            long long cur = 1;
            
            // A + 2 回で、+ B できる
            if (K >= A + 1) {
                K -= A + 1;
                cur = B;

                // 2 回で、-A + B できる
                long long num = K / 2;
                K %= 2;
                cur += (B - A) * num;
                if (K == 1) ++cur;
                
                cur = max(cur, K + 1);
            }
            else {
                cur = K + 1;
            }


            cout << cur << endl;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define EB emplace_back

using namespace std;

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

const int INF = 1e9 + 7;

vi G[100005];
int vis[100005];
void dfs(int u) {
	vis[u] = 1;
	for(int v:G[u]) {
		if(!vis[v]) {
			dfs(v);
		}
	}
}

int main()
{
	IO_OP;
	
	int n, m;
	cin >> n >> m;
	for(int i=0;i<m;i++) {
		int u, v, z;
		cin >> u >> v >> z;
		G[u].PB(v);
		G[v].PB(u);
	}
	int ans = 0;
	for(int i=1;i<=n;i++) {
		if(!vis[i]) {
			dfs(i);
			ans++;
		}
	}
	cout << ans << endl;
}



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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    int n = s.size();
    int x = (n-1) / 2, y = (n+1) / 2;
    bool ok = true;
    for (int i = 0; i < n; i++) {
        ok &= (s[i] == s[n-i-1]);
    }
    for (int i = 0; i < x; i++) {
        ok &= (s[i] == s[x-1-i]);
    }
    for (int i = y; i < n; i++) {
        ok &= (s[i] == s[n-(i-y)-1]);
    }
    if (ok) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

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

int main()
{
	int n,m;
	cin >> n >> m;
	int ans = 1;
	int t = n;
	if(m == 1)	cout << 0 << endl;
	else{
		while(n < m){
			n += t-1;
			ans ++;
		}
		cout << ans << endl;		
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a,b,c,x,ans;
int main()
{
	cin>>a>>b>>c>>x;
	for(int A=0;A<=a;A++)
	{
		if(500*A>x)
		{
			break;
		}
		for(int B=0;B<=b;B++)
		{
			if(500*A+100*B>x)
			{
				break;
			}
			for(int C=0;C<=c;C++)
			{
				if(500*A+100*B+50*C==x)
				{
					ans++;
				}	
			}
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
XL = []
for i in range(N):
    array = list(map(int, input().strip().split()))
    XL.append(array)
XL = sorted(XL)
Y = 0
cnt = 0
for i in range(N):
    if max(XL[i][0]-XL[i][1],0)>=Y:
        cnt += 1
        Y = XL[i][0]+XL[i][1]
    else:
        Y = min(Y,XL[i][0]+XL[i][1])
print(cnt)

Measured memory_bytes: 29460
/**
*  Refreshment Area
*/

#include<bits/stdc++.h>
using namespace std;

int N = 0;
int M = 0;
int D = 0;
bool space[120][120] = {0};

int solve()
{
  int ans = 0;
  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j <= M-D; j++)
    {
      bool flg = false;
      for (int k = 0; k < D; k++)
      {
        if (space[i][j+k])
        {
          flg = true;
          break;
        }
      }
      if (!flg) ans++;
    }
  }
  for (int j = 0; j < M; j++)
  {
    for (int i = 0; i <= N-D; i++)
    {
      bool flg = false;
      for (int k = 0; k < D; k++)
      {
        if (space[i+k][j])
        {
          flg = true;
          break;
        }
      }
      if (!flg) ans++;
    }
  }
  return ans;
}

int main()
{
  cin >> N >> M >> D;
  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < M; j++)
    {
      char eq = 0;
      cin >> eq;
      if      (eq == '.') space[i][j] = false;
      else if (eq == '#') space[i][j] = true;
    }
  }
  printf("%d\n", solve());
  return 0;
}



Measured memory_bytes: 3228
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	n, d, x := nextInt(), nextInt(), nextInt()
	ans := x
	for i := 0; i < n; i++ {
		a := nextInt()
		ans += 1 + (d-1)/a
	}
	puts(ans)
	wt.Flush()
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func nextMega() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, _ := rdr.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)


void func(long long N, std::vector<long long> A){
    lli ans=0;
    map<lli,lli> cnt;
    REP(i,0,N)cnt[A[i]]++;

    for(auto e:cnt){
        if(e.second%2==1)ans++;
    }
    cout<<ans<<endl;
}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    func(N, std::move(A));
    return 0;
}


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

int main()
{
     string s;
     cin>>s;
    if(s=="SAT")
        cout<<1;
    else if(s=="FRI")
        cout<<2;
    else if(s=="THU")
        cout<<3;
    else if(s=="WED")
        cout<<4;
    else if(s=="TUE")
        cout<<5;
    else if(s=="MON")
        cout<<6;
    else 
        cout<<7;
}

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


int main() {
  int n,k;
  cin >> n >> k;
  vector<int> p(n);
  rep(i,n){
    cin >> p.at(i);
  }
  sort(p.begin(),p.end());
  int ans = 0;
  rep(i,k){
    ans += p.at(i); 
  }
  cout << ans << endl;

}

Measured memory_bytes: 3592