akhauriyash/Code-Regression huggingface dataset:
//package AtCoder.ABC157;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) {
        int n = in.NI(); int m = in.NI();
        int[] ans = new int[n];
        for (int i=0;i<n;i++) ans[i]=-1;
        int fl = 1;
        for (int i=0;i<m;i++) {
            int pos = in.NI()-1; int val = in.NI();
            if (pos==0 && val==0 && n!=1) {
                fl=0; break;
            }
            if (ans[pos]==-1) {
                ans[pos] = val;
            } else if (ans[pos]==val) {
                continue;
            } else if (ans[pos]!=val) {
                fl=0;
            }
        }

        if (fl==0) {
            out.println(-1);
        } else {
            int poi = 0;
            if (ans[poi]==-1 && n!=1) {
                ans[poi]=1; poi++;
            } else if (n==1 && ans[poi]==-1) {
                ans[poi]=0; poi++;
            }
            while (poi < n) {
                if (ans[poi] == -1) ans[poi] = 0;
                poi++;
            }
            for (int i = 0; i < n; i++) out.printf("%d", ans[i]);
            out.println();
        }
        out.close();
    }

    static InputStream inputStream = System.in;
    static OutputStream outputStream = System.out;
    static InputReader in = new InputReader(inputStream);
    static PrintWriter out = new PrintWriter(outputStream);

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

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

    }
}

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

int main()
{
	int N;
	ll K;
	cin >> N >> K;
	vector<ll> A(N), F(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> F[i];
	}
	sort(A.begin(), A.end());
	sort(F.rbegin(), F.rend());
	ll lb = -1, ub = 1e13;
	while (ub - lb > 1) {
		ll m = (lb + ub) / 2;
		ll co = 0;
		for (int i = 0; i < N; i++) {
			co += max(0LL, A[i] - m / F[i]);
		}
		(co <= K ? ub : lb) = m;
	}
	cout << ub << endl;
	return 0;
}


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

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

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int MAX_N = 500010;
ll INF = 1LL<<60;
vector<vector<P>> G(MAX_N);
vector<ll> dist(MAX_N,INF);

void dijkstra(int s) {
    priority_queue<P,vector<P>,greater<P>> que;
    dist[s] = 0;
    que.push(P(0,s));
 
    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v =  p.second;
        if (dist[v] < p.first) continue;
        for (int i = 0;i < G[v].size();++i) {
            P e = G[v][i];
            if (dist[e.first] > dist[v]+e.second) {
                dist[e.first] = dist[v]+e.second;
                que.push(P(dist[e.first],e.first));
            }
        }
    }
}

int main() {
    int n,m;
    cin >> n >> m;
    for (int i = 0;i < m;++i) {
        int u,v;
        cin >> u >> v;
        u--;v--;
        for (int j = 0;j < 3;++j) {
            G[u*3+j].push_back(P(v*3+(j+1)%3,1));
        }
    }
    int s,t;
    cin >> s >> t;
    s--;t--;
    dijkstra(s*3);
    if (dist[t*3] == INF) cout << "-1" << endl;
    else cout << dist[t*3]/3 << endl;
    // p_ary(dist,0,3*n,i);
    return 0;
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define NOTUSED 0
using Graph=vector<vector<int>>;

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

    // 隣接リストGを受け取る
    Graph G(n+1);
    G[0]={NOTUSED};
    REP(i,n){
        int u,k;
        cin>>u>>k;
        G[u].resize(k);
        REP(j,k){
            cin>>G[u][j];
        }
    }

    // 隣接行列Aを作成
    Graph A(n+1);
    A[0]={NOTUSED};
    for(int i=1; i<=n; i++){
        A[i].assign(n+1,0);
        A[i][0]=NOTUSED;
        REP(j,G[i].size()){
            A[i][G[i][j]]=1;
        }
    }

    for(int i=1; i<=n; i++){
        for(int j=1; j<=n; j++){
            if(j==n){
                cout<<A[i][j]<<endl;
            }else{
                cout<<A[i][j]<<" ";
            }           
        }
    }
}


