akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
//#define pdd pair<double,double>
#define pll pair<LL,LL>
#define pb(x) push_back(x)
#define x first
#define y second
#define sqr(x) ((x)*(x))
#define EPS 1e-8
#define mii map<int,int>
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define N 500005
//#define M 1000005
#define pi 3.14159265359
#define cpdd const pdd
#define hash Hash
using namespace std;
typedef long long LL;
using namespace std;
int main(){
	int n;
	scanf("%d",&n);
	char c[2][55];
	for(int i=0;i<2;i++)
	scanf("%s",c[i]+1);
	int dp[55][3][3];
	MEM(dp);
	int first=2;
	if(c[0][1]==c[1][1]){
		for(int i=0;i<3;i++)
		dp[1][i][i]=1;
	}
	else{
		for(int i=0;i<3;i++)
			for(int j=0;j<3;j++){
				if(i!=j){
					dp[1][i][j]=1;
					dp[2][i][j]=1;
					first=3;
				}
				else{
					dp[1][i][j]=0;
					dp[2][i][j]=0;
				}
			}
	}
	int mod = 1e9+7;
	for(int i=first;i<=n;i++){
		if(c[0][i]==c[1][i]){
			MEM(dp[i]);
			for(int j=0;j<3;j++){
				dp[i][j][j]=0;
				for(int k=0;k<3;k++)
					for(int l=0;l<3;l++)
						if(k!=j&&l!=j){
							dp[i][j][j]+=dp[i-1][k][l];
							dp[i][j][j]%=mod;
						}
			}
		}
		else{
			for(int j=0;j<3;j++){
				for(int k=0;k<3;k++){
					dp[i][j][k]=0;
					dp[i+1][j][k]=0;
					if(j==k)
					continue;
					for(int x=0;x<3;x++)
						for(int y=0;y<3;y++)
							if(x!=j&&y!=k){
								dp[i][j][k]+=dp[i-1][x][y];
								dp[i][j][k]%=mod;
							}
					dp[i+1][j][k]=dp[i][j][k];
				}
			}
			i++;
		}
	}
	int ans=0;
	/*for(int i=1;i<=n;i++,printf("\n"))
		for(int j=0;j<3;j++,printf("\n"))
			for(int k=0;k<3;k++)
			printf("%d ",dp[i][j][k]);*/
	for(int i=0;i<3;i++)
		for(int j=0;j<3;j++){
			ans+=dp[n][i][j];
			ans%=mod;
		}
	printf("%d\n",ans);
}
/*
14%20,15#17
20,14-18
1#5,11,4%10,14-18,20,21
11,21,20,14-18,4%10,1#5

*/


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef vector<string> svec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-8;

void solve() {
	int n; cin >> n;
	vector<int> h(n);
	rep(i, n) {
		cin >> h[i];
	}
	string ans = "Yes";
	rep(i, n) {
		if (i == 0) {
			h[i]--;
		}
		else {
			if (h[i - 1] > h[i]) {
				ans = "No"; break;
			}
			else if (h[i - 1] < h[i])h[i]--;
		}
	}
	cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
	//stop
	return 0;
}


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

typedef long long ll;

int main(){
	cin.tie(0);	
	cout.tie(0);	
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	int a[4] = {};
	ll ans = 1;
	const int MOD = 1e9 + 7;
	fill(a,a+3,-1);
	for(int i = 0;i < n; ++i){
		int x;
		cin >> x;
		int mul = 0;
		for(int c = 0;c < 3; ++c){
			if(a[c] == x - 1){
				if(++mul == 1){
					++a[c];			
				}
			}
		}
		ans = (ans * mul) % MOD;
	}
	cout << ans << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);std::iostream::sync_with_stdio(0);cout<<std::fixed<<std::setprecision(10);cerr<<std::fixed<<std::setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}

