akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;


//System.out.println();
public class Main implements Runnable { //クラス名はMain

    public static void main(String[] args) {
    	Thread.setDefaultUncaughtExceptionHandler((t,e)->System.exit(1));
        new Thread(null, new Main(), "", 16 * 1024 * 1024).start(); //16MBスタックを確保して実行
    }

    public void run() {
    	try {
	    	FastScannerCommonRaccoonVsMonster sc = new FastScannerCommonRaccoonVsMonster(System.in);
	        int H = sc.nextInt();
	        int N = sc.nextInt();
	        int a[] = new int[N];

	        for(int i=0; i < N; i++) {
	        	a[i] = sc.nextInt();
	        }

	        if(Arrays.stream(a).sum() >= H) {
	        	System.out.println("Yes");
	        }else {
	        	System.out.println("No");
	        }


    	}catch(Exception e) {
    		e.printStackTrace();
    	}

    }
}


//高速なScanner
class FastScannerCommonRaccoonVsMonster {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScannerCommonRaccoonVsMonster(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}


Measured memory_bytes: 37156
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  char a;
  int ans=0;
  rep(i,6){
    cin>>a;
    if(a=='1') ans++;
  }
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)

mod = 1000000007
INF = 110110110

# input
N = int(input())
c = list(map(int, input().split()))
for i in range(N):
    c[i] -= 1

E = [[] for i in range(N)]
for i in range(N-1):
    a, b = list(map(int, input().split()))
    E[a-1].append(b-1)
    E[b-1].append(a-1)


# solve
child = [0] * N

def dfs(now, par):
    res = 1
    for to in E[now]:
        if to == par:
            continue
        res += dfs(to, now)
    child[now] = res
    return res

dfs(0, -1)

ans = [0] * N
ok = [N] * N
def solve(now, par):
    memo = ok[c[now]]
    up = ok[c[now]] - child[now]
    num = [up]
    for to in E[now]:
        if to == par:
            continue
        num.append(child[to])
    S = sum(num)
    ans[c[now]] += S + 1
    for n in num:
        S -= n
        ans[c[now]] += S * n

    for to in E[now]:
        if to == par:
            continue
        ok[c[now]] = child[to]
        solve(to, now)
    ok[c[now]] = memo - child[now]

solve(0, -1)

for i in range(N):
    print(ans[i])


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

int main(){
    int ans=0,sum=0;
    int n;
    
    cin >>n;
    double a[n];

    for (int i = 0; i < n; i++){
        cin >>a[i];
    }
    
    sort(a,a+n);

    for (int i = 1; i < n; i++){
        a[i]=(a[i-1]+a[i])/2;
    }
    


    cout <<fixed<<setprecision(16)<< a[n-1]<< endl;
    //cout << a[n-1] << endl;

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
# include <iostream>
# include <vector>
# define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int main() {
    int n; cin >> n; vector<int> a(n); rep(i, n) cin >> a[i];
    sort(a.begin(), a.end(), greater<int>());
    vector<int> sum_list = {0, 0};

    rep (i, n) sum_list[i%2] += a[i];
    cout << sum_list[0] - sum_list[1] << endl;
    return 0;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H & b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H & b) const { return x == b.x && y == b.y; }
	bool operator!=(const H & b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T & a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T & a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n;
signed main() {
	cin >> n;
	int a = 0, b = 0, c = 0;
	//aの数、bの数
	int ans = 0;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		int sum = 0, res = 0;
		for (int j = 1; j < s.size(); j++) {
			if (s[j] == 'B' && s[j - 1] == 'A') {
				ans++;
			}
		}
		if (s[0] == 'B' && s[s.size() - 1] == 'A') c++;
		else if (s[0] == 'B') b++;
		else if (s[s.size() - 1] == 'A') a++;
	}
	bool l = a | b;
	while (a&&b&&c) {
		a--, b--, c--;
		ans += 2;
	}
	if (c == 0) {
		ans += min(a, b);
	}
	else if (a == 0) {
		int k = min(b, c);
		ans += k;
		c -= k;
	}
	else {
		int k = min(a, c);
		ans += k;
		c -= k;
	}
	if (c > 0) {
		if (l) ans += c;
		else ans += c - 1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    double s = 0;
    for (int i = 0; i < n; i++) {
        double x;
        string u;
        cin >> x >> u;
        if (u == "JPY") {
            s += x;
        } else {
            s += x * 380000.0;
        }
    }

    printf("%.8f\n", s);

    return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rrep(i, n) for(ll i = n-1; i > 0; i--)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<60);
const ld pi=acosl((ld)1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};


template<class T>
T gcd(T a,T b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(a%b,b);
}

bool solve(){
  ll n,m;cin>>n>>m;
  vector<pair<ll,ll>>v;
  rep(i,m){
    ll a,b;cin>>a>>b;
    v.push_back(make_pair(b,a));
  }
  sort(all(v));
  ll now=-INF;
  ll ans=0;
  rep(i,m){
    if(now<=v[i].second){
      now=v[i].first;
      ans++;
    }
  }
  cout<<ans<<endl;
  return false;
}


signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
	cout<<setprecision(30);
	return solve();
}


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

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

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

  set<int> pressed;
  int now = 0;
  for (int i = 0; i < n; i++) {
    if (pressed.find(now) != pressed.end()) break;
    if (now == 1) {
      cout << i << '\n';
      return 0;
    }
    pressed.insert(now);
    now = a[now];
  }
  cout << -1 << '\n';
  return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define printYes() cout << "Yes" << endl;
