akhauriyash/Code-Regression huggingface dataset:
using System;

namespace A
{
    class Program
    {
        public static readonly string s = "Sunny";
        public static readonly string c = "Cloudy";
        public static readonly string r = "Rainy";
        static void Main(string[] args)
        {
            string x = Console.ReadLine();
            switch (x)
            {
                case "Sunny":
                   Console.WriteLine(c);
                   break;
                case "Cloudy":
                    Console.WriteLine(r);
                    break;
                case "Rainy":
                    Console.WriteLine(s);
                    break;
            }
        }
    }
}


Measured memory_bytes: 25628
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"l=sorted(map(int,open(0).read().split()[1:]))\n"
"a=sum(l)\n"
"if a%10:print(a);exit()\n"
"for t in l:\n"
" if t%10:print(a-t);exit()\n"
"print(0)\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 3280
arg_N, arg_K = map(int,input().split())

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**4 # N >= n
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


for i in range(1,arg_K+1):
    print((cmb(arg_N-arg_K+1,i,mod)*cmb(arg_K-1,i-1,mod))%mod)

Measured memory_bytes: 4584
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

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

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 = 100005;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int x, a;
    cin >> x >> a;
    if( x < a ) cout << 0 << endl;
    else cout << 10 << endl;
    return 0;
}



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


int main(void)
{
    int score[100];
    int N, M;
    int A[100];
    int B;
    int i, j;
    
    memset(score, 0, sizeof(score));

    scanf("%d%d", &N, &M);
    
    for (i = 0; i < M; i++){
        scanf("%d", &A[i]);
    }
    
     for (i = 0; i < M; i++){
        for (j = 0; j < N; j++){
            scanf("%d", &B);
            if (B == A[i]){
                score[j]++;
            }
            else {
                score[A[i] - 1]++;
            }
        }
     }
     
     for (i = 0; i < N; i++){
        printf("%d\n", score[i]);
     }
     
     return (0);
}

    

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

using namespace std;

typedef long long ll;

const int N=(int)1e5+7;
int l[N];

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

        for(int i=1;i<=9;i++)
                l[i]=1;
        int n;
        cin>>n;
        for(int i=10;i<=n;i++)
                l[i]=1+l[i/10];
        int sum=0;
        for(int i=1;i<=n;i++)
                sum+=(l[i]%2==1);
        cout<<sum<<"\n";

        return 0;
}



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

using namespace std;

struct Edge{
  int to,weight;
  Edge(int to,int weight) :
    to(to),weight(weight) {}
};

typedef vector<int> Vec;
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

int visit(const Graph &g,Graph &T,int u,int v){
  if(T[u][v].weight >= 0){
    return T[u][v].weight;
  }
  T[u][v].weight = g[u][v].weight;
  int w = T[u][v].to;
  for(int i = 0 ; i < (int)T[w].size() ; i++){
    if(T[w][i].to == u) continue;
    T[u][v].weight = max(T[u][v].weight,visit(g,T,w,i)+g[u][v].weight);
  }
  return T[u][v].weight;
}

Vec solve(const Graph &g){
  int N = g.size();
  Graph T(g);
  for(int i = 0 ; i < N ; i++){
    for(int j = 0 ; j < (int)T[i].size() ; j++){
      T[i][j].weight = -1;
    }
  }
  for(int i = 0 ; i < N ; i++){
    for(int j = 0 ; j < (int)T[i].size() ; j++){
      if(T[i][j].weight < 0){
        T[i][j].weight = visit(g,T,i,j);
      }
    }
  }
  Vec res(N);
  for(int i = 0 ; i < N ; i++){
    int max = 0;
    for(int j = 0 ; j < (int)T[i].size() ; j++){
      max = std::max(max,T[i][j].weight);
    }
    res[i] = max;
  }
  return res;
}

int main(){
  int N,a,b,c;
  cin >> N;
  Graph g(N);
  for(int i = 0 ; i < N-1 ; i++){
    cin >> a >> b >> c;
    g[a].push_back(Edge(b,c));
    g[b].push_back(Edge(a,c));
  }
  Vec v = solve(g);
  for(int i = 0 ; i < N ; i++){
    cout << v[i] << endl;
  }
  return 0;
}

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

typedef long long ll;

