akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds; 
#define gc getchar_unlocked
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long int
#define s(x)	cin>>x
#define p(x)	cout<<x<<"\n"
#define goog(x, y)  cout<<"Case #"<<x<<": "<<y<<"\n"
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define INF 100000000000
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpi;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
typedef long double ld;

mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}
int mpow(int base, int exp); 
void ipgraph(int n, int m);
void dfs(int u, int par);
int gcd(int a, int b) ;

const int mod = 1'000'000'007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];

int count(string a,string b)
{   int res=0;
    int n=a.length();
    fo(i,n)
    {   if(a[i]!=b[i]) ++res;
    }
    return res;
}

void solve() {
  string s,t;cin>>s>>t;
  int a=s.length(),b=t.length();
  int minv=1000000;
  for(int i=0;i+b-1<a;++i)
  { minv=min(minv,count(s.substr(i,b),t));}
  p(minv);
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

    int t = 1;
    //cin >> t;
    while(t--) {
      solve();
    }

    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
    //u--, v--;
		g[u].pb(v);
		g[v].pb(u);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

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

Measured memory_bytes: 10640
using System;
using System.Linq;

class Program {
    static void Main(string[] args) {
        int a = Cin.Ni();
        int total = 0;
        for (int i = 0; i < 1000000000; i++) {
            total += i;
            if(total >= a) {
                Console.WriteLine(i);
                return;
            }
        }

    }
}


public class Cin {
    private static string[] s = new string[0];
    private static int i = 0;

    private static char[] cs = new char[] { ' ' };

    public static string Next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return Next();
    }

    public static int Ni() {
        return int.Parse(Next());
    }

    public static long NextLong() {
        return long.Parse(Next());
    }

    public static double NextDouble() {
        return double.Parse(Next());
    }

}


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

int main(){
  int i,j,cnt;
  int n,k;
  cin>>n>>k;
  int h[n];
  for(i=0;i<n;i++)cin>>h[i];
  cnt=0;
  for(i=0;i<n;i++){
    if(h[i]>=k)cnt++;
  }
  cout<<cnt;  
}

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

int main() {
	ios::sync_with_stdio(0);cin.tie(0);
	int n;
	cin >> n;
	vector<long long> v(n+1), dpl(n+1), dpl2(n+1), dpr(n+1, n+1), dpr2(n+1, n+1), where(n+1);
	set<long long> pst;
	for(int i=1; i<=n; i++) {
		cin >> v[i];
		where[v[i]] = i;
	}
	for(int i=n; i>=1; i--) {
		auto it = pst.lower_bound(where[i]);
		if(it != pst.end()) {
			dpr[where[i]] = *it;
			if(next(it) != pst.end()) {
				dpr2[where[i]] = *next(it);
			}
		}
		if(it != pst.begin()) {
			it--;
			dpl[where[i]] = *it;
			if(it != pst.begin()) {
				dpl2[where[i]] = *prev(it);
			}
		}
		pst.insert(where[i]);
	}
	long long ans = 0;
	for(int i=1; i<=n; i++) {
		//printf("at i=%d, dpl2, dpl = %lld, %lld  dpr, dpr2=%lld, %lld\n", i, dpl2[i], dpl[i], dpr[i], dpr2[i]);
		//printf("added is %lld * %lld * %lld\n", v[i], (i-dpl[i]));
		ans += v[i]*((i-dpl[i])*(dpr2[i]-dpr[i]) + (dpr[i]-i)*(dpl[i]-dpl2[i]));
	}
	cout << ans;
}

Measured memory_bytes: 9600
import std.stdio, std.algorithm, std.conv, std.array, std.string;

void main()
{
    auto x = readln.split[1].to!long;
    auto as = readln.split.to!(long[]);

    auto last = as[0];
    long let = 0;
    foreach (a; as[1..$]) {
        long d;
        if (a+last > x) {
            d = (a+last) - x;
            let += d;
        }
        last = a-d < 0 ? 0 : a-d;
    }

    writeln(let);
}

Measured memory_bytes: 4424
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define rep(i,n) for (lint i = 0; i < (n); i++)
#define rep1(i,n) for (lint i = 1; i < (n); i++)
#define repre(i,n) for (lint i = N-1; i < 0; i--)
#define rep1re(i,n) for (lint i = N-1; i < 1; i--)

char C;

int main() {
    // input
    cin >> C;
    cout << ++C << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s=sc.next();
		int xcnt=0;
		int st=0;int end=s.length()-1;
		int er=0;
		while(st!=end&&st<end){
			String sst=s.substring(st, st+1);
			String send=s.substring(end,end+1);
			if(sst.equals("x")&&send.equals("x")){
				st++;
				end--;
			}else if(sst.equals("x")){
				xcnt++;
				st++;
			}else if(send.equals("x")){
				xcnt++;
				end--;
			}else {
				if(sst.equals(send)){
					st++;
					end--;
				}else{
					er=1;
					break;
				}
			}
		}
		if(er==1){
			System.out.println(-1);
		}else{
			System.out.println(xcnt);
		}
	}

}

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

