akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
using namespace std;
int main()
{
	int num;
	scanf("%d", &num);
	int t[100];
	for (int i = 0; i < num; i++)scanf("%d", &t[i]);
	int maxi = -1, rr = -1;
	for (int i = 0; i < num; i++)if (maxi < abs(t[i]))maxi = abs(t[i]), rr = i;
	printf("%d\n", num * 2 - 2);
	for (int i = 0; i < num; i++)if (i != rr)printf("%d %d\n", rr + 1, i + 1);
	if (t[rr] > 0)for (int i = 1; i < num; i++)printf("%d %d\n", i, i + 1);
	else for (int i = num - 1; i >= 1; i--)printf("%d %d\n", i + 1, i);
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <functional>
#include <cmath>
#define SIZE 200005

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int X[SIZE];

int main()
{
	int n;
	scanf("%d",&n);
	ll ret=0;
	for(int i=0;i<n;i++) scanf("%d",&X[i]);
	if(X[0]>0)
	{
		puts("-1");
		return 0;
	}
	for(int i=0;i+1<n;i++)
	{
		if(X[i+1]>X[i]+1)
		{
			puts("-1");
			return 0;
		}
	}
	for(int i=1;i<n;i++)
	{
		if(X[i]==X[i-1]+1) ret++;
		else ret+=X[i];
	}
	printf("%lld\n",ret);
	return 0;
}



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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> t chmax(t&a,u b){if(a<b)a=b; return a;};
template<class t, class u> t chmin(t&a,u b){if(a>b)a=b; return a;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll K;
  IN(K);

  ll N=50;
  vll a(N, N-1);

  ll tmp = K/N;
  REP(i,N) a[i] += tmp;

  K = K-tmp*N;

  REP(i,K){
    a[i] += N+1;
    REP(j,N) a[j] -= 1;
  }

  printf("%lld\n", N);
  REP(i,N) printf("%lld ", a[i]);
  printf("\n");

  return 0;
}

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++)
const long long mod = 1000000007;
const long long inf = 11451419198109130;
typedef pair<int, int> P;
typedef pair<int, P> PP;
struct edge { int to; int to2; int cost; };

int a[100005], b[100005];
int yo[100005];
signed main() {
	int n; cin >> n;
	rep(i, n)cin >> a[i];
	rep(i, n)cin >> b[i];

	int cnt = 0;
	rep(i, n) {
		if (a[i] < b[i])cnt++;
	}

	if (cnt == n)cout << -1 << endl;
	else if (cnt == 0) {
			cout << 0 << endl; return 0;
		}
	else {
		
		int sa = 0, sb = 0;
		int cy = 0;
		rep(i, n) {
			if (a[i] < b[i]) {
				sa += a[i]; sb += b[i];
			}
			else {
				yo[cy] = a[i] - b[i];
				cy++;
			}
		}
		sort(yo, yo + cy);
		reverse(yo, yo + cy);
		int pls = 0;

		while (pls!=cy) {	
			if (sa >= sb) {
				cout << cnt + pls << endl;
				return 0;
			}
			sa += yo[pls];
			pls++;
		}
		if (sa >= sb) {
			cout << cnt + pls << endl;
			return 0;
		}
		cout << -1 << endl;
	}
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define int long long int
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
const int N=5e6+10;
const int mod=1e9+7;
int arr[N],iarr[N];
int logi(int n){int p=0;while(n/2){n=n/2;p++;}return p;}
int poww(int x,int y){int pro=1;while(y){if(y&1)pro=((pro%mod)*(x%mod)%mod);y=y>>1;x=((x%mod)*(x%mod)%mod);}return pro;}
map<int,int> mp;
int arr1[1000001],arr2[1000001];

int solve()
{
	int n;
	cin>>n;
	if(n%2)
	{
		return cout<<0,0;
	}
	int temp=5,ans=0;
	while(temp<n)
	{
		ans+=((n/temp)/2);
		temp*=5;
	}
	cout<<ans;
}
int32_t main()																																	
{
	fast;
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 2304
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int t = sc.nextInt();

        int minCost = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            int cost = sc.nextInt();
            int time = sc.nextInt();
            if (t >= time) {
                if (minCost >= cost) {
                    minCost = cost;
                }
            }
        }
        sc.close();

        if (minCost == Integer.MAX_VALUE) {
            System.out.println("TLE");
        } else {
            System.out.println(minCost);
            sc.close();
        }
    }
}

Measured memory_bytes: 21332
#include <stdio.h>
int main(void){
    int N,K,d,i,j,a,cnt=0;
    int A[101];
    
    scanf("%d",&N);
    scanf("%d",&K);
    
    for(i=1;i<=N;i++){
        A[i]=0;
    }
    
    for(i=0;i<K;i++){
        scanf("%d",&d);
        for(j=0;j<d;j++){
            scanf("%d",&a);
            A[a]=1;
        }
     }
     
     for(i=1;i<=N;i++){
        if(A[i]==0){
            cnt++;
        }
     }
     
     printf("%d\n",cnt);
     
     return 0;
}

Measured memory_bytes: 2156
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=0
p=[]
m=[]
def app(num1):
    p.append(num1)
def apm(num2):
    m.append(num2)
if sum(a)<sum(b):
    ans=-1
