akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;


class Program
{
    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        //var n = int.Parse(Console.ReadLine());
        int[] nxy = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var n = nxy[0];
        var x = nxy[1];
        var y = nxy[2];
        x--;
        y--;

        int[] ans = new int[n - 1];
        for (int i = 0; i < n; i++)
        {
            for (int j = i + 1; j < n; j++)
            {
                var tmp = Math.Abs(j - i);
                tmp = Math.Min(tmp, Math.Abs(x - i) + Math.Abs(y - j) + 1);
                tmp = Math.Min(tmp, Math.Abs(y - i) + Math.Abs(x - j) + 1);
                ans[tmp-1]++;
            }
        }

        // 出力
        foreach (var item in ans)
        {
            Console.WriteLine(item);
        }
    }
}

Measured memory_bytes: 28336
#include <cstdio>
#include <queue>
#include <utility>

using namespace std;

int main(){
	while(true){
		int n, m;
		scanf("%d%d", &n, &m);
		if(n == 0 && m == 0){ break; }
		priority_queue<int, vector<int>, greater<int> > timestamps;
		for(int i = n + m; i > 0; i--){
			int input;
			scanf("%d", &input);
			timestamps.push(input);
		}
		int maxlen = 0, prevtime = 0;
		while(!timestamps.empty()){
			int t = timestamps.top();
			if(t - prevtime > maxlen){ maxlen = t - prevtime; }
			prevtime = t;
			timestamps.pop();
		}
		printf("%d\n", maxlen);
	}
	return 0;
}

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

int main(){
  int N;
  cin>>N;
  long long a[N]={0};
  long long s[N]={0};
  long long dif=1000000009;
  long long sum=0;
  for (int i=0;i<N;i++){
    cin>>a[i];
    sum=sum+a[i];
    s[i]=sum;
  }
  if(N==2){
    cout<<abs(a[1]-a[0])<<endl;
    return 0;}
  
  for (int i=0;i<N;i++){
    if(i==N-1){
      break;
    }
    dif=min(dif,abs(s[i]-(sum-s[i])));
    //cout<<dif<<" "<<abs(s[i]-(sum-s[i]))<<endl;
  }
  //cout<<sum<<" "<<s[4]<<endl;
  cout<<dif<<endl;
 return 0;
}

  

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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define ll long long
#define all(x) x.begin(), x.end()
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2010
#define inf 1e14
#define MOD 1000000007

int main()