#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433L;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
	string S; cin >> S;
	reverse(ALL(S));
	int N = S.size();
	vector<ll> A(N),B(N);
	for(int i = 0; i < N; ++i) {
		A[i] = S[i]-'0';
	}
	ll mul = 1;
	for(int i = 0; i < N; ++i) {
		B[i] = (A[i]*mul) % 2019;
		(mul *= 10) %= 2019;
	}
	map<ll,vector<int>> mp;
	for(int i = 1; i < N; ++i) {
		(B[i] += B[i-1]) %= 2019;
	}
	for(int i = 0; i < N; ++i) {
		mp[B[i]].push_back(i);
	}
	mp[0].push_back(-1);
	ll ans = 0;
	for(auto p:mp) {
		ll x = p.second.size();
		ans += (x*(x-1))/2;
	}
	cout << ans << endl;

    return 0;
}


Measured memory_bytes: 8312
#include<iostream>
#include<utility>
#include<queue>
using namespace std;

typedef pair<int, string> p; 

int main(){
	priority_queue <p, vector<p>,greater<p> >pq;
	int n;
	cin >> n;
	while(n--){
		string str;
		int d;
		cin >> str >> d;
		pq.push(make_pair(d,str));
	}
	int m;
	cin >> m;
	bool test=true;
	int c=0;
	int temp=0;
	string str;
	for(int i=0;i<m;i++){
		cin >> str;
		if(!test) continue;
		test=false;
		while(!pq.empty()){
			if(pq.top().second!=str||pq.top().first==temp){
				pq.pop();
			}else{
				c++;
				temp=pq.top().first;
				test=true;
				pq.pop();
				break;
			}
		}
	}
	if(c==m) cout << "Yes"<<endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 12320
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <cctype>
#include <functional>
#include <string>
#include <cstring>
#include <sstream>
#include <deque>
#define fir first
#define sec second
using namespace std;

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

const int inf1=1e9+9;
const ll inf2=1e16+9;
const ll mol=1e9+7;
const int maxn=5e6+9;
const ll maxx=1e12+9;

int n,ar[111];

int main()
{
    cin>>n;
    for(int i=0;i<n;i++) cin>>ar[i];
    sort(ar,ar+n);
    int cnt=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            for(int k=j+1;k<n;k++)
            {
                if(ar[i]!=ar[j]&&ar[j]!=ar[k]&&ar[k]!=ar[i]&&ar[i]+ar[j]>ar[k]&&ar[i]+ar[k]>ar[j]&&ar[j]+ar[k]>ar[i])
                    cnt++;
            }
        }
    }
    printf("%d\n",cnt);
}


Measured memory_bytes: 3224
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
 
using namespace std;
 
