akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>

using namespace std;

#define fst first
#define snd second
#define all(c) ((c).begin()), ((c).end())
#define TEST(s) if (!(s)) { cout << __LINE__ << " " << #s << endl; exit(-1); }


// adaptive Gauss-Lobatto integrator
template <class F>
double integrate(F f, double lo, double hi, double eps = 1e-8) {
  const double th = eps / 1e-16; // (= eps / machine_epsilon)
  function<double (double,double,double,double)> rec = [&](double x0, double x6, double y0, double y6) {
    const double a = sqrt(2.0/3.0), b = 1.0 / sqrt(5.0);
    double x3 = (x0 + x6)/2, y3 = f(x3), h = (x6 - x0)/2;
    double x1 = x3-a*h, x2 = x3-b*h, x4 = x3+b*h, x5 = x3+a*h;
    double y1 = f(x1),  y2 = f(x2),  y4 = f(x4),  y5 = f(x5);
    double I1 = (y0+y6 + 5*(y2+y4)) * (h/6);
    double I2 = (77*(y0+y6) + 432*(y1+y5) + 625*(y2+y4) + 672*y3) * (h/1470);
    if (x6 - x0 <= 1e-1 && (th + (I1 - I2) == th || x1 <= x0 || x5 >= x6)) return I2;
    return (double)(rec(x0, x1, y0, y1) + rec(x1, x2, y1, y2) + rec(x2, x3, y2, y3) + 
                    rec(x3, x4, y3, y4) + rec(x4, x5, y4, y5) + rec(x5, x6, y5, y6));
  };
  return rec(lo, hi, f(lo), f(hi));
}

// f(X) = max { a[i] (x - p[i])^2 + q[i] }
int n;
double w, h;
vector<double> a, p, q;
double f(double x) {
  double y = 0;
  for (int i = 0; i < n; ++i) 
    y = max(y, a[i] * (x - p[i])*(x - p[i]) + q[i]);
  return y;
}
double g(double x) { // sqrt(1 + (df/dx)^2) if f(x) <= W
  const double EPS = 1e-8;
  double fx = f(x), gx = (f(x+EPS) - f(x-EPS))/(2*EPS);
  if (fx <= 0 || fx >= h) return 0;
  return sqrt(1 + gx*gx);
}


int main() {
  cin >> w >> h >> n;
  a.resize(n); p.resize(n); q.resize(n);
  for (int i = 0; i < n; ++i) 
    cin >> a[i] >> p[i] >> q[i];
  printf("%.12f\n", integrate(g, 0.0, w));
}

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

int main(void) {
  int n;
  cin >> n;
  vector<int> a(n);

  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }

  int max = a.at(1) - a.at(0);
  int min = a.at(0);
  for (int i = 1; i < n; i++) {
   if (max < a.at(i) - min) max = a.at(i) - min;
   if (min > a.at(i)) min = a.at(i);
  }

  cout << max << endl;
}


Measured memory_bytes: 3636
A,B,C,X,Y=map(int,input().split())
if A+B<2*C:print(A*X+B*Y)
else:
    if X>Y:print(min(2*Y*C+(X-Y)*A,2*X*C))
    else:print(min(2*X*C+(Y-X)*B,2*Y*C))

Measured memory_bytes: 3060
use List::Util qw(max);

my $n = glob<>;

for (my $i = 0; $i < $n; $i++) {
    my ($a, $b, $c) = glob<>;
    $h[$i][0] = $a;
    $h[$i][1] = $b;
    $h[$i][2] = $c;
}

for (my $i = 0; $i < $n; $i++) {
    if ($i == 0) {
        $ha[$i] = $h[$i][0];
        $hb[$i] = $h[$i][1];
        $hc[$i] = $h[$i][2];
        next;
    }

    $ha[$i] = max($hb[$i-1] + $h[$i][0], $hc[$i-1] + $h[$i][0]);
    $hb[$i] = max($hc[$i-1] + $h[$i][1], $ha[$i-1] + $h[$i][1]);
    $hc[$i] = max($ha[$i-1] + $h[$i][2], $hb[$i-1] + $h[$i][2]);
}

print(max($ha[$n-1], $hb[$n-1], $hc[$n-1]));

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

