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

struct dat {
  int d;
  vector<int> c;
  vector<vector<int>> s;
};

int calc(const dat &a, const vector<int> &last, int day, int t) {
  int v = 0;
  v += a.s.at(day - 1).at(t);
  for (int i = 0; i < 26; i++) {
    if (i == t) continue;
    v -= a.c.at(i) * (day - last.at(i));
  }
  return v;
}

int main() {
  int d;
  cin >> d;
  vector<int> c(26);
  vector<vector<int>> s(d, vector<int>(26));
  for (int i = 0; i < 26; i++) {
    cin >> c.at(i);
  }
  for (int i = 0; i < d; i++) {
    for (int j = 0; j < 26; j++) {
      cin >> s.at(i).at(j);
    }
  }
  dat a = {d, c, s};
  
  int w = 200;
  vector<vector<int>> last(w, vector<int>(26)), ans(w);
  vector<int> score(w);
  for (int i = 0; i < d; i++) {
    vector<tuple<int, int, int>> idx;
    for (int j = 0; j < w; j++) {
      vector<int> best(w, -4e4), best_t(w);
      for (int t = 0; t < 26; t++) {
        int v = calc(a, last.at(j), i + 1, t);
        if (v > best.at(w - 1)) {
          best.at(w - 1) = v;
          best_t.at(w - 1) = t;
        }
        for (int k = w - 1; k > 0; k--) {
          if (best.at(k - 1) < best.at(k)) {
            swap(best.at(k - 1), best.at(k));
            swap(best_t.at(k - 1), best_t.at(k));
          }
        }
      }
      for (int k = 0; k < w; k++) {
        if (best.at(k) == -4e4) continue;
        idx.emplace_back(score.at(j) + best.at(k), j, best_t.at(k));
      }
    }
    sort(idx.rbegin(), idx.rend());
    vector<vector<int>> newlast(w, vector<int>(26)), newans(w);
    for (int j = 0; j < w; j++) {
      if (j >= idx.size()) break;
      int k = get<1>(idx.at(j)), t = get<2>(idx.at(j));
      score.at(j) = get<0>(idx.at(j));
      newans.at(j) = ans.at(k);
      newlast.at(j) = last.at(k);
      newans.at(j).push_back(t);
      newlast.at(j).at(t) = i + 1;
    }
    ans = newans;
    last = newlast;
  }
  for (int i = 0; i < d; i++) {
    cout << ans.at(0).at(i) + 1 << endl;
  }
}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  string s;
  cin >> s;

  cout << s[0] << s.length()-2 << s[s.length()-1] << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using namespace boost::adaptors;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    ll n, ma, mb;
    cin >> n >> ma >> mb;
    constexpr ll amax = 400;
    constexpr ll amin = 1;
    constexpr ll bmax = 400;
    constexpr ll bmin = 1;
    vector<vector<ll>> costs(amax+1, vector<ll>(bmax+1, numeric_limits<ll>::max()));
    costs.at(0).at(0) = 0;
    for (auto &&shohin: boost::irange(0LL, n)){
        ll a, b, c;
        cin >> a >> b >> c;
        auto costs_ = costs;
        for (auto &&i: boost::irange(0LL, amax+1)){
            for (auto &&j: boost::irange(0LL, bmax+1)){
                ll next_a = i+a;
                ll next_b = j+b;
                if (costs.at(i).at(j)!=numeric_limits<ll>::max() && next_a <= amax && next_b <= bmax){
                    costs_.at(next_a).at(next_b) = min(costs.at(next_a).at(next_b), costs.at(i).at(j)+c);
                }
            }
        }
        costs = costs_;
    }
    ll min_cost{numeric_limits<ll>::max()};
    for (auto &&i: boost::irange(0LL, amax+1)){
        for (auto &&j: boost::irange(0LL, bmax+1)){
            if (i == 0 || j == 0) continue;
            else {
                if (i * mb == j * ma){
                    min_cost = min(min_cost, costs.at(i).at(j));
                }
            }
        }
    }
    if (min_cost == numeric_limits<ll>::max()){
        min_cost = -1;
    }
    cout << min_cost;
    return 0;
}

Measured memory_bytes: 2840
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    int n,k;
    cin>>n>>k;

    long double ans=0;
    for(int i=1;i<=n;i++){
        int x=0;
        int tmp=i;
        long double xx=1;
        while(tmp<k){
            x++;
            tmp*=2;
            xx/=(long double)2;
        }
        ans+=xx;
    }
    ans/=(long double)n;

    cout<<fixed<<setprecision(12)<<ans<<endl;
}



Measured memory_bytes: 3748
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>

using namespace std;

#define C_MAX(a, b) ((a)>(b)?(a):(b))
#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

#define EPS 1e-8
#define EQ (abs((a) - (b)) < EPS)

int signum(double x) { return abs(x) < EPS ? 0 : x > 0 ? 1 : -1; }

typedef complex<double> P;
typedef vector<P> Poly;

double dot(P a, P b) {
    return a.real() * b.real() + a.imag() * b.imag();
}

double cross(P a, P b) {
    return a.real() * b.imag() - a.imag() * b.real();
}