ll ruijyo(ll a,ll n){
    if(n==0) return 1;
    ll x = ruijyo(a,n/2);
    x = x * x;
    if(n%2==1) x = x * a;
    return x;
}

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

    int n,k;
    cin >> n >> k;
    double ans = 1 / (double)n;
    double sum = 0.0;
    for(int i=0;i<n;i++){
        int now = i + 1;
        int cnt = 0;
        while(now<k){
            cnt++;
            now *= 2;
        }
        sum += (double)1 / ruijyo((ll)2,(ll)cnt);
    }
    ans *= sum;
    printf("%.12lf\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
const ll INF=1e18;

int main(){
    ll h,w;cin>>h>>w;
    ll m=INF;
    ll  a,b,c;
    for(ll i=0;i<h;i++){
        a=w*i;
        b=(w/2)*(h-i);
        c=w*h-a-b;
        m=min(m,max(max(a,b),c)-min(min(a,b),c));

        b=w*((h-i)/2);
        c=w*h-a-b;
        m=min(m,max(max(a,b),c)-min(min(a,b),c));
    }
    for(ll j=0;j<w;j++){
        a=h*j;
        b=(h/2)*(w-j);
        c=w*h-a-b;
        m=min(m,max(max(a,b),c)-min(min(a,b),c));

        b=h*((w-j)/2);
        c=w*h-a-b;
        m=min(m,max(max(a,b),c)-min(min(a,b),c));
    }
    cout<<m<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    ll q, h, s, d; cin >> q >> h >> s >> d;
    ll n; cin >> n;
    
    ll min2 = min(min(d, s * 2), min(h * 4, q * 8));
    ll min1 = min(s, min(h * 2, q * 4));
    
    cout << min2 * (n / 2) + min1 * (n % 2) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define randome_generate srand(std::chrono::high_resolution_clock::now().time_since_epoch().count())
using namespace std;
int n,p;
long long m,v,a[100100],b[100100],del[100100],cur,vote;
bool check(int x){//二分
	for(int i=1;i<=n;i++){
		b[i]=a[i];
		del[i]=0;
	}
	cur=a[x]+m;
	vote=m*v-m;
	b[x]+=m;
	int tmp=x;//交换，排序 
	while(tmp>1&&b[tmp]>b[tmp-1]){
		swap(b[tmp],b[tmp-1]);
		tmp--;
	}
	int xxx;
	for(int i=1;i<=n;i++)//找到它的位置 
		if(b[i]==cur){
			xxx=i;
			break;
		}
	xxx--;
	if(xxx>=p)
		return false;
	for(int i=n;i>xxx+1;i--){//计算：比它小的 
		long long delta=min((cur-b[i]),m);//尽力补 
		vote-=delta;
		del[i]=delta;
		b[i]+=delta;
		if(vote<=0){
			return true;//投完了 
		}
	}
	for(int i=1;i<=xxx;i++){
		vote-=m;
		b[i]+=m;
		if(vote<=0){
			return true;
		}
	}
	int fore=xxx;
	for(int i=xxx+2;i<=n;i++){
		vote-=(m-del[i]);
		if(b[i]+(m-del[i])>cur)
			fore++;
		if(vote<=0){
			if(fore<p)
				return true;
		}
	}
	return false;
}
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>m>>v>>p;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	reverse(a+1,a+n+1);
	int l=1,r=n,mi;
	while(l<r){
		mi=(l+r+1)/2;
		if(check(mi))
			l=mi;
		else
			r=mi-1;
	}
	cout<<l<<endl;
	return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<math.h>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<unordered_map>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep2(i,n) for(int i = -1; i < (n); i++)
#define PI 3.141592653589793

using namespace std;
using ll = long long;

const ll MA = 1000005;
int cnt[2];
int c[2];
int main() {

	int n;
	cin >> n;
	vector<int> p(n);
	int ans = 0;
	rep(i, n)cin >> p[i];

	for (int i = 1; i < n - 1; i++) {
		vector	<int> x;
		x.push_back(p[i - 1]);
		x.push_back(p[i]);
		x.push_back(p[i + 1]);

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

		if (x[1] == p[i]) ans++; 

	}

	cout << ans << endl;

	return 0;
}


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

int main(){

	while(true){
		string point;
		cin>>point;

		if(point=="0")
			break;
	
		int A=0,B=0;
	
		for(int i=1;i<point.size();i++){
			if(point[i]=='A'){
				A++;
			}
			else{
				B++;
			}
		}
		if(A>B){
			A++;
		}
		else{
			B++;
		}
		cout<<A<<' '<<B<<endl;
	}
	return 0;
}
	

Measured memory_bytes: 1188
#include <stdio.h>
#define MAX 100000
#define SENTINEL 2000000000
 
struct Card {
  char suit;
  int value;
};
 
struct Card L[MAX/2+2], R[MAX/2+2];
 
void merge(struct Card A[], int n, int left, int mid, int right) {
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;
  for(int i=0;i<n1;i++) L[i] = A[left + i];
  for(int i=0;i<n2;i++) R[i] = A[mid  + i];
  L[n1].value = R[n2].value = SENTINEL;
  i = j = 0;
  for(k=left; k<right; k++) {
    if(L[i].value <= R[j].value) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}
 
void mergeSort(struct Card A[], int n, int left, int right) {
  if(left+1 < right) {
    int mid = (left+right) / 2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid, right);
    merge(A,n,left,mid,right);
  }
}
 
int partition(struct Card A[], int n, int p, int r) {
  int i, j;
  struct Card t, x;
  x = A[r];
  i = p-1;
  for(j=p; j<r; j++) {
    if(A[j].value <= x.value) {
      i++;
      t=A[i]; A[i]=A[j]; A[j]=t;
    }
  }
  t=A[i+1]; A[i+1]=A[r]; A[r]=t;
  return i+1;
}
 
void quickSort(struct Card A[], int n, int p, int r) {
  int q;
  if(p<r) {
    q = partition(A,n,p,r);
    quickSort(A,n,p,q-1);
    quickSort(A,n,q+1,r);
  }
}
 
int main() {
  int n, i, v;
  struct Card A[MAX], B[MAX];
  char S[10];
  int stable = 1;
 
  scanf("%d", &n);
 
  for(i=0;i<n;i++) {
    scanf("%s %d",S,&v);
    A[i].suit =  B[i].suit  = S[0];
    A[i].value = B[i].value = v;
  }
 
  mergeSort(A,n,0,n);
  quickSort(B,n,0,n-1);
 
  for(i=0;i<n;i++) {
    if(A[i].suit != B[i].suit) stable = 0;
  }
 
  if(stable==1) printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<n;i++) {
    printf("%c %d\n",B[i].suit,B[i].value);
  }
 
  return 0;
}

Measured memory_bytes: 4068
def compare(hw1, hw2)
  d1 = hw1[0]**2 + hw1[1]**2
  d2 = hw2[0]**2 + hw2[1]**2
  [d1, hw1[0]] <=> [d2, hw2[0]]
end

loop do
  h, w = gets.split.map(&:to_i)
  hw = [h, w]
  break if h | w == 0
  ans = [150, 150]
  (1..150).each do |i|
    (i+1..150).each do |j|
      ij = [i, j]
      if compare(hw, ij) < 0 && compare(ij, ans) < 0
        ans = ij
      end
    end
  end
  puts ans.join(" ")
end


Measured memory_bytes: 6852
package main

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

func main() {
	N := ReadInt()
	m := map[byte]int{
		'M': 0,
		'A': 1,
		'R': 2,
		'C': 3,
		'H': 4,
	}
	c := make([]int, 5)
	for i := 0; i < N; i++ {
		s := ReadString()
		if v, ok := m[s[0]]; ok {
			c[v]++
		}
	}
	ans := 0
	for i := 0; i < 3; i++ {
		for j := i + 1; j < 4; j++ {
			for k := j + 1; k < 5; k++ {
				ans += c[i] * c[j] * c[k]
			}
		}
	}
	fmt.Println(ans)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 4420
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define MOD 998244353
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 600001
int n;
long long kai[N];
long long gya[N];
bool moda[30];
long long ni[30];

void kaiset(){
	int x = 1;
	kai[0] = 1;
	f(i, (2*n)){
		kai[i + 1] = kai[i] * (i + 1);
		kai[i + 1] = kai[i + 1] % MOD;
	}
	return;
}

void modaset(){
	int x = MOD - 2;
	f(i, 30){
		if (x % 2 == 1)moda[i] = true;
		else moda[i] = false;
		x = x / 2;
	}
	return;
}

void gyaset(){
	f(i, (2*n) + 1){
		ni[0] = kai[i];
		f(j, 29){
			ni[j + 1] = ni[j] * ni[j];
			ni[j + 1] = ni[j + 1] % MOD;
		}
		gya[i] = 1;
		f(j, 30){
			if (moda[j]){
				gya[i] = gya[i] * ni[j];
				gya[i] = gya[i] % MOD;
			}
		}
	}
}


int main(){
	long long x, y, z;
	long long xx, yy;
	long long k,s, ans;
	bool v = true;
	s = 0;
	ans = 0;
	scanf("%d %lld %lld %lld", &n, &x, &y,&k);
	kaiset();
	modaset();
	gyaset();

	xx = n;
  yy=0;
	while (v){
		z = (xx*x) + (yy*y);
		if (z== k){
			s = kai[n];
			s = s*gya[xx];
			s = s%MOD;
			s = s*gya[(n-xx)];
			s = s%MOD;
          	s = s*kai[n];
          	s = s%MOD;
			s = s*gya[yy];
			s = s%MOD;
			s = s*gya[(n-yy)];
			s = s%MOD;
			ans += s;
			ans = ans%MOD;
			if (yy >= n)v = false;
			else yy++;
		}
		else if (z < k){
			if (yy >= n)v = false;
			else yy++;
		}
		else{
			if (xx <= 0)v = false;
			else xx--;
		}
	}

	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 9600
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

class SegTree
{
private:
	int n;
	vector<int> v;

public:
	SegTree(int k)
	{
		n = 1;
		while(n < k) n = 2 * n;
		v = vector<int>(2 * n, 0);
	}

	void add(int x, int val)
	{
		x += n - 1;
		v[x] += val;
		while(x > 0){
			x = (x - 1) / 2;
			v[x] = v[2 * x + 1] + v[2 * x + 2];
		}
	}

	int getsum(int tl, int tr, int nl, int nr, int index)
	{
		if(tr <= nl || nr <= tl) return 0;
		if(tl <= nl && nr <= tr) return v[index];
		int mid = (nl + nr) / 2;
		return getsum(tl, tr, nl, mid, 2 * index + 1) + getsum(tl, tr, mid, nr, 2 * index + 2);
	}

	int getsum(int l, int r)
	{
		return getsum(l, r, 0, n, 0);
	}

};

int main()
{
	string s;
	cin >> s;
	vector<deque<int> > place(26, deque<int>());
	for(int i = 0; i < s.length(); i++){
		place[s[i] - 'a'].push_back(i);
	}

	// 各文字について、先に場所を決める
	int correctplace[200001];
	for(int i = 0; i < s.length() / 2; i++){
		int minindex = -1;
		for(int j = 0; j < 26; j++){
			if(place[j].size() < 2) continue;
			if(minindex < 0 || place[j].front() < place[minindex].front()) minindex = j;
		}
		if(minindex < 0){
			cout << -1 << endl;
			return 0;
		}
		correctplace[place[minindex].front()] = i;
		correctplace[place[minindex].back()] = s.length() - 1 - i;
		place[minindex].pop_front();
		place[minindex].pop_back();
	}
	if(s.length() % 2 == 1){
		for(int j = 0; j < 26; j++){
			if(place[j].size() == 1){
				correctplace[place[j].front()] = s.length() / 2;
				break;
			}

		}
	}

	SegTree segTree = SegTree(s.length());
	long long int ans = 0;
	for(int i = 0; i < s.length(); i++){
		ans += segTree.getsum(correctplace[i], s.length());
		segTree.add(correctplace[i], 1);
	}
	cout << ans << endl;
}

Measured memory_bytes: 4228
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll, ll> lltpl;

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

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




/******************************************************************************************/


int C[5005];
int R[5005];
int AdList[5005][5005];
bool used[5005];


int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int n, k;
	cin >> n >> k;
	
	auto Graph = make_v<int>(n + 10, 0);
	vector<ll> d(n + 10, INF);

	for (int i = 0; i < n; i++)
	{
		cin >> C[i] >> R[i];
	}

	for (int i = 0; i < k; i++)
	{
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		Graph[a].push_back(b);
		Graph[b].push_back(a);
	}
	
	for (int i = 0; i < 5005; i++)
	{
		for (int j = 0; j < 5005; j++)
		{
			AdList[i][j] = INF;
		}
	}

	for (int i = 0; i < n; ++i) {

		//町i→町itr
		queue<pii> que;
		que.push(pii(i, 0));//(町, 何本目)

		int cnt = 0;

		while (!que.empty()) {
			pii now = que.front(); 
			que.pop();

			if (now.second >= R[i]) continue;

			for (auto itr : Graph[now.first]) {

				if (AdList[i][itr] != INF) continue;

				que.push(pii(itr, now.second + 1));
				AdList[i][itr] = C[i];
			}
		}
	}


	//ダイクストラ

	priority_queue<pll, vector<pll>, greater<pll> > pque;
	pque.push(pll(0, 0));//(コスト，頂点)
	d[0] = 0LL;


	while (!pque.empty()) {
		pll p = pque.top();
		pque.pop();

		int x = p.second, c = p.first;

		if (x == n - 1) break;

		if (d[x] > c) continue;

		for (int i = 0; i < n; i++) {
			if (d[i] > d[x] + AdList[x][i]) {
				d[i] = d[x] + AdList[x][i];
				pque.push(pll(d[i], i));
			}
		}
	}

	

	cout << d[n - 1] << endl;


	return 0;
}



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

using ll = long long;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 


int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    cout<<std::fixed<<std::setprecision(15);

    ll W, H, x, y;
    cin >> W >> H >> x >> y;

    cout << W*H/2.0 << " " << ((x*2 == W && y*2 == H) ? 1 : 0)<< endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<queue>

int main(){
	long long int n;
	cin>>n;
	priority_queue<long long int , vector<long long int>, greater<long long int> > a;
	vector<long long int> b(n+1);
	priority_queue<long long int> c;
	long long int lsum=0;
	long long int rsum=0;
	for(long long int i = 0;i<n;i++){
		long long int tmp;
		cin>>tmp;
		lsum+=tmp;
		a.push(tmp);
	}
	for(long long int i = 0;i<n;i++){
		cin>>b[i];
	}
	for(long long int i = 0;i<n;i++){
		long long int tmp;
		cin>>tmp;
		rsum+=tmp;
		c.push(tmp);
	}
	vector<long long int> lall(n+1);
	vector<long long int> rall(n+1);
	lall[0]=lsum;
	rall[n]=rsum;
	for(long long int i = 1;i<n+1;i++){
		a.push(b[i-1]);
		lsum+=b[i-1];
		lsum-=a.top();
		a.pop();
		lall[i]=lsum;
		
		c.push(b[n-i]);
		rsum+=b[n-i];
		rsum-=c.top();
		c.pop();
		rall[n-i]=rsum;
	}
	
	long long int ans = -1000000000*n;
	for(long long int i = 0;i<n+1;i++){
		ans=max(ans,lall[i]-rall[i]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4340
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;

int main(void){
  ll n;
  cin >> n;
  
  vector<ll> a(n);
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }
  map<ll, ll> m;
  m[0]++;
  ll s = 0;
  for (int i = 0; i < n; i++){
    s += a[i];
    m[s]++;
  }


  ll ans = 0;
  for (auto p : m){
    ll v = p.second;
    ans += v * (v - 1)/2;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  int n; cin >> n;
  vector<ll> l(n);
  REP(i,n) cin >> l[i];
  sort(ALL(l));

  int ans = 0;
  REP(i,n) {
    for (int j = i+1; j < n; j++) {
      for (int k = j+1; k < n; k++) {
        ll a = l[i];
        ll b = l[j];
        ll c = l[k];
        if (a == b || b == c || a == c) continue;
        if (c < a+b) ans++;
      }
    }
  }
  COUT(ans);

  return 0;
}


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

using namespace std;

int main() {
	int n,f,l,x=0,y=0;
	cin>>n;
	f=n/100;
	l=n%100;
	if(f>0 && f<=12)
	x=1;
	if(l>0 && l<=12)
	y=1;
	if(x==1 && y==1)
	cout<<"AMBIGUOUS"<<endl;
	else if(x==1 && y==0)
	cout<<"MMYY"<<endl;
	else if(x==0 && y==1)
	cout<<"YYMM"<<endl;
	else
	cout<<"NA"<<endl;
	return 0;
}


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


void solve(long long a, long long b){
    if((a*b) % 2 == 0) cout << "Even" << endl;
    else cout << "Odd" << endl;
}

int main(){
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    solve(a, b);
    return 0;
}


Measured memory_bytes: 256
<?php

function Gcd($a, $b) {
  while ($b % $a != 0) {
    $tmp = $a;
    $a = $b % $a;
    $b = $tmp;
  }
  return $a;
}

fscanf(STDIN, '%d %d', $A, $B);
$gcd = Gcd($A, $B);
$lcm = ($A*$B)/$gcd;
echo $lcm;

Measured memory_bytes: 4604
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val a, b, x = sc.nextDouble()

    val h = x / (a * a)
    if (h >= b / 2) {
      println(Math.atan2(b - h, a / 2) * 180 / Math.PI)
    } else {
      println(Math.atan2(b, 2 * x / (a * b)) * 180 / Math.PI)
    }
  }

}


Measured memory_bytes: 25424
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int j = n%10;
    if (j == 2 || j == 4 || j == 5 || j == 7 || j == 9){
      System.out.println("hon");
    }else if (j == 0 || j == 1 || j == 6 || j == 8){
      System.out.println("pon");
    }else{
      System.out.println("bon");
    }
  }
}

Measured memory_bytes: 35524
def create_new_table2(table):

    v = list()

    for j in range(len(table[0])) :
        s = 0
        for i in range(len(table)):
            s += table[i][j]
        v.append(s)

    table.append(v)

    for i in range(len(table)):
        for j in range(len(table[i])):
            print(str(table[i][j]), end="")
            
            if j != len(table[i]) - 1:
                print(" ", end="")

        print("\n", end="")

if __name__ == "__main__":
    
    param = input().split(" ")
    r = int(param[0])
    c = int(param[1])

    table = list()

    l = r
    
    while(l):

        lines = input().split(" ")

        line = list([ int(n) for n in lines])
        s = sum(line)
        line.append(s)

        table.append(line)

        l -= 1

    create_new_table2(table)


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

int main(){
    while(true){
        int cnt = 0;
        int n, x;
        cin >> n >> x;
        if(n == 0 && x == 0) break;
        for(int i = 1; i <= n - 2; i++){
            for(int j = i + 1; j <= n - 1; j++){
                for(int k = j + 1; k <= n; k++){
                    if(i + j + k == x) cnt++;
                }
            }
        }
        cout << cnt << endl;
    }
}


Measured memory_bytes: 3072
import sys
from collections import Counter
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def IS(): return input()

a, b = MI()
print(a + b) if b % a == 0 else print(b - a)

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

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)