#define printNo() cout << "No" << endl;
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  int A, B, C;
  cin >> A >> B >> C;
  if (A + B >= C)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;

std::vector<ll> Color(200000, 0), max_d(200000, -1);
vvl edge = vv(200000, 0, 0, ll);
void dfs(ll now, ll d, ll c){
  if(max_d[now]>=d) return;
  //std::cout << now << " " << d  << " "<< c << '\n';
  if(Color[now]==0) Color[now] = c;
  max_d[now] = d;
  for(int i=0;i<edge[now].size();i++) if(d>0) dfs(edge[now][i], d-1, c);
}
int main(int argc, char const *argv[]) {
  ll N, M, Q, a, b;
  std::cin >> N >> M;
  for(int i=0;i<M;i++) {
    std::cin >> a >> b;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  std::cin >> Q;
  vvl query = vv(Q, 3, 0, ll);
  for(int q=0;q<Q;q++) std::cin >> query[q][0] >> query[q][1] >> query[q][2];
  for(int q=Q-1;q>=0;q--) dfs(query[q][0], query[q][1], query[q][2]);
  for(int i=1;i<=N;i++) std::cout << Color[i] << '\n';
  return 0;
}


Measured memory_bytes: 17780
while 1:
 m,f,r=map(int,input().split());s=m+f
 if m==f==r<0:break
 if(m*f<0)|(s<30):print('F')
 elif(s<50)*(r<50):print('D')
 elif s<65:print('C')
 elif s<80:print('B')
 else:print('A')


Measured memory_bytes: 5596
//Arayi
//#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <math.h>
#include <vector>
#include <cstring>
#include <ctime>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <ctime>
#include <climits>
#include <cassert>
#include <chrono>
#include <random>
#include <complex>

#define fr first
#define sc second
#define MP make_pair
#define ad push_back
#define PB push_back
#define fastio ios_base::sync_with_stdio(false); cin.tie(0);
#define lli long long int
#define y1 arayikhalatyan
#define j1 jigglypuff
#define ld long double
#define itn int
#define pir pair<int, int> 
#define all(x) (x).begin(), (x).end()
#define str string
#define enl endl
#define en endl
#define cd complex<long double>
#define vcd vector<cd>
#define vii vector<int>
#define vlli vector<lli>
using namespace std;

lli gcd(lli a, lli b) { return (b == 0LL ? a : gcd(b, a % b)); }
ld dist(ld x, ld y1, ld x2, ld y2)
{
    return sqrt((x - x2) * (x - x2) + (y1 - y2) * (y1 - y2));
}
lli S(lli a)
{
    return (a * (a + 1LL)) / 2;
}
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
char vow[] = { 'a', 'e', 'i', 'o', 'u' };
int dx[] = { 1, -1, 0, 0, -1, -1, 1, 1, 0 };
int dy[] = { 0, 0, 1, -1, -1, 1, -1, 1, 0 };


const int N = 1e5 + 230;
const lli mod = 998244353;
const ld pi = acos(-1);
const int T = 238;
const ld e = 1e-13;

lli bp(lli a, lli b = mod - 2LL)
{
    lli ret = 1;
    while (b)
    {
        if (b & 1) ret *= a, ret %= mod;
        a *= a;
        a %= mod;
        b >>= 1;
    }
    return ret;
}
ostream& operator<<(ostream& c, pir a)
{
    c << a.fr << " " << a.sc;
    return c;
}
struct pt
{
    lli x, y;
    int ind;
    int bl;
    bool operator==(const pt& a)
    {
        return ind == a.ind;
    }
    bool operator<(const pt& b)
    {
        if (x == b.x) return y < b.y;
        return x < b.x;
    }
};


str s;
int a[3];
int main()
{
    fastio;
    cin >> s;
    for (int i = 0; i < 3; i++)
    {
        a[i] = (s[i] == 'R');
    }
    if (a[1]) cout << a[0] + a[2] + 1 << endl;
    else cout << max(a[0], a[2]) << endl;
    return 0;
}

/*

  __
*(><)*
  \/ /
  ||/
--||
  ||
  /\
 /  \
/    \
*/

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

    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    # define M_PI  3.14159265358979323846

    void solve(){
        ll n;
        cin>>n;
        if(n%2)
            cout<<0;
        else{
            long long total=0;
            long long num=10;
            while(n>=num){
                total+=(n/num);
                num*=5LL;
            }
            cout<<total;
        }
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
        int t=1;
//        cin>>t;
        for(int i=1;i<=t;i++){
            solve();
        }
        return 0;
    }


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

const int KIND = 26;

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int ti = clock();
    srand((unsigned)time(NULL));
    int D; cin>>D;
    vi c(KIND);
    rep(i,KIND) cin>>c[i];
    vector<vi> s(D, vi(KIND));
    rep(i,D)rep(j,KIND) cin>>s[i][j];
    vi ans(D);
    vi cand(D);
    vi damage(KIND);
    vi weight(KIND);
    vi wsum(KIND);
    int r,idx,V;
    int Vmax=INT_MIN;
    while((double)(clock()-ti)/CLOCKS_PER_SEC < 1.98){
        V=0;
        rep(i,KIND) damage[i]=0;
        rep(i,D){
            rep(j,KIND){
                damage[j]+=c[j];
                weight[j]=s[i][j]+damage[j];
                wsum[j]=weight[j];
                V -= damage[j];
            }
            rep(j,KIND-1) wsum[j+1]+=wsum[j];
            r = rand()%wsum[KIND-1];
            idx = upper_bound(all(wsum),r) - wsum.begin();
            // cout<<r<<"/"<<wsum[KIND-1]<<" "<<idx<<endl;
            cand[i] = idx;
            damage[idx] = 0;
            V += weight[idx];
        }
        if (V > Vmax){
            ans.swap(cand);
            Vmax = V;
        }
    }
    rep(i,D) cout<<ans[i]+1<<"\n";
    return 0;
}