else:
    for i in range(n):
        if a[i]>b[i]:
            app(a[i]-b[i])
        elif a[i]<b[i]:
            apm(b[i]-a[i])
    num=sum(m)
    ans=len(m)
    p.sort(reverse=True)
    num1=0
    for i in range(len(p)):
        if num1>=num:
            break
        num1+=p[i]
        ans+=1
        if num1>=num:
            break
print(ans)


Measured memory_bytes: 24356
<?php   

//8色より多いことはないのにきをつける
//3200以上の人数だけ色を足せばいい
//3200以上しかいない時は一色
       
fscanf(STDIN,"%d",$s);
$a_li = explode(" ",trim(fgets(STDIN)));
$vali = array();
$vali_ext=0;
foreach($a_li as $n){
  switch ($n) {
      case 1<=$n && $n<=399:
          $vali['a']++;
          break;
      case 400<=$n && $n<=799:
          $vali['b']++;
          break;
      case 800<=$n && $n<=1199:
           $vali['c']++;
          break;
      case 1200<=$n && $n<=1599:
           $vali['d']++;
          break;
      case 1600<=$n && $n<=1999:
           $vali['e']++;
          break;
      case 2000<=$n && $n<=2399:
           $vali['f']++;
          break;
      case 2400<=$n && $n<=2799:
           $vali['g']++;
          break;
      case 2800<=$n && $n<=3199:
           $vali['h']++;
          break;
      default:
          $vali_ext++;
  }
}
//print_r($vali);
$vali_count = count($vali);
echo max($vali_count,1)." ".($vali_count+$vali_ext)."\n";

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

using namespace std;

#define int long long
#define PB push_back
#define PPB pop_back
typedef pair<int, int> pii;
static const int INF = 1LL<<61;
static const int MAX_N = 1005;


class UF {
public:
    int n, par[MAX_N];

    void init(int pn) {
        n = pn;
        for (int i = 1; i <= n; ++i) {
            par[i] = i;
        }
    }

    int find(int x) {
        if (x == par[x]) return x;

        return par[x] = find(par[x]);
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;

        par[x] = y;
    }

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

UF uf;
int n, m;

int temp[MAX_N];

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

    cin >> n >> m;
    uf.init(n);

    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        uf.unite(a, b);
    }

    for (int i = 1; i <= n; ++i) {
        int t = uf.find(i);
        temp[t]++;
    }

    int city = 0, mura = 0;
    for (int i = 1; i <= n; ++i) {
        if (1 < temp[i]) city++;
        else if (temp[i] == 1) mura++;
    }

    cout << abs(mura - city) << endl;

    return 0;
}

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

int n;
string a;
int main()
{
	cin >> a;
	n = a.size();
	if (a[n - 1] == 's') a += "es";
	else a += 's';
	cout << a << endl;
    return 0;
}


Measured memory_bytes: 3628
# coding: utf-8

a, b, c, d = map(int, input().split())
alice_time = [x for x in range(a, b+1)]
bob_time = [x for x in range(c, d+1)]
pushed_time = set(alice_time) & set(bob_time)

if len(pushed_time) == 0:
  print(0)
else:
  print(len(pushed_time) - 1)

Measured memory_bytes: 3060
#include <cstdio>
#include <vector>
#include <queue>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <queue>
using namespace std;
#define sd(n) scanf("%d", &n)
#define sdd(n, m) scanf("%d%d", &n, &m)
#define sddd(n, m, k) scanf("%d%d%d", &n, &m, &k)
#define pd(n) printf("%d\n", n)
#define pc(n) printf("%c", n)
#define pdd(n, m) printf("%d %d\n", n, m)
#define pddd(n, m, z) printf("%d %d %d\n", n, m, z)
#define pld(n) printf("%lld\n", n)
#define pldd(n, m) printf("%lld %lld\n", n, m)
#define plddd(n, m, z) printf("%lld %lld %lld\n", n, m, z)
#define sld(n) scanf("%lld", &n)
#define sldd(n, m) scanf("%lld%lld", &n, &m)
#define slddd(n, m, k) scanf("%lld%lld%lld", &n, &m, &k)
#define sf(n) scanf("%lf", &n)
#define sc(n) scanf("%c", &n)
#define sff(n, m) scanf("%lf%lf", &n, &m)
#define sfff(n, m, k) scanf("%lf%lf%lf", &n, &m, &k)
#define ss(str) scanf("%s", str)
#define rep(i, a, n) for (int i = a; i <= n; i++)
#define per(i, a, n) for (int i = a; i >= n; i--)
#define mem(a, n) memset(a, n, sizeof(a))
#define debug(x) cout << #x << ": " << x << endl
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define ce i == n ? '\n' : ' '
#define mod(x) ((x) % MOD)
#define gcd(a, b) __gcd(a, b)
#define lowbit(x) (x & -x)
typedef pair<int, int> PII;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const int MOD = 1e9 + 7;
const double eps = 1e-9;
const ll INF = 0x3f3f3f3f3f3f3f3fll;
const int inf = 0x3f3f3f3f;
inline int read()
{
	int ret = 0, sgn = 1;
	char ch = getchar();
	while (ch < '0' || ch > '9')
	{
		if (ch == '-')
			sgn = -1;
		ch = getchar();
	}
	while (ch >= '0' && ch <= '9')
	{
		ret = ret * 10 + ch - '0';
		ch = getchar();
	}
	return ret * sgn;
}
inline void Out(int a) //ê?3?ía1ò
{
	if (a > 9)
		Out(a / 10);
	putchar(a % 10 + '0');
}