int point_in_poly(Poly poly, P p) {
    bool in = false;
    int n = poly.size();
    for (int i = 0; i < poly.size(); i++) {
        P a = p - poly[i % n];
        P b = p - poly[(i + 1) % n];
        if (a.imag() > b.imag()) swap(a, b);
        if (a.imag() <= EPS && b.imag() > EPS && cross(a, b) < -EPS) in = !in;
        if (signum(cross(a, b)) == 0 && signum(dot(a, b)) <= 0) return 1;
    }
    return in ? 2 : 0;
}

int main() {

    int N;
    cin >> N;

    Poly poly(N);
    for (int i = 0; i < N; i++) {
        double x, y;
        cin >> x >> y;
        poly[i] = P(x, y);
    }

    int Q;
    cin >> Q;

    while (Q--) {
        double x, y;
        cin >> x >> y;
        P p(x, y);
        cout << point_in_poly(poly, p) << endl;
    }

}














































Measured memory_bytes: 3236
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long A, B;
    scan(A, B);
    writeln((A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) ? "Possible" : "Impossible");
}


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

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

	ll n;
	cin>>n;
	vector<ll> v(n);
	for(int i=0;i<n;i++)cin>>v[i];
	
	for(int i=1;i<v.size();i++)
	{
		if(v[i]==v[i-1])
		{
			v.erase(v.begin()+i);
			i--;
		}
	}
    ll ans=1000;
    for(int i=1;i<v.size();i++)
    {
    	if(v[i]>v[i-1])
    	{
    		ll p=ans/v[i-1];
    		ans+=(v[i]*p-v[i-1]*p);
		}
	}
	cout<<ans;
    return 0;
}



Measured memory_bytes: 3656
N = int(input())

res = []

def f(n, m):
    if n == 0:
        print("".join(res))
        return
    for i in range(m):
        res.append(chr(97+i))
        f(n-1, m)
        res.pop()
    else:
        res.append(chr(97+m))
        f(n-1, m+1)
        res.pop()

f(N, 0)

Measured memory_bytes: 4340
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val h  = sc.nextInt
  val w  = sc.nextInt
  val hl = List.fill(h)(sc.next)

  val sl = List.fill(w + 2)("#").mkString

  (-1 to h).foreach{k =>
    if(k == -1 || k == h) println(sl)
    else println(s"#${hl(k)}#")
  }



}


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

int main() {
  int N,X,a;
  cin >>N>>X ;
  int L[200];
  int S[200];
  a = 0;
  for (int i = 0; i < N+1; i++){
cin >> L[i];
    S[0] = 0;
    S[1] = L[0];
  }
  for (int i = 2; i < N+1; i++){
    S[i] = S[i-1] + L[i-1];
    if(S[i] <= X){
      a++;
    }
  }
  if(S[0] <= X){
      a++;
    }
  if(S[1] <= X){
      a++;
    }
 cout << a << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
 int K;
  cin>>K;
  int sum=0;
  for(int i=1;i<=K;i++){
  for(int j=1;j<=K;j++){
  for(int k=1;k<=K;k++){
  sum+=gcd(gcd(i,j),k);
  }
  }
  }cout<<sum<<endl;
return 0;
}

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

using namespace std;

#define     watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define     all(a) (a).begin(), (a).end()
#define     fi first
#define     se second

template<class A, class B>
ostream& operator << (ostream& output, const pair<A, B>& p) {
    output << "(" << p.first << ", " << p.second << ")";
    return output;
}

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9;
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);
//const int mx = 1e6;



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
//#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//#endif

    int a, b;
    cin >> a >> b;
    cout << a * b << endl;
    return 0;
}


Measured memory_bytes: 3652
Module Program
Sub Main(args As String())
        Dim iInput As String() = Split(Console.ReadLine(), " ")
        Dim iA As Double = Integer.Parse(iInput(0))
        Dim iB As Double = Integer.Parse(iInput(1))
        Dim iH As Double = Integer.Parse(iInput(2))
        Dim iM As Double = Integer.Parse(iInput(3))

        Dim rad As Double = Math.PI * 2 * ((iH / 12) + (iM / 720) - (iM / 60))

        Dim sq As Double = (iA ^ 2 + iB ^ 2) - (2 * iA * iB) * Math.Cos(rad)

        Console.WriteLine(Math.Sqrt(sq))


    End Sub
End Module

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

#define MAX_N 10000001

int N, L;
int ai[MAX_N];
int res[MAX_N];
int seg[MAX_N];

void solve(){
    int s = 0, t = 0;

    for(int i = 0; i < N; i++ ){
        while( s < t && ai[seg[t - 1]] >= ai[i] ) t--;
        seg[t++] = i;

        if ( i - L + 1 >= 0 ){
            res[i - L + 1] = ai[seg[s]];
            if(seg[s] == i - L + 1){
                s++;
            }
        }
    }

    for(int i = 0; i <= N-L; i++){
        if(i) cout << " ";
        cout << res[i];
    }
    cout << endl;

}


int main(){
    cin >> N >> L;
    for(int i = 0; i < N; i++){
        cin >> ai[i];
    }
    solve();
}



Measured memory_bytes: 14812
import sys