#define PB push_back
#define MP make_pairA
#define REP(i,n) for(int i=0;i<(n);i++)
int main()
{
    int n,k;
    cin>>n>>k;
    cout<<n-k+1<<endl;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {

	int n, d; cin >> n >> d;

	d = 2 * d + 1;

	int ans = (n + d - 1) / d;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define pb push_back
 
const int maxn = 2e5 + 20;
const int mod = 1e9 + 7;

int from[maxn] , to[maxn] , w[maxn] , fs[maxn] , fv[maxn];

ll d[2][maxn];

vector<int> adj[maxn] , out[maxn] , in[maxn];

bool cmp(int a , int b)
{
	return d[0][a] < d[0][b];
}

inline void mkay(int &a)
{
	if(a >= mod)
		a -= mod;
	else if(a < 0)
		a += mod;
}

int t2(int x)
{
	return 1LL * x * x % mod;
}

void dij(ll* d , int s)
{
	fill(d , d + maxn , 1e18);
	set<pair<ll , int> > st;
	d[s] = 0;
	st.insert({d[s] , s});

	while(!st.empty())
	{
		int v = st.begin() -> second;
		ll W = st.begin() -> first;
		st.erase(st.begin());

		if(d[v] != W)
			continue;

		for(auto e : adj[v])
		{
			int u = from[e] ^ to[e] ^ v;
			if(d[u] > d[v] + w[e])
			{
				d[u] = d[v] + w[e];
				st.insert({d[u] , u});
			}
		}
	}

}

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

	int n , m , s , t;
	cin >> n >> m >> s >> t;
	s-- , t--;

	for(int i = 0; i < m; i++)
	{
		int a , b;
		cin >> a >> b >> w[i];
		a-- , b--;

		adj[a].pb(i);
		adj[b].pb(i);

		from[i] = a , to[i] = b;
	}

	dij(d[0] , s);
	dij(d[1] , t);
	
	vector<int> topol;
	for(int v = 0; v < n; v++)
	{
		topol.pb(v);
		for(auto e : adj[v])
		{
			int u = from[e] ^ to[e] ^ v;
			if(d[0][v] + w[e] + d[1][u] == d[0][t])
				out[v].pb(u) , in[u].pb(v);
		}
	}

	sort(topol.begin() , topol.end() , cmp);
	fs[s] = 1;
	for(int i = 1; i < n; i++)
	{
		int v = topol[i];
		for(auto u : in[v])
			mkay(fs[v] += fs[u]);
	}

	fv[t] = 1;
	for(int i = n - 2; i >= 0; i--)
	{
		int v = topol[i];
		for(auto u : out[v])
			mkay(fv[v] += fv[u]);
	}

	assert(fv[s] == fs[t]);
	int res = 1LL * fv[s] * fv[s] % mod;

	for(int v = 0; v < n; v++)
	{
		if(d[0][v] + d[1][v] == d[0][t] && d[0][v] == d[1][v])
			mkay(res -= t2(1LL * fv[v] * fs[v] % mod));

		for(auto u : out[v])
			if(d[0][v] * 2 < d[0][t] && d[0][t] < d[0][u] * 2)
				mkay(res -= t2(1LL * fs[v] * fv[u] % mod));
	}

	cout << res << endl;
}


















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

using namespace std;

int main() {
#ifdef wxh010910
  freopen("input.txt", "r", stdin);
#endif
  int n, m, q;
  scanf("%d %d %d", &n, &m, &q);
  vector<int> mins(n, m);
  for (int i = 0; i < q; ++i) {
    int x, y;
    scanf("%d %d", &x, &y);
    --x;
    --y;
    mins[x] = min(mins[x], y);
  }
  int right = 0;
  for (int i = 1; i < n; ++i) {
    if (right >= mins[i]) {
      printf("%d\n", i);
      return 0;
    }
    if (right + 1 < mins[i]) {
      ++right;
    }
  }
  printf("%d\n", n);
  return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <vector>
#include <string> 
#include <set>
typedef long long ll;
using namespace std;


int main() {
    int cnt = 0;
    string s, t; cin >> s >> t;
    for (int i = 0; i < t.size(); ++i) {
        if (t[i] != s[i])
            cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

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

  cout << n+m/2 << endl;
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define MOD 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//↑templete
int main(){
	int r;
	cin>>r;
	cout<<r*r<<endl;
	return 0;
}

Measured memory_bytes: 256
n = gets.to_i
h = gets.split.map(&:to_i)
dp = [0]
n.times do |idx|
  break if h[idx+1].nil?
  dp[idx+1] = dp[idx+1].nil? ? dp[idx] + (h[idx+1] - h[idx]).abs : [dp[idx+1], dp[idx] + (h[idx+1] - h[idx]).abs].min

  next if h[idx+2].nil?
  dp[idx+2] = dp[idx+2].nil? ? dp[idx] + (h[idx+2] - h[idx]).abs : [dp[idx+2], dp[idx] + (h[idx+2] - h[idx]).abs].min
end
puts dp[n-1]


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll A, B, K; cin >> K >> A >> B;
    bool flag = false;
    rep2(i, A, B + 1){if (i % K == 0){flag = true; break;}}
    if (flag){
        cout << "OK" << endl;
    } else {
        cout << "NG" << endl;
    }
}


int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3648
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000000LL;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(),(x).end()

int main() {
    string str;
    cin >> str;
    if(str[2] == str[3] && str[4] == str[5])
      cout << "Yes" << ln;
    else
      cout << "No" << ln;
}


Measured memory_bytes: 256
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
using namespace std;
const int M = 1002;
const int N = (1 << 12);
const int INF = 0x3f3f3f3f;

int n, m, a[M], b[M];
int dp[M][N + 2];

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int t; cin >> a[i] >> t;
        while (t--) {
            int c; cin >> c;
            b[i] |= 1 << c - 1;
        }
    }
    memset(dp, 0x3f, sizeof dp);
    dp[0][0] = 0;
    dp[0][b[0]] = a[0];
    for (int i = 1; i < m; ++i) {
        for (int j = 0; j < (1 << n); ++j) {
            dp[i][j | b[i]] = min(dp[i][j | b[i]], dp[i - 1][j] + a[i]);
        }
        for (int j = 0; j < (1 << n); ++j) {
            dp[i][j] = min(dp[i][j], dp[i - 1][j]);
        }
    }
    cout << (dp[m - 1][(1 << n) - 1] == INF ? -1 : dp[m - 1][(1 << n) - 1]) << '\n';
}

Measured memory_bytes: 16256
module MakeBinaryHeap (M : sig type t val compare : t -> t -> int end) = struct

  type t = { node : M.t array; mutable size : int }

  let make n (init : M.t) = { node = Array.make n init; size = 0 }

  let empty_p t = if t.size = 0 then true else false

  let pop t =
    if t.size <= 0 then failwith "out of size" else
    let rec max_heapify i =
      let l = 2*i in
      let r = 2*i + 1 in
      let m = if l <= t.size && M.compare t.node.(l) t.node.(i) > 0 then l else i in
      let m = if r <= t.size && M.compare t.node.(r) t.node.(m) > 0 then r else m in
      if m = i then ()
      else begin
        let tmp = t.node.(i) in
        t.node.(i) <- t.node.(m);
        t.node.(m) <- tmp;
        max_heapify m
      end in
    let ret = t.node.(1) in
    t.node.(1) <- t.node.(t.size);
    t.size <- t.size - 1;
    max_heapify 1;
    ret

  let push x t =
    let parent i = int_of_float (floor (float_of_int i) /. 2.) in
    let rec doit i =
      let p = parent i in
      if i <= 1 || M.compare t.node.(p) t.node.(i) >= 0 then ()
      else begin
        let tmp = t.node.(i) in
        t.node.(i) <- t.node.(p);
        t.node.(p) <- tmp;
        doit p
      end in
    t.size <- t.size + 1;
    t.node.(t.size) <- x;
    doit t.size

end

module H = MakeBinaryHeap(struct type t = (int * int) let compare (_, x) (_, y) = y - x end)

let prim a n =
  let reached_p = Array.make n false in
  let d = Array.make n max_int in
  d.(0) <- 0;
  let que = H.make 1000 (0, 0) in
  H.push (0, 0) que;
  while not (H.empty_p que) do
    let (u, _) = H.pop que in
    reached_p.(u) <- true;
    List.iter (fun (v, c) ->
      if not reached_p.(v) && c < d.(v) then begin
        d.(v) <- c;
        H.push (v, c) que;
      end) a.(u);
  done;
  Array.fold_left (fun sum c -> if c = max_int then sum else sum + c) 0 d

let () =
  let n = read_int () in
  let a = Array.make n [] in
  for i = 0 to n - 1 do
    for j = 0 to n - 1 do
      let x = Scanf.scanf " %d" (fun i -> i) in
      if x <> (-1) then a.(i) <- (j, x) :: a.(i);
    done
  done;
  prim a n |> Printf.printf "%d\n"

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

struct CumulativeSum{
    vector<int> data;
    CumulativeSum(int sz) : data(sz, 0) {};
    void add(int k, int x){
        data[k] += x;
    }
    void build(){
        for(int i = 1; i < data.size(); i++){
            data[i] += data[i - 1];
        }
    }
    //区間[0,k]の和
    int query(int k){
        if(k < 0) return 0;
        return (data[min(k, (int)data.size() - 1)]);
    }
    //区間[l.r)の和
    int query(int l, int r){
        return query(r - 1) - query(l - 1);
    }
};

int main(){
    int n, t;
    cin >> n >> t;
    CumulativeSum cs(t + 1);
    for(int i = 0; i < n; i++){
        int l, r;
        cin >> l >> r;
        cs.add(l, 1);
        cs.add(r, -1);
    }
    cs.build();
    int ans = 0;
    for(int i = 0; i <= t; i++){
        ans = max(ans, cs.query(i));
    }
    cout << ans << endl;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll a,b,c;
    cin>>a>>b>>c;
    if(a<b && b<c)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}





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

using namespace std;

using ll = long long;

struct Edge {
    int dst, w;
    Edge() {}
    Edge(int _d, int _w) : dst(_d), w(_w) {}
};

bool Dfs(int cur, auto &d, auto &visited, const auto &adj) {
    for (auto e : adj[cur]) {
        if (!visited[e.dst]) {
            d[e.dst] = d[cur] + e.w;
            visited[e.dst] = true;
            if (Dfs(e.dst, d, visited, adj)) return true;
        }
        else if (d[e.dst] != d[cur] + e.w)
            return true;
    }
    return false;
}

bool Solve() {
    int n, m;
    cin >> n >> m;

    vector<vector<Edge>> adj(n);
    for (int i = 0; i < m; ++i) {
        int l, r, d;
        cin >> l >> r >> d;
        adj[l - 1].emplace_back(Edge(r - 1, d));
        adj[r - 1].emplace_back(Edge(l - 1, -d));
    }

    vector<int> d(n, 0);
    vector<bool> visited(n, false);
    for (int v = 0; v < n; ++v) {
        if (visited[v]) continue;
        visited[v] = true;
        if (Dfs(v, d, visited, adj)) return false;
    }

    return true;
}

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

    if (Solve()) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}


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