int main() {
    
    int n;
    cin>>n;
    int x,y;
    int len=0;int c=0;
    for(int i=0;i<n;i++){
        cin>>x>>y;
        if(x==y){
            len++;
        }
        else if(x!=y)len=0;
        if(len==3){
            cout<<"Yes"<<endl;
            c=1;
            break;
        }
    }
    if(c==0)cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3632
n,m,x = map(int,input().split())
Inf = 10**10
c = [0]*n
a= []
for i in range(n):
  y =  list(map(int,input().split()))
  c[i] = y.pop(0)
  a += [y]
#print(a)
#print(c)
#quit()

def f(i=0, s=[0]*m, p=0):
  if i == n and min(s) >= x:
    #print(s)
    #print(p)
    return p
  elif i == n and min(s) < x:
    return Inf
  else:
    return min(f(i+1,s,p),f(i+1,[s[j]+a[i][j] for j in range(m)],p+c[i]))
  

ans = f()
if ans == Inf:
  ans = -1
print(ans)

Measured memory_bytes: 9188
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll fac(ll a) { return a > 1 ? fac(a - 1) * a : 1; }
bool echeck(ll a) { return a % 2 == 0 ? 1 : 0; }
ll comb(ll n, ll m){
  ll tmp = 1;
  for(int i = n; i >= n - m + 1; i--){
    tmp *= i;
  }
  ll temp = 1;
  for(int i = 1; i <= m; i++){
    temp *= i;
  }
  return tmp / temp;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int>v(n);
  rep(i,n)cin >> v[i];
  int q;
  cin >> q;
  int tmp;
  rep(i,q){
    cin >> tmp;
    cout << lower_bound(all(v),tmp) - v.begin() << endl;
  }
  return 0;
}  


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

int gcd(int x,int y){
    if(y==0)return x;
    x=x%y;
    gcd(y,x);
}
main()
{
    string s;
    cin>>s;
    int a=s.length();
    int c=0,d=0;
    rep(i,a){
        if(s[i]=='0') c++;
        else d++;
    }
    cout<<min(c,d)*2<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
long long freq[63];
int main(){
    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n; cin >> n;
    long long a, MOD = 1000000007LL, tot = 0;
    for(int i = 0; i < n; ++i){
        cin >> a; for(long long j = 0; j < 63; ++j) if((a >> j) & 1) ++freq[j];
    }
    for(long long i = 0; i < 62; ++i) tot = (tot + (1LL << i) % MOD * freq[i] % MOD * (n - freq[i]) % MOD) % MOD;
    cout << tot << "\n";
}

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

using namespace std;

#define INF 1e14+1

typedef long long ll;

template<class T> int former(const vector<T> &v, T x) {
        return upper_bound(v.begin(), v.end(), x) - v.begin() - 1;
}

template<class T> int latter(const vector<T> &v, T x) {
        return lower_bound(v.begin(), v.end(), x) - v.begin();
}

int main() {
    ll A, B, Q; cin >> A >> B >> Q;
    vector<ll> s(A), t(B), xx(Q);

    for (int i = 0; i < A; i++) cin >> s[i];
    for (int i = 0; i < B; i++) cin >> t[i];
    for (int i = 0; i < Q; i++) cin >> xx[i];


    s.push_back(INF);
    s.push_back(-INF);
    t.push_back(INF);
    t.push_back(-INF);

    sort(t.begin(), t.end());
    sort(s.begin(), s.end());

    for (int i = 0; i < Q; i++) {
        long long x = xx[i];
        long long res = INF;

        for (int i = 0; i < 2; i++) {
            long long first = (i ? s[former(s, x)] : s[latter(s,x)]);
            for (int j = 0; j < 2; j++) {
                long long second = (j ? t[former(t, first)] : t[latter(t, first)]);
                res = min(res, abs(x-first) + abs(first - second));
            }
        }
        for (int i = 0; i < 2; i++) {
            long long first = (i ? t[former(t, x)] : t[latter(t,x)]);
            for (int j = 0; j < 2; j++) {
                long long second = (j ? s[former(s, first)] : s[latter(s, first)]);
                res = min(res, abs(x-first) + abs(first - second));
            }
        }

        cout << res << endl;
    }
}


Measured memory_bytes: 3680
#include<stdio.h>
#include<string.h>

int N,N2;

int main(){

  int i,j,c=0;

  scanf("%d",&N);

  int s[N];

  for(i=0;i<N;i++){
    scanf("%d",&s[i]);
  }

  scanf("%d",&N2);

  int s2[N2];

  for(i=0;i<N2;i++){
    scanf("%d",&s2[i]);
  }


  for(i=0;i<N2;i++){
    for(j=0;j<N;j++){
      if(s2[i]==s[j]){
        c++;
        break;
      }
      }
    }


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


  return 0;
}


Measured memory_bytes: 2108
#include <stdio.h>
#include <string.h>
#include <math.h>

int main(void)
{
    int N,L,min=300,i,minnum,ret=0;
    scanf("%d%d", &N, &L);
    for(i=L; i<=L+N-1; i++)
    {
        if(abs(i)<=min)
        {
            min=abs(i);
            minnum=i;
        }
    }
    for(i=L; i<=L+N-1; i++)
    {
        if(i==minnum);
        else ret+=i;
    }
    printf("%d", ret);
    return 0;

}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int n,k;
int S[2010][2010];

void solve(){
  cin >> n >> k;
  rep(i,n){
    int x,y;string c;
    cin >> x >> y >> c;
    if(c=="B") x+=k;
    S[1+x%(2*k)][1+y%(2*k)]+=1;
  }
  // rep(y,2*k+1){
  //   rep(x,2*k+1){
  //     cout << S[x][y] << " ";
  //   }
  //   cout << "" << endl;
  // }
  // cout << "" << endl;
  rep(x,2*k+1){
    rep(y,2*k){
      S[x][y+1]+=S[x][y];
    }
  }
  rep(y,2*k+1){
    rep(x,2*k){
      S[x+1][y]+=S[x][y];
    }
  }
  // rep(y,2*k+1){
  //   rep(x,2*k+1){
  //     cout << S[x][y] << " ";
  //   }
  //   cout << "" << endl;
  // }
  int ans=0;
  Rep(x,1,k+1){
    Rep(y,1,k+1){
      int res=0;
      res+=S[x+k-1][y+k-1]-S[x-1][y+k-1]-S[x+k-1][y-1]+S[x-1][y-1];
      res+=S[x-1][y-1];
      res+=S[x-1][2*k]-S[x-1][y+k-1];
      res+=S[2*k][y-1]-S[x+k-1][y-1];
      res+=S[2*k][2*k]-S[x+k-1][2*k]-S[2*k][y+k-1]+S[x+k-1][y+k-1];
      ans=max(ans,max(n-res,res));
    }
  }
  cout << ans << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

Measured memory_bytes: 16000
import heapq

N, M = map(int, input().split())
AB = sorted([[int(i) for i in input().split()] for i in range(N)], reverse = True)

ans = 0
A = []
for i in range(1, M + 1):
    while AB:
        if AB[-1][0] <= i:
            cand = - AB.pop(-1)[1]
            heapq.heappush(A, cand)
        else:
            break
    
    if A:
        ans += - heapq.heappop(A)
    
print(ans)

Measured memory_bytes: 22448
#include <iostream>
using namespace std;
#define M 100000


long long int n,t,q;
long long int a[M],d[M];
long long int x;
long long int m[M]={0};

long long int meet(int i){
    for (int j=i+1; j<n; j++) {
        if(d[j]==2){
            m[i]=(a[j]+a[j-1])/2;
            return m[i];
        }
    }
    m[i]=a[i]+t;
    return m[i];
}

void output(){
    for (int i=0; i<q; i++) {
        cin>>x;
        x--;
        if(d[x]==1){
            if(a[x]+t<=m[x])cout<<a[x]+t<<endl;
            else cout<<m[x]<<endl;
        }
        else{
            if(a[x]-t>=m[x])cout<<a[x]-t<<endl;
            else cout<<m[x]<<endl;
        }
    }
}

int main(){
    cin>>n>>t>>q;
    for (int i=0; i<n; i++)cin>>a[i]>>d[i];
    long long int tt=a[0]-t;
    for (int i=0; i<n-1; i++) {
        if(d[i]==1)tt=meet(i);
        if(d[i]==2)m[i]=tt;
    }
    if(d[n-1]==1)m[n-1]=a[n-1]+t;
    else m[n-1]=tt;
    output();
    return 0;
}

Measured memory_bytes: 5412
// practice with kaiboy
import java.io.*;
import java.util.*;

public class Main extends PrintWriter {
	Main() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		Main o = new Main(); o.main(); o.flush();
	}

	int[] oo; int[][] oj;
	void link(int i, int j) {
		int o = oo[i];
		if (o >= 2 && (o & o - 1) == 0)
			oj[i] = Arrays.copyOf(oj[i], o << 1);
		oj[i][oo[i]++] = j;
	}
	void init(int n, int m) {
		oo = new int[n]; oj = new int[n][2];
	}
	void main() {
		int n = sc.nextInt();
		int m = sc.nextInt();
		init(n, m);
		while (m-- > 0) {
			int i = sc.nextInt() - 1;
			int j = sc.nextInt() - 1;
			link(i, j);
		}
		int s = sc.nextInt() - 1;
		int t = sc.nextInt() - 1;
		int u = s * 3 + 0;
		int v = t * 3 + 0;
		int inf = n * 3;
		int[] qu = new int[n * 3]; int head = 0, cnt = 0;
		int[] dd = new int[n * 3]; Arrays.fill(dd, inf);
		dd[u] = 0; qu[head + cnt++] = u;
		while (cnt > 0) {
			u = qu[head++]; cnt--;
			int d = dd[u] + 1, i = u / 3, r = (u + 1) % 3;
			for (int o = 0; o < oo[i]; o++) {
				int j = oj[i][o];
				u = j * 3 + r;
				if (dd[u] == inf) {
					dd[u] = d;
					if (u == v) {
						println(d / 3);
						return;
					}
					qu[head + cnt++] = u;
				}
			}
		}
		println(-1);
	}
}


Measured memory_bytes: 63308
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 1000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
signed main(){
	int n,m=1;
	cin>>n;
    m=n;
    int min=LINF;
    for(int i=1;i*i<=n;i++){
        if(n%i==0)min=std::min(i-1+n/i-1,min);
    }
    cout<<min<<endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
arr = sorted(list(map(int, input().split())), reverse=True)

b = arr[0] // 2
i = 0
while True:
    if m == 0:
        break
    if b <= arr[i]:
        arr[i] = arr[i] // 2
        m -= 1
    else:
        arr = sorted(arr, reverse=True)
        i = 0
        b = arr[0] // 2
        continue
    if i < n-1:
        i += 1
    else:
        i = 0

print(sum(arr))

Measured memory_bytes: 63856
#include <bits/stdc++.h>
#define FOR(i, n) for(ll i = 0; i < n; i++)
#define FORR(i, n) for(ll i = n; i >= 0; i--)
#define FORS(i, m, n) for(int i = m;i < n;i++)
#define ALL(v) accumulate(v.begin(),v.end(),0)
#define SORT(v) sort(v.begin(),v.end())
#define OUT(n) (cout << n << endl)
#define IN1(a) (cin >> a)
#define IN2(a,b) (cin >> a >> b)
#define IN3(a,b,c) (cin >> a >> b >> c)
#define IN4(a,b,c,d) (cin >> a >> b >> c >> d)
using namespace std;
typedef long long ll;

int main(){
  ll k,x;
  IN2(k,x);
  FORS(i,x-k+1,x+k){
    cout << i << " ";
  }
  cout << endl;
}

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

mt19937 mt(time(nullptr));
// uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int n, d;
  cin >> n >> d;
  cout << (n-1)/(d*2+1)+1 << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
import collections
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
nsl = lambda: map(str, sys.stdin.readline().split())

a, b, c = nm()

if a <= c <= b:
    print('Yes')
elif b <= c <= a:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3316
use proconio::*;
fn main() {
    input! {
        mut a: usize, mut b: usize, mut c: usize, k: usize
    }
    let mut count = 0;
    let mut score = 0;
    while count != k {
        score += if a > 0 {
            a -= 1;
            1
        } else if b > 0 {
            b -= 1;
            0
        } else {
            c -= 1;
            -1
        };
        count += 1;
    }
    println!("{}", score);
}


Measured memory_bytes: 2092
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define show(x) for(auto i: x){cout << i << " ";}
typedef long long ll;


int main()
{
    int a, b;
    cin >> a >> b;
    
    int minn = min(a, b);
    int maxn = max(a, b);

    rep(i, maxn) cout << minn;
    cout << endl;
}


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

int main() {
  int a, b, k;
  cin >> a >> b >> k;
  int count = 0;
  int i;
  for (i = min(a, b); i > 0; i--) {
    if (a % i == 0 && b % i == 0) {
      count++;
    }
    if (count == k) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}


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

lis = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']


def dfs(ans, keep, n):
    if n == N + 1:
        print(ans)
    else:
        for i in range(keep):
            dfs(ans + lis[i], max(keep, i + 2), n + 1)


dfs('', 1, 1)


Measured memory_bytes: 76404
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
using namespace std;


void koch(int d,double p1[],double p2[]){
	double pi=3.14159265;
	double s[2],u[2],t[2];
	if(d==0)return;
	s[0]=(p1[0]*2+p2[0])/3;
	s[1]=(p1[1]*2+p2[1])/3;
	t[0]=(p1[0]+p2[0]*2)/3;
	t[1]=(p1[1]+p2[1]*2)/3;
	u[0]=(t[0]-s[0])*cos(pi/3.0)-(t[1]-s[1])*sin(pi/3.0)+s[0];
	u[1]=(t[0]-s[0])*sin(pi/3.0)+(t[1]-s[1])*cos(pi/3.0)+s[1];
	//p1,p2からsutを計算 
	koch(d-1,p1,s);
	cout<<s[0]<<' '<<s[1]<<endl;
	koch(d-1,s,u);
	cout<<u[0]<<' '<<u[1]<<endl;
	koch(d-1,u,t);
	cout<<t[0]<<' '<<t[1]<<endl;
	koch(d-1,t,p2);
}

int main(void){
    double p1[2]={0,0},p2[2]={100,0};
    int n;
    cin>>n;
    cout<<p1[0]<<' '<<p1[1]<<endl;
    koch(n,p1,p2);
    cout<<p2[0]<<' '<<p2[1]<<endl;
	return 0;
}



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

const int N=105;

int n,T;
int vis[N],belong[N];

struct Point
{
    int x,y;
}p1[N],p2[N];

vector<int> a[N];

inline int read()
{
    int a=0,f=1; char c=getchar();
    while (c<'0'||c>'9') {if (c=='-') f=-1; c=getchar();}
    while (c>='0'&&c<='9') {a=a*10+c-'0'; c=getchar();}
    return a*f;
}

inline bool judge(Point a,Point b)
{
    return a.x<b.x&&a.y<b.y;
}

inline void insert(int x,int y)
{
    a[x].push_back(y);
}

int find(int x)
{
    for (int i=0;i<a[x].size();i++)
        if (vis[a[x][i]]!=T)
        {
            vis[a[x][i]]=T;
            if (!belong[a[x][i]]||find(belong[a[x][i]]))
            {
                belong[a[x][i]]=x;
                return 1;
            }
        }
    return 0;
}

inline int Hungary()
{
    int ans=0;
    for (int i=1;i<=n;i++)
    {
        T++;
        if (find(i)) ans++;
    }
    return ans;
}

int main()
{
    n=read();
    for (int i=1;i<=n;i++)
        p1[i].x=read(),p1[i].y=read();
    for (int i=1;i<=n;i++)
        p2[i].x=read(),p2[i].y=read();
    for (int i=1;i<=n;i++)
        for (int j=1;j<=n;j++)
            if (judge(p1[i],p2[j])) insert(i,j);
    cout << Hungary() << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    bool col[8];
    memset(col, 0,sizeof(col));
    ll n;
    cin >> n;
    bool maki= 0;
    ll a, cnt = 0;
    for(int i=0;i<n;i++){
    	cin >> a;
    	a /= 400;
    	if(a >= 8LL){
    		cnt++;
    	}else{
    		col[a]=true;
    		maki = true;
    	}
    }
    if(!maki){
    	cout << 1 << " " << cnt << endl;
    }else{
    	ll num = 0;
    	for(int i=0;i<8;i++){
    		if(col[i]) num++;
    	}
    	cout << num << " " << num + cnt << endl;
    }
    return 0;
}


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

int main()
{
        double x1=0.0, y1=0.0, x2=0.0, y2=0.0;

        scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
        printf("%f\n", sqrt( ( x1 - x2 ) * (x1 - x2 ) + ( y1 - y2 ) * ( y1 - y2 ) ) );

        return 0;
}

Measured memory_bytes: 652
import math

n = input()
x = map(float, raw_input().split())
y = map(float, raw_input().split())
temp = p1 = p2 = p3 = pinf = 0

for i,j in zip(x, y):
    temp = math.fabs(i - j)
    p1 += temp
    p2 += temp ** 2
    p3 += temp ** 3
    if temp > pinf:
        pinf = temp

print u"%f\n%f\n%f\n%f" % (p1, p2**(1.0/2), p3**(1.0/3), pinf)

Measured memory_bytes: 6656
l=[]
l.append(int(input()))
l.append(int(input()))
l.append(int(input()))
l.append(int(input()))
l.append(int(input()))
t=[]
for e in l:
    t.append(e%10)
s=0
i=0
while 0 in t:
    j=t.index(0)
    t[j]=-1
    s+=l[j]
    i+=1
while i<4:
    j=t.index(max(t))
    t[j]=-1
    s+=l[j]-l[j]%10+10
    i+=1
if i==4:
    j=t.index(max(t))
    s+=l[j]
print(s)

    


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<algorithm>
#define int long long
#define ll long long
#define vel vector<ll>
#define vvel vector<vel>
#define veb vector<bool>
#define pin pair<int,int>
#define mp make_pair 
#define int long long
using namespace std;
void mmin(int &a, int b) { a = min(a, b);}
int root1(vel &par, int ser, vel &path) {
	if (par[ser] == -1) {
		for (int i = 0; i < path.size(); i++) {
			par[path[i]] = ser;
		}
		return ser;
	}
	path.push_back(ser);
	return root1(par, par[ser], path);
}
int root(vel &par, int ser) {
	vel emp(0);
	return root1(par, ser, emp);
}
void uni(int x, int y, vel &par) {
	x = root(par, x);
	y = root(par, y);
	if (x != y) { par[x] = y; }
}
bool issame(int x, int y, vel &par) {
	return root(par, x) == root(par, y);
}
signed main() {
	int n, m; cin >> n >> m;
	int su = n + m;
	vel pa(su, -1);//gengo hito
	for (int i = 0; i < n; i++) {
		int k; cin >> k;
		for (int j = 0; j < k; j++) {
			int l; cin >> l; l--;
			uni(i + m, l, pa);
		}
	}
	int x = 0;;
	for (int i = 0; i < n-1; i++) {
		if (issame(i + m, i + 1 + m,pa)) { x++; }
	}
	if (x == n-1) { cout << "YES" << endl; }
	else { cout << "NO" << endl; }
	return 0;
}

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(){
    string S;
    cin >> S;
    int N = S.size(), MOD = 1000000007;

    long long dp[100010][4] = {};
    for(int i = N; i >= 0; --i){
        for(int j = 3; j >= 0; --j){
            if(i == N){
                dp[i][j] = (j == 3 ? 1 : 0);
            }else{
                dp[i][j] = dp[i+1][j] * (S[i] == '?' ? 3LL : 1LL);
                if(j < 3 && (S[i] == '?' || S[i] == "ABC"[j])){
                    dp[i][j] += dp[i+1][j+1];
                }
                dp[i][j] %= MOD;
            }
        }
    }
    cout << dp[0][0] << endl;
}


Measured memory_bytes: 3584
import string
H, W = map(int, input().split())
hw = [list(input().split()) for _ in range(H)]
ans = []
sans = ''
for i in range(H):
    for j in range(W):
        if hw[i][j] == 'snuke':
            ans.append(i)
            ans.append(j)
            break

sans = string.ascii_uppercase[ans[1]] + str(ans[0] + 1)

print(sans)

Measured memory_bytes: 3772
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    int m;
    cin >> m;
    cin >> s;
    for(int i = 0; i < s.size(); i++)
        s[i] = (s[i] - 'A' + m) % 26 + 'A';
    cout << s<< endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;


public class Main {
    public static void main(String[] args) {
        FastScanner fsc = new FastScanner();
        char[] s=fsc.next().toCharArray();
        char[] t="CODEFESTIVAL2016".toCharArray();
        int a=0;
        for(int i=0;i<s.length;i++){
            if(s[i]!=t[i]) ++a;
        }
        System.out.println(a);
    }
}


class FastScanner {
    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() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; 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 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();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 22356
N,M = map(int, input().split())
sels = []
for _ in range(M):
    a,b = map(int, input().split())
    sels.append([a,b])

sels = sorted(sels, key = lambda x:x[1])
start = sels[0][0]
end = sels[0][1]
ans = 1

for item in sels:
    if end <= item[0]:
        start = item[0]
        end = item[1]
        ans += 1

print(ans)


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

#define M 1000000007
#define MM 998244353 
#define ll long long 
#define pb push_back
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define PI 3.1415926536
#define INF 2e18
#define endl "\n"

ll power(ll b,ll e,ll m)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b%m,e/2,m)%m;
	return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b,e/2);
	return power(b*b,e/2);
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	string s;
	cin>>s;
	for(int i=0;s[i];++i)cout<<"x";
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> A(N, vector<int>(M));
    rep(i, N) rep(j, M) cin >> A[i][j];
    set<int> se;
    for(int i = 1; i <= M; i++) {
        se.insert(i);
    }
    int res = INF;
    vector<int> cur(N, 0);
    rep(i, M) {
        vector<int> cnt(M);
        rep(j, N) { cnt[A[j][cur[j]] - 1]++; }
        int tmp = 0;
        int most = 0;
        rep(j, M) {
            if(tmp < cnt[j]) {
                most = j;
                tmp = cnt[j];
            }
        }
        res = min(res, tmp);
        se.erase(most + 1);
        rep(j, N) {
            if(se.empty())
                break;
            while(!se.count(A[j][cur[j]]))
                cur[j]++;
        }
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 4000
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <numeric>
#include <utility>
#include <iomanip>

using namespace std;
using int64 = long long;

struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

int main() {
    int n;
    cin >> n;
    int cnt = 0;
    for (int a=1; a<n; a++)
        cnt += (n-1)/a;
    cout << cnt << endl;
}


Measured memory_bytes: 3188
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(in);
String Sa=sc.next();
String Sb=sc.next();
String Sc=sc.next();
int a=Sa.length(),b=Sb.length(),c=Sc.length();
char p=Sa.charAt(Sa.length()-a);
a--;
while(true){
    switch(p){
        case 'a':
            if(a==0){
                out.println("A");
                exit(0);
            }
            p=Sa.charAt(Sa.length()-a);
            a--;
            break;
        case 'b':
            if(b==0){
                out.println("B");
                exit(0);
            }
            p=Sb.charAt(Sb.length()-b);
            b--;
            break;
        case 'c':
            if(c==0){
                out.println("C");
                exit(0);
            }
            p=Sc.charAt(Sc.length()-c);
            c--;
            break;
    }
}
}}

Measured memory_bytes: 22228
#include<cstdio>

int main(){
    int count[1201];
    char ch;
    while(scanf("%c",&ch) != EOF){
        if(ch >= 'a' && ch <= 'z'){
            count[ch - 'a']++;
        }
        else if(ch >= 'A' && ch <= 'Z'){
            count[ch - 'A']++;
        }
    }
    for(int j = 0;j < 26; j++){
        printf("%c : %d\n",j + 'a',count[j]);
    }
    return 0;
}


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

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


Measured memory_bytes: 256
n, m, l = list(map(int, input().split()))

a = [list(map(int, input().split())) for i in range(n)]
b = [list(map(int, input().split())) for i in range(m)]

for i in range(n):
    print(*[sum([a[i][k]*b[k][j] for k in range(m)]) for j in range(l)])

Measured memory_bytes: 8556
import java.util.Scanner;
import java.util.stream.IntStream;
import java.util.stream.LongStream;

/**
 * 解説通りに作成したソースコード
 */
public class Main {

	/** Nの最大値 */
	private static final int N = 50;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			long k = scanner.nextLong();
			long[] a = new long[N];
			IntStream.range(0, N).forEach(i -> a[i] = k / N + i);
			LongStream.range(0, k % N).forEach(l -> calcReverse(a, (int) (l % N)));
			System.out.println(N);
			IntStream.range(0, N - 1).forEach(i -> System.out.print(a[i] + " "));
			System.out.println(a[N - 1]);
		}
	}

	/**
	 * 指定された操作の逆操作を実施
	 * 
	 * @param a     操作対象の配列
	 * @param index 足し算をするindex
	 */
	private static void calcReverse(final long[] a, final int index) {
		a[index] += N + 1;
		IntStream.range(0, N).forEach(i -> a[i]--);
	}
}