Measured memory_bytes: 3744
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      String s = sc.next();
	  int cnt = 0;
      for(char c : s.toCharArray())
        	if(c == '-') cnt++;
      System.out.println(s.length() - cnt - cnt);
  }
}

Measured memory_bytes: 21844
M = 10**9 + 7
dp = [0] * 4
dp[0] = 1
idx = {'A': 1, 'B': 2, 'C': 3}
for c in input():
    if c == '?':
        N, A, AB, ABC = dp
        dp = [(N * 3) % M, (A * 3 + N) % M, (AB * 3 + A) % M, (ABC * 3 + AB) % M]
    else:
        dp[idx[c]] += dp[idx[c] - 1]
        dp[idx[c]] %= M
print(dp[3] % M)

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

int main()
{
	int i, n, q, left, right;
	char *s, *t, *d;

	scanf("%d%d", &n, &q);

	if ((s = (char *)malloc(sizeof(char) * (n + 1))) == NULL)
		return 1;

	scanf("%s", s);

	if ((t = (char *)malloc(sizeof(char) * q)) == NULL)
		return 1;
	if ((d = (char *)malloc(sizeof(char) * q)) == NULL)
		return 1;

	for (i = 0; i < q; i++) {
		scanf("\n%c %c", t + i, d + i);
	}

    for (i = q - 1, left = 0, right = n - 1; i >= 0; i--) {
		switch (d[i]) {
		case 'L':
			if (s[left] == t[i])
				left++;
			if (right != n - 1 && s[right + 1] == t[i])
				right++;
			break;
		case 'R':
			if (s[right] == t[i])
				right--;
			if (left != 0 && s[left - 1] == t[i])
				left--;
			break;
		}
	}

	printf("%d\n", right - left + 1);

	free(s);
	free(t);
	free(d);

	return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define mp make_pair
#define fir first 
#define sec second
#define int long long
#define endl "\n"
//# define M_PI 3.14159265358979323846
using namespace std;
const int nax=1e5+5;
vector<int>adj[nax];
const int mod=1e9+7;
const int inf=1e18+7;

signed main(){
	int n;
	cin>>n;
	std::cout << std::setprecision(15) << 2*3.1415926*n << endl;
	return 0;
}



Measured memory_bytes: 6076
N=int(input())
LR=sorted([list(map(int,input().split())) for i in range(N)])
x,y,z,w=[0]*(N+1),[10**9+1]*(N+1),[0]*(N+1),[10**9+1]*(N+1)
l=0
for i in range(N):
    x[i+1],y[i+1]=max(x[i],LR[i][0]),min(y[i],LR[i][1])
    z[-i-2],w[-i-2]=max(z[-i-1],LR[-i-1][0]),min(w[-i-1],LR[-i-1][1])
    l=max(l,LR[i][1]-LR[i][0]+1)
print(max([max(0,y[-1]-x[i]+1)+max(0,w[i]-z[0]+1) for i in range(1,N)]+[l+max(0,y[-1]-z[0]+1)]))

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

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
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;
}