using namespace std;
int main ()
{
    typedef pair<int,long> pair;
    vector<pair> pre;
    int N,M,A;
    int P[100010];
    long Y[100010];
    cin >> N >> M;
    for(int i=0;i<M;i++){
        cin >> P[i] >> Y[i];
    }
    for(int i=0; i<M; i++){
        pre.push_back(pair(i, Y[i]));
    }
    sort(
        pre.begin(),
        pre.end(),
        [](const pair& x, const pair& y){return x.second < y.second;}
    );
    int X[100010];
    map<int,int> mp;
    for(int i=0; i<M; i++){
        mp[P[pre.at(i).first]]++;
        X[pre.at(i).first]=mp[P[pre.at(i).first]];
    }
    for(int i=0;i<M;i++){
        printf("%06d",P[i]);
        printf("%06d\n",X[i]);
    }
    return 0;
}












Measured memory_bytes: 9328
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long k;
  string s;
  cin>>k>>s;
  long long n=s.size();
  string ans="";
  if(n<=k)
    ans=s;
  else{
    for(int i=0;i<k;i++){
      ans+=s[i];
    }
    ans+="...";
  }
  cout<<ans<<"\n";
  return 0;
}
 

Measured memory_bytes: 3632
s =input()
k =int(input())
a =[]
if len(s)==1:
    a.append(s)
else:
    for i in range(len(s)):
        for j in range(i,i+k+1):
            if i!=j:
                a.append(s[i:j])
            else:
                a.append(s[i])
