akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

typedef long long ll;

int vs[100000+10];

int main(void) {
  int n;
  scanf("%d", &n);
  bool odd = false;
  REP(i, n) {
    scanf("%d", &vs[i]);
    if(vs[i]%2 == 1) {
      odd = true;
    }
  }
  puts(odd ? "first" : "second");
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> as(n);
  for (auto &&a : as) {
    cin >> a;
  }
  
  as[0]--;
  
  for (int i = 1; i < n; i++) {
    if (as[i - 1] <= as[i] - 1) {
      as[i]--;
    }
    if (as[i - 1] > as[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  
  cout << "Yes" << endl;
  
  return 0;
}

Measured memory_bytes: 640
#define DEBUGGING  // Enables DEBUG macro.
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifndef DEBUGGING
#define DEBUG(...)
#else
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                     \
  do {                                 \
    cerr << " (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ": ";      \
    debug(__VA_ARGS__);                \
    cerr << endl;                      \
  } while (0)
#endif

const int matches[10] = {-1, 2, 5, 5, 4, 5, 6, 3, 7, 6};

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

  int N, M;
  cin >> N >> M;
  vector<int> A(M);
  for (auto& x : A) cin >> x;
  sort(A.begin(), A.end());

  vector<vector<int>> dp(N / 2 + 1, vector<int>(N + 1, -1));
  dp[0][0] = 0;
  REP(i, N / 2 + 2) {
    bool placed = false;
    REP(j, N + 1) {
      if (dp[i][j] < 0) continue;
      REP(k, M) {
        int m = matches[A[k]];
        if (j + m > N) continue;
        dp[i + 1][j + m] = max(dp[i + 1][j + m], A[k]);
        placed = true;
      }
    }
    if (!placed) {
      break;
    }
  }
  int mi = -1;
  for (int i = N / 2; i >= 0; --i) {
    if (dp[i][N] >= 0) {
      mi = i;
      break;
    }
  }
  assert(mi >= 0);
  int s = N;
  for (int i = mi; i > 0; --i) {
    int d = dp[i][s];
    cout << d;
    s -= matches[d];
  }
  cout << '\n';
}

Measured memory_bytes: 195840
a, b, c = map(int, input().split())
if a == 5 and b == 5 and c == 7:
  print("YES")
elif a == 5 and b == 7 and c == 5:
  print("YES")
elif a == 7 and b == 5 and c == 5:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 9052
//
// Ford-Fulkerson's maximum cardinality bipartite matching
//
// Description:
//   Compute the maximum cardinality matching for bipartite graph.
//
// Algorithm:
//   Standard augmentaing path.
//
//
// Complexity:
//   O(m n) time
//
//
// Verified:
//   AOJ Matching
//

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <queue>
#include <cstring>
#include <functional>
#include <algorithm>

using namespace std;
#define all(c) (c).begin(), (c).end()

struct graph {
  int L, R;
  vector<vector<int>> adj;
  graph(int L, int R) : L(L), R(R), adj(L+R) { }
  void add_edge(int u, int v) {
    adj[u].push_back(v+L);
    adj[v+L].push_back(u);
  }
  int maximum_matching() {
    vector<int> visited(L), mate(L+R, -1);
    function<bool(int)> augment = [&](int u) { // DFS
      if (visited[u]) return false;
      visited[u] = true;
      for (int w: adj[u]) {
        int v = mate[w];
        if (v < 0 || augment(v)) {
          mate[u] = w;
          mate[w] = u;
          return true;
        }
      }
      return false;
    };
    int match = 0;
    for (int u = 0; u < L; ++u) {
      fill(all(visited), 0);
      if (augment(u)) ++match;
    }
    return match;
  }
};

int main() {
  int L, R, m; 
  scanf("%d %d %d", &L, &R, &m);
  graph g(L, R);
  for (int i = 0; i < m; ++i) {
    int u, v;
    scanf("%d %d", &u, &v);
    g.add_edge(u, v);
  }
  printf("%d\n", g.maximum_matching());
}

Measured memory_bytes: 1316
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const string EMP = " ";
const ll INF = 1LL<<60;
const ll MOD = 1000000007;
const double PI = acos(-1);

int main(){
  int n; cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  sort(a.rbegin(), a.rend());
  vector<int> cc(n,2);
  cc[0]--;
  ll ans = 0, j = 0;
  for(int i = 0; i < n-1; i++){
    if(!cc[j]) j++;
    ans += a[j];
    cc[j]--;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4820
using System;

class B{
  public static void Main(){
    int N = int.Parse(Console.ReadLine());
    bool O = false;
    for (int i = 0; i < 26; i++){
      for (int j = 0; j < 15; j++){
        if (N == i * 4 + j * 7) O = true;
      }
    }
    if (O) Console.WriteLine("Yes");
    else Console.WriteLine("No");
  }
}


Measured memory_bytes: 13140
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.stdio;
import std.string;
import std.range;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

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

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

long calc(long[] xs) {
    long ans = xs[0];
    for (int i = 1; i < xs.length; i++) {
        ans = lcm(ans, xs[i]);
    }
    return ans;
}

void main() {
    int n = readint();
    long[] xs;
    for (int i = 0; i < n; i++) {
        xs ~= readln.chomp.to!long;
    }

    writeln(calc(xs));
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <set>
#include <complex>
#include <cmath>
#include <cstring>
#include <map>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59
const int MAX = 510000;

int main()
{
    int n, w, d;
    while (cin >> n >> w >> d)
    {
        if (n == 0 && w == 0 && d == 0)
            break;

        vector<pair<int, int>> arr;
        arr.push_back(make_pair(w, d));

        for (int i = 1; i <= n; ++i)
        {
            int p, s;
            cin >> p >> s;
            p--;
            int nw = arr[p].first;
            int nd = arr[p].second;

            arr.erase(arr.begin() + p);
            s = s % (nw + nd);

            if (0 < s && s < nw)
            {
                int lw = s;
                int rw = nw - s;
                int ld = nd;
                int rd = nd;

                if (lw * ld > rw * rd)
                {
                    arr.push_back(make_pair(rw, rd));
                    arr.push_back(make_pair(lw, ld));
                }
                else
                {
                    arr.push_back(make_pair(lw, ld));
                    arr.push_back(make_pair(rw, rd));
                }
            }
            else if (nw < s)
            {
                s -= nw;
                int lw = nw;
                int rw = nw;
                int ld = s;
                int rd = nd - s;

                if (lw * ld > rw * rd)
                {
                    arr.push_back(make_pair(rw, rd));
                    arr.push_back(make_pair(lw, ld));
                }
                else
                {
                    arr.push_back(make_pair(lw, ld));
                    arr.push_back(make_pair(rw, rd));
                }
            }
        }
        vector<int> ans;
        for (int i = 0; i < arr.size(); ++i)
        {
            ans.push_back(arr[i].first * arr[i].second);
        }
        sort(ans.begin(), ans.end());

        for (int i = 0; i < ans.size(); ++i)
        {
            if (i)
                cout << " ";
            cout << ans[i];
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 2988
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;


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

    vector<int> a(N);
    bool flag = false;
    REP(i, N){
        cin >> a[i];
    }

    int x = 1;
    int res = 0;
    flag = false;
    REP(i, N) {
        if(x == 2){
            flag = true;
            break;
        }
        res++;
        x = a[x-1];
    }

    if (flag == true){
        cout << res << endl;
        }
    
    else{
        cout << -1 << endl;
    }
    
}

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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector<int> a(n);
    for(int  i = 0; i < n; i++) {
        cin >> a[i];
    }

    sort(a.rbegin(),a.rend());
    ll ans=a[0];
    int cnt=1;
    int idx=1;
    while(cnt<(n-1)) {
        ans+=a[idx];
        cnt++;
        if(cnt%2) idx++;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3984
#include <iostream>
#include <cassert>
using namespace std;
typedef long long ll;
ll N;
const ll inf = 1e9+7;
ll dp[1000010] = {},sum[1000010] = {};

int main(){
    cin >> N;
    dp[1] = N;
    dp[2] = N*N;
    sum[1] = N;
    sum[2] = dp[1]+dp[2];
    for(ll i=3;i<=N;i++){
        dp[i] = (sum[i-1]-dp[i-2]+(N-1)*(N-1)+(N-i+2)+inf)%inf;
        sum[i] = (dp[i]+sum[i-1])%inf;
    }
    cout << (sum[N]-sum[N-1]+inf)%inf << endl;
}

Measured memory_bytes: 15872
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n,m;
    cin >> n >> m;
    vector<vector<int>>Graph(n);
    vector<pair<int,int>>index;
    vector<bool>visited(n);
    queue<int>que;
    REP(i,m){
        int a,b;
        cin >> a >> b;
        a--;b--;
        index.push_back(make_pair(a,b));
    }
    int answer = 0;
    REP(i,m){
        REP(j,n)
            Graph[j].clear();
        REP(j,n)visited[j]=false;
        REP(j,m){
            if(i==j)continue;
            Graph[index[j].first].push_back(index[j].second);
            Graph[index[j].second].push_back(index[j].first);
        }
        que.push(0);
        while(!que.empty()){
            int now = que.front();
            que.pop();
            visited[now]=true;
            REP(j,Graph[now].size()){
                if(!visited[Graph[now][j]])que.push(Graph[now][j]);
            }
        }
        REP(j,n){
            if(visited[j]==false){
                answer++;
                break;
            }
        }
    }
    
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 3616
def main():
    N = int(input())

    ans = f(N)
    print(ans)


def f(N):
    ans = 0
    for i in range(1, N+1, 2):
        x = 0
        for j in range(1, i+1, 2):
            if i % j == 0:
                x += 1

        if x == 8:
            ans += 1

    return ans


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define fr first
#define sc second
#define Rep(i,n) for(int i=0;i<(n);i++)
#define All(v) v.begin(),v.end()
#define Uniq(v) v.erase(unique(All(v)),v.end())
typedef pair<int, int> Pii;
typedef pair<int, Pii> Pip;
typedef pair<string, int> Psi;
const int INF = (1<<30);
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};

string intToString(int number)
{
  stringstream ss;
  ss << number;
  return ss.str();
}

int main()
{
  int n;
  string s;

  while( cin >> n, n ) {
    cin >> s;

    while( n-- ) {
      string next = "";
      char now = s[0];
      int cnt = 1;
      for(int i=1; i<s.size(); i++) {
	if( now == s[i] ) {
	  cnt++;
	}
	else {
	  next += (intToString( cnt ) + now);
	  now = s[i];
	  cnt = 1;
	}
      }

      next += (intToString( cnt ) + now);
      s = next;
    }

    cout << s << endl;
  }

}

Measured memory_bytes: 3336
import sys
p,t='+X'
for e in sys.stdin:
 for i in'0123456789'[(e[0]==t)*(e[1]!=p)or(p+t in e)*('+X='not in e):]:
  l,r=e.replace(t,i).split('=')
  if sum(map(int,l.split(p)))==int(r):print(i);break
 else:print('NA')


Measured memory_bytes: 5620
#include <iostream>
#include <set>
using namespace std;
set <int> die;
int main()
{
    int n,a;
    cin >> n;
    for ( int i = 1 ; i <= n ; i++){
        cin >> a;
        die.insert(a);
    }
    cout << die.size();

    return 0;
}


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

using namespace std;

char s[55][55];
int d[55][55];
int dx[] = {0,0,1,-1};
int dy[] = {1,-1,0,0};
void solve() {
    int n,m;
    cin >> n >> m;
    memset(s, '#', sizeof s);
    for (int i = 1; i <= n; i++) {
        cin >> (s[i]+1);
    }
    memset(d, 0x3f, sizeof d);
    d[1][1] = 1;
    queue<pair<int, int>> q;
    q.emplace(1,1);
    while (!q.empty()) {
        int x,y;
        tie(x,y) = q.front(); q.pop();
        for (int k = 0; k < 4; k++) {
            int u = x+dx[k], v = y+dy[k];
            if (s[u][v] == '.' && d[u][v]>1e5) {
                d[u][v] = 1 + d[x][y];
                q.emplace(u,v);
            }
        }
    }
    if (d[n][m] > 1e5) {
        cout << -1; return;
    }
    int cnt = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (s[i][j] == '#') cnt++;
        }
    }
    int res = n*m - cnt - d[n][m];
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for( int i = 2; i < SIZE; ++i ) {
        fac[i] = (fac[i - 1] * i) % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = (finv[i - 1] * inv[i]) % MOD;

    }
}

LL comb(int n, int k) {
    if( n < k ) return 0;
    if( n < 0 || k < 0 ) return 0;
    return (fac[n] * (finv[k] * finv[n - k] % MOD)) % MOD;

}

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

bool pri[55556];

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

    pri[1] = true;
    for( int i = 2; i <= 55555; ++i ) {
        if( !pri[i] ) {
            for( int j = i * 2; j <= 55555; j += i ) {
                pri[j] = true;

            }
        }
    }

    vector< int > prime;
    for( int i = 2; i <= 55555; ++i ) {
        if( !pri[i] ) prime.pb(i);

    }

    int n;
    cin >> n;

    int cnt = 0;
    for( int i = 0; i < prime.size() && cnt < n; ++i ) {
        if( prime[i] % 5 == 1 ) {
            ++cnt;
            cout << prime[i] << " ";

        }

    }
    cout << endl;
    return 0;
}



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

ll INF = 50000000000000LL;

ll f(vector<vector<ll>>& dp, const vector<int>& A, int N, int beg, int end){
    if(dp[beg][end] != INF)return dp[beg][end];
    // cout<<beg<<" "<<end<<endl;
    if(end - beg == 1){
        dp[beg][end] = abs(A[end]-A[beg]);
        return dp[beg][end];
    }
    ll x = A[beg] - f(dp,A,N,beg+1,end);
    ll y = A[end] - f(dp,A,N,beg,end-1);
    dp[beg][end] = max(x,y);
    return dp[beg][end];
}

int main(){
    int N;cin>>N;
    vector<int> A;
    for(int i = 0;i < N;i++){
        int _a;cin>>_a;
        A.push_back(_a);
    }
    if(N == 1){
        cout<<A[0]<<endl;
        return 0;
    }
    vector<vector<ll>> dp(N,vector<ll>(N,INF));
    cout<<f(dp,A,N,0,N-1)<<endl;
}

Measured memory_bytes: 71040
import numpy as np
N=int(input())
S=input()

# N=8
# S = ".#...##."

# N = 2*10**5
# S = "#"*N

ls1 = np.empty(N,dtype=np.int)
start = False
cnt1 = 0
for i,s in enumerate(S):
    if (not start) and s == "#":
        start = True
    elif start and s == ".":
        cnt1 += 1
    ls1[i] = cnt1

ls2 = np.empty(N,dtype=np.int)
start = False
cnt2 = 0
for i in range(len(S))[::-1]:
    s = S[i]
    if (not start) and s == ".":
        start = True 
    elif start and s == "#":
        cnt2 += 1
    ls2[i] = cnt2
    
ls11 = ls1.max()-ls1
ls22 = ls2.max()-ls2
# print(ls11+ls22)


print((ls11+ls22).min())

Measured memory_bytes: 29580
#include<stdio.h>
#include<math.h>
#define MAX 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,M[MAX][MAX];

int prim(){
  int i,u,v,minv;
  int d[MAX],p[MAX],color[MAX];

  for(i=0;i<n;i++){
    d[i]=INFINITY;
    p[i]=-1;
    color[i]=WHITE;
  }
  d[0]=0;

  while(1){
    minv=INFINITY;
    u=-1;
    for(i=0;i<n;i++){
      if(minv>d[i] && color[i]!=BLACK){
	u=i;
	minv=d[i];
      }
    }
    if(u==-1)break;
    color[u]=BLACK;
    for(v=0;v<n;v++){
      if(color[v]!=BLACK && M[u][v]!=INFINITY){
	if(d[v]>M[u][v]){
	  d[v]=M[u][v];
	  p[v]=u;
	  color[v]=GRAY;
	}
      }
    }
  }
  
  int sum=0;
  for(i=0;i<n;i++){
    if(p[i]!=-1)sum+=M[i][p[i]];
  }
  return sum;
}

int main(){
  int i,j,e;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&e);
      if(e==-1)M[i][j]=INFINITY;
      else M[i][j]=e;
    }
  }
  printf("%d\n",prim());
  return 0;
}



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

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

typedef double D;
typedef complex<D> P;

#define X real()
#define Y imag()

const D eps=1e-8;
const D inf=1e12;
const D PI=acos(-1);

bool cmp_x(const P& a,const P& b){ return a.X==b.X?a.Y<b.Y:a.X<b.X; }
bool cmp_y(const P& a,const P& b){ return a.Y==b.Y?a.X<b.X:a.Y<b.Y; }
bool cmp_a(const P& a,const P& b){ return arg(a)==arg(b)?norm(a)<norm(b):arg(a)<arg(b); }
D cross(P a,P b){ return (conj(a)*b).Y; }
D dot(P a,P b){ return (conj(a)*b).X; }
D toRag(D deg){ return deg*PI/180.0; }
P rot(P base,P a,D theta){ return base+polar(abs(a-base),arg(a-base)+theta); }

struct L : public vector<P> { // line and segment
  L(const P& a,const P &b){
    push_back(a);
    push_back(b);
  }
};

P projection(L l,P p){
  P b=l[1]-l[0],c=p-l[0];
  return l[0]+b*(c/b).X;
}
D distanceLP(L l,P p) {
  return abs(p-projection(l,p));
}

P calc(D r,L l1,L l2,P a){
  P v1=(l1[1]-l1[0]);
  P v2=(l2[1]-l2[0]);
  P v=((v1)*(D)(1.0/abs(v1)))+((v2)*(D)(1.0/abs(v2)));
  D lb=0,ub=100000;
  rep(_,100){
    D mid=(ub+lb)/2.0;
    P c=P(a.X+v.X*mid,a.Y+v.Y*mid);
    D dist=distanceLP(l1,c);
    if(dist>r)ub=mid;
    else lb=mid;
  }
  {
    D mid=(ub+lb)/2.0;
    P c=P(a.X+v.X*mid,a.Y+v.Y*mid);
    return c;
  }
}

D calcr(P a,P b,P c){
  D x=abs(a-b);
  D y=abs(b-c);
  D z=abs(c-a);
  D s=(x+y+z)/2.0;
  D area=sqrt(s*(s-x)*(s-y)*(s-z));
  return 2.0*area/(x+y+z);
}

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

  int N=3;
  vector<P> ps;
  rep(i,N){
    D x,y;
    cin>>x>>y;
    ps.push_back(P(x,y));
  }

  D lb=0,ub=calcr(ps[0],ps[1],ps[2]);
  rep(_,100){
    D R=(lb+ub)/2.0;
    bool ok=false;
    rep(i,N)repl(j,i+1,N){
      P c1=calc(R,L(ps[i],ps[(i+1)%N]),L(ps[i],ps[(i-1+N)%N]),ps[i]);
      if(distanceLP(L(ps[(i+1)%N],ps[(i-1+N)%N]),c1)<R)continue;
      P c2=calc(R,L(ps[j],ps[(j+1)%N]),L(ps[j],ps[(j-1+N)%N]),ps[j]);
      if(distanceLP(L(ps[(j+1)%N],ps[(j-1+N)%N]),c2)<R)continue;
      D dist=abs(c1-c2);
      if(2.0*R<dist)ok=true;
    }
    if(ok) lb=R;
    else ub=R;
  }
  printf("%.10f\n", (lb+ub)/2.0);

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define IPTLIM ( 10000 )

int primes[ IPTLIM + 1 ] = { 1, 1, 0 };

/** Application main entry point. */
int main (
  int argc,
  char *argv[ ]
  )
{
  int n;
  int i, j;

  for ( j = 2; j < IPTLIM; ++j )
  {
    if ( primes[ j ] ) continue;

    for ( i = j << 1; i <= IPTLIM; i += j )
    {
      primes[ i ] = 1;
    }
  }

  while ( scanf ( "%d", &n ) == 1 )
  {
    int res = 0;

    for ( i = 1; i <= n; ++i )
    {
      res += ! ( primes[ i ] || primes[ n - i + 1 ] );
    }

    printf ( "%d\n", res );
  }

  return ( 0 );
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;



int main() {
    ll X;
    cin >> X;
    ll ans_a,ans_b;
    for (ll A=-200;A<200;A++) {
        for (ll B = -200;B<200;B++) {
            if ((pow(A,5) - pow(B,5)) == X) {
                ans_a = A;
                ans_b = B;
            }
        }
    }
    cout << ans_a << " " << ans_b << endl;

}

Measured memory_bytes: 3940
#include<algorithm>
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include  <stdio.h>
#include   <math.h>
#include   <time.h>
#include   <vector>
#include   <bitset>
#include    <queue>
#include      <set>
#include      <map>
using namespace std;

int main()
{
	int n,m,k;cin>>n>>m>>k;
	for(int i=0;i<=n;i++)
		for(int j=0;j<=m;j++)
			if(i*m+j*n-2*i*j==k)
			{
				puts("Yes");return 0;
			}
	puts("No");
	return 0;
}


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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
const int mod = 1000000007;

class Keta {

    vector<int> digits;

public:
    Keta(ll i) : digits(log10(i) + 1) {
        for (int k = 0; k < digits.size(); k++) {
            digits[k] = i % 10;
            i /= 10;
        }
    }

    int keta() {
        return digits.size();
    }

    int get(int index) {
        assert(index != 0);
        assert(index <= keta());
        return digits[index - 1];
    }

    int top() {
        return get(keta());
    }
};

ll pow2(ll a, ll b) {
    if (b == 0) return 1;
    ll res = a;
    for (ll i = 1; i < b; i++) {
        res *= a;
    }
    return res;
}

ll calc_bk(ll top, ll back, ll n, ll k) {
    ll start = pow2(10, k + 1) * top + back;
    ll end = start;
    for (ll ik = 0; ik < k; ik++) {
        ll a = 90 * pow2(10, ik);
        end += a;
    }

    if (start > n) return 0;
    if (end < n) {
        return pow2(10, k);
    }

    Keta bk(start);

    ll top_m = top * pow2(10, k + 1);

    ll nm = n - top_m;
    nm /= 10;
    if (n % 10 >= back) nm++;
    return nm;

}

ll calc_b(ll top, ll back, ll n) {
    if (top == 0) return 0;
    ll ans = 0;
    if (top == back) ans++;
    for (ll k = 0; k < 6; k++) {
        // top k k k back;
        ll now = calc_bk(top, back, n, k);
        ans += now;
    }
    return ans;
}

ll count(ll i) {
    ll ans = 0;
//    ll cans = 0;
    for (ll a = 1; a <= i; a++) {
        Keta ak(a);
        ll now = calc_b(ak.get(1), ak.top(), i);
        ans += now;

//        for (ll b = 1; b <= i; b++) {
//
//            Keta bk(b);

//            if (ak.get(ak.keta()) == bk.get(1) && ak.get(1) == bk.get(bk.keta())) {
//                cans++;
//            }

//        }

    }
    return ans;
}

int main() {

    int n;
    cin >> n;
    if(n <= 9) {
        cout << n << endl;
        return 0;
    }

    ll ans = count(n);
    cout << ans << endl;

}



Measured memory_bytes: 512
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int n,i;
    ll t,ti;
    cin>>n>>t;
    vector<pair<ll,ll>> a;
    for (i=0;i<n;i++)
    {
        cin>>ti;
        a.pb(mp(ti,ti+t));
    }
    ll x=0,bd=a[0].ff;
    for (i=0;i<n;i++)
    {
        if (bd<=a[i].ss)
            x+=a[i].ss-bd;
        if (i!=n-1)
            bd=max({bd,a[i].ss,a[i+1].ff});
    }
    cout<<x<<endl;
}

Measured memory_bytes: 6256
# AtCoder
import heapq
N, M = map(int, input().split())
AB = [[] for _ in range(M+1)]
for i in range(N):
    A, B = map(int, input().split())
    if M >= A:
        AB[A].append(B)

hp = []
ans = 0

for B in AB:
    for b in B:
        heapq.heappush(hp, (-1)*b)
    if hp:
        ans += heapq.heappop(hp)*(-1)
print(ans)


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

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char& ch) {
	string s = "";
	s += ch;
	return "'" + s + "', ";
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cout << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL_DEFINE
#define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
   
#define int long long
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
typedef pair<int, int> pii;
const int mod = (int) 1000000007; // 998244353;
const int inf = (int) 2e18;
using ld = long double;
const ld pi  = 3.141592653589793238463;

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(9);
	#ifdef LOCAL_DEFINE
		freopen("in.txt", "rt", stdin);
	#endif
	
	
	ld a, b, h, m;
	cin >> a >> b >> h >> m;
	ld dh = (2 * pi / 12.0) * h;
	dh += (2.0 * pi / (12.0 * 60.0)) * m;
	ld dm = (2 * pi / 60.0) * m;
	ld dist = abs(dm - dh);
	debug(dh, dm, dist * 180 / pi);
	ld x = sqrtl(a * a + b * b - 2 * a * b * cos(dist));
	cout << x << '\n';
	
	return 0;
}






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

int main()
{
    int N, M;
    map<string, int> s;
    int ans = 0;

    cin >> N;
    for (int i = 0; i < N; i++)
    {
        string str;
        cin >> str;
        s[str]++;
    }

    cin >> M;
    for (int i = 0; i < M; i++)
    {
        string str;
        cin >> str;
        s[str]--;
    }

    for (auto itr = s.begin(); itr != s.end(); itr++)
    {
        ans = max(ans, itr->second);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
   ll n;
   ll mod=1e9+7;
   cin>>n;
   ll ans=1;
   for(int i=1;i<=n;i++){
       ans*=i;
       ans%=mod;
   }
   cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,x[111],y[111],p,q,ans,mn;
map<pair<long long,long long>,int> mp;
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%d%d",&x[i],&y[i]);
		mp[make_pair(x[i],y[i])]=1;
	}
	mn=1e9;
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=n;j++)
		{
			if (i==j) continue;
			p=x[i]-x[j];q=y[i]-y[j];
			ans=0;
			for (int k=1;k<=n;k++)
			{
				if (mp.find(make_pair(1ll*x[k]+1ll*p,1ll*y[k]+1ll*q))==mp.end()) ans++;
			}
			mn=min(mn,ans);
		}
	}
	if (n==1) printf("1\n");
	else printf("%d\n",mn);
	return 0;
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