int N,M;
int c[2];

int main(){
  cin >> N >> M;
  vector<int>ba(N), p(M);
  rep(i,N) cin >> ba[i];
  rep(i,M) cin >> p[i];
  rep(i,N) c[ba[i]]++;
  int sum=0;
  for(int i=0;i<M;i+=2) sum+=p[i];
  
  int res = 1<<20;
  rep(h,2){
    if(sum!=c[h]) continue;
    int pat = h;
    vector<int>b = ba;
    int cnt = 0;
    int pos = 0;
    rep(i,M){
      for(int j=0;j<p[i];j++){
	if(b[pos] != pat){
	  int k = pos;
	  while(b[k]!=pat) k++;
	  for(int l=k;l>pos;l--){
	    swap(b[l], b[l-1]);
	    cnt++;
	  }
	}
	pos++;
      }
      pat ^= 1;
    }
    res = min(res, cnt);
  }
  cout << res << endl;  
  return 0;
}

Measured memory_bytes: 1212
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use text_io::*;

fn main() {
    let x: isize = read!();
    let n: usize = read!();
    let mut ps = vec![];

    for _ in 0..n {
        let p: isize = read!();
        ps.push(p);
    }

    let mut min = std::usize::MAX;
    let mut ans = 0;
    for i in 0..=101 {
        if !ps.contains(&i) && min > (x - i).abs() as usize {
            min = (x - i).abs() as usize;
            ans = i;
        }
    }

    println!("{}", ans);
}


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

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
#define range(x,min,max) ((min) <= (x) && (x) <= (max))
#define xyrange(x, minX, maxX, y, minY, maxY) (range(x, minX, maxX) && range(y, minY, maxY))

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef pair<int,int> PII;
typedef vector<PII> VPII;