a.sort()
temp=""
cnt,i=0,0
for i in range(len(a)):
    if temp != a[i]:
        cnt += 1
        if cnt ==k:
            break
    temp = a[i]
print(a[i])

Measured memory_bytes: 4404
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
int main(){
  int N, A;
  cin >> N >> A;
  int L = A;//りんごのおいしさの開始点
  int R = A+N-1;//りんごのおいしさの終了点
  int eat;
  if(R<=0) eat=R;//りんごのおいしさの終了点が0以下なら、食べるりんごはR
  else if(L>=0)eat=L;//りんごのおいしさの開始点が0以上なら、食べるりんごはL
  else eat=0;
  
  int answer=(R+L)*(R-L+1)/2-eat;
  cout << answer << endl;
}

Measured memory_bytes: 256
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
string.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
local function array(dimensi0n, default_val) assert(type(default_val) ~= 'table') local n=dimensi0n local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end
--
x = read.n()
if x < 400 then y = 0
elseif x < 600 then y = 8 
elseif x < 800 then y = 7 
elseif x < 1000 then y = 6 
elseif x < 1200 then y = 5 
elseif x < 1400 then y = 4 
elseif x < 1600 then y = 3 
elseif x < 1800 then y = 2 
elseif x < 2000 then y = 1 
end
print(y)


Measured memory_bytes: 2748
#include <iostream>
using namespace std;
int main(void){
    while(true){
        
        int a=0;
        int n,x;
        cin >> n >> x;
        if(n==0 && x==0)    break;
        
        for(int i=1;i<=n;i++){
            for(int j=i+1;j<=n;j++){
                for(int k=j+1;k<=n;k++){
                    
                    if(i+j+k==x)    a++;
                    
                }
            }
        }
        
        cout << a << endl;
        
    }
    
}


Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n) ; i++)
#define rrep(i,n) for(int i = n-1; i >= 0 ; i--)
typedef long long ll;
constexpr auto INFI = 2147483647;
const ll INFL = 9223372036854775807;

int main(){

  int n,  m;
  cin >> n >> m;
  vector<int> parent(n,-1);
  vector<vector<int>> route(n);
  int a, b;
  rep(i,m){
    cin >> a >> b;
    a--;
    b--;
    route[a].emplace_back(b);
    route[b].emplace_back(a);
  }
  queue<int> que;
  que.push(0);
  parent[0] = INFI;
  while (!que.empty()) {
    int now = que.front();
    que.pop();
    if (route[now].empty()) continue;
    int size_route = (int)route[now].size();
    rep(i, size_route) {
      int next = route[now][i];
      if(parent[next] == -1) {
        parent[next] = now;
        que.push(next);
      }
    }
  }

  rep(i,n){
    if (parent[i] == -1){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  for(int i = 1; i<n; i++){
    cout << parent[i] + 1 << endl;
  }

  return 0;
}

Measured memory_bytes: 10136
#include <iostream>

using namespace std;

int getWays(int n, int x)
{
    int ways = 0;
    for(int i = 1; i <= n; ++i){
        for(int j = i + 1; j <= n; ++j){
            for(int k = j + 1; k <= n; ++k){
                if(i + j + k == x) ++ways;
            }
        }
    }
    return ways;
}
int main()
{
    int n, x;
    while(1){
        int n, x;
        cin >> n >> x;
        if(n == 0 && x == 0) break;
        int ways = getWays(n, x);
        cout << ways << endl;
    }
    return 0;
}

Measured memory_bytes: 3104
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>

using namespace std;

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

typedef pair<int, int> pint;
typedef long long ll;

int main()
{
    int a[3];
    for (int i = 0; i < 3; i++)
    {
        cin >> a[i];
    }
    int res = 0;
    int dif[3];
    for (int i = 0; i < 3; i++)
    {
        dif[i] = abs(a[i % 3] - a[(i + 1) % 3]);
        res += dif[i];
    }
    res -= max(dif[0], max(dif[1], dif[2]));
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"math"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// Priority Queue
type Item struct {
	priority, value, index int
}

type PQ []*Item

func (pq PQ) Len() int {
	return len(pq)
}

func (pq PQ) Less(i, j int) bool {
	return pq[i].priority < pq[j].priority
}

func (pq PQ) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *PQ) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Item)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *PQ) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	item.index = -1
	*pq = old[0 : n-1]
	return item
}

// End Priority Queue

// Path
type Edge struct {
	to, cost int
}

type Path struct {
	edges []Edge
}

// Dijkstra
type Route struct {
	path []int
}

func Dijkstra(N, S int, path []Path) ([]int, []Route) {
	pq := make(PQ, 0)
	heap.Init(&pq)
	d := make([]int, N+1)
	r := make([]Route, N+1)
	// init
	for i := 0; i <= N; i++ {
		d[i] = math.MaxInt32
	}
	d[S] = 0
	r[S].path = []int{S}
	heap.Push(&pq, &Item{0, S, 0})
	for pq.Len() > 0 {
		item := heap.Pop(&pq).(*Item)
		v := item.value
		if d[v] < item.priority {
			continue
		}
		for _, e := range path[v].edges {
			if d[e.to] > d[v]+e.cost {
				d[e.to] = d[v] + e.cost
				r[e.to].path = append(r[v].path, e.to)
				heap.Push(&pq, &Item{d[e.to], e.to, 0})
			}
		}
	}
	return d, r

}