Measured memory_bytes: 39100
#include<stdio.h>

int gcd(int x, int y);

int main(){
	int a = 0, b = 0;
	scanf("%d", &a);
	scanf("%d", &b);

	if( a > b){
		int temp = a;
		a = b;
		b = temp;
	}

	printf("%d\n", gcd(a, b));

	return 0;
}

int gcd(int x, int y){
	if( y == 0 ){
		return x;
	}
	return gcd(y, x%y);
}

Measured memory_bytes: 1020
/*input
7
6 7 8
8 8 3
2 5 2
7 8 6
4 6 8
2 3 4
7 5 1
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin >> n;
    vector<ll> a(n);
    vector<ll> b(n);
    vector<ll> c(n);
    vector<vector<ll>> dp(n, vector<ll> (3));
    for(int i = 0; i < n; i++) cin >> a[i] >> b[i] >> c[i];
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];
    for(int i = 1; i < n; i++)
    {
    	dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
    	dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i];
    	dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i];
    }
    cout << max({dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]});

    return 0;
}

Measured memory_bytes: 8064
/**
 *      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 <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// 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) cout << #x << ": " << (x) << '\n'

const int MAX_N = 110;
const int MAX_W = 101010;

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

  int N, W; cin >> N >> W;
  int64 w[N], v[N];
  for (int i = 0; i < N; ++i) cin >> w[i] >> v[i];

  int64 dp[MAX_N][MAX_W];  // dp[i + 1][j] : i 個目まで見て重さが j 以下のときの価値の総和の最大値
  
  for (int i = 0; i < MAX_N; ++i){
    for (int j = 0; j < MAX_W; ++j) dp[i][j] = 0;
  }
  
  for (int i = 0; i < N; ++i){
    for (int j = 0; j <= W; ++j){
      if (j < w[i]) dp[i + 1][j] = dp[i][j];
      else dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
    }
  }
  
  print(dp[N][W]);

  return 0;
}

Measured memory_bytes: 87040
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <set>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()

int main() {
    vector<int> v;
    PUSH(5,v);
    sort(ALL(v), greater<int>());
    REP(i,4) cout << v[i] << " ";
    cout << v[4] << endl;
    return 0;
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1000000007;
const ll N=998244353;
ll power(ll x,ll n){ll res=1;while(n>0){if(n&1) res=res*x%MOD;x=x*x%MOD;n>>=1;}return res;}
ll modinverse(ll a){return power(a, MOD-2);}
void solve()
{
    ll n;
    cin>>n;
    map<ll, ll> mp1;
    vl a(n);
    forr(i, n)
    {
    	cin>>a[i];
    	mp1[a[i]]++;
    }
    if(mp1.find(1)==mp1.end())
    {
    	cout<<-1<<endl;
    	return;
    }
    ll to_be_found=1;
    for(ll i=0; i<n; i++)
    {
    	if(a[i]==to_be_found)
    	{
    		to_be_found++;
    	}
    }
    cout<<(n-to_be_found+1)<<endl;
}
int main()
{
	#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll test=1;
    //cin>>test;
    while(test--)
    {
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

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

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


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

    
    int k;
    cin>>k;

    rep(i,k){
        cout<<"ACL";
    }
    cout<<endl;
    







}

Measured memory_bytes: 3644
import sys
input=sys.stdin.readline
def ch(s):
  if s == '10':
    return int(s)
  elif s == '00':
    return 0
  elif 2 > s.count('0') > 0:
    return int(s.replace('0',''))
  elif s.count('0') == 2:
    return 0
  else:
    return int(s)

S = input()
a = ch(S[:2])

b = ch(S[2:])

if 1 <= a <= 12 and 1 <= b <= 12:
  print('AMBIGUOUS')
elif 1<= a <= 12:
  print('MMYY')
elif 1<= b <= 12:
  print('YYMM')
else:
  print("NA")

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>


int main()
{
	char ar[100][101];
	
	int i, j, k=0, m, n;
	scanf("%d%d", &m, &n);
	getchar();
	for(i=0; i<m; i++)
		gets(ar[i]);
		
	for(i=0; i<m; i++){
		k=0;
		for(j=0; j<n; j++) if(ar[i][j]=='.') k++;
		if(k==n) for(j=0; j<n; j++) ar[i][j]='0';
	}
	
	for(i=0; i<n; i++){
	    k=0;
		for(j=0; j<m; j++) if(ar[j][i]=='.' || ar[j][i]=='0') k++;	
    	if(k==m) for(j=0; j<m; j++) ar[j][i]='0';
	}
	
	for(i=0; i<m; i++){
	    k=0;
	    for(j=0; j<n; j++){
	        if(ar[i][j]!='0'){
	            printf("%c", ar[i][j]);
	            k=1;
	        }
	    }
	    if(k==1) printf("\n");
	}	
	return 0;
}
	

Measured memory_bytes: 256
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import Data.List (sort)

main :: IO ()
main = do
  (n : k : _) <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  hs <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  print . sum . take (n - k) . sort $ hs

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 32124
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int X[] = new int[M];
		int a[][] = new int[M - 1][2];
		for(int i = 0; i < M; i++) {
			X[i] = sc.nextInt();
		}
		Arrays.sort(X);
		
		for(int i = 0; i < M; i++) {
			if(i > 0) {
				a[i - 1][0] = i - 1;
				if(X[i] <= 0 && X[i - 1] <= 0) {
					a[i - 1][1] = Math.abs(X[i] - X[i - 1]);
				} else if(X[i] > 0 && X[i - 1] <= 0){
					a[i - 1][1] = Math.abs(X[i]) + Math.abs(X[i - 1]);
				} else {
					a[i - 1][1] = X[i] - X[i - 1];
				}
			}
		}
		Arrays.sort(a, Comparator.comparingInt(o -> o[1]));
		
		int ans = 0;
		for(int i = M - N - 1; i >= 0; i--) {
			ans += a[i][1];
		}
		System.out.println(ans);
		
	}
}


Measured memory_bytes: 63264
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.14159265358979323846264338327950
#define pow2(a) a*a


int main(){
  double a,b,h,m;
  long double c;
  scanf("%lf %lf %lf %lf",&a,&b,&h,&m);
  double abrad = h*30 + m/2 -m*6;
  if(abrad <0) abrad *= -1;
  if(abrad >180) abrad =360 -abrad;
  abrad = abrad * PI /180;
  c = sqrt(pow2(a)+pow2(b)-(2*a*b)*cos(abrad));
  //printf("%lf %lf \n",pow2(a),pow2(b));
  printf("%20.20llf",c);
}

Measured memory_bytes: 2600
#include<iostream>
#include <algorithm>
#include <stdlib.h>
using namespace std;

int main(void) {
	long long int n, a, b, m, l;
	int i;
	bool flag = true;
	cin >> a >> b;
	for (i = 0;; i++) {
		if ((i * 0.08 >= a && i * 0.08 < a + 1)&& (i * 0.10 >= b && i * 0.10 < b + 1))break;
		if (i * 0.08 >= a + 1 || i * 0.10 >= b + 1) {
			i = -1;
			break;
		}
	}
	cout << i << endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	var ps, ys []int
	for i := 0; i < m; i++ {
		var p, y int
		fmt.Scan(&p, &y)
		ps = append(ps, p)
		ys = append(ys, y)
	}

	p2cs := make(map[int][]int)
	for i := 0; i < m; i++ {
		ar := p2cs[ps[i]]
		p2cs[ps[i]] = append(ar, ys[i])
	}

	sorted_m := make(map[int][]int)
	for k, v := range p2cs {
		sort.Ints(v)
		sorted_m[k] = v
	}

	for i := 0; i < m; i++ {
		p := ps[i]
		y := ys[i]
		r := rank(sorted_m[p], y)
		format(p, r)
	}
}

func format(p, r int) {
	fmt.Printf("%06d%06d\n", p, r)
}

func rank(sorted []int, v int) int {
	l := 0
	r := len(sorted)
	for l+1 < r {
		m := (l + r) / 2
		if v < sorted[m] {
			r = m
		} else {
			l = m
		}
	}
	return l + 1
}


Measured memory_bytes: 23680
#include <bits/stdc++.h>
#define pb push_back
#define vii vector<int>
#define task "RESORT"
#define pll pair<ll, ll>
#define pii pair< ll, pair< ll, ll > >
#define fi first
#define se second

using ll = long long;
using ld = long double;
using ull = unsigned long long;
const int mod = 1e9 + 7;
using namespace std;
const int N = 5005;
ll n, m, a[N], b[N], ma[N][N], k, T, tong, d[N][N], ans, t, s;
;
bool ck;

inline void sol()
{
	cin >> n >> m;
	for(int i = 0; i <= n; i ++)
    {
        if(m >= i * 2 && (m - i * 2) % 4 == 0 && (m - i * 2) / 4 + i == n)
        {
            cout << "Yes";
            return;
        }
    }
    cout << "No";
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    if(fopen(task".INP", "r"))
    {
		freopen(task".INP","r",stdin);
		freopen(task".OUT","w",stdout);
    }
    sol();

}
/*
3 11
4 1 3 7 8
5 2 3 4 5 6
4 11 10 9 8
4 9
*/