Measured memory_bytes: 3172
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int m = in.nextInt();
		int l = in.nextInt();
		long[][] aryA = new long[n][m];
		long[][] aryB = new long[m][l];
		long[][] aryC = new long[n][l];
		
		//????????§?????????????´????????´???????
		for(int i=0; i<n; i++){
			for(int j=0; j<m; j++){
				aryA[i][j] = in.nextInt();
			}
		}
		for(int i=0; i<m; i++){
			for(int j=0; j<l; j++){
				aryB[i][j] = in.nextInt();
			}
		}
		
		//??????????????????
		for(int i=0; i<n; i++){
			for(int j=0; j<l; j++){
				for(int k=0; k<m; k++){
					aryC[i][j] += aryA[i][k]*aryB[k][j];
				}
			}
		}
		//??¨???
		for(int i=0; i<n; i++){
			for(int j=0; j<l; j++){
				System.out.print(aryC[i][j]);
				if(j != l-1){
					System.out.print(" ");
				}
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 45468
H, W = map(int, input().split())
maze = [list(input()) for _ in range(H)]

output = [[0] * W for _ in range(H)]
for i in range(H):
    for j in range(W):
        if maze[i][j] == '#':
            output[i][j] = '#'

dx = [0, 0, 1, 1, 1, -1, -1, -1]
dy = [1, -1, 0, 1, -1, 0, 1, -1]

for i in range(H):
    for j in range(W):
        if output[i][j] == '#':
            continue
        #cnt = 0
        for dxi, dyi in zip(dx, dy):
            nx = j + dxi
            ny = i + dyi
            if 0 <= nx < W and 0 <= ny < H: 
                if maze[ny][nx] == '#':
                    #cnt += 1
                    output[i][j] += 1
                
for i in range(H):
    print(''.join(map(str, output[i])))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 999999999
#define MINF -999999999
#define ALL(n) n.begin(),n.end()
#define MP make_pair
#define F first
#define S second

int main()
{
	int n,h,w,ans = 0,a,b;
	cin >> n >> h >> w;
	REP(i, n) {
		cin >> a >> b;
		if (a >= h && b >= w) ans++;
	}
	cout << ans << endl;
}

  


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;


int main() {
  ll n; cin >> n;
  if(n%2 != 0) cout << 0 << endl;
  else{
    ll cnt = 0;
    ll now = 10;
    rep(i, 1, 27){
      cnt += n/now;
      now *= 5;
    }
    cout << cnt << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;

void insertionSort(int A[], int n, int g)
{
    for(int i=g; i<n; i++)
    {
        int v = A[i];
        int j = i-g;
        while(j>=0 && A[j]>v)
        {
            A[j+g] = A[j];
            j -= g;
            cnt++;
        }
        A[j+g] = v;
    }
}
void shellSort(int A[], int n)
{
    for(int h = 1; ; )
    {
        if(h > n)   break;
        G.push_back(h);
        h = 3*h + 1;
    }
    for(int i=G.size()-1; i>=0; i--)
    {
        insertionSort(A, n, G[i]);
    }
}

int main()
{
    cin >> n;
    for(int i=0; i<n; i++)
        scanf("%d", &A[i]);
    cnt = 0;
    shellSort(A,n);
    cout << G.size() << endl;
    for(int i=G.size()-1; i>=0; i--)
    {
        printf("%d", G[i]);
        if(i)  printf(" ");
    }
    cout << endl;
    cout << cnt << endl;
    for(int i=0; i<n; i++)
        cout << A[i] << endl;
    return 0;
}

Measured memory_bytes: 7168
# -*- coding: utf-8 -*-

# リュカ数

#L0 = 2
#L1 = 1
#L2 = 1 + 2 = 3
#L3 = 3 + 1 = 4
#L4 = 4 + 3 = 7
#L5 = 7 + 4 = 11
#L6 = 11 + 7 = 18

N = int(input())

Li_2 = 2
Li_1 = 1
Li = 1

for i in range(2, N + 1):
    Li = Li_1 + Li_2
    Li_2, Li_1 = Li_1, Li

print(Li)

Measured memory_bytes: 9080
n=int(input())
a=list(map(int,input().split()))
odd=0
even=0
for i in range(n):
  if a[i]%2 == 0:
    even += 1
  else:
    odd += 1
if n == 1:
  print('YES')
elif odd % 2 == 0:
  print('YES')
else:
  print('NO')


Measured memory_bytes: 14108
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		ArrayList<Integer> p = new ArrayList<Integer>();
		ArrayList<Integer> q = new ArrayList<Integer>();
		ArrayList<Integer> r = new ArrayList<Integer>();
		for (int i = 0; i < a; i++) {
			p.add(sc.nextInt());
		}
		for (int i = 0; i < b; i++) {
			q.add(sc.nextInt());
		}
		for (int i = 0; i < c; i++) {
			r.add(sc.nextInt());
		}
		Collections.sort(p);
		Collections.reverse(p);
		Collections.sort(q);
		Collections.reverse(q);
		Collections.sort(r);
		Collections.reverse(r);
		sc.close();

		long sum = 0;
		for (int i = 0; i < x; i++) {
			sum += p.get(i);
		}
		for (int i = 0; i < y; i++) {
			sum += q.get(i);
		}

		int index1 = x - 1;
		int index2 = y - 1;
		for (int i = 0; i < c; i++) {
			int v1 = index1 >= 0 ? p.get(index1) : Integer.MAX_VALUE;
			int v2 = index2 >= 0 ? q.get(index2) : Integer.MAX_VALUE;
			if (v1 < v2) {
				if (v1 < r.get(i)) {
					sum += (r.get(i) - v1);
					index1--;
				} else {
					break;
				}
			} else {
				if (v2 <= r.get(i)) {
					sum += (r.get(i) - v2);
					index2--;
				} else {
					break;
				}
			}
		}

		System.out.println(sum);
	}
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,A,B;
ll X[101010],Y[101010],T;
map<ll,vector<pair<ll,int>>> U,D;
map<ll,set<pair<ll,int>>> US,DS;
ll ret;

void dfs(int cur) {
	ll UD=Y[cur]-X[cur];
	ll DD=Y[cur]+X[cur];
	
	US[UD].erase({X[cur],cur});
	DS[DD].erase({X[cur],cur});
	
	ret += lower_bound(ALL(U[UD+T]),make_pair(X[cur],0))  -lower_bound(ALL(U[UD+T]),make_pair(X[cur]-T,0));
	ret += lower_bound(ALL(D[DD+T]),make_pair(X[cur]+T+1,0))-lower_bound(ALL(D[DD+T]),make_pair(X[cur],0));
	ret += lower_bound(ALL(U[UD-T]),make_pair(X[cur]+T,0))-lower_bound(ALL(U[UD-T]),make_pair(X[cur],0));
	ret += lower_bound(ALL(D[DD-T]),make_pair(X[cur],0))  -lower_bound(ALL(D[DD-T]),make_pair(X[cur]-T+1,0));
	
	while(1) {
		auto it=US[UD+T].lower_bound({X[cur]-T,0});
		if(it==US[UD+T].end() || it->first>X[cur]) break;
		dfs(it->second);
	}
	while(1) {
		auto it=US[UD-T].lower_bound({X[cur],0});
		if(it==US[UD-T].end() || it->first>X[cur]+T) break;
		dfs(it->second);
	}
	while(1) {
		auto it=DS[DD+T].lower_bound({X[cur],0});
		if(it==DS[DD+T].end() || it->first>X[cur]+T) break;
		dfs(it->second);
	}
	while(1) {
		auto it=DS[DD-T].lower_bound({X[cur]-T,0});
		if(it==DS[DD-T].end() || it->first>X[cur]) break;
		dfs(it->second);
	}
	
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>A>>B;
	A--,B--;
	FOR(i,N) {
		cin>>X[i]>>Y[i];
		U[Y[i]-X[i]].push_back({X[i],i});
		D[X[i]+Y[i]].push_back({X[i],i});
		US[Y[i]-X[i]].insert({X[i],i});
		DS[X[i]+Y[i]].insert({X[i],i});
	}
	
	T=abs(X[A]-X[B])+abs(Y[A]-Y[B]);
	
	FORR(r,U) sort(ALL(r.second));
	FORR(r,D) sort(ALL(r.second));
	
	dfs(A);
	cout<<ret/2<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 95360
#include<iostream>
using namespace std;
int main()
{
    int H,W,h,w;
    cin >> H >> W;
    cin >> h >> w;
    if(H>=1 && W<=20 && h>=1 && H>=h && w>=1 && W>=w)
    {
        int result = (H-h)*(W-w);
        cout << result << endl;
    }
    return 0;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define ll long long
#define all(x) begin(x), end(x)
#define range(x) begin(x), begin(x)
#define what(x) cout << #x << ": " << x << '\n'
#define print(x) for (auto &el: x) cout << el << ' '; cout << '\n'
using namespace std;
 
template<typename S, typename T>
ostream& operator <<(ostream &os, pair<S, T> &m) { 
    os << '[' << m.first << " " << m.second << ']'; 
    return os; 
}

ll divs[10000002];

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

    int n;
    cin >> n;

    for (int i = 1; i <= n; ++i) {
        for (int j = i; j <= n; j += i) {
            divs[j]++;
        }
    }

    for (int i = 1; i <= n; ++i) divs[i] = i * divs[i];
    cout << accumulate(divs, divs + n + 1, 0LL) << endl;

    return 0;
}

Measured memory_bytes: 81760
#include <bits/stdc++.h>
 
using namespace std;
 
using i64 = long long;
#define forn(a, e) for (i64 a = 0; a < (i64)(e); a++)
#define forr(a, s, e) for (i64 a = s; a < (i64)(e); a++)
#define fore(e, a) for (auto& e : a)
 
#ifdef LOCAL
#define logv(a) {cerr << #a << " = "; fore(e, a) {cerr << e << " ";} cerr << "\n";}
#define logvp(a) {cerr << #a << " = "; fore(e, a) {cerr << "(" << e.first << ", " << e.second << ") ";} cerr << "\n";}
#define logvv(a) {cerr << #a << " = \n"; fore(r, a) { fore(e, r) {cerr << e << " ";} cerr << "\n";} }
#define logvf(a, field) {cerr << #a"."#field << " = \n"; fore(e, a) { cerr << e.field << " ";} cerr << "\n"; }
#define logvff(a, f1, f2) {cerr << #a".{"#f1 << ", "#f2 << "} = \n"; fore(e, a) { cerr << "(" << e.f1 <<", " << e.f2 << ") ";} cerr << "\n"; }
#define logs(a) cerr << #a << " = " << (a) << "\n";
#define logss(a, b) cerr << #a << " = " << (a) << ", " << #b << " = " << (b) << "\n";
#define logp(a) cerr << #a << " = " << "(" << a.first << ", " << a.second << ")" << "\n";
#define cond(pred, stmt) if (pred) { stmt }
#else
#define logv(a)
#define logvp(a)
#define logvv(a)
#define logvf(a, field)
#define logvff(a, f1, f2)
#define logs(a)
#define logss(a, b)
#define logp(a)
#define cond(pred, stmt)
#endif
 
using iip = pair<int, int>;
using llp = pair<i64, i64>;
using ivec = vector<int>;
using llvec = vector<i64>;
using svec = vector<string>;
template<typename T> using vec = vector<T>;
 
template<typename T, typename Dim>
auto make_vec(T value, Dim dim) { return vector<T>(dim, value); }
template<typename T, typename Dim1, typename... Dim>
auto make_vec(T value, Dim1 dim1, Dim... dims) { return make_vec(make_vec(value, dims...), dim1); }
 
template<typename T>
bool uax(T& v, const T& newv) { if (v < newv) { v = newv; return true; } else return false; }
template<typename T>
bool uin(T& v, const T& newv) { if (v > newv) { v = newv; return true; } else return false; }
 
template<typename T>
istream& operator>>(istream& is, vector<T>& c) { for (auto& e : c) is >> e; return is; }
template<typename T, size_t N>
istream& operator>>(istream& is, array<T, N>& c) { for (auto& e : c) is >> e; return is; }
 
template<typename ...T>
istream& read(T&... args) { return (cin >> ... >> args); }
 
static mt19937 rande(123123);
template<typename T>
T rand_int(T from, T to) { uniform_int_distribution<T> distr(from, to); return distr(rande); }
 
constexpr int INF = 1e9;
constexpr int MXB = 20;
using bin = bitset<MXB>;
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    rande.seed(chrono::steady_clock::now().time_since_epoch().count());
    
    int x, y;
    while (read(x, y)) {
        if (y % 2 != 0) {
            cout << "No" << endl;
        } else {
            int mx = y / 2;
            int mn = y / 4 + (y % 4 != 0);
            if (x <= mx && x >= mn) {
                cout << "Yes" << endl;
            } else {
                cout << "No" << endl;
            }
        }
    }

}

Measured memory_bytes: 3568
#include <stdio.h>

int t[10];

int main(void){
	int num;
	int i;
	
	i = 0;
	
	while (scanf("%d", &num) != EOF){
		if (num == 0){
			printf("%d\n", t[i-1]);
			i--;
		}
		else {
			t[i] = num;
			i++;
		}
	}
	
	return 0;
}

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

#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define NP next_permutation
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;

const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;

template<class T> bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T> void decimal(T a){cout<<fixed<<setprecision(a);}
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<endl;}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}

void YesNo(bool a){if(a) out("Yes"); else out("No");}
void yesno(bool a){if(a) out("yes"); else out("no");}
void YESNO(bool a){if(a) out("YES"); else out("NO");}
ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){ll c=1; while(b>0){if(b&1){c=a*c %mod;}a=a*a %mod;b>>=1;}return c;}
vi calc(ll x){vi res; while(x>0){res.eb(x%10);x/=10;}reverse(all(res)); return res;}