const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};
const int INF = INT_MAX / 2;

string s1, s2, s3;

char solve() {
	int a, b, c;
	a = b = c = 0;
	char next = 'a';
	while (1) {
		switch (next) {
			case 'a':
				if (s1.size() == a) return 'A';
				next = s1[a++];
				break;
			case 'b':
				if (s2.size() == b) return 'B';
				next = s2[b++];
				break;
			case 'c':
				if (s3.size() == c) return 'C';
				next = s3[c++];
				break;
			default:
				break;
		}
	}
}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	cin >> s1 >> s2 >> s3;
	cout << solve() << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

int main()
{
    ll n, x, m;
    cin >> n >> x >> m;
    vector<int> rem(m, -1);
    vector<ll> ans(m+2, 0);
    ll a = x;
    ans[1] = a;
    rem[a] = 0;

    int i = 1;
    n--;
    while (n > 0) {
        a = (a * a) % m;
        if (rem[a] >= 0)
            break;
        rem[a] = i;
        ans[i+1] = ans[i] + a;
        n--; i++;
    }
    ll score_loop = ans[i] - ans[rem[a]];
    ll len_loop = i - rem[a];

    cout << ans[i] + (n / len_loop) * score_loop
        + ans[(int)(n % len_loop) + rem[a]] - ans[rem[a]] << endl;
    return 0;
}