void solve(long long H, long long W, long long h, long long w) {

  cout << (H-h) * (W-w) << endl;
}

int main() {
  long long H;
  scanf("%lld", &H);
  long long W;
  scanf("%lld", &W);
  long long h;
  scanf("%lld", &h);
  long long w;
  scanf("%lld", &w);
  solve(H, W, h, w);
  return 0;
}


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

using namespace std;

int main() {
  string s;
  cin >> s;
  
  sort(s.begin(),s.end());
  if(s == "abc")
    cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3612
#include <array>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#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 FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

struct UnionFind
{
  vector< int > data;

  UnionFind(int sz)
  {
    data.assign(sz, -1);
  }

  bool unite(int x, int y)
  {
    x = find(x), y = find(y);
    if(x == y) return(false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return(true);
  }

  int find(int k)
  {
    if(data[k] < 0) return(k);
    return(data[k] = find(data[k]));
  }

  int size(int k)
  {
    return(-data[find(k)]);
  }

  bool same(int x, int y)
  {
      return find(x) == find(y);
  }
};

LL dp[2000][2000];

int main()
{
    int H, W;
    cin >> H >> W;
    vector<string> a(H);
    REP(r, H) cin >> a[r];
    dp[1][1] = 1;
    REP(r, H) REP(c, W)
    {
      if (r == 0 && c == 0) continue;

      if (a[r][c] == '.')
      {
        dp[r + 1][c + 1] = (dp[r + 1][c] + dp[r][c + 1]) % MOD;
      }
      else
      {
        dp[r + 1][c + 1] = 0;
      }
    }
    cout << dp[H][W] << endl;
    return 0;
}


Measured memory_bytes: 17152
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    float a,c=0;
    cin>>n;
    for(int i=1;i<=n;i++)
        {
            if(i%2!=0)
            c++;
        }
    a=c/n;
    cout<<a;
}


Measured memory_bytes: 256
while (m,f,r = gets.split(" ").map(&:to_i)) != [-1,-1,-1]
    if m + f < 30 or m < 0 || f < 0
    puts 'F'
elsif m + f >= 80
    puts 'A'
elsif m + f >= 65
    puts 'B'
elsif m + f >= 50 || r >= 50
    puts 'C'
else
    puts 'D'
end
end


Measured memory_bytes: 8896
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter

val br = BufferedReader(InputStreamReader(System.`in`))
val pw = PrintWriter(System.out)
fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    // 回答をここに書く
    val b = next()
    val ret = b.mapIndexed { key, value ->
        if (value == 'A' || value == 'C' || value == 'T' || value == 'G') {
            var cnt = 0
            for (i in (key until b.length)) {
                if (b[i] == 'A' || b[i] == 'C' || b[i] == 'T' || b[i] == 'G') {
                    cnt++
                }else return@mapIndexed cnt
            }
            cnt
        } else 0
    }
    println(ret.max())
}

// 入力取得
fun next() = br.readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() =listOfString().map { it.toInt() }
fun listOfLong() =listOfString().map { it.toLong() }
fun listOfDouble() =listOfString().map { it.toDouble() }

// 約数のList
fun divisor(value : Long) : List<Long> {
    val max = Math.sqrt(value.toDouble()).toLong()
    return (1..max)
            .filter { value % it == 0L }
            .map { listOf(it, value / it) }
            .flatten()
            .sorted()
}

// 範囲内の素数を取得
// fromだけ指定すると戻り値の個数で素数判定ができる
fun prime(from : Long, to : Long = from) : List<Long> {
    return (from..to).filter { i ->
        val max = Math.sqrt(i.toDouble()).toLong()
        (2..max).all { j ->  i % j != 0L }
    }
}

// 素因数分解
fun decom(value : Long) : List<Long>{
    if (value == 1L) return listOf(1)
    val max = Math.sqrt(value.toDouble()).toLong()
    return prime(2, max).filter { value % it == 0L }
}

// 最大公約数
fun gcd(a : Long, b : Long) : Long {
    return if (a % b == 0L) b else gcd(b, a % b)
}

// 文字列を入れ替え
fun swap(base : String, a : String, b : String) : String {
    return base.map {
        when (it) {
            a.toCharArray()[0] -> b
            b.toCharArray()[0] -> a
            else -> it.toString()
        }
    }.joinToString()
}

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 29600
// 解説に倣ってDP
#include<bits/stdc++.h>
using namespace std;