void solve() {
  ll n,k;
  cin>>n>>k;
  vi h(n);
  rep(i,n) cin>>h[i];
  sort(all(h));
  ll ans=inf;
  rep(i,n-k+1){
    ll p=h[i+k-1]-h[i];
    chmin(ans,p);
  }
  out(ans);
}

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


Measured memory_bytes: 1024
#include<stdio.h>
#include<string>
#include<iostream>
using namespace std;

int main() {
	string s;
	cin >> s;
	
	string h = "2019/04/30";

	if(s > h) {
		puts("TBD");
	} else {
		puts("Heisei");
	}
	return 0;
}

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

int main(){
#ifdef _DEBUG
	freopen("in" , "r", stdin );
	freopen("out", "w", stdout);
#endif
	ios::sync_with_stdio(0); cin.tie(0);
	int n, k; cin >> n >> k;
	int ans = k;
	for(int i = 2; i <= n; i++) ans *= k - 1;
	cout << ans << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

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

    string s;cin>>s;
    if(s[2]==s[3] and s[4]==s[5]){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
n,m,y = map(int,input().split())
inf = float('inf')
C = [0]*n
A = [[] for _ in range(n)]
for i in range(n):
    I = list(map(int,input().split()))
    C[i] = I[0]
    A[i] = I[1:]
ans = inf
for i in range(2**n):
    skill = [0]*m
    flag = 1
    cost = 0
    x = i
    j = 0
    while x > 0:
        if x&1:
            cost += C[j]
            for k in range(m):
                skill[k] += A[j][k]
        x = x >> 1
        j += 1
    for k in range(m):
        if skill[k] < y:
            flag = 0
    if flag:
        ans = min(ans,cost)
print(ans if ans != inf else -1)


Measured memory_bytes: 9108
fn main() {
    let a: i64 = read();
    let b: i64 = read();
    let c: i64 = read();
    let d: i64 = read();
    println!("{}", std::cmp::max(a * b, c * d));
}

fn read<T: std::str::FromStr>() -> T {
    use std::io::prelude::*;

    let stdin = std::io::stdin();
    let s: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    s.parse().ok().unwrap()
}

Measured memory_bytes: 4352
//おまじない
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define INF 1e9+7
#define roop(i,m,n) for(int i=m;i<n;i++)
#define mroop(i,m,n) for(int i=m;i<n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;

//(int)'a'は97 (int)'A'は65
//おまじない



int main() {
	
	int x, a, b;
	cin >> x >> a >> b;

	if (abs(x - a) <= abs(x - b)) {
		cout << 'A' << endl;
	}
	else {
		cout << 'B' << endl;
	}

	return 0;
}


Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))
cnt = 0
for i in range(n):
  for j in range(i + 1, n):
    for k in range(j + 1, n):
      sum_ = sum([l[i], l[j], l[k]])
      max_ = max([l[i], l[j], l[k]])
      if l[i] != l[j] and l[i] != l[k] and l[j] != l[k] and (sum_ - max_) > max_:
        cnt += 1