Measured memory_bytes: 4572
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <functional>
#include <vector>
#include <queue>
#include <map>
#include <stack>

using namespace std;

typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)

int H, W;
int cs[10][10];
int min_cs[10][10];

int A[201][201];

vector<int> ns;

void show() {
  return ;
  printf("----------\n");
  rep(i, 10) {
    printf("i: %d, ", i);
    rep(j, 10) {
      printf(" [%d] %d, ", j, cs[i][j]);
    }
    printf("\n");
  }
}

int main() {
  scanf("%d %d", &H, &W);
  rep(i, 10) {
    rep(j, 10) {
      scanf("%d", &cs[i][j]);
    }
  }
  rep(i, H) {
    rep(j, W) {
      int a;
      scanf("%d", &a);
      if (a != -1 && a != 1) ns.push_back(a);
    }
  }

  rep(t, 10) {
    rep(i, 10) {
      rep(j, 10) {
        rep(k, 10) {
          int mp = cs[i][j];
          int mp_st = cs[i][k] + cs[k][j];
          if (mp_st < mp) cs[i][j] = mp_st;
        }
      }
    }
  }

  ll sum = 0;
  for (int x : ns) sum += cs[x][1];
  printf("%lld\n", sum);
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define ull unsigned long long int  // ranges from (0 - twice of long long int)
#define rep(i,a,n) for (ll i=a;i<n;i++)
#define per(i,a,n) for (ll i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define vll vector<ll>
#define mod 1000000007LL
#define llpair pair<ll,ll>
#define INF 1000000000000000000ll
#define np next_permutation
#define PI acos(-1)
#define deb(x) cout<<#x<<" "<<x<<endl;
//ALWAYS USE ll DATA TYPE FOR INTEGER(FASTER THAN INTEGER AS WELL AS SOMETIMES WITHOUT USE LONG UR ANSWER WILL NOT ACCEPTED) && DOUBLE FOR DECIMAL VALUE
template<typename T> // for removing front element from the vector
void pop_front(std::vector<T> &v)
{
    if (v.size() > 0) {
        v.erase(v.begin());
    }
}
template<typename R> // for removing back element from the vector or can directly
void pop_back(std::vector<R> &v) // use vec.pop_back() function...
{
    if (v.size() > 0) {
        v.erase(v.begin()+v.size()-1);
    }
}

bool isprime(ll n)  //IN  O(sqrt(n))
{
    if(n<=1) return false;
    for(ll i=2;i*i<=n;i++)
        if(n%i==0)
            return false;

    return true;
}

vector<ll> factors(ll n){    //IN  O(sqrt(n))

    vll v;
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            v.pb(i);
            if((n/i)!=i)
            v.pb(n/i);
        }
    }
    return v;
}