n, k = map(int, sys.stdin.readline().split())

def main():
    c1 = n // k
    if (k & 1): cnt = pow(c1, 3)
    else: c2 = n // (k // 2); cnt = pow(c1, 3) + pow(c2 - c1, 3)
    print(cnt)

if __name__ ==  '__main__':
    main()

Measured memory_bytes: 3060
N = gets.to_i
R = []
N.times{
  x, l = gets.chomp.split(" ").map(&:to_i)
  R << [x - l, x + l]
}

R.sort_by!{|l, r| l}
del = 0
right = R[0][1]
(1...R.size).each{|i|
  l, r = R[i]
  if right <= l then
    right = r
  else
    del += 1
    if right > r then
      right = r
    end
  end
}

puts R.size - del


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

typedef long long LL;

char s[100];
int n;

int main(){
  scanf("%s",s+1);
  n=strlen(s+1);
  if (n&1) {puts("No");return 0;}
  for (int i=1;i<=n;++i)
	if (i&1&&s[i]^'h'||i&1^1&&s[i]^'i') {puts("No");return 0;}
  puts("Yes");
  return 0;
}

Measured memory_bytes: 3688
abc=list(map(int,input().split()))
ans=0
while min(abc)*3!=sum(abc):
    ans+=1
    abc.sort()
    sa=abc[2]-abc[0]
    if sa>=2:
        abc[0]+=2
    elif sa==1:
        abc[0]+=1
        abc[1]+=1
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  string s,c;
  int sum=0,r,l=0;
  bool f=true;
  cin>>s;
  r=s.size()-1;
  for(int i=0;i<s.size();i++){
    if(s[i]!='x') c+=s[i];
  }
  int o=0,p=c.size()-1;
  while(o<p){
    if(c[o]!=c[p]){
      f=false;
      break;
    }
    o++;
    p--;
  }
  if(f){
    while(l<r){
      if(s[l]!=s[r]){
        if(s[l]=='x') sum++;
        else l--;
        if(s[r]=='x') sum++;
        else r++;
      }
      l++,r--;
    }
  }
  if(f) cout<<sum<<"\n";
  else cout<<"-1\n";
}

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

using namespace std;

int main() {
    int k;
    string s;

    cin >> k >> s;

    if(s.length() <= k) {
        cout << s << endl;
        return 0;
    } else {
        cout << s.substr(0, k) << "..." << endl;
        return 0;
    }
}

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

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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


// 最大公約数
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  
  ll N, M; cin >> N >> M;
  dsu d(N);
  rep(i, M) {
    int a, b; cin >> a >> b;a--;b--;
    d.merge(a, b);
  }
  
  ll ans = d.groups().size() - 1;

  cout << ans << endl;
}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


Measured memory_bytes: 8912
#include <bits/stdc++.h>
using namespace std;
const int N = 300010;
struct node {int l, r, mx, tag;} T[N << 2];
inline void pushup(int rt) {T[rt].mx = max(T[rt << 1].mx, T[rt << 1 | 1].mx);}
inline void pushdown(int rt) {
	T[rt << 1].mx += T[rt].tag, T[rt << 1 | 1].mx += T[rt].tag;
	T[rt << 1].tag += T[rt].tag, T[rt << 1 | 1].tag += T[rt].tag, T[rt].tag = 0;
}
int w, h, x[N], y[N], id[N], n;
void build(int rt, int l, int r) {
	T[rt].l = l, T[rt].r = r, T[rt].tag = 0;
	if (l == r) return T[rt].mx = w + y[id[l]], void();
	int mid = (l + r) >> 1; 
	build(rt << 1, l, mid), build(rt << 1 | 1, mid + 1, r), pushup(rt);
}
void update(int rt, int start, int end, int x) {
	int l = T[rt].l, r = T[rt].r, mid = (l + r) >> 1;
	if (start <= l && r <= end) return T[rt].mx -= x, T[rt].tag -= x, void();
	if (T[rt].tag) pushdown(rt);
	if (start <= mid) update(rt << 1, start, end, x);
	if (end > mid) update(rt << 1 | 1, start, end, x);
	pushup(rt);
}
int query(int rt, int start, int end) {
	int l = T[rt].l, r = T[rt].r, mid = (l + r) >> 1; int res = -1e9;
	if (start <= l && r <= end) return T[rt].mx;
	if (T[rt].tag) pushdown(rt);
	if (start <= mid) res = max(res, query(rt << 1, start, end));
	if (end > mid) res = max(res, query(rt << 1 | 1, start, end));
	return res;
}
bool cmp(int a, int b) {return y[a] < y[b];}
int stk1[N], stk2[N], top1, top2;
inline int work() {
	for (int i = 1; i <= n; i++) id[i] = i;
	sort(id + 1, id + n + 1, cmp), y[0] = h, build(1, 1, n), top1 = top2 = 0;
	int mid = w / 2; stk1[0] = stk2[0] = n; int res = 0;
	for (int i = n - 1; i >= 1; i--) {
		int at = id[i];
		res = max(res, 2 * (query(1, i + 1, n) - y[at]));
		//cout << at << ' ' << res << ' ' << y[at] << endl;
		if (x[at] <= mid) {
			update(1, i + 1, stk1[top1], x[at]);
			while (top1 && x[id[stk1[top1]]] <= x[at]) update(1, stk1[top1] + 1, stk1[top1 - 1], x[at] - x[id[stk1[top1]]]), top1--;
			stk1[++top1] = i;
		} else {
			update(1, i + 1, stk2[top2], w - x[at]);
			while (top2 && x[id[stk2[top2]]] >= x[at]) update(1, stk2[top2] + 1, stk2[top2 - 1], x[id[stk2[top2]]] - x[at]), top2--;
			stk2[++top2] = i;
		}
	}
	return res;
}
int main() {
	scanf("%d%d%d", &w, &h, &n);
	for (int i = 1; i <= n; i++) scanf("%d%d", &x[i], &y[i]);
	x[++ n] = 0; y[n] = 0;
	x[++ n] = w; y[n] = h;
	int res = work(); swap(w, h);
	for (int i = 1; i <= n; i++) swap(x[i], y[i]);
	res = max(res, work()), printf("%d\n", res);
}

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