print(cnt)

Measured memory_bytes: 9192
#include<iostream>
#include<string>
#include<algorithm>
#define int long long
using namespace std;


signed main(){

	int N, i, countR = 0, countB = 0;
	cin >> N;

	string s;
	
	for(i = 0; i < N; i++){
		cin >> s[i];
		if(s[i] == 'R'){
			countR++;
		}else{
			countB++;
		}

	}

	if(countR > countB){
		cout <<"Yes\n";
	}else{
		cout << "No\n";
	}
		
	

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<math.h>
#include <string>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;
ll mod=1e9+7;
int cnt[100000];
int main(){
 	int n; cin >>n;
 	vector<int> d(n);
 	cinf(n,d);
 	int m; cin >>m;
 	vector<int> t(m);
 	cinf(m,t);
 	map<int,int> mp;
 	for(int i=0;i<n;i++){
 		mp[d[i]]++;
 	}
 	for(int i=0;i<m;i++){
 		if(mp[t[i]]==0){
 			cout << "NO" << endl;
 			return 0;
 		}
 		else{
 			mp[t[i]]--;
 		}
 	}
 	cout << "YES" << endl;
 	return 0;
 }

Measured memory_bytes: 11136
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

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

class BellmanFord{
private:
    struct edge{int from,to,cost;};
    int n;
    vector<int> used,reach;
    vector<edge> es;
    vector<vector<int> > g;
    void dfs(int v){
        if(used[v])return;
        used[v]++;
        for(int u: g[v])dfs(u);
    }
public:
    BellmanFord(){}
    BellmanFord(int size){
        n = size;
        g = vector<vector<int> >(size);
    }
    void add_edge(int a, int b, int c){
        edge e = {a,b,c};
        es.push_back(e);
        g[a].push_back(b);
    }
    int ans = 0;
    bool calc(int from, int to){//O(N^2+NM)
        reach = vector<int>(n,0);
        for(int i = 0; i < n; i++){
            used = vector<int>(n,0);
            dfs(i);
            reach[i] = used[to];
        }
        const int MAX = INF;//LINF
        vector<int> ds(n,MAX);
        ds[from] = 0;
        for(int i = 0; i < n; i++){
            bool update = 0;
            for(auto e :es){
                if(!reach[e.from] || !reach[e.to] || ds[e.from] == MAX)continue;
                if(ds[e.to] > ds[e.from] + e.cost){
                    ds[e.to] = ds[e.from] + e.cost;
                    update = 1;
                }
            }
            if(!update)break;
            if(i == n-1){
                ans = MAX;
                return false;//負閉路検出
            }
        }
        ans = ds[to];
        return true;//正常な値がansに入った
    }
};


signed main(void) {
    int n,m,p;
    cin >> n >> m >> p;
    BellmanFord bf(n);
    rep(i,m){
        int a,b,c;
        cin >> a >> b >> c;
        bf.add_edge(a-1,b-1,p-c);
    }
    if(!bf.calc(0,n-1)){
        cout << -1 << endl;
    }else{
        cout << max(0LL,-bf.ans) << endl;
    }
}


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

int main() {
  
  vector<int> t(3);
  rep(i,3) cin >> t[i];
  
  sort(t.begin(),t.end());
  
  if(t[0] + t[1] == t[2]) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}


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

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> num(N);
  vector<vector<int>> vec(N,vector<int>(M+1));
  for(int i=0; i<N; i++){
    cin >> num.at(i);
    for(int j=0; j<num.at(i); j++){
      cin >> vec.at(i).at(j);
    }
  }
  int count = 0;
  for(int k=1; k<M+1; k++){
   int ans = 0;
    for(int l=0; l<N; l++){
      for(int m=0; m<M; m++){
        if(vec.at(l).at(m) == k){
          ans++;
          break;
        }
      }
    }
   if(ans == N){
     count++;
   }
  }
 cout << count << endl;
}

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