ll gcd(ll a, ll b)
{
	return b == 0 ? a : gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
///快速幂m^k%mod
ll qpow(ll x, ll n, ll mod)
{
	ll res = 1;
	while (n)
	{
		if (n & 1)
			res = (res * x) % mod;
		x = x * x % mod, n >>= 1;
	}
	return res;
}

const int N = 2e5 + 10;
int n, m;
int x, pre[N];
int ans[N];
int main()
{
	sd(n);
	mem(ans, 0);
	rep(i, 2, n)
	{
		sd(x);
		pre[i] = x;
	}
	rep(i, 1, n)
		ans[pre[i]]++;
	rep(i, 1, n)
		pd(ans[i]);
	return 0;
}


Measured memory_bytes: 5392
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    string S;
    cin >> S;
    ll N=S.size();
    ll i,j;
    ll ans=0;
    ll tmp;
    for(i=0;i<N;i++){
        tmp=S[i]-'0';
        ans+=tmp*pow(10,N-1-i)*pow(2,i);
        for(j=0;j<N-1-i;j++){
            ans+=tmp*pow(10,j)*pow(2,N-j-2);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
// AOJ 1338: Clock Hands
// 2017.12.7 bal4u@uu

#include <stdio.h>

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

int main()
{
    long long H, h, m, s, d, n;
	long long c3600, ha, ma, sa, a1, a2, g;

    while (scanf("%lld%lld%lld%lld", &H, &h, &m, &s) && H > 0) {
        d = 119*H - 1;
		c3600 = 3600*H*d;
        n = s * d;
        while (1) {
            ha = (60 * h + m) * 60*d + n;
            ma = 60 * H * m * d + n * H;
            sa = 60 * H * n;
            ma = (ma - ha) % c3600;
            sa = (sa - ha) % c3600;
            if (ma < 0) ma += c3600;
            if (sa < 0) sa += c3600;
            if (ma != 0) {
                if (ma < sa) a1 = c3600 - sa, a2 = sa - ma;
                else         a1 = sa, a2 = ma - sa;
                if (a1 == a2) break;
            }
            n++;
            if (n == 60 * d) m++, n = 0;
            if (m == 60) m = 0, h++;
            if (h == H) h = 0;
        }
        g = gcd(n, d);
        printf("%lld %lld %lld %lld\n", h, m, n/g, d/g);
    }
}

Measured memory_bytes: 1748
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define fi first
#define se second
#define inf (INT_MAX/2-1)
#define infl (1LL<<60)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) begin(a),end(a)
#define y0 y5656
#define y1 y7878
#define aaa system("pause");
#define dbg(x) cerr<<(#x)<<": "<<(x)<<'\n',aaa
#define dbga(x,n) cerr<<(#x)<<"[]: ";for(int _=0;_<n;_++)cerr<<x[_]<<' ';cerr<<'\n',aaa
#define dbgs(x) cerr<<(#x)<<"[stl]: ";for(auto _:x)cerr<<_<<' ';cerr<<'\n',aaa
#define dbgp(x) cerr<<(#x)<<": "<<x.fi<<' '<<x.se<<'\n',aaa
#define maxn 200000

using namespace std;

int main () {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n, k, i; cin >> n >> k;
  vi v(n), u(n+1);
  for (i = 0; i < n; i++) cin >> v[i];
  while (k && *min_element(all(v)) < n) {
    fill(all(u), 0);
    for (i = 0; i < n; i++) {
      u[max(0, i-v[i])]++;
      u[1+min(n-1, i+v[i])]--;
    }
    for (i = 0; i < n; i++) {
      if (i) u[i] += u[i-1];
      v[i] = u[i];
    }
    k--;
  }
  for (int x: v) cout << x << ' ';
  return 0;
}

Measured memory_bytes: 4768
#include <cstdio>
#include <algorithm>
#include <limits>

constexpr int INF_I = std::numeric_limits<int>::max();
constexpr int MAX_N = 100000;

int main(){
    int N;
    int L[MAX_N], length = 1;
    std::fill(L, L + MAX_N, INF_I);
    scanf("%d", &N);
    for(int i = 0; i < N; ++i){
        int A;
        scanf("%d", &A);
        *std::lower_bound(L, L + N + 1, A) = A;
    }
    printf("%d\n", std::find(L, L + N, INF_I) - L);
    return 0;
}

Measured memory_bytes: 3100
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include <iomanip>
using namespace std;


int main(){
	int n,m,k;
	cin>>n>>m;
	string s,ans;
	char t,u='1',v='0';
	for(int i=0;i<n;i++){
		ans+='#';
	}
	
	for(int i=0;i<m;i++){
		cin>>k>>t;
		if(ans[k-1]=='#'||ans[k-1]==t){
			ans[k-1]=t;
			if(k==1&&t=='0'&&n!=1){
				ans="-1";
			}
		}
		else if(ans[k-1]!=t){
			ans="-1";
			break;
		}
	}
	if(ans!="-1"){
		for(int i=0;i<n;i++){
			if(ans[i]=='#'){
				ans[i]=v;
			}
		}
	}
	if(n!=1&&ans[0]==v){
		ans.replace(0,1,"1");
	}
    
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <climits>
#include <cmath>
#include <utility>
#include <iomanip>
//#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using namespace std;
using ll = long long int;
//// 任意長整数型
namespace mp = boost::multiprecision;
//using Bint = mp::cpp_int;



int main(int argc, char *argv[])
{
	using Real1024 = mp::number<mp::cpp_dec_float<1024>>;

	//input
	Real1024 a, b, c;
	cin >> a >> b >> c;


	//calc
	string ans;
	if (2 * mp::sqrt(a * b) < c - a - b){
		ans = "Yes";
	}
	else{
		ans = "No";
	}



	//ans
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 512
/*
 
 * This code is written by Sanskar Agarwal
 
*/
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define VPLL vector<PLL>
#define VPII vector<PII>
#define PQ priority_queue<PLL,VPLL, greater<PLL> > 
#define PQI priority_queue<PII,VPII,greater<PII> >
#define UMLL unordered_map<ll,ll>
#define UMII unordered_map<int,int>
#define VI vector<int>
#define VL vector<ll>
#define S second
#define F first
#define PB push_back


int main()
{

    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n,i;
    cin>>n;
    double a[n];
    for(i=0;i<n;i++)
        cin>>a[i];
    double sm=0.00000000000000000000,pre=1.0000000000000000000000;
    for(i=0;i<n;i++) {
        sm+=(pre/a[i]);
    }
    sm=(pre/sm);
    cout << fixed << setprecision(25) << sm;
    
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;

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

int main() {
	int a=read(),b=read();
	puts(a==b?"Yes":"No"); 
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr ll INF = (1LL << 55);
 
int main(){
  int n;
  cin >> n;
  bool ok = true;
  int pt = 0, px = 0, py = 0;
  while (n--) {
    int t, x, y;
    cin >> t >> x >> y;
    int dt = t - pt, dx = abs(x - px), dy = abs(y - py);
    ok &= ((dt >= dx + dy) && (dt % 2 == (dx + dy) % 2));
    pt = t, py = y, px = x;
  }
  cout << (ok ? "Yes" : "No") << endl;
  return 0;
} 


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

int a, b;
int32_t main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> a >> b;
	if (a >= 1 && a <= 9 && b >= 1 && b <= 9) cout << a*b;
	else cout << -1;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; i++)
#define all(a) (a).begin(), (a).end()

int N;
vector<int> t, v;

int main () {
  cin >> N;
  t.resize(N);
  v.resize(N+1, 0);
  rep(i,N) {
    cin >> t[i];
    t[i] *= 2;
  }
  rep(i,N) {
    cin >> v[i];
    v[i] *= 2;
  }

  vector<int> d(N+1, 0);
  rep(i,N) d[i+1] = d[i] + t[i];
  rep(i,N+1) d[i] += v[i];
  for(int i = N - 1; i >= 0; i--) {
    d[i] = min(d[i], d[i+1]);
  }

  double x = 0;
  int vc = 0;
  int tc = 0;
  rep(i,N) {
    int tb = tc;
    rep(j,t[i]) {
      if(vc >= - tc + d[i+1]) {
        x += vc - 0.5;
        vc -= 1;
      } else if(vc >= v[i]) {
        x += vc;
      } else {
        x += vc + 0.5;
        vc += 1;
      }
      tc += 1;
    }
  }

  printf("%.4lf\n", x*0.25);
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var s int
	fmt.Scan(&s)
	list := make([]int, 1000000)

	list[0] = s
	for i := 1; i < 1000000; i++ {
		if list[i-1]%2 == 0 {
			list[i] = list[i-1] / 2
		} else {
			list[i] = 3*list[i-1] + 1
		}
		for j := 0; j < i; j++ {
			if list[i] == list[j] {
				fmt.Println(i + 1)
				return
			}
		}
	}
}


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

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

	int min = 2000000;
	int max = -2000000;
	long long int sum = 0;
	for (int i = 0; i < n; i++) {
		int k;
		cin >> k;
		if (k < min)	min = k;
		if (k > max)	max = k;
		sum += k;
	}

	cout << min << " " << max << " " << sum << endl;

	return 0;
}

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

#define fi first
#define se second
#define mp make_pair
#define sz(v) (int) v.size()
#define all(v) v.begin(), v.end()

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int MAX_N = 4005;

int n;
string s;
int pref[MAX_N][26];

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> s;
	for (int i = 0; i < n; ++i) {
		if (i) for (int j = 0; j < 26; ++j) pref[i][j] = pref[i - 1][j];
		pref[i][s[i] - 'A']++;
	}
	ll ans = 0;
	for (int j = 1; j < n; ++j) {
		for (int k = j + 1; k < n; ++k) {
			if (s[j] == s[k]) continue;
			if ('R' != s[j] && 'R' != s[k]) {
				ans += pref[j - 1]['R' - 'A'];
				if (2 * j - k > -1 && s[2 * j - k] == 'R') ans--;
			} else if ('G' != s[j] && 'G' != s[k]) {
				ans += pref[j - 1]['G' - 'A'];
				if (2 * j - k > -1 && s[2 * j - k] == 'G') ans--;
			} else {
				ans += pref[j - 1]['B' - 'A'];
				if (2 * j - k > -1 && s[2 * j - k] == 'B') ans--;
			}
		}
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3956
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

class UF {
private:
  vector<int> data; // parent or size
  vector<int> next;
  vector<int> last;
  void init(int n) {
    data.assign(n, -1);
    next.assign(n, -1);
    last.resize(n);
    for (int i = 0; i < n; ++i) {
      last[i] = i;
    }
  }

public:
  UF() {}
  UF(int n) {
    init(n);
  }
  int root(int x) {
    if (data[x] < 0) return x;
    return data[x] = root(data[x]);
  }
  bool unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return false;
    if (data[x] > data[y]) swap(x, y); // data[x] and data[y] are negative.
    data[x] += data[y];
    data[y] = x;
    next[last[x]] = y;
    last[x] = last[y];
    return true;
  }
  int size(int x) {
    return -data[root(x)];
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  int get_next(int x) {
    return next[x];
  }
};

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  vi p(n);
  rep (i, n) {
    scanf("%d", &p[i]);
    p[i] -= 1;
  }
  UF uf(n);
  rep (i, m) {
    int x, y;
    scanf("%d %d", &x, &y);
    x -= 1; y -= 1;
    uf.unite(x, y);
  }

  vector<bool> done(n, false);
  int ans = 0;
  rep (i, n) {
    if (done[i]) {
      continue;
    }
    int r = uf.root(i);
    vi indices;
    vector<bool> exist_val(n, false);
    for (int j = r; j != (-1); j = uf.get_next(j)) {
      done[j] = true;
      indices.push_back(j);
      exist_val[p[j]] = true;
    }
    for (int ind : indices) {
      if (exist_val[ind]) {
        ans += 1;
      }
    }
  }
  printf("%d\n", ans);
    
  return 0;
}


Measured memory_bytes: 2432
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　redcoderになるためAtCoderを巡る旅をしてます。

　　　 　 ＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　 ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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; }

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

    ll a, b; cin >> a >> b;
    if(a % 2 != b % 2) cout << "IMPOSSIBLE" << endl;
    else {
        cout << (a + b) / 2 << endl;
    }
}


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

template <typename T>
vector<T> make_vector(size_t sz)
{
	return vector<T>(sz);
}

template <typename T, typename... U>
auto make_vector(size_t sz, U... tails)
{
	return vector<decltype(make_vector<T>(tails...))>(sz, make_vector<T>(tails...));
}

template <typename T>
void fill_vector(vector<T> &v, T init)
{
	fill(v.begin(), v.end(), init);
}

template <typename T, typename U>
void fill_vector(vector<U> &vec, T init)
{
	for (auto &&v : vec)
	{
		fill_vector<T>(v, init);
	}
}

int main()
{
	string s;
	int64_t k;
	cin >> s >> k;

	int64_t n = s.size();

	auto dp = make_vector<int64_t>(n + 1, 2, 4, 2);
	fill_vector<int64_t>(dp, 0);

	dp[0][1][0][0] = 1;

	for (int64_t i = 0; i < n; i++)
	{
		for (int64_t j = 0; j < 2; j++)
		{
			for (int64_t l = 0; l <= 3; l++)
			{
				for (int64_t m = 0; m < 2; m++)
				{
					int64_t lim = j ? (s[i] - '0') : 9;
					for (int64_t d = 0; d <= lim; d++)
					{
						if ((l + (d != 0)) <= 3)
						{
							dp[i + 1][j && (d == lim)][l + (d != 0)][m || (0 < d)] += dp[i][j][l][m];
						}
					}
				}
			}
		}
	}

	cout << (dp[n][0][k][1] + dp[n][1][k][1]) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
typedef long long int ll;

int main(){
	int n; cin >> n;
	vector<ll> a(n),b(n);
	ll ans=0;
	vector<ll> v;
	for(int i=0;i<n;i++){
		cin >> a[i] >> b[i];
		ans-=b[i];
		v.push_back(a[i]+b[i]);
	}
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	for(int i=0;i<n;i+=2){
		ans+=v[i];
	}
	cout << ans << endl;
}

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

int main(){
    int N;
    string S, T;
    cin >> N;
    cin >> S >> T;
    string ans = "";

    for (int i=0; i<N; i++){
        ans += S[i];
        ans += T[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;
 
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll
 
int n, h[100010], l[100010], r[100010], st[100010];
signed main(void)
{
  cin >> n;
  REP(i, n) cin >> h[i];
  int t = 0;
  REP(i, n) {
    while(t>0 && h[st[t-1]] >= h[i]) t--;
    l[i] = t == 0 ? 0 : (st[t-1]+1);
    st[t++] = i;
  }
  t = 0;
  for(int i=n-1; i>=0; --i) {
    while(t > 0 && h[st[t-1]] >= h[i]) t--;
    r[i] = t == 0 ? n : st[t-1];
    st[t++] = i;
  }
  ll ret = 0;
  REP(i, n) ret = max(ret, (ll)h[i]*(r[i]-l[i]));
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 4632
import heapq
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''

N, M = map(int, input().split())
A, B = [0] * N, [0] * N
C = []

for i in range(N):
	A[i], B[i] = map(int, input().split())
	heapq.heappush(C, (A[i], B[i]))
	
ans = 0

for i in range(M):
	tmp = heapq.heappop(C)
	ans += tmp[0]
	if tmp[1] > 1:
		heapq.heappush(C, (tmp[0], tmp[1] - 1))

print(ans)

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

using namespace std;

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

  int n, m;
  cin >> n >> m;
  long long res = 1;
  if (abs(n-m) > 1) {
    res = 0;
  } else {
    long long mod = 1e9+7;
    for (long long i = 1; i <= n; ++i) {
      res = (res * i)%mod;
    }
    for (long long i = 1; i <= m; ++i) {
      res = (res * i)%mod;
    }
    if (n == m) res = (res * 2)%mod;
  }
  cout << res << endl;

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <stdio.h>
#include <vector>
using namespace std;
#define ll long long
int n, color[200005];
int prevv[200005];
int nex[200005];
ll mod = 1e9 + 7;
ll memo[200005];

ll dp(int x){
	if (x == n) return 1;
	if (memo[x] != -1) return memo[x];
	if (nex[x] == -1 || nex[x] == x + 1) return memo[x] = dp(x + 1)%mod;
	return memo[x] = (dp(x + 1) + dp(nex[x]))%mod;
}

int main(){
	memset(prevv, -1, sizeof(prevv));
	memset(nex, -1, sizeof(nex));
	memset(memo, -1, sizeof(memo));
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		scanf("%d", &color[i]);
		if (prevv[color[i] - 1] == -1){
			prevv[color[i] - 1] = i;
		} else {
			nex[prevv[color[i] - 1]] = i;
			prevv[color[i] - 1] = i;
		}
	}
	printf("%lld\n", dp(0));
}

Measured memory_bytes: 10496
n = int(input())
w_li = [input() for _ in range(n)]

if len(set(w_li)) != len(w_li):
    print("No")
else:
    for i in range(n-1):
        if w_li[i][-1] != w_li[i+1][0]:
            print("No")
            break
        elif i == n-2:
            print("Yes")
            break
        else:
            continue


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to))
#define sort(a) sort(a.begin(), a.end())
#define reverse(s) reverse(s.begin(), s.end())
#define p(s) cout << (s) << endl

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

template<class T>
T max(vector<T> &v) {
  return *max_element(v.begin(), v.end());
}

template<class T>
T min(vector<T> &v) {
  return *min_element(v.begin(), v.end());
}

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

  if (k == 1) {
    p(0);
  } else {
    p(n - k);
  }
}

Measured memory_bytes: 256
#include <iostream>
#include<iomanip>
#include <string>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<math.h>
#include<stack>
#include<set>
#include<map>
#include<ctime>
#include<cstdlib>
#define INF long long int(1e18+1)
#define rep(i,n,m) for(int i=n;i<m;i++)

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<char>a(n);
	vector<int>w, r;
	rep(i, 0, n) {
		cin >> a[i];
		if (a[i] == 'W')w.push_back(i);
		else r.push_back(i);
	}
	reverse(r.begin(), r.end());
	int ans = 0;
	int W, R;
	W = w.size(); R = r.size();
	if (W && R) {
		for (int i = 0; i < W && i < R; i++) {
			if (w[i] < r[i])ans++;
		}
	}
	cout << ans << endl;

}


Measured memory_bytes: 4688
from numpy.linalg import solve
mod = 10**9+7
x,y=map(int,input().split(' '))
left = [[1,2],
        [2,1]]
right = [x,y]

A=solve(left,right)
ax,ay=float(A[0]),float(A[1])
if not 0.5 <= y/x <= 2:
    print(0)
    exit()
if not float.is_integer(ax) or not float.is_integer(ay):
    print(0)
    exit()
ax,ay=int(ax),int(ay)
fac=[0 for i in range(ax+ay+1)]
inv=[0 for i in range(ax+ay+1)]
finv=[0 for i in range(ax+ay+1)]
fac[0] = 1
fac[1] = 1
finv[0]=1
finv[1]=1
inv[1] = 1
for i in range(2,ax+ay+1):
    fac[i] = fac[i-1]*i%mod
    inv[i] = mod-inv[mod%i]*(mod//i)%mod
    finv[i]= finv[i-1] * inv[i]%mod
ans = fac[ax+ay]*(finv[ax]*finv[ay])
ans %= mod
print(int(ans))


Measured memory_bytes: 93432
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define int long long
#define INF 1145141919810364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int l;

signed main() {
	cin >> l;
	long double x = l * l*l;
	printf("%.15Lf", x / 27.0);
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bits/stdc++.h>
using namespace std;
int n,k,h[100004];
int main(){
	cin>>n>>k;
	for (int i=1;i<=n;i++)
		cin>>h[i];
	int rp=1e9;
	sort (h+1,h+n+1);
	for(int i=k;i<=n;i++){
		if (h[i]-h[i-k+1]<rp)
			rp=h[i]-h[i-k+1];
	}
	cout<<rp; 
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>

int dp[45];
int fib(int n){
    if(n == 0 || n == 1) return dp[n] = 1;
    if(dp[n] != -1) return dp[n];
    return dp[n] = fib(n-1) + fib(n-2);
}
int main(){
    int a,n,i;
    for(i =0;i<50;i++){
        dp[i] = -1;
    }
    scanf("%d",&n);
    if(0<=n && n<=44){
    printf("%d\n",fib(n));
    }
    return 0;
}


Measured memory_bytes: 2056
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextssort(n,a){return a?cin.slice(cid,cid+=n).map(a=>+a).sort((a,b)=>b-a):cin.slice(cid,cid+=n).map(a=>+a).sort((a,b)=>a-b);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}
var streams=[];function print(s){streams.push(s);}

var mod = 998244353;
function mul(){for(var a=arguments,r=a[0],i=a.length;--i;)r=((r>>16)*a[i]%mod*65536+(r&65535)*a[i])%mod;return r;}
var fac=[],finv=[],invs=[],pow2=[];
function fset(n){
  fac.length=n+1,fac[0]=fac[1]=1;
  for(var i=2;i<=n;)fac[i]=mul(fac[i-1],i++);
  finv.length=n+1,finv[0]=finv[1]=1,finv[n]=inv(fac[n]);
  for(i=n;2<i;)finv[i-1]=mul(finv[i],i--);
  //invs.length=n+1,invs[0]=invs[1]=1;
  //for(i=2;i<=n;)invs[i]=mul(fac[i-1],finv[i++]);
  //pow2.length=n+1,pow2[0]=1;
  //for(i=1;i<=n;i++)pow2[i]=pow2[i-1]*2%mod;
}
function inv(b){for(var a=mod,u=0,v=1,t;b;v=t)t=a/b|0,a-=t*b,u-=t*v,t=a,a=b,b=t,t=u,u=v;u%=mod;return u<0?u+mod:u;}
function pow(a,n){for(var r=1;n;a=mul(a,a),n>>=1)if(n&1)r=mul(a,r);return r;}
function ncr(n,r){return mul(fac[n],finv[r],finv[n-r]);}
function npr(n,r){return mul(fac[n],finv[n-r]);}
function mput(n){return (n%mod+mod)%mod;}

var myOut = main();
if(myOut !== undefined)console.log(String(myOut));
if(streams.length)console.log(streams.join("\n"));

function main(){
  var n = next();
  var k = next();
  var x = nextm(k,2);
  var dp = xArray(0,n);
  dp[0] = 1;
  var tot = xArray(0,k);
  for(var i = 1; i < n; i++){
    for(var j = 0; j < k; j++){
      var [l,r] = x[j];
      if(l <= i)tot[j] += dp[i-l];
      if(r < i)tot[j] -= dp[i-r-1];
      dp[i] += tot[j];
    }
    dp[i] %= mod;
  }
  return dp[n-1];
}

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

int main()
{
    int N, M;
    long long K;
    cin >> N >> M >> K;
    vector<long long> A(N, 0LL), B(M, 0LL);
    for (int i = 0; i < N; i++)
        cin >> A[i];
    for (int i = 0; i < M; i++)
        cin >> B[i];
    vector<long long> a = {0}, b = {0};
    for (int i = 0; i < N; i++)
        a.push_back(a[i] + A[i]);
    for (int i = 0; i < M; i++)
        b.push_back(b[i] + B[i]);
    int ans = 0, j = M;
    for (int i = 0; i <= N; i++)
    {
        if (K < a[i])
            break;
        while (K - a[i] < b[j])
            j--;
        ans = max(ans, i + j);
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

set<pair<int,int>> fill(vector<string>& S, set<pair<int,int>>& remaining, set<pair<int,int>> candidate){
    int h = S.size();
    int w = S.front().size();
    set<pair<int,int>> candidate_new;

    set<pair<int,int>> newFill;
    for(auto p : candidate){
        auto i = p.first;
        auto j = p.second;
        bool b=false;
        if(S[i][j]=='#') continue;
        if(j+1<w && S[i][j+1]=='#') b=true;
        if(j>0   && S[i][j-1]=='#') b=true;
        if(i+1<h && S[i+1][j]=='#') b=true;
        if(i>0   && S[i-1][j]=='#') b=true;
        if(b) newFill.insert(make_pair(i,j));
    }
    for(auto p : newFill){
        auto i = p.first;
        auto j = p.second;
        S[i][j] = '#';
        remaining.erase(p);
        if(j+1<w && S[i][j+1]=='.') candidate_new.insert(make_pair(i,j+1));
        if(j>0   && S[i][j-1]=='.') candidate_new.insert(make_pair(i,j-1));
        if(i+1<h && S[i+1][j]=='.') candidate_new.insert(make_pair(i+1,j));
        if(i>0   && S[i-1][j]=='.') candidate_new.insert(make_pair(i-1,j));
    }
    return candidate_new;
}

int main()
{
    ll H, W;
    cin >> H >> W;
    vector<string> S;
    set<pair<int,int>> remaining;
    set<pair<int,int>> candidate;
    string si;
    for(int i=0;i<H;i++){
        cin >> si;
        S.push_back(si);
        for(int j=0;j<W;j++){
            if(si[j]=='.') remaining.insert(make_pair(i,j));
            else{
                if(j+1<W) candidate.insert(make_pair(i,j+1));
                if(j>0  ) candidate.insert(make_pair(i,j-1));
                if(i+1<H) candidate.insert(make_pair(i+1,j));
                if(i>0  ) candidate.insert(make_pair(i-1,j));
            }
        }
    }
    int count = 0;
    for(int c = 0; c<=H*W; c++){
        if(remaining.empty()){
            cout<<c<<endl;
            return 0;
        }
        candidate = fill(S, remaining, candidate);
    }

    return 0;
}


Measured memory_bytes: 125056
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, x, n) for (int i = x; i < (int)(n); i++)
#define sc(x) scanf("%d",&x)
#define scll(x) scanf("%lld",&x)
int main(){
    bool check = true;
    ll n, time = 0; scll(n);
    vector<P> a(n);
    rep(i, 0, n) sc(a[i].second), sc(a[i].first);
    sort(a.begin(), a.end());
    rep(i, 0, n){
        time += a[i].second;
        if (time > a[i].first) check = false;
    }
    if (check) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <sstream>
#include <stack>
#include <string>
using namespace std;
stack<double>X;
double f(string s){
	double a,b;
	b=X.top();X.pop();
	a=X.top();X.pop();
	if(s=="+")a+=b;
	else if(s=="-")a-=b;
	else if(s=="*")a*=b;
	else if(s=="/")a/=b;
	return a;
}
int main(){
	string s;
	while(getline(cin,s)){
		stringstream ss(s);
		while(ss>>s)X.push((s=="+"||s=="-"||s=="*"||s=="/")?f(s):atoi(s.c_str()));
		printf("%.6f\n",X.top());
		X.pop();
	}
}

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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
void debug(vector<vector<ll>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
void debug(vector<ll>v,ll n){cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}
//m.emplace(x,0).fi->se++;

int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll n;cin>>n;
  rep(i,1,n+1){
    buf=i;
    ll countbuf=0;
    while(buf!=0){
      countbuf++;
      buf/=10;
    }
    if(countbuf%2==1)res++;
  }
  cout<<res<<endl;


  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  ld a,b;
  cin >> a >> b;
  cout << fixed << setprecision(10) << a/b << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
  {int M, D, c{}, d1, d10; cin >> M >> D;
  for (int m{1}; m <= M; ++m) for (int d{}; d <= D; ++d)
    d1 = d % 10, d10 = d / 10, c += d1 > 1 and d10 > 1 and d1 * d10 == m;
  cout << c;}

Measured memory_bytes: 3516
s = input()
i = s.count('h')
j = s.count('i')
h = 'hi'

if h in s:
  if ('ii' or 'hh') in s:
    print('No')
  else:
    if i == j:
        print('Yes')
    else:
        print('No')
else:
  print('No')


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

int main(){
	int n,m,t;
	int mi;
	vector<int> p;
	
	while(cin >> n >> m && n || m){
		mi = 0;
		p.clear();
		for(int i=0;i<n+m;i++){
			cin >> t;
			p.push_back(t);
		}
		p.push_back(0);
		sort(p.begin(),p.end());
		for(int i=0;i+1<n+m+1;i++){
			mi = max(mi,p[i+1]-p[i]);
		}
		cout << mi << endl;
	}
}

Measured memory_bytes: 0
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n =  sc.nextInt();
	int k =  sc.nextInt();
	int x[] = new int[n];
	int cou = 0;

	for(int i=0;i<k;i++) {
			int d =  sc.nextInt();
			for(int j=0;j<d;j++) {
				int a = sc.nextInt();
				x[a-1] = 1;
			}
	}
	for(int i=0;i<n;i++) {
		if(x[i]!=1) {
			cou++;
		}
	}
	System.out.println(cou) ;
  }
}

Measured memory_bytes: 46252
use std::io::*;
use std::str::FromStr;
   
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")
}
     
fn main() {
    let s: i32 = read();
    let t: i32 = read();
    let v: Vec<i32> = vec![1,2,3];
    for i in v {
    	if i != s && i != t {
        	println!("{}", i);
        }
    }
}

Measured memory_bytes: 4352
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using LayoutKind = System.Runtime.InteropServices.LayoutKind;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;


static class P
{
    static void Main()
    {
        //桁ごとに特定していきたい
        long res = 0;
        while (true)
        {
            int valid = 10;
            int invalid = res == 0 ? 0 : -1;
            while (valid - invalid > 1)
            {
                var mid = (valid + invalid) / 2;
                Console.WriteLine($"? {(res * 10 + mid).ToString().PadRight(11, '9')}");
                var ans = Console.ReadLine();
                if (ans == "Y") valid = mid;
                if (ans == "N") invalid = mid;
            }
            if (invalid == -1)
            {
                Console.WriteLine($"? {"".PadRight(res.ToString().Length, '9')}");
                var ans = Console.ReadLine();
                if(ans == "Y")
                {

                    Console.WriteLine($"! {res}");
                    break;
                }
            }
            res = (res * 10 + valid);
        }

    }
}


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

int main(){
  long long a, b, x;
  cin >> a >> b >> x;
  long long n = b - a + 1; // a以上b以下の数字の数
  long long r = n % x;     // nをxで割ったあまり
  long long ans;
  ans = n / x;
  if(r){
    if((a % x) + r - 1 >= x || a % x == 0 ) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256