Measured memory_bytes: 3644
x = int(input())

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

p = make_divisors(x)

for i in p:
  for b in range(-1000,1000):
    if (b+i)**5 - b**5 == x:
      print(b+i,b)
      exit()

Measured memory_bytes: 9108
import java.util.*;

public class Main implements Runnable {

    private static int n;
    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) throws Exception {

        new Thread(null, new Main(), "", 16 * 1024 * 1024).start();
    }

    public void run() {
        n = sc.nextInt();
        int ans = dfs(0, false);
        System.out.println(ans);
    }

    private static int dfs(long num, boolean flag) {//深さ優先探索
        if (num > n) return 0;
        String s = String.valueOf(num);
        int count = 0;

        if (!flag) {
            if (s.contains("3") && s.contains("5") && s.contains("7")) {
                count++;
                flag = true;
            }
        } else {
            count++;
        }

        return count + dfs(10 * num + 3, flag) + dfs(10 * num + 5, flag) + dfs(10 * num + 7, flag);
    }
}


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


int main() {
  int h , w;
  cin >> h >> w;
  vector<vector<char>> data(h+2,vector<char>(w+2));
  
  for(int i=1;i<h+1;i++){
    for(int j=1;j<w+1;j++){
      cin >> data.at(i).at(j);
    }
  }
  
   vector<int> dx = {-1,0,1,1,1,0,-1,-1};
   vector<int> dy =  {1,1,1,0,-1,-1,-1,0};
  
  for(int i=1;i<h+1;i++){
    for(int j=1;j<w+1;j++){
      if(data.at(i).at(j) == '.'){
        int count = 0;
        for(int k=0;k<8;k++){
          if(data.at(i+dx.at(k)).at(j+dy.at(k)) == '#')
            count ++;
        }
          cout << count ;
      }
       else
          cout << '#';
      }
      cout << endl;
    }

        
  
  
}



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