int main(){
  double x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  double dx = x1 - x2;
  double dy = y1 - y2;
  cout << setprecision(10) << fixed << sqrt(dx * dx + dy * dy) <<endl;
}


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

using namespace std;

int main(void)
{
    string c1, c2;
    cin >> c1 >> c2;
    char tmp = c2[2];
    c2[2] = c2[0];
    c2[0] = tmp;

    cout << (c1 == c2 ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
ll a,b,c,d,e,f,g,ans=0;
const ll INF=99999999999999999;
int main(){
    ll n;
    string s,t;
    cin>>n;
    cin>>s>>t;
    for(int i=n;i>0;i--){
        a=1;
        for(int j=0;j<i;j++){
            if(s[n-i+j]!=t[j])a=0;
        }
        if(a==1){
            ans=n*2-i;
          break;
        }
    }
    if(ans==0)ans=2*n;
    cout<<ans<<endl;
   
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod998 = 998244353;
const ll intmax = 2147483647;
const ll llmax = 9223372036854775807;
const char sp = ' ';

struct point {
	int x, y, id;
};
struct kd {
	point p;
	int l, r;
};

bool orderx(const point &a, const point &b) {
	return a.x < b.x;
}
bool ordery(const point &a, const point &b) {
	return a.y < b.y;
}

int N, Q, c, sx, sy, tx, ty;
vector<point>p;
vector<kd>tree;
vector<int>res;

int make_tree(int l,int r,int depth) {
	if (r == l)return -1;
	int k = c;
	c++;
	if (depth & 1) {
		sort(p.begin() + l, p.begin() + r, ordery);
		tree[k].p = p[(l + r) / 2];
		tree[k].l = make_tree(l, (l + r) / 2, depth + 1);
		tree[k].r = make_tree((l + r) / 2 + 1, r, depth + 1);
	}
	else {
		sort(p.begin() + l, p.begin() + r, orderx);
		tree[k].p = p[(l + r) / 2];
		tree[k].l = make_tree(l, (l + r) / 2, depth + 1);
		tree[k].r = make_tree((l + r) / 2 + 1, r, depth + 1);
	}
	return k;
}

void solve(int t,int depth) {
	if (t == -1)return;
	int X = tree[t].p.x;
	int Y = tree[t].p.y;
	if (sx <= X&&X <= tx&&sy <= Y&&Y <= ty)res.push_back(tree[t].p.id);
	if (depth & 1) {
		if (sy <= Y)solve(tree[t].l, depth + 1);
		if (Y <= ty)solve(tree[t].r, depth + 1);
	}
	else {
		if (sx <= X)solve(tree[t].l, depth + 1);
		if (X <= tx)solve(tree[t].r, depth + 1);
	}
}

int main() {
	scanf("%d", &N);
	tree = vector<kd>(N);
	for (int i = 0; i < N; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		p.push_back({ x,y,i });
	}
	make_tree(0, N, 0);
	scanf("%d", &Q);
	while (Q--) {
		scanf("%d%d%d%d", &sx, &tx, &sy, &ty);
		res.clear();
		solve(0, 0);
		sort(res.begin(), res.end());
		for (int i : res) {
			printf("%d\n", i);
		}
		printf("\n");
	}
}




Measured memory_bytes: 18608
//a+mod-b %mod
//a^x first not1 buta notf+f butf*f
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define REPS(i,n) for(int i=1; i<=(int)(n); i++)
//#define ARRAY(type,n) (type *)malloc(sizeof(type)*n)
template<typename T>
T* ARRAY(int n){
	(T*)malloc(sizeof(T)*n);
}
template<typename T>
T** ARRAY2(int m,int n){
	T** type = (T**)malloc(sizeof(T*)*m);
	for(int i=0;i<m;i++){
		type[i]=(T*)malloc(sizeof(T)*n);
	}
	return type;
}
class llm{
public:
llm(ll value){this->value = (ll)value;}
ll value;
llm operator + (llm obj){return llm((this->value + (ll)(obj.value))%MOD);}
llm operator + (ll obj){return llm((this->value + obj)%MOD);}
llm operator - (llm obj){return llm(((this->value + MOD - (ll)(obj.value)))%MOD);}
llm operator - (ll obj){return llm(((this->value + MOD - obj))%MOD);}
llm operator * (llm obj){return llm((this->value * (ll)(obj.value))%MOD);}
llm operator * (ll obj){return llm((this->value * obj)%MOD);}
llm operator / (llm obj){return llm(this->value / (ll)(obj.value));}
llm operator / (ll obj){return llm(this->value / obj);}
llm operator % (llm obj){return llm(this->value % (ll)(obj.value));}
llm operator % (ll obj){return llm(this->value % obj);}};
ostream& operator<<(ostream& os, llm l){os << l.value;return os;} 
llm operator+(ll a,llm l){return llm((a + l.value)%MOD);} 
llm operator*(ll a,llm l){return llm((a * l.value)%MOD);}

ll D(int i,ll x){
	if(x==1){
		return (ll)i;
	}else if(x%2==0){
		ll a = D(i,x/2);
		return a*a%MOD;
	}else{
		ll b = D(i,x/2);
		return b*b%MOD*i%MOD;
	}
}

void C(ll ans[],int n){
	ll now=n+1;
	ans[1]=now;
	for(int i=2;i<=n+1;i++){
		now = now*(n+2-i)%MOD*D(i,MOD-2)%MOD;
		ans[i]=now;
	}
}

int main(void){
	int n;
	cin>>n;
	int a[100001];
	int b[100001];
	for(int i=0;i<n+1;i++){
		cin>>a[i];
		b[i]=a[i];
	}
	sort(a,a+n+1);
	int check = 0;
	for(int i=0;i<n;i++){
		if(a[i]==a[i+1]){
			check = a[i];
			break;
		}
	}
	int memo1,memo2;
	for(int i=0;i<n+1;i++){
		if(b[i]==check){
			memo1=i;
			break;
		}
	}

	for(int i=memo1+1;i<n+1;i++){
		if(b[i]==check){
			memo2 = i;
		}
	}

	ll ans[100005];

	C(ans,n);

	ll memo[100005];
	int k=2;
	memo[1]=1;
	ll now = n+1-(memo2-memo1)-1;
	memo[2]=now;
	for(int t=2;t<=n+1-(memo2-memo1)-1;t++){
		now = now*(n-(memo2-memo1)-t+1)%MOD*D(t,(MOD-2))%MOD;
		memo[t+1]=now;
		k = t+1;
	}
	for(int i=k+1;i<=n+1;i++){
		memo[i]=0;
	}

	for(int i=1;i<=n+1;i++){
		cout<<(ans[i]+MOD-memo[i])%MOD<<endl;
	}
	


	return 0;
}


Measured memory_bytes: 3584
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;

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

	string s;

	map<string, int> t;
	for (int i = 0; i < n; i++) {
		cin >> s;
		t[s]++;

	}

	int mx = 0;
	for (auto p : t) {
		mx = max(p.second, mx);

	}
	for (auto p : t) {
		if (p.second == mx) cout << p.first << endl;
	}


	return 0;
}

Measured memory_bytes: 25216
#include<bits/stdc++.h>
using namespace std;
int H,W;
vector<vector<int>> dp(100+1,vector<int> (100+1,-1));

int go(vector<vector<int>> v,int i,int j)
{
	if(i<0||j<0||i>=H||j>=W)return 2000;
	if(dp[i][j]!=-1)
	{
		return dp[i][j];
	}
	if(i==H-1&&j==W-1)
	{
		dp[i][j]=v[i][j];
		return v[i][j];
	}
	int dist1 = go(v,i+1,j);
	int dist2 = go(v,i,j+1);
	if(i<H-1&&v[i][j]==1&&v[i+1][j]==0)dist1+=1;	
	if(j<W-1&&v[i][j]==1&&v[i][j+1]==0)dist2+=1;
	dp[i][j]=min(dist1,dist2);
	return dp[i][j];
}

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);
	string s;
	cin>>H>>W;
	vector<vector<int>> v(H+1,vector<int> (W+1));
	for(int i=0;i<H;i++)
	{
		cin>>s;
		for(int j=0;j<W;j++)
		{
			if(s[j]=='.')v[i][j]=0;
			else v[i][j]=1;
		}
	}
	cout<<go(v,0,0)<<'\n';
}