{

    ll a,b, c, x;
    cin >> a >> b >> c >> x;
    ll ans = 0;
    for(ll i = 0; i <=a; i++)
    {

        for(ll j = 0; j <= b; j++)
        {

            for(ll k = 0; k <= c; k++)
            {

                if(i*500+j*100+k*50==x) ans++;
            }
        }
    }
    cout << ans;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

int main() {
    ll s, c, ans = 0;
    cin >> s >> c;

    if (s * 2 <= c) {
        ans = s + ((c - s * 2) / 4);
    } else {
        ans = c / 2;
    }

    cout << ans << endl;

    return 0;
}

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

typedef long long ll;
const int N = 2000006;

int n,k;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	cin>>n>>k;
	
	int hano = (n-1)*(n-2)/2;
	if(k > hano){
		cout<<-1;
		return 0;
	}
	
	vector<pair<int,int> > v;
	for(int i=1;i<n;i++){
		v.push_back({i,n});
	}
	
	int x = 1,y = 2;
	while(hano > k){
		hano--;
		v.push_back({x,y});
		y++;
		if(y == n){
			x++;
			y = x+1;
		}
	}
	
	cout<<v.size()<<endl;
	for(auto p:v){
		cout<<p.first<<" "<<p.second<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 3656
#include "bits/stdc++.h"
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define IOS std::cin.tie(0),std::ios::sync_with_stdio(false)

namespace idaten {

	using namespace std;
	using ll = int_fast64_t;
	using ull = uint_fast64_t;
	using P = std::pair<int64_t, int64_t>;
	template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
	template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
	template<class T> inline std::istream& operator >> (std::istream& is, std::vector<T>& v) { for (T& x : v) { is >> x; }return is; }
	template<class T> inline std::ostream& operator << (std::ostream& os, const std::vector<T>& v) {
		for (auto itr = v.begin(); itr != v.end();) { os << (*itr) << ((++itr != v.end()) ? " " : ""); }
		return os;
	}
	template<class V, typename T>inline void fill(V& v, const T& val) { v = val; }
	template<class V, typename T>inline void fill(std::vector<V>& v, const T& val) { for (V& x : v) { fill(x, val); } }
	template<class V, typename H>inline void resize(std::vector<V>& v, const H h) { v.resize(h); }
	template<class V, typename H, typename... T>inline void resize(std::vector<V>& v, const H& h, const T& ... t) { v.resize(h); for (auto& x : v) { resize(x, t...); } }
	inline void put() {}
	template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
	template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }

	int f(string& s) {
		if (s == "AB") {
			return 2;
		} else if (s == "BC") {
			return 0;
		} else {
			return 1;
		}
	}

	void solve() {
		IOS;
		ll n, a, b, c;
		cin >> n >> a >> b >> c;
		vector<ll> d = { a,b,c };
		vector<string> s(n);
		cin >> s;
		vector<int> res(n);
		REP(i, n) {
			int t1, t2, t3;
			int t4 = f(s[i]);
			if (s[i] == "AB") {
				t1 = 0, t2 = 1, t3 = 2;
			} else if (s[i] == "BC") {
				t1 = 1, t2 = 2, t3 = 0;
			} else {
				t1 = 0, t2 = 2, t3 = 1;
			}
			if (d[t1] == d[t2] && d[t1] == 0) {
				put("No");
				return;
			}
			if (d[t1] == d[t2] && d[t1] == 1 && d[t3] == 0&& i < n - 1) {
				int t5 = f(s[i + 1]);
				if (t4 == t5) {
					res[i] = t2;
					d[t1]--;
					d[t2]++;
				} else {
					int t6 = 3 - t4 - t5;
					int t7 = t1 + t2 - t6;
					res[i] = t6;
					d[t7]--;
					d[t6]++;
				}
				
			} else {
				if (d[t1] < d[t2]) {
					res[i] = t1;
					d[t1]++;
					d[t2]--;
				} else {
					res[i] = t2;
					d[t1]--;
					d[t2]++;
				}
			}
		}
		put("Yes");
		REP(i, n) {
			char c = (char)'A' + res[i];
			put(c);
		}
	}
} // namespace idaten

int main() {
	idaten::solve();
	return 0;
}


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

int main() {
    string s;
    cin>>s;
    for(int i=1;i<s.length();i++){
        if(s[i]==s[i-1]){
            cout<<"Bad\n";
            return 0;
        }
    }
    cout<<"Good\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T> void chmax(T &x, T y) { if (x < y) x = y; }
int main() {
    int H, W; cin >> H >> W;
    vector<string> S(H); for (auto &s : S) cin >> s;
    vector<vector<int>> A(H - 1, vector<int>(W - 1));
    for (int i = 0; i < H - 1; i++) {
        for (int j = 0; j < W - 1; j++) {
            int a0 = S[i][j] == S[i][j + 1];
            int a1 = S[i + 1][j] == S[i + 1][j + 1];
            int b0 = S[i][j] == S[i + 1][j];
            int b1 = S[i][j + 1] == S[i + 1][j + 1];
            A[i][j] = (a0 == a1) && (b0 == b1);
        }
    }
    vector<vector<int>> B(H - 1, vector<int>(W));
    for (int i = 0; i < H - 1; i++) {
        for (int j = 0; j < W - 1; j++) {
            if (i == 0 && A[i][j]) {
                B[i][j] = 1;
            } else if (A[i][j]) {
                B[i][j] = B[i - 1][j] + 1;
            }
        }
    }
    int ans = max(H, W);
    for (int i = 0; i < H - 1; i++) {
        stack<pair<int, int>> T; // idx, height
        for (int j = 0; j < W; j++) {
            int height = B[i][j];
            int from = j;
            while (!T.empty() && T.top().second > height) {
                int idx, hei; tie(idx, hei) = T.top();
                T.pop();
                chmax(ans, (j - idx + 1) * (hei + 1));
                from = idx;
            }
            if (height > 0 && (T.empty() || (T.top().second != height))) {
                T.emplace(from, height);
            }
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 35712
#include <stdio.h>

int main(void) {

    int N;
    int i;
    int x = 0;
    int y = 0;
    char S[N];
    scanf("%d", &N);
    scanf("%s", S);
    //printf("%d\n", N);

    for(i=0;i<N;i++){
        if(S[i]=='I'){
            x++;
            if(y<x){
                y = x;
            }
        }
        else{
            x--;
        }

    }

    printf("%d\n", y);

    return 0;
}

Measured memory_bytes: 128
import sys

max_dist = -1

p, n = map(int, input().split())
a = list(map(int, input().split()))

for i in range(n):
	if i == n - 1:
		max_dist = max(max_dist, p + a[0] - a[i])
	else:
		max_dist = max(max_dist, a[i + 1] - a[i])

print(p - max_dist)



Measured memory_bytes: 77388
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
using namespace std;

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

typedef long long ll;

int main(){
    int N,ans=0;
    cin >> N;
    int h[110];
    rep(i,N){
        cin >> h[i];
        //if (h[i] > 0) h[i]--;
    }
    h[N] = 0;
    //rep()
    //cout << h[0] << endl;
    rep(j,10000){
        for(int i=0;i<N;i++){
            //cout << "h[i]" << h[i] << endl;
            //if (h[i] == 0 && h[i+1] == 0) continue;
            if (h[i] > 0 && h[i+1] > 0){
                //cout << h[i] << endl;
                if (h[i]) h[i]--;
                //cout << h[i] << " " << h[i+1] << endl;
                
            }else if (h[i] > 0 && h[i+1] <= 0){
              if (h[i]) h[i]--;
              ans++;
              break;
            }
        }
    }
    cout << ans << endl;

}

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

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int N;
string s;
int M;
int a[10];
int L;
int toidx[10];
int dfs(int idx, int sum){
  if(idx == L){
    if(sum % 10 == 0) return 1;
    else              return 0;
  }else{
    int res = 0;
    REP(i, M){
      s[toidx[idx]] = a[i] + '0';
      int n = a[i];
      if((N - toidx[idx]) % 2 == 0) n *= 2;
      if(n >= 10) n = n / 10 + n % 10;
      res += dfs(idx + 1, sum + n);
    }
    return res;
  }
}

int main(){
  cin>>N>>s;
  L = 0;
  REP(i, N) if(s[i] == '*') toidx[L++] = i;
  cin>>M;
  REP(i, M) cin>>a[i];
  int sum = 0;
  REP(i, N)if(s[i] != '*'){
    int n = s[i] - '0';
    if((N - i) % 2 == 0) n *= 2;
    if(n >= 10) n = n / 10 + n % 10;
    sum += n;
  }
  cout<<dfs(0, sum % 10)<<endl;
  return 0;
}

Measured memory_bytes: 1332
#include <cstdio>
#include <cstring>

using namespace std;

void Get_Val(int &Ret)
{
	Ret = 0;
	char ch;
	while (ch = getchar(), ch > '9' || ch < '0')
		;
	do
	{
		(Ret *= 10) += ch - '0';
	}
	while (ch = getchar(), ch >= '0' && ch <= '9');
}

//(A[i] + A[j] + B[i] + B[j])! / (A[i] + A[j])! / (B[i] + B[j])!
//等价于(-A[j], -B[j])到(A[i], B[i])的路径计数

const int MOD(1000000000 + 7);
typedef long long int LL;
const int Max_N(200050);
const int Max_AB(4050);
const int Add(2005);

inline int Mult(const int &a, const int &b)
{
	return static_cast<int>(static_cast<LL>(a) * static_cast<LL>(b) % static_cast<LL>(MOD));
}

void exgcd(const int &a, const int &b, int &x, int &y)
{
	if (b == 0)
		x = 1, y = 0;
	else
		exgcd(b, a % b, y, x), y -= x * (a / b);
}

inline int inverse(const int &a)
{
	int invx, invy;
	exgcd(a, MOD, invx, invy);
	return (invx % MOD + MOD) % MOD;
}

int N, A[Max_N], B[Max_N], F[Max_AB + 5][Max_AB + 5];
int Fac[100000 + 5], Inv[100000 + 5];

void init()
{
	Get_Val(N);
	for (int i = 1;i <= N;++i)
		Get_Val(A[i]), Get_Val(B[i]), ++F[A[i] + Add][B[i] + Add];
}

inline void update(int &a, const int &b)
{
	((a += b) >= MOD) ? (a -= MOD) : 0;
}

void dp()
{
	for (int i = Add;i >= -Add;--i)
		for (int j = Add;j >= -Add;--j)
		{
			update(F[i + Add][j + Add], F[(i + 1) + Add][j + Add]);
			update(F[i + Add][j + Add], F[i + Add][(j + 1) + Add]);
		}
}

void work()
{
	int Ans(0);
	for (int i = 1;i <= N;++i)
		update(Ans, F[-A[i] + Add][-B[i] + Add]);
	Fac[0] = 1;
	for (int i = 1;i <= 100000;++i)
		Fac[i] = Mult(Fac[i - 1], i);
	Inv[100000] = inverse(Fac[100000]);
	for (int i = 100000 - 1;i >= 0;--i)
		Inv[i] = Mult(Inv[i + 1], i + 1);
	for (int i = 1;i <= N;++i)
		Ans -= Mult(Fac[2 * A[i] + 2 * B[i]], Mult(Inv[A[i] + A[i]], Inv[B[i] + B[i]])), Ans = (Ans % MOD + MOD) % MOD;
	printf("%d", Mult(Ans, inverse(2)));
}

int main()
{
	init();
	dp();
	work();
	return 0;
}

Measured memory_bytes: 66816
# -*- coding: utf-8 -*-
n,k = list(map(int,input().split()))

from decimal import Decimal
k = Decimal(k)
n_list = [Decimal(i) for i in range(n,0,-1)]
coin_cnt_list = [0] * n
cur_coin_cnt = 0
cur_pow_coin_cnt = 1

for i,v in enumerate(n_list):
    while v * cur_pow_coin_cnt < k:
        cur_coin_cnt+=1
        cur_pow_coin_cnt*=2
    coin_cnt_list[i]=cur_coin_cnt

from collections import defaultdict
d = defaultdict(int)

for key in coin_cnt_list:
    d[key] += 1

ret = Decimal(0)
for k,v in d.items():
    ret += 1/Decimal(2**k) * Decimal(v)
ret /= Decimal(n)
print(ret)

Measured memory_bytes: 21588
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_145
{
    class B
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            string s = Read();
            if (n % 2 == 1)
            {
                WriteLine("No");
                return;
            }
            int same = 0;
            for(int i = 0; i < n/2; i++)
            {
                if (s[i] == s[i + n / 2]) same++;
            }
            if (same == n / 2) WriteLine("Yes");
            else WriteLine("No");
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define rep(i, n) REP(i, 0, n)
#define REP(i, l, r) for (int i = l; i < r; ++i)
#define int long long
#ifdef DEBUG
#define dout cout
#else
std::stringstream dout;
#endif
using namespace std;
typedef pair<int, int> P;
struct edge {
  int to, cost;
};
// other libs
int gcd(int a, int b) {
  if (a % b == 0)
    return b;
  else
    return gcd(b, a % b);
}
int lcm(int a, int b) {
  return a * b / gcd(a, b);
}

class dijkstra {
private:
  int V;
  int d[100002];
  priority_queue<P, vector<P>, greater<>> que;

public:
  dijkstra(int v, int s, vector<edge> G[]) {
    V = v;
    update(s, G);
  }

  void update(int s, vector<edge> G[]) {
    fill(d, d + V + 1, 100000000000ll);
    d[s] = 0;
    que.push(make_pair(0, s));
    while (!que.empty()) {
      P p = que.top();
      que.pop();
      int v = p.second;
      if (d[v] < p.first)
        continue;
      rep(i, G[v].size()) {
        edge e = G[v][i];
        if (d[e.to] > d[v] + e.cost) {
          d[e.to] = d[v] + e.cost;
          que.push(make_pair(d[e.to], e.to));
        }
      }
    }
  }

  int find(int e) {
    return d[e];
  }
};
template<typename T>
class Union_Find {
private:
  vector<T> t, s;

public:
  Union_Find(T max_length) {
    rep(i, max_length + 1) {
      t.push_back(i);
      s.push_back(1);
    }
  }

  void Union(T x, T y) {
    if (same(x, y))
      return;
    T tx = Find(x), ty = Find(y);
    if (s[tx] < s[ty]) {
      s[ty] += s[tx];
      t[tx] = ty;
    }
    else if (s[tx] > s[ty]) {
      s[tx] += s[ty];
      t[ty] = tx;
    }
    else if (tx > ty) {
      t[tx] = ty;
      s[ty] += s[tx];
    }
    else {
      t[ty] = tx;
      s[tx] += s[ty];
    }
  }
  T Find(T n) {
    if (t[n] == n)
      return n;
    else
      return t[n] = Find(t[n]);
  }

  bool same(T x, T y) {
    return Find(x) == Find(y);
  }

  T get_Size(size_t a) {
    return s[a];
  }
};
bool ifPrime(int n) {
  if (n == 1)
    return false;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0)
      return false;
  }
  return true;
}

set<int> prime_num_factor(int n){
  if(n<2)return set<int>();
  set<int> prime;
  prime.insert(2);
  for(int i=3;i<=n;i++){
    for(int it:prime){
      if(it*it>i){
        prime.insert(i);
        break;
      }
      if(i%it==0)break;
    }
  }
  return prime;
}
vector<int> makeDivisors(int n){
  vector<int> re;
  REP(i,1,sqrt(n)+1){
    if(n%i==0){
      re.push_back(i);
      if(i!=n/i)re.push_back(n/i);
    }
  }
  return re;
}
int modPow(int a,int n,int mod){
  int ret=1;
  while(n){
    if(n&1)ret=ret*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return ret;
}
signed main(signed argc, char* argv[]) {
  int n;
  string s;
  cin>>n>>s;
  int ans=1;
  REP(i,1,n){
    if(s[i]!=s[i-1])ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 512
{
  const run = (input: string) => {
    const split = input.trim().split("\n")
    const n = parseInt(split[0])

    let ac = 0
    let wa = 0
    let tle = 0
    let re = 0
    for (let i = 1; i <= n; i++) {
      if (split[i] === 'AC') {
        ac++
      } else if (split[i] === 'WA') {
        wa++
      } else if (split[i] === 'TLE') {
        tle++
      } else if (split[i] === 'RE') {
        re++
      }
    }

    return `AC x ${ac}
WA x ${wa}
TLE x ${tle}
RE x ${re}`
  }

  const Main = (input: string) => {
    console.log(run(input))
  };

  Main(require("fs").readFileSync("/dev/stdin", "utf8"));
}


Measured memory_bytes: 37120
#include <cstdio>
#include <algorithm>

using namespace std;

int main(){
    int N,sum,mn,mx;
    
    while(true){
        scanf("%d",&N);
        
        if(N == 0) break;
        
        sum = 0;
        mn = 1000;
        mx = 0;
        
        for(int i = 0,a;i < N;++i){
            scanf("%d",&a);
            
            sum += a;
            mn = min(mn,a);
            mx = max(mx,a);
        }
        
        printf("%d\n",(sum - mn - mx) / (N - 2));
    }
    
    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>

int main()
{
  std::string input = "";
  int taps = 0;
  int needs = 0;
  int tapEnter = 0;
  int tmp = 0;
  std::cin >> input;
  tapEnter = std::stoi(input);
  std::cin >> input;
  needs = std::stoi(input);
  if(needs <= 1)
  {
    std::cout << "0" << std::endl;
    return 0;
  }
  else if(tapEnter == 2)
  {
    std::cout << needs - 1 << std::endl;
    return 0;
  }
  tmp = needs % (tapEnter - 1);
  if (tmp <= 1) taps = needs / (tapEnter - 1);
  else taps = needs / (tapEnter - 1) + 1;
  std::cout << taps << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void OnestrokePath(int n,vector<vector<int>> &ABC,vector<bool> &ok,int &ans) {
    bool ok2 = true;
    for(int i = 0; i < ok.size(); i++) {
        if(ok[i] == false && i != n) {
            ok2 = false;
        }
    }
    if(ok2) {
        ans++;
        return;
    }
    ok[n] = true;
    for(int i = 0; i < ABC[n].size(); i++) {
        if(ok[ABC[n][i]] == true) {
            continue;
        }
        OnestrokePath(ABC[n][i],ABC,ok,ans);
    }
    ok[n] = false;
    return;
}
int main() {
    int N,M;
    cin >> N >> M;
    vector<vector<int>>ABC(N);
    vector<bool>ok(N,false);
    for(int i = 0; i < M; i++) {
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        ABC[a].push_back(b);
        ABC[b].push_back(a);
    }
    int ans = 0;
    OnestrokePath(0,ABC,ok,ans);
    cout << ans << endl;
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,k; cin>>n>>k;
	vector<int>h(n); for(auto&&i:h)cin>>i;
	vector<int>dp(n,2e9); dp.front()=0;
	for(int i=0;i<n;++i){
		for(int j=i+1,lim=min(i+k+1,n);j<lim;++j){
			dp.at(j)=min(dp.at(j),dp.at(i)+abs(h.at(j)-h.at(i)));
		}
	}
	cout<<dp.back()<<"\n"s;
}


Measured memory_bytes: 3968
N=int(input())
h=list(map(int,input().split()))

ans=0
while sum(h)>0:
  for i in range(N):
    if i<N-1 and h[i]>0 and h[i+1]==0:
      ans+=1
    else:
      if i==N-1 and h[i]>0:
        ans+=1
    if h[i]>0:
      h[i]-=1
  #print(h)
print(ans)

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

int main(){
	string s,t;
	cin>>s>>t;
	
	int n, m;
	m = s.length();
	n = t.length();
	
	int dp[m+1][n+1];
	
	for(int i=0;i<=m;i++){
		for(int j=0;j<=n;j++){
			
			if(i==0 || j==0)
			dp[i][j] = 0;
			
			else if(s[i-1] == t[j-1]){
				dp[i][j] = dp[i-1][j-1] + 1;
			}
			
			else{
				dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
			}
		}
	}
	
	int i = m;
	int j = n;
	vector <char> res;
	while(i > 0 && j > 0){
		if(s[i-1] == t[j-1]){
			res.push_back(s[i-1]);
			i--;
			j--;
		}
		else{
			if(dp[i-1][j] > dp[i][j-1])
			i--;
			
			else
			j--;
		}
	}
	
	for(int i=res.size()-1;i>=0;i--){
		cout<<res[i];
	}
	return 0;
}

Measured memory_bytes: 38776
from collections import deque

INFTY = 1e9 + 1


def merge(a, l, m, r):
    global cnt
    ll = deque(a[l:m])
    rl = deque(a[m:r])
    for k in range(l, r):
        if not rl or ll and ll[0] < rl[0]:
            a[k] = ll.popleft()
        else:
            a[k] = rl.popleft()
            cnt += len(ll)


def merge_sort(a, l, r):
    if l + 1 < r:
        m = (l + r) // 2
        merge_sort(a, l, m)
        merge_sort(a, m, r)
        merge(a, l, m, r)


n, a, cnt = int(input()), list(map(int, input().split())), 0
merge_sort(a, 0, n)
print(cnt)

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

int main()
{
  int N, X[110];
  cin >> N;
  for(int i = 0; i < N; ++i) cin >> X[i];

  // 考え得る最大の消費量(100^2x100人分)を初期値にしておく
  int min = 1000000;
  for(int p = 1; p <= 100; ++p)
  {
    int sum = 0;
    for(int i = 0; i < N; ++i)
    {
      sum += (X[i]-p) * (X[i]-p);
    }
    if(min > sum)
    {
      min = sum;
    }
  }
  
  cout << min << endl;
}

Measured memory_bytes: 3556
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#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;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)

typedef long long ll;

const int Inf = 100100100;
const double EPS = 1e-9;

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

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, ans;
    cin >> n;
    ans = 0;
    rep(i, n / 4 + 1) {
      rep(j, n / 7 + 1) {
        if (4 * i + 7 * j == n) {
          ans = 1;
          break;
        }
      }
    }

    if (ans) {
      cout << "Yes" << '\n';
    } else {
      cout << "No" << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
unittest
{
	assert( [ "3 5" ].parse.expand.solve == 0 );
	assert( [ "4 5" ].parse.expand.solve == 2 );
	assert( [ "5 5" ].parse.expand.solve == 4 );
	assert( [ "100000 2" ].parse.expand.solve == 1 );
	assert( [ "100000 100000" ].parse.expand.solve == 50000 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto hw = input.front.split.to!( long[] );
	return tuple( hw[ 0 ], hw[ 1 ] );
}

auto solve( long h, long w )
{
	// 差が小さいほうを取る
	return div3( h, w );
}

auto div3( long h, long w )
{
	if( h % 3 == 0 || w % 3 == 0 ) return 0L;		// マス目に沿って均等に三等分できる
	
	// 三分割したときのサイズを計算
	auto dws = h * ( w / 3 );		// 縦に分割（小さいほう）
	auto dwb = h * ( w / 3 + 1 );		// 縦に分割（大きいほう）
	auto dhs = w * ( h / 3 );		// 横に分割（小さいほう）
	auto dhb = w * ( h / 3 + 1 );		// 横に分割（大きいほう）
	
	// 残りの部分を二等分したときの1つの大きさを計算
	auto rss = new long[ 3 ][ 4 ];
	rss[ 0 ] = dws ~ div2( h, w - w / 3 );
	rss[ 1 ] = dwb ~ div2( h, w - ( w / 3 + 1 ) );
	rss[ 2 ] = dhs ~ div2( h - h / 3, w );
	rss[ 3 ] = dhb ~ div2( h - ( h / 3 + 1 ), w );
	
	// 差が一番小さいものを取る
	auto r = 100000L;
	foreach( rs; rss )
	{
		auto mm = rs.reduce!( max, min );
		r = min( r, mm[ 0 ] - mm[ 1 ] );
	}
	return r;
}

auto div2( long h, long w )
{
	// 二分割したときのサイズを計算
	auto dws = ( 2 <= w ) ? h * ( w / 2 ) : 1000000;		// 縦に分割（小さいほう）
	auto dwb = ( 2 <= w ) ? h * ( w / 2 + 1 ) : 1000000;		// 縦に分割（大きいほう）
	auto dhs = ( 2 <= h ) ? w * ( h / 2 ) : 1000000;		// 横に分割（小さいほう）
	auto dhb = ( 2 <= h ) ? w * ( h / 2 + 1 ) : 1000000;		// 横に分割（大きいほう）
	
	// 偶数行数または偶数列数の場合は等分できる
	if( w % 2 == 0 ) return [ dws, dws ];
	if( h % 2 == 0 ) return [ dhs, dhs ];
	
	// 奇数行数または奇数列数の場合は片方にかたよる
	if( h < w ) return [ dwb, dws ];
	else        return [ dhs, dhb ];
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <deque>
#include <list>
#if __cplusplus >= 201103L
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define pb push_back
//#define mp make_pair
#ifdef GRAPH
typedef pair <int, int> Edge;
#define v first
#define w second
#endif
using LL = long long;
using ULL = unsigned long long;
#define lsh(i) (1 << (i))
#define lshll(i) (1LL << (i))
#define rep(i, n) for (int (i) = 0; (i) < n; (i)++)
#define until(x) while (!x)
#define fail(s) assert(!s)
const int INF = 0x3f3f3f3f;
const int EPS = 1e-6;
unordered_map < string, int > mp;
int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	LL ans = 0;
	while (n--) {
		string s;
		cin >> s;
		sort(s.begin(), s.end());
		if (!mp.count(s))mp[s] = 1;
		else mp[s]++;
	}
	for (auto i:mp) {
		LL res = i.second;
		ans += (res - 1) * res / 2;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 10660
#include <stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,M[N][N];
int color[N],d[N],f[N],tt;

void dfs_visit(int u){
    int v;
    color[u]=GRAY;
    d[u]=++tt;
    for(v=0;v<n;v++){
        if(M[u][v]==0)
            continue;
        if(color[v] == WHITE){
            dfs_visit(v);
        }
    }
    color[u]=BLACK;
    f[u]=++tt;
}

void dfs(){
    int i;
    tt=0;
    for(i=0;i<n;i++){
        if(color[i]==WHITE)
            dfs_visit(i);
    }
    for(i=0;i<n;i++){
        printf("%d %d %d\n",i+1,d[i],f[i]);
    }
}

int main(void){
    int u,v,k,i,o;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d %d",&u,&k);
        u--;
        for(o=0;o<k;o++){
            scanf("%d",&v);
            v--;
            M[u][v]=1;
        }
    }
    dfs();
    return 0;
}

Measured memory_bytes: 632
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()

int main() {
    int H,W,h,w;
    cin>>H>>W>>h>>w;
    cout<<H*W-h*W-H*w+h*w<<endl;
return 0;
}

Measured memory_bytes: 256
// D - Maximal Value.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <algorithm>
using namespace std;

const int N = 100 + 5;
int arr[N];
int main()
{
	int n;
	cin >> n;

	int ans = 0 ;
	int count = 0;
	for (int i = 0; i < n - 1 ; i++) {
		cin >> arr[i];
	}

	ans = arr[0] + arr[n - 2];

	int i = 0;
	while (i < n - 2) {
		ans += min(arr[i], arr[i + 1]);
		i++;
	}
	
	cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
using namespace std;
const LL mod=1e9+7;
map<LL,LL>mp;
LL B[10]={1,2,4,5};
LL F(LL x){
	if(mp[x]>0)return mp[x];
	if(x<2)return mp[x]=B[x];
	return mp[x]=((F((x-1)/2)+F((x-2)/2))%mod+F(x/2))%mod;
}
int main(){
	LL n;
	cin>>n;
	cout<<F(n)<<endl;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            int iX1 = int.Parse(sS[0]);
            int iY1 = int.Parse(sS[1]);
            int iX2 = int.Parse(sS[2]);
            int iY2 = int.Parse(sS[3]);

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            int iX3 = iX2 - (iY2 - iY1);
            int iY3 = iY2 + (iX2 - iX1);
            int iX4 = iX1 - (iY2 - iY1);
            int iY4 = iY1 + (iX2 - iX1);

            // 出力
            string sOut = iX3.ToString() + " " + iY3.ToString() + " " + iX4.ToString() + " " + iY4.ToString();
            System.Console.WriteLine("{0}", sOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int ans = 0;
  for(int i=1;i<=n;i++){
  	if(n%i==0){
  		ans += (n/i)-1;
	}
	else{
		ans += n/i;
	}
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3624
n = int(input())
ans = ""
for i in range(1,n+1):
  if i%3 == 0:
    ans += " "+str(i)
  else:
    if i%10 == 3:
      ans += " " + str(i)
    else:
      i = str(i)
      if i.count("3")>0:
          ans += " " + str(i)
print(ans)


Measured memory_bytes: 5636
$N = gets.to_i
$MOD = 10 ** 9 + 7
$memo = Array.new($N+1) { {} }

def ok(last4)
  4.times do |i|
    t = last4.split(//)
    t[i - 1], t[i] = t[i], t[i - 1] if i >= 1
    return false unless t.join.index('AGC').nil?
  end

  true
end

def dfs(cur, last3)
  return $memo[cur][last3] if $memo[cur].key? last3
  return 1 if cur == $N

  ret = 0
  'ACGT'.each_char do |c|
    ret = (ret + dfs(cur + 1, last3[1..3] + c)) % $MOD if ok(last3 + c)
    $memo[cur][last3] = ret
  end
  ret
end

puts dfs(0, 'TTT')

Measured memory_bytes: 4988
while True:
    n,r = map(int, raw_input().split())
    if n==0: break
    card = range(n,0,-1)
    for i in range(r):
        p,c = map(int, raw_input().split())
        block = card[p-1:p+c-1]
        del card[p-1:p+c-1]
        card = block + card
    print(card[0])

Measured memory_bytes: 6248
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String s=sc.nextLine();
		long k=sc.nextLong();
		char c[]=s.toCharArray();
		int one=0;
		char ans='a';
		for(int i=0;i<s.length();i++){
			if(c[i]=='1'){
				one++;
			}else{
				ans=c[i];
				break;}
		}
		if(one>=k){
			System.out.println(1);
		}else{
			System.out.println(ans);
		}

	}}

Measured memory_bytes: 21972
//Author: Pakhomovee 
#include <iostream> 
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <chrono>
#include <deque>
#include <iomanip>
#include <queue>

using namespace std;
using namespace std::chrono;

#define ld long double

int r(ld x)
{
	int z = (int)x;
	x -= z;
	if (x < 0.5)
	{
		return z;
	}
	return z + 1;
}

void solve()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	vector<int> cnt(n + 1, 0);
	for (int i = 0; i < n; ++i)
	{
		cnt[i + 1] = cnt[i];
		if (s[i] == 'W')
		{
			++cnt[i + 1];
		}
	}
	int ans = n - cnt.back();
	for (int i = 1; i <= n; ++i)
	{
		int left_ok = i - cnt[i];
		int right_ok = (cnt.back() - cnt[i]);
		int left = i - left_ok;
		int right = n - i - right_ok;
		//cout << i << ' ' << left << ' ' << right << endl;
		int m = min(left, right);
		left -= m;
		right -= m;
		ans = min(ans, left + right + m);
	}
	cout << ans;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	auto start = system_clock::now();

	solve();

	auto end = system_clock::now();
	cerr << "Time: " << duration_cast<milliseconds> (end - start).count() << "ms" << endl;
}

Measured memory_bytes: 4440
import collections

n, k = map(int, input().split())
a_list = [int(i) for i in input().split()]

c = collections.Counter(a_list)
c = c.most_common()

changenum = len(c) - k
if changenum <= 0:
    print(0)
    exit()

changecount=0
for changeidx in range(changenum):
    index = -1 - changeidx
    changecount += c[index][1]
print(changecount)


Measured memory_bytes: 39296
import java.util.*;
public class Main{
  public static void main(String[]args){
      Scanner sc = new Scanner(System.in);

      int k = sc.nextInt();

      if(k%2!=0){
        System.out.println((k/2)*(k/2+1));
      }else{
        System.out.println((k/2)*(k/2));
      }

      }

  }

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

int main() {
	int n, m;
	cin >> n >> m;
	priority_queue<int> q;
	
	for(int i = 0; i < n; i++) {
		int a;
		cin >> a;
		q.push(a);
	}
	
	for (int i = 0; i < m; i++) {
		int a = q.top();
		q.pop();
		q.push(a/2);
	}
	
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		ans = ans + q.top();
		q.pop();
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 892
#include<iostream>
using namespace std;
int main(){
	for (int h = 0; h < 1000; h++){
		int a, b;
		cin >> a >> b;
		if (a == 0 && b == 0){
			break;
		}
		for (int i = 0; i < a; i++){
			for (int j = 0; j < b; j++){
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3100
#include <stdio.h>
#define MAX 200


int main(){
    int N;
    int ans=0;
    int d[MAX];
    scanf("%d", &N);
    for (int i = 0; i <N ; ++i) {
        scanf("%d",&d[i]);
    }
    for (int i = 0; i <N ; ++i) {
        for (int j = i+1; j <N ; ++j) {
            ans+=d[i]*d[j];
        }
    }
    printf("%d", ans);
}

Measured memory_bytes: 128
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.Math;

public class Main {
    public static void main(String[] args) {
        FS reader = new FS();
        // write reader
        int N = reader.nextInt();
        System.out.println((N-1)/2);
    }

    // Read Class
    static class FS {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
    
        private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
        private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
        private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public int nextInt() {
            return (int)nextLong();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if(b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
    }
}



Measured memory_bytes: 21076
#include<bits/stdc++.h>
#define ll long long
using namespace std;
void solve()
{
	string s;cin>>s;
	if(s[0]=='7' || s[1]=='7' || s[2]=='7')
	cout<<"Yes";
	else
	cout<<"No";
}
int main()
{
//	int t;cin>>t;
//	while(t--)
	solve();
}


Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstdlib>
#include <stack>
#include <vector>
#define INF 0x3f3f3f3f
#define MOD 1000000009
# define FOR(i,a,n) for(register int i=a; i<=n; ++i)
# define FDR(i,a,n) for(register int i=a; i>=n; --i)
typedef long long ll;
typedef unsigned long long ull;

inline int scan() {
    int x=0,f=1; char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}
inline void Out(int a) {
    if(a<0) {putchar('-'); a=-a;}
    if(a>=10) Out(a/10);
    putchar(a%10+'0');
}
using namespace std;
struct A
{
    int x;
    int y;
};
A a[105];
struct B
{
    int x;
    int y;
};
B b[105];
int maps[105][105];
int pei[105];
int vis[105];
int n;
bool dfs(int cur)
{
    for(int i = 1; i <= n; i++)
    {
        if(!vis[i] && maps[cur][i] == 1)
        {
            vis[i] = 1;
            if(pei[i] == -1|| dfs(pei[i]))
            {
                pei[i] = cur;
                return true;
            }
        }
    }
    return false;
}

int main()
{
    cin >> n;
    for(int i = 1; i <= n; i++)
    cin >> a[i].x >> a[i].y;
    for(int i = 1; i <= n; i++)
    cin >> b[i].x >> b[i].y;
    memset(maps, 0, sizeof(maps));
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= n; j++)
        {
//            if(i == j)continue;
            if(a[i].x < b[j].x && a[i].y < b[j].y)
            maps[i][j] = 1;
        }
    }
    int ans = 0;
    memset(pei, -1, sizeof(pei));
    for(int i = 1; i <= n; i++)
    {
        memset(vis, 0, sizeof(vis));
        if(dfs(i))ans++;
    }
    cout << ans << endl;
    return 0;
}
/*
                 ___====-_  _-====___
           _--^^^#####//      \\#####^^^--_
        _-^##########// (    ) \\##########^-_
       -############//  |\^^/|  \\############-
     _/############//   (@::@)   \\############\_
    /#############((     \\//     ))#############\
   -###############\\    (oo)    //###############-
  -#################\\  / VV \  //#################-
 -###################\\/      \//###################-
_#/|##########/\######(   /\   )######/\##########|\#_
|/ |#/\#/\#/\/  \#/\##\  |  |  /##/\#/  \/\#/\#/\#| \|
`  |/  V  V  `   V  \#\| |  | |/#/  V   '  V  V  \|  '
   `   `  `      `   / | |  | | \   '      '  '   '
                    (  | |  | |  )
                   __\ | |  | | /__
                  (vvv(VVV)(VVV)vvv)
                  ÁúÉñ±£ÓÓ ÓÀÎÞbug
*/


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cstdio>
#include<cstdlib>
#include<queue>
#include<list>
#include<deque>
#include<cmath>
#include<unordered_map>
#include<unordered_set>
#include<numeric>
using namespace std;

using ll = int64_t;

/// <summary>
/// 単純なcoutの時に使う
/// </summary>
#define co(a) cout<<a<<"\n"


/// <summary>
/// [beg, end)の範囲を，添え字indexでループするfor文に置換します
/// </summary>
#define rep(i,a) for(ll i=0; i<a; ++i)

/// <summary>
/// 迷路等で使う方向のベクトル
/// </summary>
const vector<ll> dx = { 0, 1, 0, -1 }, dy = { 1, 0, -1, 0 };

/// <summary>
/// デバッグ時に使う
/// </summary>
#define DEBUG(x)     std::cout << #x << " : " << x << "\n"

///////////////////////////////////////////////////////////////////////////

vector<vector<ll>> grid;

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

	ll H, W;
	cin >> H >> W;
	grid = vector<vector<ll>> (1000, vector<ll>(1000, 0));

	rep (y, H) rep (x, W) {
		char in;
		cin >> in;
		
		if (in == '#') {
			grid[y][x] = -1;
		}
	}

	rep (y, H) {
		if (grid[y][0] == -1) {
			break;
		}
		grid[y][0] = 1;
	}

	rep (x, W) {
		if (grid[0][x] == -1) {
			break;
		}
		grid[0][x] = 1;
	}

	for (ll y = 1; y < H; ++y) {
		for (ll x = 1; x < W; ++x) {
			if (grid[y][x] == -1) {
				continue;
			}

			int sum = 0;
			sum += grid[y - 1][x] == -1 ? 0 : grid[y - 1][x];
			sum += grid[y][x - 1] == -1 ? 0 : grid[y][x - 1];
			grid[y][x] = sum % 1000000007;
		}
	}

	cout << grid[H - 1][W - 1] << endl;
}

Measured memory_bytes: 8064
#include <stdio.h>

int main(){
    int n,d,x;
    int a[1010];
    scanf("%d%d%d",&n,&d,&x);
    for(int i=0;i<n;i++)scanf("%d",&a[i]);
    int ans=x;
    for(int i=0;i<n;i++){
        ans+=(d+a[i]-1)/a[i];
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 128
calc x h =
  let x' = sqrt(2*x*x) / 2.0
      y  = sqrt(x'*x' + h*h)
      y' = sqrt(y*y - x*x/4.0)
  in
    x*x + 4*x*y'/2

ans (0:0:_) = []
ans (x:h:xs) =
  ((calc x h):(ans xs))

main = do
  c <- getContents
  let i = map read $ lines c :: [Double]
      o = ans i
  mapM_ print o
  

Measured memory_bytes: 3912
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;
const int MOD = 1000000007;

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

  int n, query; cin >> n >> query;
  vector<queue<int>> v(1010);

  for (int i = 0; i < query; ++i) {
    int op; cin >> op;
    if (op == 0) {
      int t, x; cin >> t >> x;
      v[t].push(x);
    } else if (op == 1) {
      int t; cin >> t;
      if (v[t].empty()) {
        continue;
      } else {
        cout << v[t].front() << '\n';
      }
    } else {
      int t; cin >> t;
      if (v[t].empty()) {
        continue;
      } else {
        v[t].pop();
      }
    }
  }

  return 0;
}


Measured memory_bytes: 4272
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/
 

// void chmod(ll &M){
//     if(M >= mod) M %= mod;
//     else if(M < 0){
//         M += (abs(M)/mod + 1)*mod;
//         M %= mod;
//     }
// }

const ll mod = 1e9+7;

int n, k;
vector<int> G[100005];
vector<ll> p(100005, 0); // p[i] := (k-2)Pi

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

    cin >> n >> k;
    for(int i=0; i<n-1; ++i){
        int a, b; cin >> a >> b;
        --a; --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    ll ans = k;
    p[0] = 1;
    for(int i=1; i<=k-2; ++i) p[i] = p[i-1]*(k-1-i)%mod;
    
    for(int i=0; i<n; ++i){
        if(i == 0){
            if(G[i].size() > k-1){
                cout << 0 << endl;
                return 0;
            }
            else if(G[i].size()){
                ans *= (k-1)*p[G[i].size()-1];
            }
        }
        else{
            if(G[i].size()-1 > k-2){
                cout << 0 << endl;
                return 0;
            }
            else{
                ans *= p[G[i].size()-1];
            }
        }
        ans %= mod;
    }

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

Measured memory_bytes: 6904