ll power(ll a, ll n)  // using Binary Exponential in TC O(logn)
{                     // Self Written By </ME> :)
    ll res=1;
    while(1)
    {
        if(n%2){
            res=res*a; n--;
        }
        if(n==0) break;
        a=a*a; n/=2;
    }
    return res;
}

ll ts(ll arr[],int l,int r,int x) // ternary search to find x in sorted array arr
{
    
    while(l<=r)
    {
        ll mid1= l+(r-l)/3;
        ll mid2= r -(r-l)/3;
        if(arr[mid1]==x || arr[mid2]==x)
            return 1;
        if(x<arr[mid1])
            r=mid1-1;
        else if(x>arr[mid2])
            l=mid2+1;
        else
        {
            l=mid1+1;
            r=mid2-1;
        }
    }

    return -1;
}


bool f(string s,ll start,ll end)
{
    while(start<=end)
    {
        if(s[start]!=s[end])
            return false;

        start++; end--;
    }

    return true;
}


int main() {
    auto start = chrono::high_resolution_clock::now();
    fio;
    ll T=1;
    //cin>>T;
    while(T--)
    {
      double n; cin>>n;
      n=n/3;
      n=n*n*n;
      cout<<fixed<<setprecision(12)<<n;
    }
    
    auto finish = chrono::high_resolution_clock::now();
    cerr << "Time elapsed: " << (chrono::duration<long double>(finish-start)).count() << "s\n";
    return 0;
}





Measured memory_bytes: 256
import sys
import collections as col
input=sys.stdin.readline

def mainA():
	N,R=map(int,input().split())
	#N=input().rstrip()
	#N=int(input())
	#vA=list(map(int,input().split()))
	
	if N >= 10:
		res = R
	else:
		res = R + 100*(10-N)
	
	print(res)

def mainB():
	N,K=map(int,input().split())
	#N=input().rstrip()
	#N=int(input())
	#vA=list(map(int,input().split()))
	
	res = 0
	while N:
		N //= K
		res += 1
	
	print(res)

def mainC():
	#N,K=map(int,input().split())
	N=input().rstrip()
	#N=int(input())
	vA=list(map(int,input().split()))
	
	res = float("inf")
	for i in range(1, 101):
		t = sum((x-i)**2 for x in vA)
		res = min(res, t)
	
	print(res)


#mainA()
#mainB()
mainC()


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

const int MAX_PRICE = 1251;