ll dx[] = {1,0,-1,0};
ll dy[] = {0,1,0,-1};
string str = "LDRU";

int main(){
	int n;cin >> n;
	
	vector<pair<ll,ll>> v;
	bool parity[2] = {};
	
	REP(i,n){
		ll a,b;cin >> a >> b;
		parity[(a+b)%2] = true;
		v.PB(MP(a,b));
	}
	
	if(parity[0] & parity[1]){
		cout << -1 << endl;
		return 0;
	}
	
	vector<ll> ans;
	ll sum = 0;
	for(int i = 35;i >= 0;i--){
		ans.PB(1LL << i);
		sum += (1LL << i);
	}
	if(parity[0]){
		ans.PB(1);
		sum++;
	}
	
	cout << ans.size() << endl;
	REP(i,ans.size()){
		cout << ans[i];
		if(i != ans.size()-1)cout << ' ';
	}
	cout << endl;
		
	REP(i,n){
	//	cout << i << endl;
		ll x = v[i].FI;
		ll y = v[i].SE;
		ll nsum = sum;
		REP(j,ans.size()){
			nsum -= ans[j];
			REP(k,4){
				ll nx = x + dx[k] * ans[j];
				ll ny = y + dy[k] * ans[j];
				
				if(abs(nx) + abs(ny) <= nsum){
					x = nx;
					y = ny;
					cout << str[k];
					break;
				}
			}
	//		cout << "   " << x << ' ' << y << endl;
		}
		cout << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define mx 10005
//#define y 3
using namespace std;
typedef  long long int ll;
#define  f(i, n) for(int i = 0; i < n; ++i)
#define pb push_back
#include <bitset>

void input(){
ll r, d,x;
cin >> r >> d>> x;
f(i, 10){
    x = (r * x) -d;
    cout << x <<endl;

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



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

int dp[100001][3], a[100001][3];

int main()
{
    int n;
    cin >> n;
    
    for (int i=0; i<n; i++) {
        cin >> a[i][0] >> a[i][1] >> a[i][2];
    }
    
    dp[0][0] = a[0][0];
    dp[0][1] = a[0][1];
    dp[0][2] = a[0][2];
    

    for (int i=1; i<n; i++) {
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i][0];
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + a[i][1];
        dp[i][2] = max(dp[i - 1][1], dp[i - 1][0]) + a[i][2];
    }
    
    
    cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])) << endl;
    return 0;
}