int32_t main(){

    string s;
    int k;
    cin>>s>>k;
    char p='$';
    int ans=0,cur=0,ae=1;
    for(char c:s){
        ae&=c==s[0];
        if(c==p){
            cur++;
        }else{
            ans+=cur/2;
            cur=1;
        }
        p=c;
    }
    ans+=cur/2;
    if(s[0]!=p||k==1){
        cout<<ans*k<<'\n';
    }else{
        if(ae){
            int n=s.size();
            cout<<(n*k)/2<<'\n';
        }else{
            int cu=0;
            for(char c:s){
                if(c==s[0])cu++;
                else break;
            }
            dbg(ans);
            ans-=cu/2;
            ans-=cur/2;
            dbg(ans);
            ans*=k;
            dbg(ans);
            ans+=cu/2;
            ans+=cur/2;
            ans+=((cu+cur)/2)*(k-1);
            dbg(ans,cu,cur);
            cout<<ans<<'\n';
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         sort(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

vector<char> stocvec(string s) {
  int n = s.size();
  vector<char> ret(n);
  for (int i = 0; i < n; i++) ret[i] = s[i];
  return ret;
}

string vecctos(vector<char> v) {
  string ret = "";
  for (char vi : v) ret += vi;
  return ret;
}

void solve() {
  string s, t; cin >> s >> t;
  vector<char> sv = stocvec(s); sort(sv);
  vector<char> tv = stocvec(t); sort(tv); reverse(tv);

  if (vecctos(sv) < vecctos(tv)) Yes();
  else No();
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)

{
	int mado;
	int katen;
	int i = 0;

	scanf("%d",&mado);
	scanf("%d",&katen);

	katen*=2;

	if(mado-katen <=0)
		printf("%d",i);
	else
		printf("%d",mado - katen);

return 0;

}

Measured memory_bytes: 128
import java.math.BigDecimal;
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        String bstr = sc.next();
        BigDecimal b = new BigDecimal(bstr);
        BigDecimal result = new BigDecimal(a).multiply(b);
        result = result.setScale(0, BigDecimal.ROUND_DOWN);

        System.out.println(result.toPlainString());
    }
}

Measured memory_bytes: 27220
while True:
  ans = 0
  n, x = map(int, input().split())
  if n == 0 and x == 0:
    break
  for i in range(1, n - 1):
    for j in range(i + 1, n):
      for k in range(j + 1, n + 1):
        if i + j + k == x:
          ans += 1
  print(ans)


Measured memory_bytes: 5596
#include <iostream>

using namespace std;

int N, M, K, f, i, ans;

int main(){
    while( cin >> N >> M ){
        ans = 0;
        int F[M] = {0};
        for( i=0; i<N; ++i ){
            cin >> K;
            while( K-- ){
                cin >> f;
                --f;
                ++F[f];
            }
        }
//        for( i=0; i<M; ++i ) cout << F[i] << ' '; cout << endl;
        for( i=0; i<M; ++i )
            if( F[i] == N )
                ++ans;
        cout << ans << endl;
    }
    return 0;
}
/*
3 4
2 1 3
3 1 2 3
2 3 2

5 5
4 2 3 4 5
4 1 3 4 5
4 1 2 4 5
4 1 2 3 5
4 1 2 3 4

1 30
3 5 10 30

*/


Measured memory_bytes: 256
/*#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <array>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
*/

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())

typedef long long ll;
const ll INF = 9000000000000;
const ll mod = 2e9 + 7;
const int MAX_N = 5e5 + 5;
int dx[] = { -1LL,0,1LL,0 }, dy[] = { 0,1LL,0,-1LL };
vector<ll> prime;

ll inv[MAX_N], fac[MAX_N];

template <class T = ll> T in() { T x; cin >> x; return (x); }
inline ll GCD(ll a, ll b) { ll c; while (b != 0) { c = a % b; a = b; b = c; }return a; }
inline ll LCM(ll a, ll b) { return a * b / GCD(a, b); }
inline ll POW(ll a, ll b) { ll c = 1LL; while (b > 0) { if (b & 1LL) { c = a * c%mod; }a = a * a%mod; b >>= 1LL; }return c; }
inline void _nCr() { fac[0] = 1LL; for (int i = 1LL; i < MAX_N; i++) { fac[i] = fac[i - 1LL] * i%mod; }for (int i = 0; i < MAX_N; i++) { inv[i] = POW(fac[i], mod - 2); } }
inline ll nCr(ll n, ll r) { return (fac[n] * inv[r] % mod)*inv[n - r] % mod; }
inline void PRI(ll n) { bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) { a[i] = 1LL; }for (int i = 2; i < n + 1LL; i++) { if (a[i]) { prime.pb(i); ll b = i; while (b <= n) { a[b] = 0; b += i; } } } }

int bd[2010][2010];

signed main() {
	int r,g;
	cin >> r >> g;
	cout << g * 2 - r << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input()
.split()))
min = pow(10,9)
#print(min)
max = 1
for i in range(n):
    if a[i]<min:
        min = a[i]
    if a[i]>max:
        max = a[i]
print(max-min)


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j,k;
    ll n,m,l;
    cin >> n >> m >> l;
    vector<vector<ll>> graph(n, vector<ll>(n,1e14));
    for(i = 0;i < m;++i){
        ll a,b,c;
        cin >> a >> b >> c;
        --a;    --b;
        graph.at(a).at(b) = c;
        graph.at(b).at(a) = c;
    }
    for(i = 0;i < n;++i){
        graph.at(i).at(i) = 0;
    }
    rep(k,n){
        for(i = 0;i < n;++i){
            rep(j,n){
                graph.at(i).at(j) = min(graph.at(i).at(j), graph.at(i).at(k) + graph.at(k).at(j));
            }
        }
    }
    vector<vector<ll>> ans(n,vector<ll>(n, 1e9));
    for(i = 0;i < n;++i){
        rep(j,n){
            if(graph.at(i).at(j) <= l) ans.at(i).at(j) = 1;
        }
    }
    for(i = 0;i < n;++i){
        ans.at(i).at(i) = 0;
    }
    rep(k,n){
        for(i = 0;i < n;++i){
            rep(j,n){
                ans.at(i).at(j) = min(ans.at(i).at(j), ans.at(i).at(k) + ans.at(k).at(j));
            }
        }
    }

    ll q;
    cin >> q;
    for(i = 0;i < q;++i){
        ll s,t;
        cin >> s >> t;
        --s;    --t;
        if(ans.at(s).at(t) == 1e9) cout << -1 << endl;
        else cout << ans.at(s).at(t)-1 << endl;
    }

    return 0;
}

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

int main() {
    int N, M, like[30] = { 0 }, count = 0;
    cin >> N >> M;
    for (int i = 0; i < N; i++)
    {
        int K;
        cin >> K;
        for (int j = 0; j < K; j++)
        {
            int A;
            cin >> A;
            like[A - 1]++;
        }
    }
    for (int i = 0; i < M; i++) if (like[i] == N) count++;
    cout << count;
}