func main() {
	sc.Split(bufio.ScanWords)

	N, M := getInt(), getInt()
	path := make([]Path, N+1)

	for i := 0; i < M; i++ {
		f, t := getInt(), getInt()
		path[f].edges = append(path[f].edges, Edge{t, 1})
		path[t].edges = append(path[t].edges, Edge{f, 1})
	}

	S, D := 1, N

	d, _ := Dijkstra(N, S, path)

	if d[D] == 2 {
		out("POSSIBLE")
	} else {
		out("IMPOSSIBLE")
	}
}


Measured memory_bytes: 34944
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;cin>>n;
  int kazu,non=1,all=1;
  for(int i=0;i<n;i++){
    cin>>kazu;
    if(kazu%2==0){
    	non*=2;
    }
    all*=3;
  }
  cout<<all-non<<endl;
}

Measured memory_bytes: 256
#include<functional>
#include<algorithm>
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define all(v) (v).begin(),(v).end()
#define pf push_front
#define pb push_back
#define int long long
using namespace std;
const int INF=1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


signed main(){
  int a[3];
  rep(i,3)cin>>a[i];
  sort(a,a+3);
  rep(i,3){
    cout<<a[i];
    if(i<2)cout<<' ';
  }
  cout<<endl;

  return 0;
}

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

using Field=vector<string>;
struct State{
    int h,w;
    int f;
    int bit;
    int cnt;
};
using vi=vector<int>;
using v2i=vector<vi>;
using v3i=vector<v2i>;
using v4i=vector<v3i>;
int dh[]={0,-1,0,1};
int dw[]={1,0,-1,0};
int main(){
    int w,h;
    cin>>w>>h;
    Field org(h);
    for(int i=0;i<h;i++) cin>>org[i];
    int s;
    cin>>s;
    vector<Field> swt(s,Field(h));
    for(int i=0;i<s;i++){
        for(int j=0;j<h;j++){
            cin>>swt[i][j];
        }
    }
    const int INF=1e9;
    v4i dp(h,v3i(w,v2i(2,vi(1<<s,INF))));
    auto isUsed=[&](State x){
        if(dp[x.h][x.w][x.f][x.bit]!=INF) return true;
        dp[x.h][x.w][x.f][x.bit]=x.cnt;
        return false;
    };

    queue<State> que;
    State goal;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(org[i][j]=='%'){
                org[i][j]='_';
                que.push({i,j,0,0,0});
            }
            if(org[i][j]=='&'){
                org[i][j]='_';
                goal={i,j,0,-1,INF};
            }
        }
    }
    auto turn=[&](State x){
        if(!isalpha(org[x.h][x.w])) return x;
        int k;
        if(isupper(org[x.h][x.w])){
            k=org[x.h][x.w]-'A';
        }
        else{
            k=org[x.h][x.w]-'a';
        }
        x.bit^=(1<<k);
        if(swt[k][x.h][x.w]=='*') x.f=(!x.f);
        return x;
    };
    auto stair=[&](State x){
        if(org[x.h][x.w]=='|'){
            x.f=!x.f;
            return x;
        }
        else return x;
    };
    auto height=[](char c){
        if(c=='_') return 0;
        if(c=='^') return 1;
        assert(isalpha(c));
        if(islower(c)) return 0;
        else return 1;
    };
    auto isValid=[&](State x){
        if(org[x.h][x.w]=='#') return false;
        else if(org[x.h][x.w]=='|') return true;
        else{
            int f=height(org[x.h][x.w]);
            for(int i=0;i<s;i++){
                if((x.bit>>i)&1 && swt[i][x.h][x.w]=='*'){
                    f=!f;
                }
            }
            return f==x.f;
        }
    };
    assert(que.size()==1);
    while(!que.empty()){
        State st=que.front(); que.pop();
        if(isUsed(st)) continue;
        for(int i=0;i<4;i++){
            State to={st.h+dh[i],st.w+dw[i],st.f,st.bit,st.cnt+1};
            if(isValid(to)){
                que.push(to);
            }
        }
        st.cnt++;
        que.push(turn(st));
        que.push(stair(st));
    }
    int res=INF;
    for(int i=0;i<(1<<s);i++){
        for(int j=0;j<2;j++){
            res=min(res,dp[goal.h][goal.w][j][i]);
        }
    }
    cout<<(res==INF ? -1 : res)<<endl;
    return 0;
}


Measured memory_bytes: 28548
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <algorithm>
#include <set>
#include <string>
#include <queue>

using namespace std;

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