int main() {
  int a, b;
  cin >> a >> b;
  int price;
  bool find = false;
  for ( price = 0; price <= MAX_PRICE; price++ ) {
    if ( price*8/100 == a && price*10/100 == b ) {
      find = true;
      break;
    }
  }
  price = ( find ) ? price : -1;
  cout << price << endl;
  return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 2e9
#define LINF 1e18
#define MOD 1000000007
#define PI 3.141592653589793
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define input(x, n)for(ll i = 0; i <(ll)(n); i++)cin >> x[i];
#define until(i,n) for(ll i = 1; i <= (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << "=" << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl

int main(){

    ll h, w;
    cin >> h >> w;

    vector<string> a(h);
    vector<bool> fh(h, 0);
    vector<bool> fw(w, 0);

    for(ll i = 0; i < h; i++){
        cin >> a[i];
        for(ll j = 0; j < w; j++){
            if(a[i][j] == '#'){
                fh[i] = 1; 
                fw[j] = 1;
            }
        }
    }

    for(ll i = 0; i < h; i++){
        bool f = 0;
        for(ll j = 0; j < w; j++){
            if(fh[i] && fw[j])cout << a[i][j];
        }
        if(fh[i])cout << endl;
    }





}

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

using namespace std;

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

#define FASTIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define ff it->first
#define ss it->second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(auto i=0;i<n;++i)
#define LOOP_IT(it,s) for(auto it=(s).begin();it!=(s).end();++it)


#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}


template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif










int main(int argv, char* argc[])
{
    FASTIO

    int a,b,c,d;
    cin>>a>>b>>c>>d;
    string ans;
    while(1)
    {
        c-=b;
        if(c<=0)
        {
            ans="Yes";
            break;
        }
        a-=d;
        if(a<=0)
            {ans="No";break;}
    }
    cout<<ans;

    return 0;
}


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

using namespace std;

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

    long n;
    cin >> n;
    char s[n];
    // cin >> s;
    scanf("%s", &s);
    long right_e = 0;
    for (long i = 1; i < n; i++) right_e += (s[i] == 'E');
    long min_count = right_e;
    // long left_w = 0;
    for (long i = 1; i < n; i++) {
        if (!min_count) break;
        right_e -= s[i] == 'E';
        right_e += s[i - 1] == 'W';
        min_count = min(min_count, right_e);
    }
    // cout << min_count << endl;
    cout << min_count << '\n';

    return 0;
}

Measured memory_bytes: 512
N = int(input())
A = list(map(int, input().split()))

negatives = len([a for a in A if a < 0])
if negatives % 2 == 0:
    m = 0
else:
    m = min(abs(a) for a in A)
print(sum(abs(a) for a in A) - 2 * m)


Measured memory_bytes: 14412
#include<stdio.h>

int main(void)
{
  int i,j,n,m,a[1000],s,s1;

  while(1)
    {
      scanf("%d",&n);
      scanf("%d",&m);
      if(n==0&&m==0){
          break;
      }
      for(i=0;i<=n-1;i++){
	  scanf("%d",&a[i]);
	}
      s1=0;
      for(i=0;i<=n-1;i++){
	  for(j=i+1;j<=n-1;j++){
	      s=a[i]+a[j];
	      if(s<=m && s1<s) s1=s;
	    }
	}
      if(s1==0) printf("NONE\n");
      else printf("%d\n",s1);
    }
  return 0;
}


Measured memory_bytes: 2104
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

int sum[SIZE];

int main() {
  int N, M;


  scanf("%d%d", &N, &M);

  for (int i=0; i<M; i++) {
    int L, R;
    scanf("%d%d", &L, &R);
    sum[L-1]++;
    sum[R]--;
  }

  for (int i=1; i<N; i++)
    sum[i] += sum[i-1];

  int ans = 0;
  for (int i=0; i<N; i++)
    ans += sum[i] == M;

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

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include<iostream>
using namespace std;
using ll = long long;
int main(){
	ll n,w;
  	scanf("%lld%lld",&n,&w);
    vector<ll> dp1(w+1,0);
    for(int i=0;i<n;i++){
     	ll we,val;
        vector<ll> dp(w + 1);
     	scanf("%lld%lld",&we,&val);
     	for(int j=0;j<=w;j++){
          	if(j<we) dp[j]=dp1[j];
      		else dp[j]=max(dp1[j-we]+val,dp1[j]);
     	}
      	for(int j=0;j<=w;j++){
        	dp1[j]=dp[j];
        }
    }

	ll answer = 0;
   	for(int i=0;i<=w;i++) {
      //printf("%lld ",dp1[i]);
        answer=max(answer, dp1[i]);
   	}
   	printf("%lld\n", answer);
}


Measured memory_bytes: 1804
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int minT = 0, minB = 0;

        if (a > b) {
            minT = b;
        } else {
            minT = a;
        }

        if (c > d) {
            minB = d;
        } else {
            minB = c;
        }

        System.out.println((minT + minB));
        sc.close();
    }    
}


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

#define maxn 302
#define FOR(i, l, r) for (int i=l; i<=r; ++i)
#define FORD(i, r, l) for (int i=r; i>=l; --i)
#define REP(i, r) for (int i=0; i<(int)r; ++i)
#define REPD(i, r) for (int i=(int)r-1; i>=0; --i)
#define fi first
#define se second
#define mk make_pair
#define nil NULL
#define y0 y902
#define y1 y232
#define x0 x92
#define x1 x899
#define next asdfa
#define sz size
#define Debug(X) {cerr << #X << " = " << X << '\n';}
#define PR(A, n) {cerr << #A << " = "; FOR(i, 1, n) cerr << A[i] << ' '; cerr << '\n';}
#define PR0(A, n) {cerr << #A << " = "; REP(i, n) cerr << A[i] << ' '; cerr << '\n';}
typedef long long ll;
typedef double db;
typedef pair<db, db> dd;
typedef pair<int, int> ii;
typedef vector<int> vi;
const int inf = 1e9;
template<class T> int getbit(T x, int pos) {return (x>>(pos-1)) & 1;}
template<class T> void turn_on(T &x, int pos) {x = x | ((T)1<<(pos-1));}
template<class T> void turn_off(T &x, int pos) {x = x & ~((T)1<<(pos-1));}
template<class T> T sqr(T a) {return a*a;}