Measured memory_bytes: 3632
from collections import deque
h, w = map(int, input().split())
s = [list(input()) for i in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            A = False
            B = False
            C = False
            D = False
            if i != h-1 and s[i+1][j] == '#':
                A = True
            if i != 0 and s[i-1][j] == '#':
                B = True
            if j != w-1 and s[i][j+1] == '#':
                C = True
            if j != 0 and s[i][j-1] == '#':
                D = True
            if not A and not B and not C and not D:
                print('No')
                exit(0)
print('Yes')


Measured memory_bytes: 3316
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
    cin.tie(0);
    ios::sync_with_stdio;
    string s;
    int a,b,x;
    cin>>x;
    cout<<x/3<<'\n';
    
    return(0);
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll> > P3;

const ll MOD = ll(1e9 + 7);
const ll LLINF = LLONG_MAX;
const int IINF = INT_MAX;
const int MAX_N = int(2e5) + 5;
const int MAX_A = int(15e6);
const double EPS = 1e-8;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
string dir = "RDLU";
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()


int main() {
    ll n, a, b, c, d;
    string ans = "NO";
    cin >> n >> a >> b >> c >> d;
    b = abs(b-a);
    for(ll i = 0; i*2 <= n-1; i++){
        if((n-i-1)*c-i*d <= b && b <= (n-i-1)*d-i*c){
            ans = "YES";
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


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

alice = 0
bob = 0
for i in range(n):
    if len(cards) == 0:
        break
    card = max(cards)
    cards.remove(card)
    if i % 2 == 0:
        alice += card
    else:
        bob += card

print(alice - bob)

Measured memory_bytes: 3060
#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 RFOR(i, a, b) for (int i = (b - 1); i >= a; i--)
#define RREP(i, n) RFOR(i, 0, n)
#define rep(i, a, b) for (auto i = a; i < b; i++)
#define rrep(i, a, b) for (auto i = a; i > b; i--)
#define fs first
#define sc second
typedef pair<int, int> P;

void solve(int h, int w) {
	int mn = 1000000, tmp = h * h + w * w;
	P ans = P(-1, -1);
	FOR(i, 1, 150) {
		FOR(j, i + 1, 150) {
			int cur = i * i + j * j;
			if (cur < tmp) continue;
			if (cur == tmp && h >= i) continue;
			if (mn > cur) {
				ans = P(i, j);
				mn = cur;
				break;
			}
		}
	}
	cout << ans.fs << " " << ans.sc << endl;
}

signed main() {
	int h, w;
	while (cin >> h >> w, h) {
		solve(h, w);
	}
}


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner src = new Scanner(System.in);
		int a = src.nextInt();
		int b = src.nextInt();

		int d = a / b;
		int r = a % b;
		double f = (double)a /(double)b;

		System.out.println(String.format("%d %d %.5f",d ,r ,f));
	}
}



Measured memory_bytes: 26556
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
ll INF = 1e10;
int MOD = 1e9+7;
int N,A,B,H[100000];
bool judge(ll T){
    ll cnt = 0;
    for(int i = 0;i < N;i++){
        ll num = H[i] - B*T;
        if(num <= 0)continue;
        cnt += max((num+A-B-1)/(A-B),0LL);
    }
    return cnt <= T;
}
main(){
    cin >> N >> A >> B;
    for(int i = 0;i < N;i++)cin >> H[i];
    //にぶたん
    ll ng = -1,ok = INF;
    while(llabs(ok - ng) > 1){
        ll mid = (ok + ng) / 2;
        if(judge(mid)) ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
}

Measured memory_bytes: 640
// AtCoder Beginner Contest - Problem B: Palace (https://beta.atcoder.jp/contests/abc113/tasks/abc113_b)
#include <bits/stdc++.h>

using namespace std;

#define REP(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)

const int MAX { 1010 };
const int oo { 2000000010 };

int hs[MAX];

void solve(int N, int T, int A)
{
    auto ans = -1;
    double min_dist = oo;

    REP(i, 1, N)
    {
        auto avg = T - hs[i] * 0.006;

        if (abs(avg - A) < min_dist)
        {
            min_dist = abs(avg - A);
            ans = i;
        }
    }

    cout << ans << endl;
}

int main()
{
    ios::sync_with_stdio(false);

    int N, T, A;
    cin >> N >> T >> A;

    REP(i, 1, N)
        cin >> hs[i];

    solve(N, T, A);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a,b;
char ch[201][201];
int main()
{
	for(int i=1;i<=50;i++)
		for(int j=1;j<=100;j++)
			ch[i][j]='.';
	for(int i=51;i<=100;i++)
		for(int j=1;j<=100;j++)
			ch[i][j]='#';
	cin>>a>>b;
	a--;b--;
	int cnt1=0,cnt2=0;
	for(int i=1;i<=50;i+=2){
		if(cnt1==b) break;
		for(int j=1;j<=100;j+=2){
			if(cnt1==b) break;
			cnt1++;
			ch[i][j]='#';
		}
	}
	for(int i=52;i<=100;i+=2){
		if(cnt2==a) break;
		for(int j=1;j<=100;j+=2){
			if(cnt2==a) break;
			cnt2++;
			ch[i][j]='.';
		}
	}
	cout<<"100 100"<<endl;
	for(int i=1;i<=100;i++){
		for(int j=1;j<=100;j++){
			cout<<ch[i][j];
		}
		cout<<endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>

int fib(int);


int main(void)
{
    int a;
    
    scanf("%d", &a);
    
    printf("%d\n", fib(a));
    
    return 0;
}



int fib(int A)
{
  int N[100];
  int i;
  N[0] = N[1] = 1;
  for ( i = 2; i <= 44; i++ ) N[i] = N[i - 1] + N[i - 2];
  return N[A];
}



Measured memory_bytes: 2080
import math 
n=int(input())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
for j in range(3):
	w=0
	dist=0
	dist_2=[]
	for i in range(n):
		w=abs(x[i]-y[i])
		dist+=w**(j+1)
		dist_2.append(w)
	print(pow(dist,1/(j+1)))
print(float(max(dist_2)))
	


Measured memory_bytes: 5696
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val N = sc.nextInt()
    val K = sc.nextLong()
    val A = Array.fill(N)(sc.nextLong()).sorted
    val F = Array.fill(N)(sc.nextLong()).sorted(Ordering.Long.reverse)
    val AF: Array[(Long, Long)] = A zip F

    val MAX = A.last * F.head

    def binarySearch(l: Long, r: Long): Long =
      if (r - l > 1) {
        val X = l + (r - l) / 2
        val _K = AF.foldLeft(0L) { case (r, (a, f)) =>
          r + ((a - X / f) max 0)
        }
        if (_K <= K) binarySearch(l, X)
        else binarySearch(X, r)
      } else r

    println(binarySearch(-1, MAX))
  }

}


Measured memory_bytes: 147840
package main

import "fmt"

func main() {
	var S string
	fmt.Scan(&S)
	var Q int
	fmt.Scan(&Q)

	reversed := false
	rs := []rune(S)
	hs := make([]rune, 0)
	ts := make([]rune, 0)

	for i := 0; i < Q; i++ {
		var q1 int
		fmt.Scan(&q1)
		if q1 == 1 {
			reversed = !reversed
			continue
		}
		var f int
		var s string
		fmt.Scan(&f)
		fmt.Scan(&s)
		cs := []rune(s)
		c := cs[0]
		if f == 1 && !reversed || f == 2 && reversed {
			// front
			hs = append(hs, c)
		}
		if f == 1 && reversed || f == 2 && !reversed {
			// last
			ts = append(ts, c)
		}
	}

	if reversed {
		fmt.Printf("%s%s%s\n", string(reverse(ts)), string(reverse(rs)), string(hs))
		return
	}

	fmt.Printf("%s%s%s\n", string(reverse(hs)), string(rs), string(ts))
}

func reverse(rs []rune) []rune {
	res := make([]rune, len(rs))
	for i := 0; i < len(rs); i++ {
		res[i] = rs[len(rs)-i-1]
	}
	return res
}


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

int main(){
  int x, y;
  int a[] = {0,1,3,1,2,1,2,1,1,2,1,2,1};
  cin >> x >> y;
  cout << (a[x] == a[y] ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
const int maxn=100100;
 
long long dp[maxn];
long long h[maxn];
long long n,k;
 
int main () {
	memset(dp, -1, maxn);
	
	cin >> n >> k;
	for (int i=0;i<n;++i){
		cin >> h[i];
	}
	
	for (int i=0;i<k;++i){
		dp[i]=abs(h[i]-h[0]);
	}
		
	for (int i=k;i<n;++i){
		dp[i]=abs(h[i]-h[i-1])+dp[i-1];
		
		for (int j=2; j <= k; j++)
			if (dp[i]!=-1){
				dp[i]=min(abs(h[i]-h[i-j])+dp[i-j], dp[i]);
			}
	}
	cout << dp[n-1];
	return 0;
}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.IO;

class _Class
{
	void _Do()
	{
		//
		var _s = _stringArray();
		var R_ = int.Parse(_s[0]);
		var G_ = int.Parse(_s[1]);
		var B_ = int.Parse(_s[2]);

		var c = B_ + 10*G_+10*10*R_;

		if (c % 4 == 0)
			Console.WriteLine("YES");
		else
			Console.WriteLine("NO");	



	}

	static void Main(string[] args)
	{
		new _Class()._Do();
	}


	// 1
	string[] _stringArray()
	{
		return Console.ReadLine().Split();
	}

	// 2.1 -2,147,483,648 ~ +2,147,483,647
	int[] _intArray()
	{
		var _s = Console.ReadLine().Split();

		var x = new int[_s.Length];
		for (var i = 0; i < _s.Length; i++)
			x[i] = int.Parse(_s[i]);

		return x;
	}

	// 2.2 -9,223,372,036,854,775,808 ~ +9,223,372,036,854,775,807
	long[] _longArray()
	{
		var _s = Console.ReadLine().Split();

		var x = new long[_s.Length];
		for (var i = 0; i < _s.Length; i++)
			x[i] = long.Parse(_s[i]);

		return x;
	}
}


Measured memory_bytes: 11092
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cmath>
#include<map>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<unordered_map>
#include<ctime>
const  int N = 1e6 + 5;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
typedef long long ll;
typedef long double ld;
#define pa pair<int,int>
#define sc(n) scanf("%lld",&n)
#define fo(i,a,b) for(int i=a;i<b;i++)
#define mem(a,b) memset(a,b,sizeof a)
using namespace std;
int n, m;
unordered_map<char, int> mp;
int a[50], b[50];
//struct cmp
//{
//	bool operator () (int x, int y)
//	{
//		return x > y;
//	}
//};
int main()
{
	int t;
	int cnt = 0;
	sc(n);
	fo(i, 0, n)
		sc(a[i]);
	fo(i, 1, n - 1)
	{
		b[0] = a[i - 1], b[1] = a[i], b[2] = a[i + 1];
		sort(b, b + 3);
		if (b[1] == a[i])
			cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;


int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    int count = 0;
    for (int i = 1; i <= n; i++) {
        if (i >= 1 && i <= 9) {
            count++;
        } else if (i >= 100 && i <= 999) {
            count++;
        } else if (i >= 10000 && i <= 99999) {
            count++;
        }
    }
    cout << count << endl;
    return 0;
}


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

int main()
{
	int n, cnt = 0;
	vector<int> p;
	cin >> n;
	p.resize(n);
	for (int i = 0; i < n; i++)
	{
		cin >> p[i];
	}
	for (int i = 0; i < n - 2; i++)
	{
		if (p[i] < p[i + 1] && p[i + 1] < p[i + 2])
			cnt++;
		else if (p[i] > p[i + 1] && p[i + 1] > p[i + 2])
			cnt++;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cstdio>
using namespace std;
#define N 102
int x[N],y[N];
int main() {
	int i,n,m,X,Y;
	scanf("%d%d%d%d",&n,&m,&X,&Y);
	for( i=0;i<n;i++ )
	{
		scanf("%d",&x[i]);
	}
	for( i=0;i<m;i++ )
	{
		scanf("%d",&y[i]);
	}
	sort(x,x+n);
	sort(y,y+m);
	if( x[n-1]>=y[0] || x[n-1]>=Y || y[0]<=X )
		printf("War\n");
	else
		printf("No War\n");
	return 0;
	}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, k;
	cin >> n >> k;

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

	cout << count(v.begin(),v.end(),0) << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const ll INF = ll(1e15)+10;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;

// Binary indexed tree (0-indexed)
template<typename T>
struct BIT {
  int n; vector<T> d;
  BIT(int n=0) : n(n), d(n+1) {}
  void add(int i, T a=1) {for (i++; i <= n; i += i & -i) d[i] += a;}
  // sum [0, i)
  T sum(int i) {T x = 0;  for (; i > 0; i -= i & -i)  x += d[i]; return x;}
};


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

  vector<BIT<int>> num(26, BIT<int>(N));
  rep(i, N) {
    int x = S[i] - 'a';
    num[x].add(i);
  }

	rep(q, Q) {
		int t; cin >> t;
		if (t == 1) {
			int i; char c; cin >> i >> c;
			i--;
      int x = S[i] - 'a';
      int y = c - 'a';
      S[i] = c;
      num[x].add(i, -1);
      num[y].add(i);
		}
		if (t == 2) {
			int l, r; cin >> l >> r;
			l--; r--;
      ll ans = 0;
      rep(x, 26) {
        (num[x].sum(r+1) - num[x].sum(l)) ? (ans++) : (false);
      }
			cout << ans << endl;
		}
	}
}


Measured memory_bytes: 53636
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int main() {
    ll N,M; cin>>N>>M; ll A[N],B[N+1]={};
    rep(i,N) {cin>>A[i]; B[i+1]=(B[i]+A[i])%M;}
    map<ll,ll> ct;
    rep(i,N+1) ++ct[B[i]];
    ll ans=0; 
    for(auto x:ct) ans+=(x.second*(x.second-1))/2;
    cout<< ans<<"\n";
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
template<typename T>
using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define all(v)			((v).begin()), ((v).end())
#define SZ(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define has(c,i) 		((c).find(i) != end(c))
#define UNIQUE(v)       sort(all(v));v.erase(unique(all(v)),v.end());
#define has_str(s, c)	((s).find(c) != string::npos)
typedef long long ll;
int main() {
#ifdef online_judge
    freopen("input.txt", "wt", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(ll &i : a)
        cin >> i;
    ll ans = 0;
    for(int i = 1; i < n; ++i) {
        if(a[i] < a[i - 1]) {
            ans += a[i - 1] - a[i];
            a[i] = a[i - 1];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4744
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
typedef long long ll;

struct S { ll n0, n1, inv; };
using F = bool;
S op(S l, S r) { return {l.n0 + r.n0, l.n1 + r.n1, l.inv + r.inv + l.n1 * r.n0}; }
S e() { return {0, 0, 0}; }
S mapping(F f, S x) { return f ? S{x.n1, x.n0, x.n0*x.n1-x.inv} : x; }
F composition(F f, F g) { return (f && !g) || (!f && g); }
F id() { return false; }

int main() {
	int N, Q;
	cin >> N >> Q;
	vector<S> a(N);
	for (int i = 0; i < N; ++ i) {
		int x;
		cin >> x;
		a[i] = {1-x, x, 0};
	}
	lazy_segtree<S, op, e, F, mapping, composition, id> seg(a);
	for (int i = 0; i < Q; ++ i) {
		int t, l, r;
		cin >> t >> l >> r;
		if (t == 1) {
			seg.apply(l-1, r, true);
		} else {
			cout << seg.prod(l-1, r).inv << endl;
		}
	}
}


Measured memory_bytes: 20464
n, a, b, c = map(int, input().split())
length = []
inf = 10**9 + 7

for i in range(n):
    length.append(int(input()))


def DFS(cur, x, y, z):
    if cur == n:
        return abs(x - a) + abs(y - b) + abs(z - c) - 30 if min(x, y,
                                                                z) else inf

    part0 = DFS(cur + 1, x, y, z)
    part1 = DFS(cur + 1, x + length[cur], y, z) + 10
    part2 = DFS(cur + 1, x, y + length[cur], z) + 10
    part3 = DFS(cur + 1, x, y, z + length[cur]) + 10

    return min(part0, part1, part2, part3)


print(DFS(0, 0, 0, 0))


Measured memory_bytes: 3064
x, n = map(int, input().split())
if n == 0:
    print(x)
else:
    p = sorted(list(map(int, input().split())))

    ans = [10**4, 10**4]
    for i in range(102):
        if i not in p:
            if ans[1] == abs(x-i):
                ans[0] = min(ans[0], i)
            elif ans[1] > abs(x-i):
                ans[0] = i
                ans[1] = abs(x-i)
    print(ans[0])



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

int main(){
  int N; cin >> N;
  unordered_set<int> p;
  for(int i = 0; i < N; i++){
    int a; cin >> a;
    if(p.find(a) == p.end()) p.emplace(a);
    else p.erase(a);
  }
  cout << p.size();
}

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

int main()
{
  int n;
  cin >> n;
  if(n == 1){
    cout << "Hello World" << endl;
  }
  else if(n == 2){
    int a,b;
    cin >> a >> b;
    cout << a+b << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;

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

int N, M;
vector<vector<int> >g(5002);

int main(){
  rep(i,5002){
    g[i].resize(i+2);
    fill(g[i].begin(), g[i].end(), 0);
  }
  //  memset(g, 0, sizeof(g));
  scanf("%d%d", &N, &M);

  int A, B, X;
  rep(i, M){
    scanf("%d%d%d",&A,&B,&X); A--; B--; X++;
    g[A][B] += 1;
    g[A][B+1] += -1;
    g[A+X][B] += -1;
    g[A+X+1][B+1] += 1;
    g[A+X][B+X+1] += 1;
    g[A+X+1][B+X+1] += -1;
  }

  rep(i, 5001) rep(j,i+1) g[i][j+1] += g[i][j];
  rep(j, 5001) REP(i,j,5000) g[i+1][j] += g[i][j];
  rep(i, 5001) rep(j,i+1) g[i+1][j+1] += g[i][j];

  int res = 0;
  rep(i, 5001) rep(j, i+1) res += (g[i][j]>=1);
  printf("%d\n", res);
  return 0;
}

Measured memory_bytes: 49848
#include<stdio.h>
#include<math.h>

int isPrime(int x){
  if(x==2){
    return 1;
  }
  if(x<2 || x%2==0){
    return 0;
  }

  int i=3;
  while(i<=sqrt(x)){
    if(x%i==0){
      return 0;
    }
    i = i+2;
  }

  return 1;
}

int main(){
  int n;
  scanf("%d",&n);

  int N[n];
  int c=0;
  for(int i=0;i<n;i++){
    scanf("%d",&N[i]);
    if(isPrime(N[i])){
      c++;
    }
  }
  printf("%d\n",c);

  return 0;
}



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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= 9; i++)
    {
        for (int j = 1; j <= 9; j++)
        {
            if (i * j == n)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

cnt = 0
for i, j in zip(a, b):
    if i < j:
        cnt += (j - i) // 2 + (j - i) % 2
sa = sum(b) - sum(a)
if cnt <= sa:
    print("Yes")
else:
    print("No")
            

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

typedef long long LL;  
using namespace std;

#define fillchar(a, x) memset(a, x, sizeof(a))
#define MP make_pair
#define PB push_back
#define endl '\n'

const int M = (int)1e9+7;

int main()
{
//ios_base::sync_with_stdio(0); 
cout.precision(15);
cout.setf(ios::fixed);

int i,n,x;

cin >> n >> x;

int k;
int car = 0;
LL ans = 0;
LL tmp;

for(i=0;i<n;i++)
	{
	cin >> k;

	// cout<<k<<' '<<car<<endl;

	if(k+car>x)
		{
		tmp = k+car-x;
		ans = ans + tmp;	
		car = k - tmp;
		}
	else
		car = k;
			
	}

cout<<ans<<endl;

}


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

using namespace std;

int main() {
  int n, tt;
  std::cin >> n >> tt;
  std::vector<int> ts(n);
  for (auto& t : ts) {
    std::cin >> t;
  }
  int64_t ret = static_cast<int64_t>(tt) * n;
  int64_t endTime = ts.front() + tt;
  for (int i = 1; i < n; i++) {
    auto const t = ts[i];
    ret -= std::max(endTime - t, INT64_C(0));
    endTime = t + tt;
  }
  std::cout << ret << std::endl;
  return 0;
}


Measured memory_bytes: 1024
#include <map>
#include <queue>
#include <vector>
#include <iostream>

using namespace std;

const vector<int> p2 = { 1, 2, 3, 15, 16, 30, 29, 28 };
const vector<int> p4 = { 7, 8, 9, 13, 18, 24, 23, 22 };
const vector<int> p5 = { 1, 4, 7, 10, 21, 30, 27, 24 };
const vector<int> p7 = { 3, 6, 9, 12, 19, 28, 25, 22 };

const vector<int> last = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 4, 4, 4, 6, 6, 6, 5, 5, 5, 3, 3, 3, 3, 3, 3, 3, 3, 3 };

bool ok(vector<int> v)
{
	return v == last;
}

int solve(vector<int> v)
{
	map<vector<int>, int> d; d[v] = 1;

	queue<vector<int> > que; que.push(v);

	if (ok(v)) { return 0; }

	while (!que.empty())
	{
		vector<int> v1 = que.front(); que.pop();

		vector<int> v2, v4, v5, v7;

		v2 = v1; v4 = v1; v5 = v1; v7 = v1;

		for (int i = 0; i < 8; i++) { v2[p2[i] - 1] = v1[p2[7 - i] - 1]; } v2[18] = v1[20]; v2[20] = v1[18];
		for (int i = 0; i < 8; i++) { v4[p4[i] - 1] = v1[p4[7 - i] - 1]; } v4[9] = v1[11]; v4[11] = v1[9];
		for (int i = 0; i < 8; i++) { v5[p5[i] - 1] = v1[p5[7 - i] - 1]; } v5[15] = v1[17]; v5[17] = v1[15];
		for (int i = 0; i < 8; i++) { v7[p7[i] - 1] = v1[p7[7 - i] - 1]; } v7[12] = v1[14]; v7[14] = v1[12];

		if (ok(v2)) { return d[v1]; }
		if (ok(v4)) { return d[v1]; }
		if (ok(v5)) { return d[v1]; }
		if (ok(v7)) { return d[v1]; }

		if (d[v2] == 0) { d[v2] = d[v1] + 1; que.push(v2); }
		if (d[v4] == 0) { d[v4] = d[v1] + 1; que.push(v4); }
		if (d[v5] == 0) { d[v5] = d[v1] + 1; que.push(v5); }
		if (d[v7] == 0) { d[v7] = d[v1] + 1; que.push(v7); }
	}

	return -1;
}

int main()
{
	vector<int> v(30);

	int n; cin >> n;

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < 30; j++)
		{
			cin >> v[j];
		}

		cout << solve(v) << endl;
	}

	return 0;
}

Measured memory_bytes: 3220
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
#define PI 3.14159265358979
//const int64_t INF = 1LL << 60;
const int INF = 1 << 29;
//const int64_t MOD = 1000000007;
//const int64_t INF = 998244353;
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; }
using namespace std;
typedef pair<int64_t, int64_t> P;

int main(){
    int a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);
    rep(i, 0, b){
        cout << a;
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
int main() {
	int H; cin >> H;
	vi A(H); rep(i, 0, H) cin >> A[i];
	make_heap(all(A));
	cout << " " << A[0];
	rep(i, 1, H) cout << " " << A[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 4496
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
typedef pair<ll, int> P;

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

    int n;
    cin >> n;

    ll x[n], y[n];
    ll mn = 1e9, mx = 0;
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
        if (x[i] < y[i]) swap(x[i], y[i]);
        mn = min(mn, y[i]);
        mx = max(mx, x[i]);
    }

    // Rmax = mx, Bmin = mn の時
    ll Bmax = 0, Rmin = 1e9;
    for (int i = 0; i < n; i++) {
        Rmin = min(Rmin, x[i]);
        Bmax = max(Bmax, y[i]);
    }
    ll ans = (mx - Rmin) * (Bmax - mn);

    // Rmax = mx, Rmin = mn の時
    priority_queue <P, vector<P>, greater<P>> q;

    ll Bmin = 1e9;
    Bmax = 0;
    for (int i = 0; i < n; i++) {
        Bmin = min(Bmin, y[i]);
        Bmax = max(Bmax, y[i]);
        q.push(P(y[i], i));
    }
    ans = min(ans, (mx - mn) * (Bmax - Bmin));


    while (true) {
        P p = q.top();
        q.pop();

        if (p.first < x[p.second]) {
            q.push(P(x[p.second], p.second));

            Bmin = q.top().first;
            Bmax = max(Bmax, x[p.second]);
            ans = min(ans, (mx - mn) * (Bmax - Bmin));
        } else {
            break;
        }
    }

    cout << ans << "\n";
    return 0;
}

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

const int MAXN = 1000 * 1000 + 10;

int n;

int arr[MAXN];
bool check_arr[MAXN];

bool check(int x)
{

    //cerr << "x: " << x << endl;

    for(int i = 0; i < 2 * n - 1; i++){
        check_arr[i] = false;
        if(arr[i] < x) check_arr[i] = true;
        //cerr << check_arr[i] << ' ';
    }
    //cerr << endl;
    bool result;
    int nearest = MAXN;

    for(int i = (2 * n - 1) / 2; i < 2 * n - 2; i++){
        if(check_arr[i] == check_arr[i + 1]){
            nearest = i - (2 * n - 1) / 2;
            result = check_arr[i];
            break;
        }
    }

    //cerr << "nearest : " << nearest << ' ' << result << endl;

    for(int i = (2 * n - 1) / 2; i > 0; i--){
        if(check_arr[i] == check_arr[i - 1]){
            if(nearest > (2 * n - 1) / 2 - i){
                nearest = (2 * n - 1) / 2 - i;
                result = check_arr[i];
            }
            break;
        }
    }
     //cerr << "nearest : " << nearest << ' ' << result << endl;
    if(nearest == MAXN){
        if(check_arr[0] == false)
            return 0;
        return 1;
    }

    return result;
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //cout << fixed << setprecision(10);

    cin >> n;

    for(int i = 0; i < 2 * n - 1; i++) cin >> arr[i];

    int l = 1, r = 2 * n;
    while(r - l > 1){
        int mid = (l + r) / 2;

        if(check(mid)){
            r = mid;
        }
        else{
            l = mid;
        }
        //cerr << "mid : " << mid << " = " << check(mid) << endl;
    }
    cout << l << endl;

    return 0;
}



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

using namespace std;
#define INF 1000007
#define MOD 1000000007
#define maxn 101
#define maxh 1001
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
const int dx[4] = {0, 1, -1, 0}, dy[4] = {1, 0, 0, -1};
typedef std::pair<int, int> P;
#define int long long
#define double long double

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *) array, (T *) (array + N), val);
}

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void) {
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++) {
        if (!prime[i]) {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i) {
            prime[j] = false;
        }
    }
}

int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

int lcm(int a, int b) { return a / gcd(a, b) * b; }

bool IsPrime(int num) //素数判定
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2) {
        if (num % i == 0) {
            return false;
        }
    }

    return true;
}

vector<int> divisor(int n) //約数列挙
{
    vector<int> ret;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i - 1);
            if (i * i != n) {
                ret.push_back((n / i) - 1);
            }
        }
    }
    sort(ret.begin(), ret.end());
    return (ret);
}

int a, b;

void f(int x) {
    while (x) {
        a++;
        b = x;
        x /= 10;
    }
}

signed main() {
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N) {
        cin >> a[i];
    }
    int now = 1;
    rep(i, N) {
        if (a[i] == now) {
            now++;
        }
    }
    now--;
    if (now == 0) {
        cout << "-1" << endl;
    } else {
        cout << N - now << endl;

    }
}



Measured memory_bytes: 4880
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 200005

struct Info{

	ll x,y;
};

int N;
ll D;
Info info[SIZE];

int main(){

	scanf("%d %lld",&N,&D);
	D = D*D;

	int ans = 0;

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

		scanf("%lld %lld",&info[i].x,&info[i].y);

		if(info[i].x*info[i].x+info[i].y*info[i].y <= D){

			ans++;
		}
	}

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

	return 0;
}


Measured memory_bytes: 6864
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
INF = 10**18


def main():
    N = int(input())
    A = list(map(int, input().split()))

    if 0 in A:
        print(0)
        return

    ans = 1
    for a in A:
        ans *= a
        if INF < ans:
            print(-1)
            return
    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 21708
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main(){
    string S;   cin>>S;
    int size=S.size();
    int Q;  cin>>Q;
    deque<char> que;
    for(int i=0;i<size;i++){
        que.push_back(S[i]);
    }
    int count=0;
    for(int i=0;i<Q;i++){
        int T;  cin>>T;
        if(T==1){
            count++;
        }
        else{
            int F;  cin>>F;
            char C; cin>>C;
            if(count%2==0){ //反転してない
                if(F==1){
                    que.push_front(C);
                } else{
                    que.push_back(C);
                }
            } else{ //反転状態
                if(F==1){
                    que.push_back(C);
                } else{
                    que.push_front(C);
                }
            }
        }
    }
    if(count%2==0) {
        for (auto itr = que.begin(); itr < que.end(); itr++) {
            cout << *itr;
        }
    } else{
        for (auto itr = que.end()-1; itr >= que.begin(); itr--) {
            cout << *itr;
        }
    }
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int main(){
    ll n, m;
    cin >> n >> m;
    vector<pair<ll, ll>> buy(n);
    vector<ll> a(n), b(n);
    rep(i, n) {
        cin >> a[i] >> b[i];
    }
    rep(i, n) {
        buy[i].first = a[i];
        buy[i].second = b[i];
    }
    sort(all(buy));
    ll sum = 0;
    rep(i, n) {
        if(m <= 0) break;
        ll M = min(buy[i].second, m);
        sum += buy[i].first * M;
        m -= M;
    }
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 6432
from itertools import accumulate
import operator
while True:
    L = [0] * 86401
    num = int(input())
    if num == 0:
        break

    for _ in range(num):
        s, t = input().split()
        hh, mm, ss = [int(x) for x in s.split(":")]
        s  = 3600 * hh + 60 * mm + ss
        hh, mm, ss = [int(x) for x in t.split(":")]
        t = 3600 * hh + 60 * mm + ss
        L[s] +=1
        L[t] -=1

    S = accumulate(L, operator.add)
    print(max(S))



Measured memory_bytes: 7040
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1e17 - 10;
const double PI = acos(-1);
typedef pair<LL, LL> Pll;
LL n, m, ans = 0, d[1000] = {}, sum = 0;
int flag = 0;
string str;
int main(){
	cin >> str;
	//cin >> n >> m;
	for(int i=0;i<2;i++)
	if (str[i+0]==str[i+1]&& str[i+0] == str[i+2])flag = 1;
	cout << (flag == 1 ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int K = Integer.parseInt(sc.next());
    int Q = Integer.parseInt(sc.next());
    int[] ans = new int[N];
    for(int i=0;i<Q;i++){
      ans[Integer.parseInt(sc.next())-1]++;
    }
   
    for(int i=0;i<N;i++){
      if((K-(Q-ans[i]))>0){
        System.out.print("Yes\n");
      }else{
        System.out.print("No\n");
      }
    }
    System.out.flush();
  }
}

Measured memory_bytes: 48916
import sys
L,R=map(int,input().split())

if R-L>2017:
  print(0)
  sys.exit()

L%=2019
while(R-L>2019):
  R-=2019
  
#print(L,R)
answer=10**10
for i in range(L,R):
  for j in range(i+1,R+1):
    answer=min(answer,(i*j)%2019)
    
print(answer)

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

int main(){
    int N, K;
    double ans, temp=0;
    cin >> N >> K;
    vector<double> p(N);
    for (int i=0; i<K; i++){
        cin >> p.at(i);
        temp += (p.at(i)+1)/2;
    }
    ans = temp;
    for (int i=K; i<N; i++){
        cin >> p.at(i);
        temp = temp + (p.at(i) - p.at(i-K))/2;
        if (temp > ans){
            ans = temp;
        }
    }
    cout << fixed << setprecision(10);
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <math.h>
int main(){
	int a,b,d,i,sum;
	char op;
	double r,area,syu;
	while(1){
		scanf("%d %c %d",&a,&op,&b);
		if(op == '+'){
			sum = a+b;
		}else if (op == '-')
		{
			sum = a-b;
		}else if (op == '*')
		{
			sum = a*b;
		}else if (op == '/')
		{
			sum = a/b;
		}else{
			break;
		}
		printf("%d\n",sum);
	}
	return 0;
}

Measured memory_bytes: 600