int main(){
    ll N, K;
    cin >> N >> K;
    vector<ll> aSum(N);
    vector<ll> bSum(N);
    ll zero = 0;

    rep(i, N){
        cin >> aSum[i];
        bSum[i] = max(aSum[i], zero);
    }

    for(int i = 0; i < N - 1; i ++){
        aSum[i + 1] += aSum[i];
        bSum[i + 1] += bSum[i];
    }


    ll ans = -1e18;
    for(int k = 0; k + K  - 1 < N ; k ++){
        ll tmp = bSum[N - 1] - bSum[k + K - 1];
        ll b = aSum[k + K - 1];
        if(k >= 1){
            b -= aSum[k - 1];
            tmp += bSum[k - 1];
        }
        if(b > 0){
            tmp += b;

        }

        ans = max(ans, tmp);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int a;
	cin >> a;
	cout << a + a * a + a * a * a << endl;
	return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>
int main(){
	int i,j,a[10],x;
	for(i=0;i<10;i++)scanf("%d",&a[i]);
	for(i=0;i<10;i++){
		for(j=i+1;j<10;j++){
			if(a[i]<a[j]){
				x=a[i];
				a[i]=a[j];
				a[j]=x;
			}
		}
	}
	printf("%d\n%d\n%d\n",a[0],a[1],a[2]);
	return 0;
}


Measured memory_bytes: 2040
use std::collections::*;
use std::io;
use std::io::prelude::*;

fn main() {
    let t_cases = 1usize;
    // (0..t_cases).for_each(|_| solvea()); // run every test case
    (0..t_cases).for_each(|_| solveb());
}

// solve every test case
fn solvea(){
    let mut buf  = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let n = buf.trim().to_owned().parse::<f64>().unwrap();
    println!("{}",2f64*3.14159265*n);
}

fn solveb(){
    let mut buf  = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let a = buf.trim().split_whitespace().map(|x| x.parse::<i32>().unwrap()).collect::<Vec<_>>();
    let (n,_) = (a[0],a[1]);
    buf.clear();
    io::stdin().read_line(&mut buf).unwrap();
    let a = buf
                .trim()
                .split_whitespace()
                .map(|x| x.parse::<i32>().unwrap())
                .collect::<Vec<_>>()
                .iter()
                .sum::<i32>();
    if a<=n{
        println!("{}",n-a);
    }else{
        println!("{}",-1);
    }
}

Measured memory_bytes: 2212
// AOJ 1067 Cutting a Chocolate
// 2018.3.17 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define getchar_unlocked()  getchar()
int in()        // get a non-negative integer from stdin
{
	int n = 0, c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

double dbl()    // get a non-negative real number from stdin  
{
	double x, y;
	int n = 0, c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	x = n;
	if (c == '.') {
		y = 1, c = getchar_unlocked();
		do y *= 0.1, x += y * (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	}
	return x;
}

#define EQ(a,b)   (fabs(a-b)<1e-7)

typedef struct { double x, y; } P;
P p[30002];

int hl[30002], hr[30002], s[30002], a[30002];

int binary_search(int *tbl, int hi, int k, int key)
{
	int lo = 0, mi, r;

    while (lo < hi) {
        mi = (lo + hi) >> 1;
		r = tbl[mi]*k - key;
		if (!r) return mi;
        if (r < 0) lo = mi + 1; else hi = mi;
    }
	return lo-1;
}

int cmp(P *a, P *b)
{
	if (!EQ(a->y, b->y)) { if (a->y <= b->y) return -1;	return 1; }
	if ( EQ(a->x, b->x)) return 0; if (a->x <= b->x) return -1; return 1;
}

int main()
{
	int n, m, w, h, S, i, j, ans;
	double x, y, y1, y2;

	while (n = in()) {
		m = in(), w = in(), h = in(), S = (w*h-in()) << 1;
		for (i = 0; i < m; i++) {
			hl[i] = in(), hr[i] = in(), a[i] = 0;
			s[i] = hl[i] + hr[i];
		}
		for (i = 0; i < n; i++) p[i].x = dbl(), p[i].y = dbl();
		qsort(p, n, sizeof(P), cmp);

		j = 0; for (i = 0; i < n; i++) {
			x = p[i].x, y = p[i].y;
			while (1) {
				if (j == 0) y1 = 0;
				else y1 = (hr[j-1] - hl[j-1]) * x / w + hl[j-1];
				y2 = (hr[j] - hl[j]) * x / w + hl[j];
				if (y1 < y && y < y2) break;
				if (y < y1) j--;
				else j++;
			}
			a[j]++;
		}
		for (i = 1; i < m; i++) a[i] += a[i-1];

		if      (S == 0    ) { printf("%d\n", n); continue; }
		else if (S == 2*w*h) { puts("0");         continue; }

		j = binary_search(s, m, w, S); ans = a[j++];
		for (i = 0; j < m; j++) {
			while ((s[j] - s[i])*w > S) i++;
			if (a[j] - a[i] > ans) ans = a[j] - a[i];
		}
		printf("%d\n", n - ans);
	}
	return 0;
}



Measured memory_bytes: 3140
S = input()
[a,b,c,d] = list( map(int, [S[0],S[1],S[2],S[3]]) )

def pm_hantei(n,l_pm):
  return "+"*(l_pm[n]==0)+"-"*(l_pm[n]==1)


j=2**(4-1)
for k in range(j):
  b_str = format(k,"0{}b".format(4-1))
  l_pm = [ int(b_str[i]) for i in range(len(b_str)) ]
  wa = a + b*(-1)**(l_pm[0]) + c*(-1)**(l_pm[1]) + d*(-1)**(l_pm[2])
  

  if wa == 7:
    print("{}{}{}{}{}{}{}=7".format(a,pm_hantei(0,l_pm),b,pm_hantei(1,l_pm),c,pm_hantei(2,l_pm),d ) )
    break
  else:
    continue

Measured memory_bytes: 38256
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;


void solve() {
    int H1, M1, H2, M2, K; cin >> H1 >> M1 >> H2 >> M2 >> K;

    int time = (H2 - H1) * 60 + (M2 - M1);
    time -= K;

    cout << time << endl;

}


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

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

using namespace std;

int n,a[120000];

int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;++i) scanf("%d",a+i);
	sort(a+1,a+n+1,greater<int>());
	for (int i=1;i<=n;++i)
		if (i==n||i+1>a[i+1]){
			int t1=0,t2=0;
			for (int j=i+1;j<=n&&a[j]==i;++j) t1^=1;
			t2=(a[i]-i)&1;
			puts(t1|t2?"First":"Second");
			return 0;
		}
	
	return 0;
}
			

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

int main()
{
    int A, B, C;
    int64_t K;

    cin >> A >> B >> C >> K;

    if ( K % 2 == 0 ) {
        cout << A - B << endl;
    } else {
        cout << B - A << endl;
    }

    return (0);
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	string s,t;
	cin>>s>>t;
	int n=s.size();
	int m=t.size();
	s='0'+s;
	t='0'+t;
	string ans;
	int dp[n+1][m+1];
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=m;j++)
		{
			dp[i][j]=0;
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(s[i]==t[j])
			{
				dp[i][j]=1+dp[i-1][j-1];
			}
			else
			{
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			}
		}
	}
	int i=n;
	int j=m;
	while(i>=1&&j>=1)
	{
		if(s[i]==t[j])
		{
			ans=s[i]+ans;
			i--;
			j--;
			continue;
		}
		if(dp[i-1][j]>dp[i][j-1])
		{
			i--;
			continue;
		}
		else
		{
			j--;
			continue;
		}
		
	}
	cout<<ans;
}