Measured memory_bytes: 8968
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
double dp[310][310][310] = {};
ll N;

double calc(ll c1, ll c2, ll c3){
    double &v = dp[c1][c2][c3];
    if(v >= -0.1){
        return v;
    }
    v = 1.0;
    ll sum = c1 + c2 + c3;
    if(c3 > 0){
        v += calc(c1, c2+1, c3-1) * (double) c3 / (double) N; 
    }
    if(c2 > 0){
        v += calc(c1+1, c2-1, c3) * (double) c2 / (double) N;
    }
    if(c1 > 0){
        v += calc(c1-1, c2, c3) * (double) c1 / (double) N;
    }
    v /= (1.0 - (double) (N-sum) / (double) N);
    return v = v;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    ll a[310];
    rep(i,0,N) cin >> a[i];
    rep(i,0,N+1){
        rep(j,0,N+1){
            rep(k,0,N+1){
                dp[i][j][k] = -1.0;
            }
        }
    }
    dp[0][0][0] = 0.0;
    ll c1 = 0, c2 = 0, c3 = 0;
    rep(i,0,N){
        if(a[i] == 1) c1++;
        if(a[i] == 2) c2++;
        if(a[i] == 3) c3++;
    }

    double ans = calc(c1,c2,c3);
    cout << setprecision(12) << ans << endl;
    

}