int gcd(int a, int b){
    if(a < b) swap(a, b);
    int d, r;
    d = a / b;
    r = a % b;
    if(r == 0) return b;
    else return gcd(b, r);
}

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

    int n, x;
    cin >> n >> x;
    vector<int> A(n + 1);
    A[0] = x;
    for(int i = 0; i < n; i++){
        cin >> A[i + 1];
    }

    sort(A.begin(), A.end());

    int g;
    for(int i = 1; i < n + 1; i++){
        if(i > 1){
            g = gcd(g, A[i] - A[i - 1]);
        }else{
            g = A[i] - A[i - 1];
        }
    }

    cout << g << endl;

    return 0;
}

Measured memory_bytes: 640
d = {}
N = int(input())
for _ in range(N):
  c = input()
  d[c] = d.get(c, 0)+1
M = int(input())
for _ in range(M):
  c = input()
  d[c] = d.get(c, 0)-1
print(max(max(d.items(), key=lambda x: x[1])[1], 0))

Measured memory_bytes: 3060
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cout << #x << ": " << x << endl
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'

int gcd(int a, int b){ return ((b == 0) ? a : gcd(b, a % b)); }

int n, k;

ll v[55];

ll dp[55][55][105];

ll solve(int l, int r, int x){
	if(x < 0) return -1e9;
	if(x == 0 || l > r) return 0;
	if(dp[l][r][x] != -1) return dp[l][r][x];
	ll op1 = solve(l + 1, r, x - 1) + v[l];
	ll op2 = solve(l, r - 1, x - 1) + v[r];
	ll op3 = solve(l + 1, r, x - 2);
	ll op4 = solve(l, r - 1, x - 2);
	ll op5 = 0;
	ll ret = max({op1, op2, op3, op4, op5});
	return dp[l][r][x] = ret;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	memset(dp, -1, sizeof(dp));
	cin >> n >> k;
	rep(i, n) cin >> v[i];
	cout << solve(0, n - 1, k) << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 2688
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int n,q;
ll int data[100000];

bool mybinary_serach(int l,int r,ll int tg){//left,right,target
	//cout << l << " " << r << endl;
	int nowpos = (l+r)/2;
	if(data[nowpos]==tg) return true;
	else if(l==r||l==r-1) return false;
	else if(data[nowpos] > tg) return mybinary_serach(l,nowpos,tg);
	else if(data[nowpos] < tg) return mybinary_serach(nowpos,r,tg);
}
int main(){
	ll int cnt = 0;
	cin >> n;
	REP(i,n) cin >> data[i];
	sort(data,data+n);
	cin >> q;
	REP(i,q){
		ll int tmp;
		cin >> tmp;
		if(mybinary_serach(0,n,tmp)) cnt++;
	}
	cout << cnt << endl;
	
}

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

students = [list(map(int, input().split())) for _ in range(N)]
t_points = [list(map(int, input().split())) for _ in range(M)]

ans_list = []

for s_point in students:
    # 各学生に対して、マンハッタン距離を計算
    min_mhd = 9999999999
    p_index = 0
    for index, t_point in enumerate(t_points):
        temp_mhd = abs(s_point[0] - t_point[0]) + abs(s_point[1] - t_point[1])
        if min_mhd > temp_mhd:
            min_mhd = temp_mhd
            p_index = index
    ans_list.append(p_index+1)

for ans in ans_list:
    print(ans)


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

typedef vector<int > vi;
typedef vector< vi > vvi;
typedef pair< int, int > ii;
#define sz(a)  int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define forn(i,n) for(int i=0;i<n;++i)
#define foru(i,n) for(int i=1;i<=n;++i)
#define fortr(i,v) for(auto &i:v)
#define set(n) __builtin_popcount(n)
#define ll long long
#define MOD 1000000007

int main()
{
	char a;
	cin>>a;
	char c='b'+a-'a';
	cout<<c<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  string s;
  cin >> s;
  map<char, int> mp;
  mp[s.at(0)]++;
  mp[s.at(1)]++;
  mp[s.at(2)]++;
  mp[s.at(3)]++;
  for(auto p : mp){
    if(p.second != 2){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 3600
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
 
public class Main {
 
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
         
        final String word = sc.next();
         
        int count = 0;
        while(true){
            final String txt = sc.next();
             
            if("END_OF_TEXT".equals(txt)){
                break;
            }else if(word.equalsIgnoreCase(txt)){
                count++;
            }
        }
         
        System.out.println(count);
    }
 
}

Measured memory_bytes: 25996
<?php
fscanf(STDIN,"%d%d",$n,$k);
$sort_num = array();
for($i=0;$i<$n;$i++){
  $ab = explode(" ",trim(fgets(STDIN)));
  $sort_num[$ab[0]] += $ab[1];
}

ksort($sort_num);
//print_r($sort_num);
$sum_c = 0;
foreach($sort_num as $num => $c){
  $sum_c += $c;
  if($sum_c>=$k){
    echo $num;
    exit;
  }
}



Measured memory_bytes: 20880
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);  cin.tie(NULL); cout.tie(NULL);
#define scan(a,n) for(long int index=0;index<n;index++) cin>>a[index];
#define print(a,n) for(long int index=0;index<n;index++) cout<<a[index]<<" ";cout<<endl;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define vli vector<long long int>
#define vlli vector<pair<long long int,long long int>>
#define vsi vector<string>
#define vci vector<char>


 
int main() {
   #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    fast;
    ll n;
    cin>>n;
    if(n%1000>0) cout<<1000-(n%1000)<<endl;
    else cout<<0<<endl;



   }
 
  


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

int main() {

    int n; cin >> n;
    ll m_num = 0;
    ll a_num = 0;
    ll r_num = 0;
    ll c_num = 0;
    ll h_num = 0;
  
    for (int i = 0; i < n; i++) {
        string s; cin >> s;
        if (s[0] == 'M') m_num++;
        if (s[0] == 'A') a_num++;
        if (s[0] == 'R') r_num++;
        if (s[0] == 'C') c_num++;
        if (s[0] == 'H') h_num++;
    }

    ll ans = 0;
    ans += m_num * a_num * r_num;
    ans += m_num * a_num * c_num;
    ans += m_num * a_num * h_num;    

    ans += m_num * r_num * c_num;
    ans += m_num * r_num * h_num;
    ans += m_num * c_num * h_num;

    ans += a_num * r_num * c_num;
    ans += a_num * r_num * h_num;
    ans += a_num * c_num * h_num;
    
    ans += r_num * c_num * h_num;

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

bool check(long long n, long long d)
{
    while(n%d==0) n/=d;
    n=n%d;
    return n==1;
}

main()
{
    int n,m; cin>>n>>m;
    int sum=0;
    vector<int> a(n);
    for(int i=0; i<n; ++i)
    {
        cin>>a[i];
        sum+=a[i];
    }
    int cnt=0;

    for(int i=0; i<n; ++i)
    {
        if(m*4*a[i]>=sum) cnt++;
    }
    if(cnt>=m) cout << "Yes" << "\n";
    else cout << "No" << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  ll n, x, y;
  cin >> n >> x >> y;
  x--;
  y--;

  vector<vector<int>> g(n, vector<int>(n, INF));

  // ワーシャルフロイド
  // 全頂点間の最短距離を求める
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      // iからjへのコストより、iからkを経由してjにいくコストの方が低いなら最短コストを更新
      if (i < j) {
        g[i][j] = min((int)abs(j - i), (int)(abs(x - i) + abs(y - j) + 1));
      }
    }
  }

  vector<int> ans(n + 1, 0);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i >= j) continue;
      int cost = g[i][j];

      ans[cost]++;
    }
  }

  for (int i = 1; i < n; i++) {
    cout << ans[i] << ln;
  }

  return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