Measured memory_bytes: 38840
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;
using ll = long long;
const int INF = 999999999;

int N, M;
vector<vector<int>> G;
vector<int> visited;
int ans;
int n_visited;

void dfs(int now) {
    visited[now] = 1;
    n_visited++;
    if (n_visited == N) ans++;
    for (int i = 0; i < G[now].size(); ++i) {
        int next = G[now][i];
        if(!visited[next]) dfs(next);
    }
    visited[now] = 0;
    n_visited--;
}

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

    G = vector<vector<int>>(N, vector<int>(N));
    visited = vector<int>(N, 0);
    for (int i = 0; i < M; ++i) {
        int a, b; cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    dfs(0);
    cout << ans << endl;

}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
using namespace std;

int main(){
    int a,b;
    cin>>a>>b;
    cout<<a*b<<" "<<2*(a+b)<<endl;
    return 0;
}


Measured memory_bytes: 3012
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define radrad(a)  180.0 * a / M_PI
#define pow(x) x*x
#define ll long long
static const int MAX = 100010;
static const ll INFTY = 1e12;
static const int NUMMAX = 300;


int main() {
 
 int N;

 cin >> N;

 cout << N * N * N << endl;

}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

signed main(){
	vint v(5);
	rep(i,5)cin>>v[i];
	sort(all(v));
	int ans=1001001001;
	do{
		int t=0;
		rep(i,5){
			t=(t+9)/10*10;
			t+=v[i];
		}
		chmin(ans,t);
	}while(next_permutation(all(v)));
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import math
input_num = int(input())
input_list = [int(input()) for i in range(input_num)]
input_list.sort()

max = input_list[len(input_list)-1]
sqrt_max = int(math.sqrt(max))
nums = [i + 2 for i in range(sqrt_max - 1)]
for num in input_list:
    if num > sqrt_max:
        nums.append(num)

prime_nums = []
while True:
    first_num = nums[0]
    if first_num > math.sqrt(max):
        break
    prime_nums.append(first_num)
    deleted = 0
    for i in range(len(nums)):
        index = i - deleted
        if nums[index] % first_num == 0:
            del nums[index]
            deleted += 1

prime_nums.extend(nums)

prime_count = 0
for num in input_list:
    if num in prime_nums:
        prime_count += 1

print(prime_count)



Measured memory_bytes: 6544
N, A, B = map(int, input().split())
towns = list(map(int ,input().split()))
sum_e = 0
for i in range(1, N):
  dis = towns[i] - towns[i-1]
  if dis * A > B:
    sum_e += B
  else:
    sum_e += dis * A
print(sum_e)

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

int main(){
  int n,k;
  cin>>n;
  vector<int> v(n);
  for(int i=0;i<n;i++){
    cin>>v[i];
  }
  k=1;
  for(int i=0;i<n;i++){
    if(v[i]==k) k++;
  }
  if(k==1){
    cout<<-1;
  }else{
    cout<<n+1-k;
  }
}


Measured memory_bytes: 1024