Measured memory_bytes: 227584
//aoj 0118 Property Distribution
//多次dfs求?通?个数，有3?果子
//注意H和W，不是row和col
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;

char tile[123][123];

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

bool out_of_range(int x, int y)
{
    return x<0 || x>=H || y<0 || y>=W;
}

void dfs(int x, int y, char now)
{
    if(out_of_range(x,y) || tile[x][y]!=now) return;//超界或者不是本区域
    int nx, ny;
    tile[x][y] = '%';//????不要忘?
    for(int i=0; i<4; ++i)
    {
        nx = x+dx[i], ny = y+dy[i];
        dfs(nx,ny,now);
    }
}

void debug()
{
    for(int i=0; i<H; ++i)
    {
        for(int j=0; j<W; ++j)
        {
            printf("%c", tile[i][j]);
        }
        putchar(10);
    }
    putchar(10);
}

void solve()
{
    ans = 0;
    for(int i=0; i<H; ++i)
    {
        for(int j=0; j<W; ++j)
        {
            if(tile[i][j]!='%') {dfs(i,j,tile[i][j]); ans++;}
        }
    }
    //debug();
    printf("%d\n", ans);
}

int main()
{
    while(scanf("%d %d", &H, &W)==2 && H && W)
    {
        for(int i=0; i<H; ++i) scanf("%s", tile[i]);
        solve();
    }
    return 0;
}

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

using namespace std;

int main(void){
    int n;
    cin >> n;
    vector<queue<int> > a(n+1); 
    //入力
    for(int i = 1; i <= n; i++){
        int id, num;
        cin >> id >> num;
        for(int j = 0; j < num; j++){
            int temp;
            cin >> temp;
            a[i].push(temp);
        }
    }
    vector<int> d(n+1);
    vector<int> f(n+1);
    stack<int> place;
    place.push(1);
    int time = 0;
    while(place.size()){
        int now = place.top();
        //初めて来たらタイムスタンプ
        if(!f[now]){
            f[now] = ++time;
        }
        //次に行く場所を決める
        while(a[now].size()){
            //まずnowの隣接リストから探す
            if(!f[a[now].front()]){
                place.push(a[now].front());
                a[now].pop();
                break;
            }else{
                a[now].pop();
            }
        }
        //nowの隣接リストに見探索の頂点が無ければ一個前に戻る。
        //同時に終了のタイムスタンプを押す
        if(now == place.top()){
            place.pop();
            d[now] = ++time;
        }
        //たどり切ったときに、探索出来ない場所に見探索の頂点があれば次の目的地にする
        if(place.size() == 0){
            for(int i = 1; i <= n; i++){
                if(f[i] == 0){
                    place.push(i);
                    break;
                }
            }
        }
    }
    for(int i = 1; i <= n; i++){
        cout << i << " " << f[i] << " " << d[i] << endl;
    }
    return 0;
}


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

int main() {
  string s;
  cin >> s;
  
  int ans = 0;
  for (int i = 0; i < s.size() / 2; i++) {
    if (s.at(i) != s.at(s.size() - i - 1)) {
      ans += 1;
    }
  }
    
  cout << ans << endl;

}


Measured memory_bytes: 256
//(・ω・)
#include <stdio.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, atoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip> //setprecision
#include <limits>
#include <sstream> //istringstream
#include <stdlib.h>
#include <list>
#include <iterator>//std::advance()
using namespace std;

int main(){
    int a,b,h,m;
    cin >> a >> b >> h >> m;
    double xh,yh,xm,ym;
    double pi=3.1415926535897932384626433832795;
    xh=a*(cos(pi/2.00000000000-pi*(h/6.00000000000+m/360.00000000000)));
    yh=a*(sin(pi/2.0-pi*(h/6.0+m/360.00000000000)));
    xm=b*cos(pi/2.0000000000-pi*m/30.00000000000);
    ym=b*sin(pi/2.00000000000-pi*m/30.00000000000);
    cout << setprecision(20) <<  sqrt((xh-xm)*(xh-xm)+(yh-ym)*(yh-ym)) << endl;
}