ll n;
ll a[201010];
ll sum[201010];
map<ll,ll> cnt;

int main(){
  cin>>n;
  rep(i,n)cin>>a[i];
  rep(i,n)sum[i+1]=sum[i]+a[i];
  ll res=0;
  rep(i,n+1){
    res+=cnt[sum[i]];
    cnt[sum[i]]++;
  }
  cout<<res<<endl;
  return 0;
}


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

int main(){
    int m,f,r;
    char G;

    while(1){
        cin >> m >> f >> r;
        if(m==-1 && f==-1 && r==-1)break;

        if(m==-1 || f==-1){
            G='F';
        }else if(80 <= (m+f)){
            G='A';
        }else if(65 <= (m+f) && (m+f)<80){
            G='B';
        }else if(50 <= (m+f) && (m+f)<65){
            G='C';
        }else if(30 <= (m+f)&& (m+f)<50){
            if (50 <= r)G='C';
            else G='D';
        }else if((m+f)<30){
            G='F';
        }

        cout << G << endl;
    }

    return 0;

}


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

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b)a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b)a=b;}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    //cout << setprecision(15) << fixed;
    int n;
    cin >> n;
    vector<int> a(n);
    bool containsExit = false;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] == 0) containsExit = true;
    }
    if (!containsExit){
        cout << 0 << endl;
        return 0;
    }
    int curMax = 0;
    vector<int> maxTime(n, 0);
    for (int i = 0; i < n; i++){
        if (a[i] == 0) curMax = 1 << 29;
        else if (a[i] < 0){
            chmin(curMax, abs(a[i]));
        }
        else chmax(maxTime[i], curMax);
        curMax--;
    }
    curMax = 0;
    for (int i = n - 1; i >= 0; i--){
        if (a[i] == 0) curMax = 1 << 29;
        else if (a[i] < 0){
            chmin(curMax, abs(a[i]));
        }
        else chmax(maxTime[i], curMax);
        curMax--;
    }
    int res = 0;
    for (int i = 0; i < n; i++){
        if (a[i] <= 0) continue;
        if (maxTime[i] <= 0) continue;
        res += min(a[i], maxTime[i]);
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 3624
#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <string>
#include <cmath>
//#include <vector>
#include <queue>
//#include <stack>
//#include <map>
//#include <set>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
int main()
{
    ll t,x,y;
    cin>>t;
    while(t--)
    {
        cin>>x>>y;
        ll sum=x*y;
        ll a=floor(pow(sum,0.5)+0.0001);
        ll ans=2*a-2;
        if(a*(a+1)<x*y)
            ans+=1;
//        if(a!=x&&a!=y)
//            ans-=1;
        if(x==y)
            ans++;
        if(a*a==x*y)
            ans-=1;
        cout<<ans<<endl;
    }
    return 0;
}

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

int main(){
    int n, sum = 0, tmp;
    cin >> n;
    tmp = n;
    while(tmp){
        sum += tmp % 10;
        tmp /= 10;
    }
    cout << (n % sum == 0 ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
def abc177b():
    s = input()
    t = input()
    min_val = float('inf')
    for i in range(len(s) - len(t) + 1):
        cnt = 0
        for j in range(len(t)):
            if s[i + j] != t[j]:
                cnt += 1
        min_val = min(cnt, min_val)
    print(min_val)


abc177b()

Measured memory_bytes: 9056
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}

	Scanner sc = new Scanner(System.in);

	
	
	void run() {

		long n = sc.nextInt();
		long m = sc.nextInt();
		String s = sc.next();
		String t = sc.next();
		
		
		if(m > n){
			long swp = n;
			n = m;
			m = swp;
			String sw = s;
			s = t;
			t = sw;
		}
		
		for(long i = 1; ; i++){
			long l = n*i;
			
			if(l > n*m){
				System.out.println(-1);
				return;
			}
			
			if(l % m != 0){
				continue;
			}
			
			long xx = l / m;
			long yy = l / n;
			boolean ok = true;
			for(int j = 0 ; j < m ; j++){
				
				if( (xx * j) % yy == 0 ){
					if(t.charAt((int)j) != s.charAt((int)(xx*j/yy))){
						ok = false;
						break;
					};
				}
				
			}
			if(ok){
				System.out.println(l);
				return;
			}
		}
	}
}


Measured memory_bytes: 27672
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

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

#include <atcoder/dsu>
using namespace atcoder;

const bool ready = [](){
    ios_base::sync_with_stdio(false); cin.tie(0);
    cout << fixed << setprecision(12);
    return true;
}();

const double PI = acos(-1);
using ll= long long;
//#define int ll
#define all(v) (v).begin(), (v).end()
#define fori(n) for(int i=0; i<int(n); i++)

#define cini(i) int i; cin>>i;
#define cins(s) string s; cin>>s;
#define cind(d) double d; cin>>d;
#define cinai(a,n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s,n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a,n) vd a(n); fori(n) { cin>>a[i]; }

using pii= pair<int, int>;
using pdd= pair<double, double>;
using vd= vector<double>;
using vb= vector<bool>;
using vi= vector<int>;
using vvi= vector<vi>;
using vs= vector<string>;

#define endl "\n"

void solve() {
    cini(n);
    cini(q);
    
    dsu d(n);
    for(int i=0; i<q; i++) {
        cini(t);
        cini(u);
        cini(v);
        if(t==0) 
            d.merge(u,v);
        else {
            cout<<d.same(u,v)<<endl;
        }
    }
}

signed main() {
    solve();
}

// FIRST THINK, THEN CODE
// DO NOT JUMP BETWEEN PROBLEMS


Measured memory_bytes: 3976
s=io.read()
function check(i)
  if (#s - i) % 2 == 0 then
    l=#s - i
    m=l//2
    a=s:sub(1,m)
    b=s:sub(m+1,#s-i)
    return a==b
  else
    return false
  end
end
for i=1,#s-2 do
  if check(i) then
    print(#s-i)
    return
  end
end

Measured memory_bytes: 508
#include <bits/stdc++.h>
 
using namespace std;
 
int a[200005];
map<int,int> l;
int main() {
 int n;
 cin >> n;
 long long ans = 0;
 for (int i = 1; i <= n; i++) {
    cin >> a[i];
    l[i + a[i]]++;
    ans += l[i - a[i]];
 }
 cout << ans;
 return 0;
}

Measured memory_bytes: 21252
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}


int main(void){
  	cin.tie(0);
  	ios::sync_with_stdio(false);
  	
    vl n(4);
    cin>>n;
    vl four{1,9,7,4};
    rep(i,4){
        auto itr=find(all(four),n[i]);
        if(itr!=four.end()) four.erase(itr);
    }

    cout<<(four.size()==0?"YES":"NO")<<endl;
}


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

int main()
{
    string number;
    int num;
    getline(cin,number);
    while(number != "0"){
        int sum = 0;
        for(int i = 0 ;i < number.length() ;i++){
            num = number[i] - '0';
            sum += num;
        }
        cout << sum << endl;
        getline(cin,number);
    }
    
    return 0;
}

Measured memory_bytes: 1180
#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<vector>
#include<string.h>

using namespace std;

typedef pair<int , int > P;

P tmp[202];

vector <int > G[101];
int n;

bool used [203];
int last [203];
bool find (int x )
{
    for (int i=0;i<G[x].size();i++)
    {
        if (!used[G[x][i]])
        {
           // cout<<x<<"  "<<G[x][i]<<endl;
            used[G[x][i]] =true ;
            if (last [G[x][i]] == -1 || find (last [G[x][i]] ) )
            {
            last[G[x][i] ] = x;
            //cout<<x<<"  "<<G[x][i]<<endl;
            return true;
            }

        }
    }
    return false;
}

int main ()
{
    //freopen("d:\\1.txt","r",stdin);
    while (scanf ("%d",&n)!=EOF)
    {
        int a,b;

        memset (last, 0xff , sizeof(last) );
        for (int i=0;i<2*n;i++)
        {
            scanf ("%d%d",&a,&b);
            tmp[i].first=a;
            tmp[i].second=b;
        }

        for (int i=0;i<n;i++) G[i].clear ();

        for (int i=0;i<n;i++)
            for (int j=n;j<2*n;j++)
        {
            if ( tmp[i].first<tmp[j].first && tmp[i].second <tmp[j].second ) G[i].push_back(j);
        }
        int sum=0;

        /*for (int i=0;i<n;i++)
            for (int j=0;j<G[i].size ();j++)
        {
            printf ("%d-> %d\n ",i,G[i][j]);
        }*/
     // cout<<endl ;
       for (int i=0;i<n;i++)
       {
           memset(used , false , sizeof (used ));
           if (find(i)) {sum++; }
       }
       printf ("%d\n",sum);
    }

    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <map>
#include <set>
#include <string>
#include <cassert>

#define INFLL 2000000000000000000
#define INF 2000000000
#define MOD 1000000007
#define PI acos(-1.0)

using namespace std;

typedef pair <int, int> pii;
typedef long long ll;
typedef vector <ll> vll;

int nxt[200000][26];
string str;
int dp[200001];
int step[200000];

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin >> str;
	for (int i = 0; i < str.length(); i++) for (int j = 0; j < 26; j++) nxt[i][j] = str.length();
	nxt[str.length() - 1][str[str.length() - 1] - 'a'] = str.length() - 1;
	for (int i = str.length() - 2; i >= 0; i--) {
		for (int j = 0; j < 26; j++) nxt[i][j] = nxt[i + 1][j];
		nxt[i][str[i] - 'a'] = i;
	}
	dp[str.length()] = 0;
	for (int i = str.length() - 1; i >= 0; i--) {
		dp[i] = INF;
		for (int j = 0; j < 26; j++) {
			if (nxt[i][j] == str.length() && dp[i] > 1) {
				step[i] = j;
				dp[i] = 1;
			} else {
				if (nxt[i][j] == str.length() - 1) {
					if (dp[i] > 2) {
						dp[i] = 2;
						step[i] = j;
					}
				}
				else if (dp[i] > dp[nxt[i][j] + 1] + 1) {
					dp[i] = dp[nxt[i][j] + 1] + 1;
					step[i] = j;
				}
			}
		}
	}
	int cur = 0;
	while (cur < str.length()) {
		cout << (char)('a' + step[cur]);
		cur = nxt[cur][step[cur]] + 1;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 22404
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl
#define dv(name, value) cerr << (name) << " is " << (value) << endl
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl


void solve(long long N, std::vector<long long> A){
  vector<int> v(N+5);
  REP(x, N-1) {
    v.at(A.at(x)) += 1;
  }
  FOR1(x, N) {
    cout << v.at(x) << endl;
  }
}

signed main(){
  long long N;
  scanf("%lld",&N);
  std::vector<long long> A(N-2+1);
  for(int i = 0 ; i < N-2+1 ; i++){
    scanf("%lld",&A[i]);
  }
  solve(N, std::move(A));
}


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

#define IOS                               \
	ios_base::sync_with_stdio(false); \
	cin.tie(0);                       \
	cout.tie(0)
#define int long long int
#define endl "\n"
#define N 1009
#define all(a) a.begin(), a.end()

int n;
int a[N][N];
int ptr[N];
bool vis[N];

int32_t main()
{
	IOS;

	cin >> n;

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < (n - 1); j++)
		{
			cin >> a[i][j];
			a[i][j]--;
		}
		ptr[i] = 0;
	}

	int days = 0;
	bool done = 0;
	bool possible = 1;
	while (!done)
	{
		memset(vis, 0, sizeof(vis));

		int took = 0;

		for (int i = 0; i < n; i++)
		{
			if (ptr[i] >= (n - 1))
				continue;
			if (vis[a[i][ptr[i]]] == 1 || vis[i] == 1)
				continue;
			int num = a[i][ptr[i]];
			if(ptr[num] >= (n-1))
			{
				possible = 0;
				break;
			}
			if (a[num][ptr[num]] != i)
			{
				continue;
			}
			vis[i] = 1;
			vis[a[i][ptr[i]]] = 1;
			ptr[i]++;
			ptr[num]++;
			took = 1;
		}

		if (possible == 0)
			break;
		days++;

		done = 1;

		for (int i = 0; i < n; i++)
		{
			if (ptr[i] != (n - 1))
				done = 0;
		}

		if(took == 0)
		{
			done = 0;
			break;
		}

	}

	if (possible == 0 ||done == 0)
	{
		cout << "-1\n";
		return 0;
	}

	cout << days << endl;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
using namespace std;
int main() {
    ll H,W;
    char ch;
    cin>>H>>W;
    vector<vector<ll>> dp(H+1,vector<ll> (W+1,0));
    /*
    State
    dp[i][j]: Denotes the number of ways to reach cell (i,j)
    Recurrence:
    dp[i][j] = (dp[i-1][j]%mod + dp[i][j-1]%mod)%mod
    i.e we can arrive at this cell from the left or from the top cell
    */
    dp[1][1] = 1;
    for(ll i=1;i<=H;i++){
        for(ll j=1;j<=W;j++){
            cin>>ch;
            if(ch != '#' && !(i==1 && j==1)){
                dp[i][j] = (dp[i][j-1]%mod + dp[i-1][j]%mod)%mod;
            }
        }
    }
    cout<<dp[H][W];
	return 0;
}


Measured memory_bytes: 8192
x,k,d = gets.split.map(&:to_i)
o = (x / d).abs #最小の移動で0に近づく移動回数
z = (x % d).abs #最小の移動で0に近づいた時の絶対値
ato = k - o #残りの移動回数

if k <= o
  ans = (x.abs - (k * d)).abs
elsif k > o
  if ato.even?
    ans = z
  else ans = (z - d).abs
  end
end

p ans

Measured memory_bytes: 14216
#include <stdio.h>

int main()
{
    long long i,n;
    while(~scanf("%lld",&n))
    {
        for(i=n;i>=1;i--)
        {
            if(sqrt(i)==(int)sqrt(i))
            {
                printf("%lld\n",i);
                break;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 128
while True:
    H,W = list(map(int,input().split(" ")))
    if H == 0 and W == 0:
        break
    else:
        for i in range(H):
            if i == 0 or i == H-1:
                print("#" * W)
            else:
                print("#" + "."*(W-2) + "#")
        print("")


Measured memory_bytes: 5608
s = input()
y = int(s[:4])
m = int(s[5:7])
d = int(s[8:])
if y <= 2018:
    print("Heisei")
elif y > 2019:
    print("TBD")
else:
    if m <= 4:
        print("Heisei")
    elif m >= 5:
        print("TBD")


Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<iomanip>
#include<map>
#include<ctime>
#include<cstdlib>
using namespace std;
long long val[200010];
int main()
{
	ios::sync_with_stdio(0);
	int n;cin>>n;n<<=1;
	for(int i=1;i<=n;i++)cin>>val[i];
	sort(val+1,val+n+1);
	double ans=0;
	for(int i=1;i<=n;i++)ans+=1.0*(i-1)*val[i]/(n-1);
	cout<<fixed<<setprecision(6)<<ans;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
//#include<boost/multiprecision/cpp_int.hpp>
//using boost::multiprecision::cpp_int;

#define int long long
#define cint cpp_int
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2
#define PI acos(-1.0)

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vvout(VVi &v){for(int i=0;i<(v).size();i++) vout(v[i]);}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int mypow(int x, int n, int m){if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
int digit(int k,int i){string s = to_string(k);return s[s.size()-i]-'0';}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
Vi accum(Vi v){Vi ret((v).size());ret[0]=v[0];REP(i,1,(v).size()) ret[i]=ret[i-1]+v[i];return ret;}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}


const string YES = "Yes";
const string NO = "No";

void solve(long long A, long long B, long long C){
    if(A==B && B==C) cout<<NO<<endl;
    else if(A!=B && B!=C && A!=C) cout<<NO<<endl;
    else cout<<YES<<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)
signed main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    solve(A, B, C);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#include<map>
#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;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using vvii = vector<vector<int> >;
using vvll =  vector<vector<ll> >;

const ll inf = 1LL << 60;

int main(){
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
    int N;cin>>N;
    map<ll,int> A;
    ll ans = 0;
    REP(i,N){
        ll a; cin>>a;
        ans += a;
        A[a]++;
    }
    
    int Q; cin>>Q;
    vector<ll> ansans(Q);
    REP(i,Q){
        ll b,c; cin>>b>>c;
        ll num = A[b];
        ans += num * (c-b);
        ansans[i] = ans;
        A.erase(b);
        A[c] += num;
    }
    REP(i,Q){
        cout << ansans[i]<<endl;
    }


}

Measured memory_bytes: 7912