Measured memory_bytes: 6012
void main() {
	auto N = ri;
	auto a = readAs!(long[]);
	ulong now = 0, bad = 0;
	foreach(i; 0..N) {
		if(a[i] == now+1) {
			now++;
		} else bad++;
	}
	if(now == 0) writeln(-1);
	else writeln(bad);
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 11408
#include<iostream>
#include<vector>

using namespace std;

typedef pair<int,int> pii;
typedef vector<int> vi;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

int main(){
    string s;
    while(cin>>s){
        if(s=="#")return 0;
        pii data[10];
        data[0]=pii(3,4);
        data[1]=pii(4,3);
        data[2]=pii(1,4);
        data[3]=pii(-1,5);
        data[4]=pii(3,-1);
        data[5]=pii(2,1);
        string ans="";
        
        int now=0;
        rep(i,s.size()){
            if(s[i]=='0'){
                now=data[now].first;
            }else{
                now=data[now].second;
            }
            if(now==-1){
                ans="No";
                break;
            }
        }
        if(now==1)ans="Yes";
        else ans="No";
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 1188
import java.util.Scanner;

public class Main{

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int amount = 0;
        int maxPrice = 0;
        for (int i = 0; i < N; i++){
            int p = sc.nextInt();
            amount += p;
            if(p > maxPrice) maxPrice = p;
        }
        sc.close();
        amount -= maxPrice / 2;
        System.out.println(amount);

    }

}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    vector<string> S(N);
    vector<int> T(N);
    
    for(int i=0;i<N;i++){
        cin>>S[i]>>T[i];
    }
    
    string X;cin>>X;
    
    int ans=0;
    
    for(int i=0;i<N;i++){
        if(S[i]==X){
            for(int j=i+1;j<N;j++){
                ans+=T[j];
            }
            break;
        }
    }
    
    cout<<ans<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,m,i,l,r,ans;
	int a[100009]={0},b[100009]={0};
	scanf("%d%d",&n,&m);
	for (i=0;i<m;i++)
	{
		scanf("%d%d",&l,&r);
		a[l]++;
		a[r+1]--;
	}
	for (i=1;i<=n;i++)
	{
		b[i]=b[i-1]+a[i];
	}
	ans=0;
	for (i=1;i<=n;i++)
	{
		if (b[i]==m) ans++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#define N 654321
using namespace std;
int n,rt,size[N],fa[N],cnt=0,sum1,sum2;
int TOT,EN[N],LA[N],NE[N];
void ADD(int x,int y)
{
	TOT++;
	EN[TOT]=y;
	NE[TOT]=LA[x];
	LA[x]=TOT;
}
void DFS(int u,int f)
{
	int i,v;
	fa[u]=f;
	size[u]=1;
	for(i=LA[u];i;i=NE[i])
	{
		v=EN[i];
		if(v!=f)
		{
			DFS(v,u);
			size[u]+=size[v];
		}
	}
}
int main()
{
	int i,x,y;
	scanf("%d",&n);
	for(i=1;i<n;i++)
	{
		scanf("%d%d",&x,&y);
		ADD(x,y);ADD(y,x);
	}
	DFS(1,0);i=n;
	while(i!=1)i=fa[i],cnt++;
	cnt--;i=0;x=n;
	while(i<cnt/2)x=fa[x],i++;
	y=fa[x];
	DFS(x,0);
	sum1=size[y];sum2=n-sum1;
	if(sum1>sum2)cout<<"Fennec";
	else cout<<"Snuke";
}


Measured memory_bytes: 16000
#include <bits/stdc++.h>
using namespace std;
int main() {
  int w, h, n;
  cin >> w >> h >> n;
  int x[110], y[110], a[110];
  for(int i=0; i<n; i++){
    cin >> x[i] >> y[i] >> a[i];
  }
  int max1 = 0;
  int min2 = w;
  int max3 = 0;
  int min4 = h;
  for(int i=0; i<n; i++){
    if(a[i]==1) max1 = max(max1, x[i]);
    if(a[i]==2) min2 = min(min2, x[i]);
    if(a[i]==3) max3 = max(max3, y[i]);
    if(a[i]==4) min4 = min(min4, y[i]);
  }
  if(min2<=max1) {
    cout << 0 << endl;
    return 0;
  }
  if(min4<=max3) {
    cout << 0 << endl;
    return 0;
  }
  cout << (min2-max1)*(min4-max3) << endl;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
abm = [list(map(int,input().split())) for _ in range(m)]

countDic = {}

for nn in range(n+1):
	countDic[nn] = 0
	
for ab in abm:
	countDic[ab[0]] += 1
	countDic[ab[1]] += 1

ks = countDic.keys()
ks = sorted(ks)[1:]

for k in ks:
	print(countDic[k])

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
  int n; cin >> n;
  int d=n;
  int sn=0;
  while(n>0){
    int i = n%10;
    sn += i;
    n = n/10;
  }
  //cout << sn << endl;
  if(d%sn==0) cout << "Yes" << endl; // nの初期値をあらかじめコピーしておく.
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<ll, ll> pii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int OO = (int) 2e9;
const double eps = 1e-9;

const int N = 2e5 + 5;

ll n, d, k;
pii a[N];
ll r[N];

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	cin >> n >> d >> k;
	for (int i = 0; i < n; i++)
		cin >> a[i].first >> a[i].second;
	sort(a, a + n);
	ll res = 0, cur = 0;
	for (int i = 0; i < n; i++) {
		cur -= r[i];
		if (cur * k < a[i].second) {
			ll v = a[i].second - cur * k;
			ll need = (v + k - 1) / k;
			res += need;
			cur += need;
			r[upper_bound(a + i + 1, a + n, mp(a[i].first + 2 * d + 1, 0LL)) - a] += need;
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 4992
import static java.lang.Math.*;
import static java.util.Arrays.*;

import java.util.*;
import java.io.*;

public class Main {

	void run() {
		Scanner sc = new Scanner(System.in);
		int m = sc.nextInt();
		for(int k=0;k<m;k++) {
			int c = sc.nextInt(), y = sc.nextInt(), n = sc.nextInt(), max = c;
			for(int i=0;i<n;i++) {
				boolean f = sc.nextInt() == 1;
				double r = sc.nextDouble();
				int t = sc.nextInt();
				if( f ) {
					int cc = c;
					for(int j=0;j<y;j++) cc = (int)((1.0+r)*cc) - t;
					max = max(max, cc);
				}
				else {
					int cc = c, tmp = 0;
					for(int j=0;j<y;j++){ tmp += (int)(r*cc); cc -= t;} 
					max = max(max, cc+tmp);
				}
			}
			System.out.println(max);
		}
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

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

Measured memory_bytes: 40256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
        int b = a;
		String s = sc.next();
        for(int i=1;i<a;i++){if(s.charAt(i)==s.charAt(i-1))
                             {b--;}
                            }
		System.out.println(b);
	}
}


Measured memory_bytes: 24304
#include<bits/stdc++.h>
using namespace std;
using Int = 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;}

//INSERT ABOVE HERE
signed main(){
  string s;
  cin>>s;
  if(s.size()&1) reverse(s.begin(),s.end());
  cout<<s<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    long a,b,c,d,ac,ad,bc,bd,ans;
    // 整数の入力
    scanf("%ld %ld %ld %ld", &a,&b,&c,&d);
    if(a==0){
        a++;
        if(a>b) a=b;
    }
    if(b==0){
        b--;
        if(b<a) b=a;
    }
    if(c==0){
        c++;
        if(c>d) c=d;
    }
    if(d==0){
        d--;
        if(d<c) d=c;
    }
    ac=a*c;
    ad=a*d;
    bc=b*c;
    bd=b*d;
    ans = ac;
    if(ans<ad) ans=ad;
    if(ans<bc) ans=bc;
    if(ans<bd) ans=bd;
    // 出力
    printf("%ld\n",ans);
    return 0;
}

Measured memory_bytes: 1732
#include<stdio.h>
#include<string.h>
#define M 1000001
#define NIL (-1)
#define L 13
char H[M][L];

int getChar(char ch){
  if(ch == 'A')return 1;
  else if(ch == 'C')return 2;
  else if(ch == 'G')return 3;
  else if(ch == 'T')return 4;
}
long long getKey(char str[]){
  long long sum = 0,p = 1,i;
  for(i = 0;i < strlen(str);i++){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}
int h1(int key){
    return key % M;
    }
int h2(int key){
    return 1 + (key % (M-1));
    }
int find(char str[]){
    long long key,i,h;
    key = getKey(str);
    for(i=0;;i++){
        h=(h1(key)+i*h2(key)) % M;
      if(strcmp(H[h],str) == 0)return 1;
      else if(strlen(H[h]) == 0)return 0;
    }
    return 0;
  }
  int insert(char str[]){
   long long key,i,h;
    key = getKey(str);
    for(i=0;;i++){
      h=(h1(key) + i * h2(key)) % M;
      if(strcmp(H[h],str) == 0)return 1;
      else if(strlen(H[h]) == 0){
          strcpy(H[h],str);
          return 0;
      }
    }
    return 0;
  }



int main(){
    int i,n,h;
    char str[L],com[9];
    for(i = 0;i < M;i++){
        H[i][0] = '\0';
    }
    scanf("%d",&n);
    for(i = 0;i < n;i++){
	scanf("%s %s",com,str);
	if(com[0] == 'i'){
	    insert(str);
	}else{
        if(find(str)){
		printf("yes\n");
        }else{
            printf("no\n");
        }
    }
    }return 0;
}



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

int main() {
    ll x;
    cin>>x;
    ll sum=0;
    for(int i=1;i<=x;i++){
        sum+=i;
        if(sum>=x){
            cout<<i;
            break;
        }
    }
}

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

int main() {
  int a, b;
  cin >> a >> b;
  if(a <= 8 && b <= 8) cout << "Yay!" << endl;
  else cout << ":(" << endl;
  
  return 0;
}


Measured memory_bytes: 256
h, w = [int(c) for c in input().split()]

board = [input() for _ in range(h)]

directions = [[-1, 0], [-1, 1], [0, 1], [1, 1], [1, 0], [1, -1], [0, -1], [-1, -1]]


def find_bom(board, row_i, i, direction):
    if -1 < row_i + direction[0] < h and -1 < i + direction[1] < w:
        if board[row_i+direction[0]][i+direction[1]] == "#":
            return 1
        else:
            return 0
    else:
        return 0


new_board = []
for i in range(h):
    new_row = ''
    for j in range(w):
        if board[i][j] != "#":
            bom_count = 0
            for d in directions:
                bom_count += find_bom(board, i, j, d)
            new_row += str(bom_count)
        else:
            new_row += '#'
    new_board.append(new_row)

print('\n'.join(new_board))

Measured memory_bytes: 3064