void counting_sort(vector<int> a, vector<int> &b, int k) {
    vector<int> c(k);
    int n = a.size();

    rep(i, n) {
        c.at(a.at(i))++;
    }
    for (int i = 1; i < k; i++) {
        c[i] = c[i] + c[i-1];
    }

    for (int i = n-1; 0 <= i; i--) {
        b[c[a[i]]-1] = a[i];
        c[a[i]]--;
    }
}

int main() {
    int n; cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    rep(i, n) cin >> a.at(i);
    counting_sort(a, b, 10000);

    rep(i, n) {
        cout << b.at(i);
        if (i != n -1) cout << " ";
    }
    cout << endl;
}


Measured memory_bytes: 26268
N = int(input())
A= list(map(int, input().split()))
print(" ".join(map(str, A)))
for i in range(1, N):
    v = A[i]
    j = i-1
    while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
    print(" ".join(map(str, A)))


Measured memory_bytes: 5596
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author vdewansa
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        LDeque solver = new LDeque();
        solver.solve(1, in, out);
        out.close();
    }

    static class LDeque {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int[] a = new int[N + 1];
            for (int i = 1; i <= N; i++) {
                a[i] = in.nextInt();
            }
            long[] v = new long[N + 1];
            for (int start = N; start >= 1; start--) {
                v[start] = a[start];
                for (int end = start + 1; end <= N; end++) {
                    v[end] = Math.max(a[start] - v[end], a[end] - v[end - 1]);
                }
            }
            out.println(v[N]);
        }

    }
}



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

int main(){
  int N;
cin >> N;
string S;
cin >> S;
long long r = 0;
long long g = 0;
long long b = 0;
for(int i = 0; i < N; i++) {
    if(S[i] == 'R') r += 1;
    else if(S[i] == 'G') g += 1;
    else if(S[i] == 'B') b += 1;
}

long long ans = r * b * g;
long long s = 0;
for(int i = 0; i < N; i++) {
    for(int j = i + 1; j < N; j++) {

        if(S[i] == S[j]) continue;
        int k = 2 * j - i;
        if(k >= N || S[k] == S[j] || S[i] == S[k]) continue;
        s++;
    }
}

  cout<<ans-s;

  return 0;
}


Measured memory_bytes: 3608