int m, n, a[maxn][maxn], hist[maxn], head[maxn];
bool avail[maxn];

bool check(int v) {
    FOR(i, 1, m) head[i] = 1;
    memset(avail, true, sizeof(avail));
    while (true) {
        FOR(i, 1, m) {
            while (head[i]<=n && !avail[a[i][head[i]]]) ++head[i];
        }
        FOR(i, 1, m) {
            if (head[i]==n+1) return false;
        }
        memset(hist, 0, sizeof(hist));
        bool ok = true;
        FOR(i, 1, m) {
            hist[a[i][head[i]]]++;
            ok = ok && hist[a[i][head[i]]]<=v;
        }
        if (ok)
            return true;
        FOR(i, 1, m) {
            if (hist[a[i][head[i]]]>v) {
                avail[a[i][head[i]]] = false;
                ++head[i];
            }
        }
    }
}

void bisect() {
    int l = 1, r = m, mid = (l+r)/2;
    while (l!=mid && mid!=r) {
        if (check(mid)) r = mid;
        else l = mid;
        mid = (l+r)/2;
    }
    FOR(i, l, r) {
        if (check(i)) {
            printf("%d", i);
            return;
        }
    }
}

int main() {
    //freopen("sports.inp", "r", stdin);
    //freopen("sports.ans", "w", stdout);
    //ios::sync_with_stdio(0); cin.tie(0);
    scanf("%d%d", &m, &n);
    FOR(i, 1, m) FOR(j, 1, n) scanf("%d", &a[i][j]);
    check(2);
    bisect();
}



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

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

typedef vector <int>  Edges;
typedef vector<Edges> Graph;

Graph g;

int main() {
  int N, M; cin>>N>>M;
  g = Graph(N);
  vector<int> H(N);
  REP(i,N) cin>>H[i];
  REP(i,M) {
    int a, b; cin>>a>>b; a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  int ans = 0;
  REP(i,N) {
    bool ok = true;
    REP(j, g[i].size()) {
      int to = g[i][j];
      if(H[i] <= H[to]) {
	ok = false; break;
      }
    }

    if(ok) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 8432
//Echo
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <map>
#include <stdio.h>
#include <string.h>
#include <initializer_list>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <queue>
#include <set>

using namespace std;

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

    if (N % 2 == 1) {
        cout << "No" << endl;
        return 0;
    }

    int l = N / 2;
    S[l];

    for (int i = 0; i < l; i++) {
        if (S[i] == S[i+l]) {
            continue;
        }
        else {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

ll mod = 1000000007;

class UnionFind {
 public:
  vector<int> Parent;
 
  UnionFind(int N) {
    Parent = vector<int>(N, -1);
  }
 
  int root(int A) {
    if (Parent[A] < 0) return A;
    return Parent[A] = root(Parent[A]);
  }
 
  int size(int A) {
    return -Parent[root(A)];
  }
 
  bool connect(int A, int B) {
    A = root(A);
    B = root(B);
    if (A == B) {
      return false;
    }
    if (size(A) < size(B)) swap(A, B);
 
    Parent[A] += Parent[B];
    Parent[B] = A;
    return true;
  }
};


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

  int n, m;
  cin >> n >> m;

  UnionFind uf(n);

  rep(i, m) {
    int x, y, z;
    cin >> x >> y >> z;
    uf.connect(x-1, y-1);
  }

  set<int> s;
  rep(i, n) {
    int root = uf.root(i);
    s.insert(root);
  }

  cout << s.size() << endl;  

  return 0;
}


Measured memory_bytes: 5376
#include <stdio.h>
int main(void)
{
	int x, y;
	int time = 1;
	while (time!=3001) {
		scanf("%d", &x);
		scanf("%d", &y);

		if (x == 0 && y == 0) {
			break;
		}

		else if (x<y) {
			printf("%d %d\n", x, y);
		}

		else if (y < x) {
			printf("%d %d\n", y, x);
		}
		
		else if (x == y) {
			printf("%d %d\n", x, y);
		}

		time++;
	}

    return 0;
}


Measured memory_bytes: 1984
#include <stdio.h>
#include <stdlib.h>

int main(){

  	long n, k;
    long x = 0;
    long t;
  
    scanf("%ld %ld", &n, &k);
    
    t = n % k;
  
    if(t < labs(t-k)){
    	printf("%ld", t);
    }else{
        printf("%ld", labs(t-k));
    }
  
	return 0;
}

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

using namespace std;

int main(){
  string S, T;
  int A, B;
  string U;
  
  cin >> S >> T;
  cin >> A >> B;
  cin >> U;
  
  if(S == U){
    A--;
  }else{
    B--;
  }
  
  cout << A << " " << B << endl;
  
  return 0;
}

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

using namespace std;

typedef long long ll;

const double pi = 3.14159265358979323846;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define CIN(v) cin >> v;
#define COUT(v) cout << v << "\n";

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

  int X, Y;
  CIN(X >> Y);

  COUT(X + Y / 2);

  return 0;
}


Measured memory_bytes: 256