int main(){
  int h,n;
  cin>> h >> n;
  vector<vector<int>> magic(n,vector<int>(2));
  for(int i=0; i<n; i++) cin>> magic[i][0] >> magic[i][1];
  
  sort(magic.begin(),magic.end());
  int impossible=1e9;
  vector<int> dp(h+1,impossible); dp[0]=0; // dp[i]:体力をi減らすために消耗する魔力の最小値
  for(int i=0; i<h; i++){
    if(dp[i]==impossible) continue;
    for(int j=0; j<n; j++){
      int index= i+magic[j][0]<h ? i+magic[j][0] : h;
      if(dp[index]>dp[i]+magic[j][1]){
        dp[index]=dp[i]+magic[j][1];
      }
    }
  }
  cout<< dp[h] <<endl;
}

Measured memory_bytes: 3708
var
  n,m,i,j:longint;
  p:boolean;
begin
  readln(n,m);
  p:=false;
  for i:=0 to n do
    if p=false then
      for j:=0 to n-i do
        if 10000*i+5000*j+1000*(n-i-j)=m then begin p:=true;write(i,' ',j,' ',n-i-j);break;end;
  if p=false then write('-1 -1 -1');
end.

Measured memory_bytes: 128
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include<iomanip>
#include<set>
#include<random>
using namespace std ;

#define MOD 1000000007
#define MAXN 5007

int n , k ;
string a ;

long long dp[ MAXN ][ MAXN ] ;

long long fastpow ( long long x , long long pw ) {
    long long ret = 1 ;
    while ( pw > 0 ) {
        if ( ( pw & 1 ) == 0 ) {
            x = ( x * x ) % MOD ;
            pw /= 2 ;
        }
        else {
            ret = ( ret * x ) % MOD ;
            -- pw ;
        }
    }
    return ret ;
}

void input ( ) {
    cin >> k ;
    cin >> a ;
    n = a.size ( ) ;
}

void solve ( ) {
    dp[ 0 ][ 0 ] = 1 ;
    for ( int j = 0 ; j < k ; ++ j ) {
        for ( int i = 0 ; i < MAXN - 1 ; ++ i ) {
            int nw = i - 1 ;
            if ( nw < 0 ) { nw = 0 ; }
            dp[ nw ][ j + 1 ] = ( dp[ nw ][ j + 1 ] + dp[ i ][ j ] ) % MOD ;
            dp[ i + 1 ][ j + 1 ] = ( dp[ i + 1 ][ j + 1 ] + 2 * dp[ i ][ j ] ) % MOD ;
        }
    }
    long long aux = fastpow ( 2 , n ) ;
    aux = fastpow ( aux , MOD - 2 ) ;
    printf ( "%lld\n" , ( dp[ n ][ k ] * aux ) % MOD ) ;
}


int main ( ) {
    ios_base :: sync_with_stdio ( false ) ;
    cin.tie ( NULL ) ;
    input ( ) ;
    solve ( ) ;
    return 0 ;
}


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

int main(){
	ll N,M;
	cin >> N >> M;
	vector<ll> v[100005];
	rep(i,N){
		ll x,y;
		cin >> x >> y;
		v[x].push_back(y);
	}
	
	priority_queue<ll> q;
	ll ans = 0;
	for (int i = M-1; i >= 0 ; --i) {
		for (auto u: v[M-i]){
			q.push(u);
		}
		if(!q.empty()) {
			ans += q.top();
			q.pop();
		}
	}
	
	cout << ans << endl;
    return 0;
}

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