Measured memory_bytes: 4160
import java.util.*;
import java.io.*;
class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int N = sc.nextInt();
        int M = sc.nextInt();
    if(N*500>=M)p("Yes");
    else p("No");
    }
    public static <T> void p(T element) {
	System.out.println(element);
    }
    public static <T> void pe(T element) {
        System.err.println(element);
    }
    public static int min(int a, int b, int c) {
	int min = Math.min(a,b);
	min = Math.min(min,c);
	return min;
    }
    public static int max(int a, int b,int c) {
	int max= Math.max(a,b);
	max = Math.max(max,c);
        return max;
    }
}
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
 
    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }
 
    private boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }
 
    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }
 
    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
 
    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
 
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }
    public int[] nextIntArray(int N) {
        int[] a = new int[N];
        for(int i = 0; i<N; i++) {
            a[i] = nextInt();
        }
        return a;
    }
 
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

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

ans=1

flag=1
zero=0

for i in range(0,N):
    if A[i]==0:
        zero=1


for i in range(0,N):
    ans*=A[i]
    if ans>1000000000000000000:
        flag=0
        break;

if zero==1:
    print(0)
elif flag==0:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 21700
#include<bits/stdc++.h>
using namespace std;
const int N=1005;
int a[N],n,k;
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	int s=0;
	for(int i=1;i<=k;i++)
		s+=a[i];
	printf("%d\n",s);
	return 0;
}

Measured memory_bytes: 3796
import sys

s = sys.stdin.readline().strip()
x, y = map(int, sys.stdin.readline().split())

goal = {"x": x, "y": y}
dist = {"x": [], "y": []}

if s[-1] != "T":
    s += "T"
d = 0
f = 0
x_init = -1
for i in s:
    if i == "F":
        d += 1
    else:
        if f % 2 == 0:
            if x_init == -1:
                x_init = d
            else:
                dist["x"].append(d)
        else:
            dist["y"].append(d)
        d = 0
        f += 1

# print(dist)
for mode in ("x", "y"):
    len_d = len(dist[mode])
    cand = set()
    if mode == "x":
        cand.add(x_init)
    else:
        cand.add(0)
    for i in range(len_d):
        next_cand = set()
        for d in cand:
            next_cand.add(d + dist[mode][i])
            next_cand.add(d - dist[mode][i])
        cand = next_cand

    if goal[mode] not in cand:
        print("No")
        sys.exit()

print("Yes")

Measured memory_bytes: 80592
#include<bits/stdc++.h>
using namespace std;
int main(){long x=0;int n;cin>>n;
     vector<long>a(n);for(int i=0;i<n;i++)cin>>a.at(i);
     sort(a.begin(),a.end());
    for(int i=0;i<n-2;i++)
     for(int j=i+1;j<n-1;j++)
      if(a.at(i)!=a.at(j))for(int k=j+1;k<n;k++){
       if(a.at(i)+a.at(j)>a.at(k)){if(a.at(j)!=a.at(k))x++;}else break;}
           cout<<x<<endl;}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
/*
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
*/
int main()
{
	long long int X;
	cin >> X;
	//vector<long long> v = divisor(X);
	
	//long long a = 0, b = 0; 
	
	for (int a = -200; a <= 200; a++)
	{
		for (int b = -200; b <= 200; b++)
		{
			if (pow(a, 5) == X + pow(b, 5))
			{
				cout << a << " " << b << endl;
				return 0;
			}
		}
	}
	/*
	for (int i = 0; i < v.size(); i++)
	{
		for (int j = 0; j < v[i]; j++)
		{
			a = j;
			b = j - v[i];
			
			if (pow(a, 5) - pow(b, 5) == X)
			{
				cout << a << " " << b << endl;
				return 0;
			}
		}
	}
	*/
	
	return 0;
}


Measured memory_bytes: 4060
def main():
    a, b, c = [int(x) for x in input().split()]
    count = int(input())

    while a >= b:
        b *= 2
        count -= 1
    while b >= c:
        c *= 2
        count -= 1

    print('Yes' if count >= 0 else 'No')


if __name__ == '__main__':
    main()


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

int main(){
    int a,b,c,x;
    cin >> a >> b >> c >> x;
    int ans = 0;
    int cnt = 0;
    for (int i = 0;i <= a;i++){
        for (int j = 0;j <= b;j++){
            for (int k = 0;k <= c;k++){
                ans = 500*i + 100*j + 50*k;
                if (ans == x){
                    cnt++;
                }
            }
        }
    }
    cout << cnt << endl;
}

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

typedef pair<int,int> P;

int main(){
  int n;

  while(cin >> n,n){
    vector<P> v,b;
    for(int i = 0 ; i < n ; i++){
      int m,s,sum = 0,num;
      cin >> num;
      for(int j = 0 ; j < 4 ; j++){
	cin >> m >> s;
	sum += m*60 + s;
      }
      v.push_back(P(-sum,num));
      b.push_back(P(sum,num));
    }
    sort(v.begin(),v.end());
    sort(b.begin(),b.end());
    cout << b[0].second << endl;
    cout << b[1].second << endl;
    cout << v[1].second << endl;
  }

  return 0;
}

Measured memory_bytes: 1324
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

    public static void main(String[] args) throws Exception {

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            String firstRow = br.readLine();
            if (firstRow.equals("1")) {
                System.out.println("Hello World");
            } else if (firstRow.equals("2")) {
                int secondRow = Integer.parseInt(br.readLine());
                int thirdRow = Integer.parseInt(br.readLine());
                System.out.println(secondRow + thirdRow);
            }
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 21204