int main(){
  int n,x;
  cin >>n >>x;
  vector<int> l(n);
  rep(i,n) cin >>l[i];
  int ans = 1;
  int bound = 0;
  rep(i,n){
    bound += l[i];
    if(x<bound) break;
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import Data.List
import Data.Maybe

----------------------------------------------------------------------

solve :: Int -> Int -> [[Char]] -> String
solve h w ass = unlines $ transpose $ compress $ transpose $ compress ass

compress :: [[Char]] -> [[Char]]
compress ass = catMaybes $ map f ass
  where f as | and [ a == '.' | a <- as] = Nothing
             | otherwise = Just as

tmain :: String -> String
tmain cont =
  let sh : sw : ass = words cont
      h = read sh
      w = read sw
  in solve h w ass

main = putStr . tmain =<< getContents


Measured memory_bytes: 2044
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn readu() -> usize {
    read::<usize>()
}

#[allow(dead_code)]
fn readi() -> i32 {
    read::<i32>()
}

fn main() {
    input! {
        n: usize,
        p: [usize; n],
    }
    let mut ps = p.clone();
    ps.sort();
    let mut c: usize = 0;
    for i in 0..n {
        if ps[i] != p[i] {
            c += 1;
        }
    }
    if c == 0 || c == 2 {
        println!("YES");
    } else {
        println!("NO");
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back

typedef long long LL; 
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    int A,B,C; cin >> A >> B >> C;

    if(A == B && B == C) cout << "Yes" << endl;
    else cout << "No" << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <vector>
using namespace std;
#define endl "\n"
using Int = long long;

int main() {
    ios::sync_with_stdio(false);
    int N,M;
    cin>>N>>M;
    vector<Int>foods(M,0);
    for(int i=0;i<N;i++){
        Int k;
        cin>>k;
        for(Int j=0;j<k;j++){
            Int food;
            cin>>food;
            food--;
            foods[food]++;
        }
    }
    Int ans=0;
    for(Int i=0;i<M;i++){
        if(foods[i]==N){ans++;}
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
int k; scanf ("%d",&k);
  int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  printf ("%d\n",a[k-1]);
}

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

// clang-format off
#define forn(i, x, y) for(int i = x; i < y; i++)
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(NULL)
// clang-format on

using LL = long long;
using VI = vector<int>;
using VLL = vector<LL>;

class LazySegTree {
public:
    int n = 1, h;
    VLL data, lazy;

    LazySegTree(int N) {
        while (n < N) n *= 2;
        data.resize(2 * n);
        lazy.resize(2 * n);
        h = sizeof(int) * 8 - __builtin_clz(n);
    }

    void apply(int i, LL val) {
        data[i] += val;
        if (i < n) lazy[i] += val;
    }

    void build(int i) {
        while (i > 1) {
            i >>= 1;
            data[i] = max(data[i << 1], data[i << 1 | 1]) + lazy[i];
        }
    }

    void incr(int l, int r, LL val) {
        l += n; r += n;
        int l0 = l, r0 = r;
        for (; l < r; l >>= 1, r >>= 1) {
            if (l & 1) apply(l++, val);
            if (r & 1) apply(--r, val);
        }
        build(l0);
        build(r0 - 1);
    }

    void push(int p) {
        for (int s = h; s > 0; s--) {
            int i = p >> s;
            if (lazy[i] != 0) {
                apply(i << 1, lazy[i]);
                apply(i << 1 | 1, lazy[i]);
                lazy[i] = 0;
            }
        }
    }

    LL query(int l, int r) {
        l += n; r += n;
        push(l);
        push(r - 1);
        LL res = LONG_MIN;
        for (; l < r; l >>= 1, r >>= 1) {
            if (l & 1) res = max(res, data[l++]);
            if (r & 1) res = max(res, data[--r]);
        }
        return res;
    }
};

int main() {
    IOS;

    int N, M;
    cin >> N >> M;
    unordered_map<int, VI> add;
    unordered_map<int, vector<pair<int, int>>> del;
    int l, r, a;
    forn(i, 0, M) {
        cin >> l >> r >> a;
        add[l].push_back(a);
        del[r].push_back(make_pair(l, a));
    }

    LazySegTree seg(N);
    LL res = 0;
    for (int k = 1; k <= N; k++) {
        for (auto a: add[k])
            seg.incr(0, k, a);

        LL mx = seg.query(0, k);
        res = max(res, mx);
        seg.incr(k, k + 1, mx);

        for (auto d: del[k])
            seg.incr(0, d.first, -d.second);
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 46616
#include <bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

static const double pi = 3.141592653589793;

struct Problem {

	double n(pair<double, double> v) {
		double buf = 0.0;
		if (v.first < 0.0) buf += pi;
		if (v.first == 0.0) {
			if (v.second > 0.0) buf += pi * 0.5;
			else buf -= pi * 0.5;
		}
		else { buf += atan(v.second / v.first); }
		return buf + pi * 0.5;
	}

	void Solve() {
		UL N; cin >> N;
		vector<pair<double, double>> P(N);
		rep(i, N) cin >> P[i].first >> P[i].second;
		rep(i, N) {
			double s = 0.0, r = 2.0 * pi;
			vector<double> buf;
			rep(j, N) {
				if (i == j) continue;
				auto l = n({ P[j].first - P[i].first, P[j].second - P[i].second });
				while (l >= pi) l -= pi * 2;
				while (l < -pi) l -= pi * 2;
				buf.push_back(l);
			}
			sort(buf.begin(), buf.end());
			buf.push_back(buf[0] + 2.0 * pi);
			double d = 0.0;
			rep(i, buf.size() - 1) { d = max(d, buf[i + 1] - buf[i]); }
			cout << (max(0.0, d - pi) / (2.0 * pi)) << endl;
		}
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}

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

long long hash[200001];
long long a[200001];

int main()
{
	int n;
	long long temp;
	long long sum=0;
	cin>>n;
	
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		hash[a[i]]++;
	}
	
	for(int i=1;i<=n;i++)
	{
		temp=hash[i];
		sum+=temp*(temp-1)/2;
	}
	
	for(int i=1;i<=n;i++)
		cout<<sum-hash[a[i]]+1<<endl;
	return 0;
}

Measured memory_bytes: 4736
#include<iostream>
using namespace std;
int main(){
int H,W;

while(1){
cin >> H >> W;
if(H==0&&W==0)break;
for(int i=1;i<=H;i++){
for(int j=1;j<=W;j++){cout << "#";
}
cout << "\n";
}
cout << endl;
}



return 0;
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
int N; long long a[101010];
vector<pair<int, int> > ans;
void ADD(int x, int y)
{
  ans.emplace_back(x, y);
  a[y] += a[x];
}
int main()
{
  scanf("%d", &N);
  for(int i=1; i<=N; ++i) scanf("%lld", a+i);
  int mini = min_element(a+1, a+N+1)-a;
  int maxi = max_element(a+1, a+N+1)-a;
  if(a[mini] < 0 && a[maxi] > 0)
  {
    int pind;
    if(-a[mini] < a[maxi]) pind = maxi;
    else pind = mini;
    for(int i=1; i<=N; ++i)
      if(i!=pind) ADD(pind, i);
  }
  
  bool m = false;
  for(int i=1; i<=N; ++i) if(a[i] < 0) m = true;
  
  if(m)
    for(int i=N-1; i>=1; --i)
      ADD(i+1, i);
  else
    for(int i=1; i<=N-1; ++i)
      ADD(i, i+1);

  printf("%d\n", (int)ans.size());
  for(auto x: ans)
    printf("%d %d\n", x.first, x.second);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define repR(i, n) for(ll i = n; i >= 0; i--)
#define For(i, m, n) for(ll i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

using namespace std;
struct Fast {Fast(){std::cin.tie(0);std::ios::sync_with_stdio(false);}} fast;

ll gcd(ll a, ll b){
    ll r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

bool vector_find(std::vector<ll> vec, ll number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
    if (index != vec.size()) {
        return true;
    }
    else {
        return false;
    }
}

vector<string> split(const string& src, const char* delim = ":") {
    vector<string> vec;
    string::size_type len = src.length();
    
    for (string::size_type i = 0, n; i < len; i = n + 1) {
        n = src.find_first_of(delim, i);
        if (n == string::npos) {
            n = len;
        }
        vec.push_back(src.substr(i, n - i));
    }
    
    return vec;
}

int main(int argc, char *argv[]){
    ll result = 0;
    ll N, M;
    cin >> N >> M;
    
    vector<ll> L(M);
    vector<ll> R(M);
    rep(i, M){
        cin >> L[i];
        cin >> R[i];
    }
    sort(ALL(L));
    sort(ALL(R));
    
    result = R[0] - L[M-1] + 1;
    if(result < 0){
        result = 0;
    }
    
    cout << result << endl;
}


Measured memory_bytes: 1792
import java.util.*;

import javax.lang.model.util.ElementScanner6;

public class Main{
    static long[] sum, p;
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        long X = sc.nextLong();
        sc.close();

        sum = new long[N+1];
        p = new long[N+1];
        for(int i = 0; i < N+1; i++){
            if(i == 0){
                sum[0] = 1;
                p[0] = 1;
            } else {
                sum[i] = 2*sum[i-1]+3;
                p[i] = 2*p[i-1]+1;
            }
        }
        System.out.println(ans(N, X));
    }
    static long ans(int N, long X){
        if(X == 1){
            if(N == 0)
                return 1;
            else
                return 0;
        } else {
            if(1 < X && X <= 1+sum[N-1])
                return ans(N-1, X-1);
            else if(X == 2+sum[N-1])
                return p[N-1]+1;
            else if(2+sum[N-1]<X && X <= 2+2*sum[N-1])
                return p[N-1]+1+ans(N-1, X-2-sum[N-1]);
            else 
                return 2*p[N-1]+1;
        }
    }
}

Measured memory_bytes: 21716
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>

int main(){

  int N;
  scanf("%d",&N);
  std::multimap<long long, long long > value;
  long long temp1, temp2;
  for (int i=0; i<N; i++){
    scanf("%lld",&temp1);
    scanf("%lld",&temp2);
    value.insert(std::make_pair(temp2, temp1));
  }
  bool result = true;
  long long counter = 0;
  for (auto const& entry: value) {
    counter += entry.second;
    //printf("counter=%lld\n",counter);
    //printf("entry.first=%lld\n",entry.first);
    if (entry.first<counter){
      result = false;
      break;
    }
  }
  printf("%s\n",result?"Yes":"No");
  return 0;
}


Measured memory_bytes: 14848
#include <iostream>
#include <algorithm>
#include <tr1/unordered_map>
using namespace std;

int n , v[20];

tr1::unordered_map<int,int> memo[20];

int f(int pos , int sum){
	return pos == n ? abs(sum) : memo[pos].count(sum) ? memo[pos][sum] : memo[pos][sum] = min( f(pos+1,sum+v[pos]) , f(pos+1,sum-v[pos]) );
}

int main(){
	while(cin >> n && n){
		for(int i = 0 ; i < n ; i++) cin >> v[i] , memo[i].clear() ;
		cout << f(0,0) << endl;
	}
}

Measured memory_bytes: 3452
while true
    w = gets.to_i
    break if w == -1
    sum = 1150
    sum += 125 * [(w - 10), 10].min if w > 10
    sum += 140 * [(w - 20), 10].min if w > 20
    sum += 160 * (w - 30) if w > 30
    puts 4280 - sum
end



Measured memory_bytes: 6832
#include<cstdio>
#include<cstring>
char str[100005];
int main()
{
    int N;
    scanf("%s",str);
    N=strlen(str);
    int win,lose;
    win=0;
    lose=0;
    int m=0;
    for(int i=0;i<N;i++)
    {
        if(m>0)
        {
            if(str[i]=='g')
            {
                win++;
            }
            m--;
        }
        else
        {
            if(str[i]=='p')
            {
                lose++;
            }
            m++;
        }
    }
    printf("%d\n",win-lose);
    return 0;
}


Measured memory_bytes: 256
from collections import deque
n = int(input())
li = []
for _ in range(n - 1):
    li.append(list(map(int, input().split())))

# construct graph
edges = [set() for _ in range(n)]
for i, j in li:
    i -= 1
    j -= 1
    edges[i].update({j})
    edges[j].update({i})

# search middle edge and cut
Q = deque()
Q.append([0, 0])
visited = {0}
pre = {}
while len(Q) > 0:
    u, d = Q.pop()
    if u == n - 1:
        i = (d - 1) // 2
        a = u
        for _ in range(i + 1):
            b = a
            a = pre[b]
        edges[a].remove(b)
        edges[b].remove(a)
        break
    for v in edges[u]:
        if v not in visited:
            pre[v] = u
            visited.update({v})
            Q.append([v, d + 1])

# count Fennec's area
Q = deque()
Q.append(0)
visited = {0}
while len(Q) > 0:
    u = Q.pop()
    for v in edges[u]:
        if v not in visited:
            visited.update({v})
            Q.append(v)

ans = 'Snuke' if len(visited) <= n // 2 else 'Fennec'

print(ans)

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

int main(void){
int n;
int i,j,k;
long ans=0;
long t[998][998];
for(i=1;i<998;i++){
	for(j=1;j<999;j++){
		if(i<j)t[i][j]=(i+j)*(j-i+1)/2;
	}
}
while(true){
ans=0;
cin>>n;
if(n==0)return 0;
for(i=1;i<998;i++){
	for(j=1;j<998;j++){
		if(i<j&&t[i][j]==n){ans+=1;/*cout<<"i="<<i<<endl;cout<<"j="<<j<<endl;*/}
	}
}
cout<<ans<<endl;
}
return 0;
}



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

ll mod = 998244353;
vector<ll> fact;
vector<ll> ifact;

ll mod_pow(ll x, ll n)
{
  ll ret = 1;
  while (n > 0)
  {
    if (n & 1)
      ret = ret * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return ret;
}

void mod_ifact(ll n)
{
  fact.resize(n + 1);
  fill(fact.begin(), fact.end(), 1);
  ifact.resize(n + 1);
  fill(ifact.begin(), ifact.end(), 0);
  for (ll i=1; i<n+1; i++)
    fact[i] = fact[i-1] * i % mod;
  ifact[n] = mod_pow(fact[n], mod - 2);
  for (ll i=n; i>0; i--)
    ifact[i-1] = ifact[i] * i % mod;
}

ll mod_comb(ll n, ll k)
{
  if (k < 0 || k > n)
    return 0;
  return fact[n] * ifact[k] % mod * ifact[n-k] % mod;
}
int main()
{
  int n, m, k;
  cin >> n >> m >> k;
  mod_ifact(n);
  ll ans = 0;
  rep(i, k + 1)
    ans = (ans + mod_comb(n - 1, i) * m % mod * mod_pow(m - 1, n - 1 - i)) % mod;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6364
N, P = map(int, input().split())


def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def divisorize(fct):
    b, e = fct.pop()  # base, exponent
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]


def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a


if P==1:
    print(1)
else: 
    fct = factorize(P)
    
    al = []

    for div in divisorize(fct):
        al.append(num(div))

    al.sort()
    al.reverse()

    for i in range(len(al)-1):
        c =0
        tmp = P
        while tmp%al[i] == 0 and al[i]>1:
            c = c+1
            tmp = tmp//al[i]
        if c>=N:
            print(al[i])
            break
    else:
        print(1)


Measured memory_bytes: 3192