akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define LLI long long int
#define MOD 1000000007
using namespace std;

vector<int> adj[100007];
LLI dp[100007][0] = {};

void DFS( int x, int p) {
	
	LLI w = 1;
	LLI b = 1;
	for( auto y:adj[x]) {
		if( y == p)
			continue;
		DFS( y, x);
		w *= ( dp[y][0] + dp[y][1] ) % MOD;
		w %= MOD;
		b *= dp[y][0];
		b %= MOD;
	}
	dp[x][0] = w;
	dp[x][1] = b;
}

int main() {
	
	int i,j;
	int N;
	
	cin >> N;
	for( i=1; i<=N-1; i++) {
		int x,y;
		cin >> x >> y;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	DFS( 1, 1);
	printf("%lld\n", ( dp[1][0] + dp[1][1]) % MOD);
	
	return 0;
}

Measured memory_bytes: 16080
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) throws Exception {
        Scanner scn = new Scanner(System.in);
        int x = scn.nextInt();
        if(x==0){
        	System.out.println(1);
        }else if(x==1){
        	System.out.println(0);
        }
    }
}

Measured memory_bytes: 35708
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

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

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = INF+7;

struct edge{int to,cost;};

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

	ll a,b,c;
	cin >> a >> b >> c;

	if(a%2==0 || b%2==0 || c%2==0) cout << "0\n";
	else	cout << min(a*b,min(b*c,a*c)) << "\n";

	return 0;
}

Measured memory_bytes: 256
//Use valgrind once if the submission doesn't go through. It can detect uninitialized variables and see where they could be an issue.
#include <bits/stdc++.h>
using namespace std;

int main(){

	ios_base::sync_with_stdio(false);
    	cin.tie(NULL);

	int l, r, d, c{0};
	cin>>l>>r>>d;
	for(int i=l;i<=r;i++){
		if(!(i%d)){
			c++;
		}
	}
	cout<<c<<endl;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define int           long long
#define pb            push_back
#define x             first
#define y             second
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define PI            3.14159265358979
#define N             200005

int solve(){
    char c; cin>>c;
    if(c>='a'&&c<='z') cout<<"a";
    else cout<<"A";
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0;
}

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

const int maxn = 1000010, P = 1000000007;
int n, ans, fact[maxn], finv[maxn];

int qp(int x, int y) {
    int z = 1;
    for (; y; y >>= 1, x = 1LL * x * x % P) {
        if (y & 1) z = 1LL * z * x % P;
    }
    return z;
}

int C(int x, int y) {
    if (x < y || y < 0) return 0;
    return 1LL * fact[x] * finv[y] % P * finv[x - y] % P;
}

int main() {
    scanf("%d", &n);
    for (int i = fact[0] = finv[0] = 1; i <= n; i++) {
        fact[i] = 1LL * i * fact[i - 1] % P;
        finv[i] = qp(fact[i], P - 2);
    }
    for (int i = 0; i < n - 1; i++) {
        int t = 1LL * C(n - 2, i) * fact[i] % P;
        t = (t + 1LL * fact[i] * C(n - 2, i - 1)) % P;
        t = (t - 1LL * C(i - 1, i + i - n) * fact[i] % P + P) % P;
        ans = (ans + 1LL * t * fact[n - 1 - i]) % P;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 8064
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0)
#define END return EXIT_SUCCESS
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR(I,0,N)
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP(I,N) cin>>V[I]
#define INS2(I,N,V1,V2) REP(I,N) cin>>V1[I]>>V2[I];
#define INS3(I,N,V1,V2,V3) REP(I,N) cin>>V1[I]>>V2[I]>>V3[I];
#define OUT(P) cout<<P<<endl
#define OUT2(P1,P2) cout<<P1<<" "<<P2<<endl
#define OUT3(P1,P2,P3) cout<<P1<<" "<<P2<<" "<<P3<<endl
#define OUTS(I,N,V) REP(I,N) cout<<V[i]<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
typedef unsigned long ul;
typedef unsigned int ui;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

ul N,ans;
map<ul,ul> cnt;
ul MOD=(ul)1e9+7;

void fact(ul n){
  ul i=2;
  while(n!=1){
    while(n%i==0){
      n/=i;
      cnt[i]++;
      cnt[i]%=MOD;
    }
    i++;
  }
}

inline void solve(){
  IN(N);
  ul i;
  UP(i,2,N){
    fact(i);
  }
  ans=1;
  for(map<ul,ul>::iterator it=cnt.begin();it!=cnt.end();it++){
    ans*=(it->second+1);
    ans%=MOD;
  }
  OUT(ans);
}

int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 256
/*input
9 5
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld long double
#define pii pair<int,int>
#define f first
#define s second
#define pb emplace_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define sz(_a) (ll)(_a.size())
#define FILL(n) memset(n,0,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
const ll maxn=100005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
ll mypow(ll a,ll b){
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}
int arr[maxn];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	cout<<3*n*n;
}

Measured memory_bytes: 256
n = int(input())
def dfs(x):
    if int(x) > n:
        return 0
    
    if all(x.count(i) > 0 for i in "753"):
        ret = 1
    else:
        ret = 0
    
    for i in "753":
        ret += dfs(x+i)
        
    return ret
print(dfs("0"))

Measured memory_bytes: 3060
n,k=map(int,input().split())
s=input()
s1=[0 for i in range(n)]
for i in range(n):
    if i==(k-1):
        s1[i]=s[i].lower()
    else:
        s1[i]=s[i]
retu="".join(s1)
print(retu)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
const int N = 100000;
int x[N], y[N], d[N];

int main(){
  ios_base::sync_with_stdio();
  int h, w, D;
  cin >> h >> w >> D;
  for(int i=0;i<h;i++){
	for(int j=0;j<w;j++){
	  int t;
      cin >> t;
      x[t] = i;
      y[t] = j;
    }
  }
  for(int i = D+1; i<=h*w; i++){
    d[i] = d[i-D] + abs(x[i]-x[i-D]) + abs(y[i]-y[i-D]);
  }
  int q;
  cin >> q;
  while(q--){
    int l, r;
    cin >> l >> r;
    cout << d[r]-d[l] << '\n';
  }return 0;
}

Measured memory_bytes: 4684
#include <iostream>
#include <vector>
#include <cstring>
#include <map>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); ++i) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;

using namespace std;


int main(){
  ll N,res;
  cin >> N;

  if(N % 2 == 0)
  {
    N--;
  }


  res = 0;

  for(ll j = 105; j <= N; j+=2)
  {
    //jは入れておく
    ll cnt = 1;

    for(ll i = 1; i <= j/2 + 1; i+=2)
    {
  
      if(j % i == 0)
      {
        cnt++;
      }
    }
  
    if(cnt >= 8)
    {
      res++;
    }
  }

  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
def gcd(x, y):
	if x < y:
		tmp = y
		y = x
		x = tmp
	
	if x % y == 0:
		return y
	else:
		return gcd(y, x % y)


#input number
l = raw_input()

x, y = [int(e) for e in l.split()]
 
if x < 1 and x > 10000000000:
	exit()

if y < 1 and y > 10000000000:
	exit()

print gcd(x, y)

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

int main() {
  int n; scanf("%d", &n);
  int ans[10050] = {0};
  for(int x = 1; x <= 100; x++) {
    for(int y = 1; y <= 100; y++) {
      for(int z = 1; z <= 100; z++) {
        int v = x*x+y*y+z*z+x*y+y*z+z*x;
        if(v < 10050) ans[v]++;
      }
    }
  }
  for(int i = 1; i <= n; i++) {
    printf("%d\n", ans[i]);
  }
  return 0;
}


Measured memory_bytes: 3756
// header {{{
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <queue>
#include <map>
#include <list>
#include <stack>
#include <tuple>
#include <cstdio>
#include <cmath>
using namespace std;

#define kita            cout << "kita\n"
#define print2(i, n)    cout << (i) << ": " << (n) << endl
#define print3(i, j, n)     cout << "(" << (i) << ", " << (j) << ") : " << (n) << endl
#define print4(i, j, n, m)  cout << "(" << (i) << ", " << (j) << ") : " << (n) << ", " << (m) << endl
#define print_mat(mat, h, w) for(int i=0;i<(h);i++){for(int j=0;j<(w);j++){cout << mat[i][j] << " ";}cout << endl;}

#define EPS (1e-10)
#define EQ(a, b) (fabs((a)-(b)) < eps)

typedef long long ll;
typedef unsigned long long ull;
// }}}
// number {{{
#define SIZE      100005
#define MOD 1000000007LL

// べき乗
// verified AOJ NTL_1_B
ll pow(ll a, ll b) {
    if(b == 0) return 1;
    ll aa = pow(a, b/2);
    return aa*aa%MOD*(b%2 == 1 ? a : 1)%MOD;
}

ll fact[SIZE] = {1, 1};
ll finv[SIZE] = {1, 1};

void fact_init() {
    // fact
    for(ll i=2;i<SIZE;i++){
        fact[i] = fact[i-1]*i%MOD;
    }

    // finv
    finv[SIZE-1] = pow(fact[SIZE-1], MOD-2);
    for(ll i=SIZE-1;i>=3;i--){
        finv[i-1] = finv[i]*i%MOD;
    }
}

ll comb(int n, int r) {
    if(r > n) return 0;
    return fact[n]*(finv[r]*finv[n-r]%MOD)%MOD;
}

ll gcd(ll x, ll y) {
    return y ? gcd(y, x%y) : x;
}
//}}}

int main() {
    fact_init();
    int n;

    cin >> n;

    vector<int> pos(n, -1);

    int l, r;

    for(int i=0;i<n+1;i++){
        int aa;
        cin >> aa;
        aa--;
        if(pos[aa] != -1){
            l = pos[aa];
            r = i;
        }
        pos[aa] = i;
    }

    for(int k=1;k<=n+1;k++){
        ll ans = comb(n+1, k) - comb(l+n-r, k-1);
        if(ans < 0){
            ans += MOD;
        }
        cout << ans << endl;
        // cout << comb(n+1, k) << endl;
    }

    return 0;
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
int n,m,en[105],sum=0;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>en[i];
        sum+=en[i];
    }
    cin>>m;
    int a,b;
    while(m--){
        cin>>a>>b;
        cout<<sum-en[a]+b<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';

ll kaijo(ll ind){
    ll ans=1;
    rep(i, ind){
        ans*=(i+1);
    }
    return ans;
}

using namespace std;

int main(void){
    ll N, ansp=0, ansq=0;
    ll p[10], q[10];
    cin>>N;
    rep(i, N) cin>>p[i];
    rep(i, N) cin>>q[i];
    vector<ll> usedp, usedq;
    rep(i, N){
        ll usedcount=0;
        rep(j, usedp.size()){
            //cout<<usedp[j]<<sp<<i<<endl;
            if(usedp[j]<p[i]) usedcount++;
        }
        //cout<<usedcount<<endl;
        ansp+=(p[i]-1-usedcount)*kaijo(N-i-1);
        //cout<<ansp<<endl;
        usedp.push_back(p[i]);
    }
    rep(i, N){
        ll usedcount=0;
        rep(j, usedq.size()){
            //cout<<usedp[j]<<sp<<i<<endl;
            if(usedq[j]<q[i]) usedcount++;
        }
        //cout<<usedcount<<endl;
        ansq+=(q[i]-1-usedcount)*kaijo(N-i-1);
        //cout<<ansq<<endl;
        usedq.push_back(q[i]);
    }
    //cout<<ansp<<sp<<ansq<<endl;
    cout<<abs(ansp-ansq)<<endl;
    return 0;
}


Measured memory_bytes: 256
#!/bin/env python3
def main():
    l,r = map(int,input().split())
    res = 2019
    if r-l >= 2019:
      res = 0
    else:
      for i in range(l%2019,r-2019*(l//2019)+1):
        for j in range(i+1,r-2019*(l//2019)+1):
          res = min(res,(i*j)%2019)

    print(res)

main()


Measured memory_bytes: 3064
#pragma region Macros
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define REP2(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; ++i)
#define REP3(i, l, r) for (int i = (l), i##_len = (int)(r); i < i##_len; ++i)
#define GET_MACRO_REP(_1, _2, _3, NAME, ...) NAME
#define REP(...) GET_MACRO_REP(__VA_ARGS__, REP3, REP2) (__VA_ARGS__)
#define RREP2(i, n) for (int i = (n - 1); i >= 0; --i)
#define RREP3(i, l, r) for (int i = (r - 1), i##_len = (l); i >= i##_len; --i)
#define GET_MACRO_RREP(_1, _2, _3, NAME, ...) NAME
#define RREP(...) GET_MACRO_REP(__VA_ARGS__, RREP3, RREP2) (__VA_ARGS__)
#define IN(type, n) type n; cin >> n
#define INALL(type, v) REP(i, v.size()) { IN(type, _tmp); v.at(i) = _tmp; }
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

#ifdef _DEBUG
#define DEBUG(x) cout << #x << ": " << x << endl
#else
#define DEBUG(x)
#endif

template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#pragma endregion

int main() {
  IN(int, A);
  IN(int, B);
  IN(int, K);
  int rng = A;
  chmin(rng, B);
  int count = 0;
  RREP(i, 1, rng + 1) {
    if ((A % i == 0) && (B % i == 0)) {
      count++;
      if (count == K) {
        cout << i << endl;
        return 0;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int long long i=0;i<n;i++)
typedef int long long ll;
using namespace std;

int main(){
    
    ll n;
    ll ans=0;
    cin>>n;
    vector<ll> a(n),b(n);
    rep(i,n){
        cin>>a[i];
    }
    rep(i,n){
        cin>>b[i];
    }
    vector<pair<ll,ll>> c1;
    vector<ll> c11;
    vector<ll> c2;
    ll ccc=0;
    rep(i,n){
        if(a[i]<b[i]){
            c1.push_back(make_pair(a[i],b[i]));
            c11.push_back(b[i]-a[i]);
            ccc+=b[i]-a[i];
            ans++;
        }else{
            c2.push_back(a[i]-b[i]);
        }
    }
    
    sort(c2.rbegin(),c2.rend());
        sort(c11.rbegin(),c11.rend());
    // cout<<c1.size()<<endl;
    if(c1.size()==n){
        cout<<-1<<endl;
        return 0;
    }else if(c2.size()==n){
        cout<<0<<endl;
        return 0;
    }
    
   
    ll po=0;
    
    for(ll i=0;i<c2.size();i++){
        ccc-=c2[i];
        ans++;
        if(ccc<=0){
            cout<<ans<<endl;
            return 0;
        }
    }
    
    if(ccc>0){
        cout<<-1<<endl;
        return 0;
    }
    
    
    
    return 0;
}

Measured memory_bytes: 3820
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

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

L = [0]*(N+1)
R = [0]*(N+1)

for i in range(N):
    L[i+1] = gcd(L[i], A[i])
    R[N-i-1] = gcd(R[N-i], A[N-i-1])
    
M = []
for i in range(N):
    M.append(gcd(L[i],R[i+1]))

print(max(M))

Measured memory_bytes: 64228
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <mutex>
using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef pair<int, int> P;

struct position {
	int i, j;

	position(int i, int j) :i(i), j(j){
	}
};

struct edge {
	int to, cost;

	edge(int to, int cost) :to(to), cost(cost){
	};
};

const int MAX_V = 3600;
const int INF = 9999999;

int dxl[] = {1, 1, 1, 1, 1, 2, 2, 2, 3}, dyl[] = {-2, -1, 0, 1, 2, -1, 0, 1, 0};
int dxr[] = {-1, -1, -1, -1, -1, -2, -2, -2, -3}, dyr[] = {-2, -1, 0, 1, 2, -1, 0, 1, 0};

int d[MAX_V];
int V;
vector<edge> G[MAX_V];

int h, w;

bool in(int i, int j){
	return 0 <= i && i < h && 0 <= j && j < w;
}

int toV(int i, int j, int foot){
	return 2 * (i * w + j) + foot;
}

void calc(int s){
	priority_queue<P, vector<P>, greater<P>> que;
	fill(d, d + V, INF);
	d[s] = 0;
	que.push(P(0, s));

	while (!que.empty()) {
		P p = que.top();
		que.pop();
		int v = p.second;
		if (d[v] < p.first) continue;
		for (auto&& e : G[v]) {
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

int main(){
	while (cin >> w >> h , w != 0 || h != 0) {
		auto s = vvc(h, vc(w, 0));
		for (int i = 0; i < h; i++)
			for (int j = 0; j < w; j++)
				cin >> s[i][j];

		V = w * h * 2;

		auto start = vector<position>();
		auto goal = vector<position>();
		for (int i = 0; i < h; i++)
			for (int j = 0; j < w; j++) {
				if (s[i][j] == 'S') start.push_back(position(i, j));
				else if (s[i][j] == 'T') goal.push_back(position(i, j));
			}

		for (int i = 0; i < MAX_V; i++)
			G[i].clear();

		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				// left foot
				for (int k = 0; k < 9; k++) {
					int ni = i + dyl[k], nj = j + dxl[k];
					if (!in(ni, nj)) continue;
					if ('1' <= s[ni][nj] && s[ni][nj] <= '9')
						G[toV(i, j, 0)].push_back(edge(toV(ni, nj, 1), s[ni][nj] - '0'));
					else if (s[ni][nj] == 'S' || s[ni][nj] == 'T')
						G[toV(i, j, 0)].push_back(edge(toV(ni, nj, 1), 0));
				}
				// right foot
				for (int k = 0; k < 9; k++) {
					int ni = i + dyr[k], nj = j + dxr[k];
					if (!in(ni, nj)) continue;
					if ('1' <= s[ni][nj] && s[ni][nj] <= '9')
						G[toV(i, j, 1)].push_back(edge(toV(ni, nj, 0), s[ni][nj] - '0'));
					else if (s[ni][nj] == 'S' || s[ni][nj] == 'T')
						G[toV(i, j, 1)].push_back(edge(toV(ni, nj, 0), 0));
				}
			}
		}

		int ans = INF;
		for (auto&& sp : start) {
			calc(toV(sp.i, sp.j, 0));
			for (auto&& gp : goal) {
				ans = min(ans, d[toV(gp.i, gp.j, 0)]);
				ans = min(ans, d[toV(gp.i, gp.j, 1)]);
			}
			calc(toV(sp.i, sp.j, 1));
			for (auto&& gp : goal) {
				ans = min(ans, d[toV(gp.i, gp.j, 0)]);
				ans = min(ans, d[toV(gp.i, gp.j, 1)]);
			}
		}

		if (ans == INF)
			cout << -1 << endl;
		else
			cout << ans << endl;

	}
}

Measured memory_bytes: 1844
#include <stdio.h>
int main(void){
  int A,B,C;
  scanf("%d%d%d",&A,&B,&C);
  if(A==B&&A!=C)
   printf("Yes");
  else if(B==C&&B!=A)
   printf("Yes");
  else if(C==A&&C!=B)
   printf("Yes");
  else
   printf("No");  
  
                                
  return 0;
}

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

std::vector<bool> cango;
std::stack<int> ans;

void dfs(std::vector<std::vector<int> > &g,int now){
    cango[now]=false;
    for(size_t i=0;i<g[now].size();++i){
        if(cango[g[now][i]])dfs(g,g[now][i]);
    }
    ans.push(now);
}

int main(){
    int v,e;
    std::cin>>v>>e;
    std::vector<std::vector<int> > g(v);
    std::vector<int> ec(v,0);
    for (int i = 0; i < e; ++i) {
        int s,t;
        scanf("%d%d",&s,&t);
        g[s].push_back(t);
    }
    cango=std::vector<bool>(v,true);
    for (int i = 0; i < v; ++i) {
        if(cango[i])dfs(g,i);
    }
    while(!ans.empty()){
        printf("%d\n",ans.top());
        ans.pop();
    }
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=998244353;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
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;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
int n,s,a[3010],dp[3010];
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>n>>s;
    rep(i,n)cin>>a[i];
    dp[0]=modpow(2,n);
    int inv2=inv(2);
    rep(i,n){
        for(int j=s-1;j>=0;j--){
            if(j+a[i]<=s){
                dp[j+a[i]]+=dp[j]*inv2%mod;
                dp[j+a[i]]%=mod;
            }
        }
    }
    cout<<dp[s]<<endl;
    return 0;
}


Measured memory_bytes: 3704
#include<bits/stdc++.h>
using namespace std;
#define maxn 1e18
long long a[100005],b[250],len,c[250];
/*void sr()
{
	string str1,str2;
	cin>>str1>>str2;
	memset(a,0,sizeof(a));
	memset(b,0,sizeof(b));
	a[0]=str1.length();
	for(int i=1;i<=a[0];i++)
	{
		a[i]=str1[a[0]-i]+1-'0';
	}
	b[0]=str2.length();
	for(int i=1;i<=b[0];i++)
	{
		b[i]=str2[b[0]-i]+1-'0';
	}
}
void jiafa()
{
	len=max(a[0],b[0]);
	for(int i=1;i<=len;i++)
	{
		a[i]+=b[i];
		a[i+1]+=a[i]/10;
		a[i]%=10;
	}
	len++;
	while(a[len]==0&&(len>1))len--;
	for(int i=len;i>=1;i--)
	{
		cout<<a[i];
	}
	cout<<endl;
}
void cf()
{
	memset(c,0,sizeof(c));
	for(int i=1;i<=a[0];i++)
	{
		for(int j=1;j<=b[0];j++)
		{
			c[i+j-1]+=a[i]*b[j];
			c[i+j]+=c[i+j-1]/10;
			c[i+j-1]%=10;
		}
	}
	len=a[0]+b[0]+1;
	while((c[len]==0)&&(len>1))len--;
	for(int i=len;i>=1;i--)
	{
		cout<<c[i];
	}
	cout<<endl;
}*/
int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++)
  {
  	cin>>a[i];
	   }
	   for(int i=0;i<n;i++)
	   {
	   	if(a[i]==0)
	   	{
		   cout<<"0"<<endl;
	   	return 0;	
		   }
	   	
	   }
	   long long sum=1;
	   for(int i=0;i<n;i++)
	   {
	   	if(a[i]<=1000000000000000000/sum)
	   	{
	   		sum*=a[i];
		   }
		   else
		   {
		   	cout<<"-1"<<endl;
		   	return 0;
		   }
			} 
			cout<<sum<<endl;    
} 


Measured memory_bytes: 4408
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

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

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
string tone[12] = {
  "C",
  "C#",
  "D",
  "D#",
  "E",
  "F",
  "F#",
  "G",
  "G#",
  "A",
  "A#",
  "B"
};
int to_int(string s){
  REP(i, 12) if(s == tone[i]) return i;
  assert(false);
  return -1;
}
string to_str(int n){
  assert(n >= 0 && n < 12);
  return tone[n];
}
string code_name[5] = {
  "",
  "7",
  "M7",
  "m",
  "m7"
};
int code_tone[][5] = {
  {0, 4, 7, -1, -1},
  {0, 4, 7, 10, -1},
  {0, 4, 7, 11, -1},
  {0, 3, 7, -1, -1},
  {0, 3, 7, 10, -1}
};
string tension_name[12] = {
  "",
  "(-9)",
  "(9)",
  "(+9)",
  "(-11)",
  "(11)",
  "(+11)",
  "",
  "(-13)",
  "(13)",
  "(+13)",
  "",
};
string special_tension[2] = {
  "(-5)",
  "(+5)"
};

vector<string> solve(vector<string> tone_str){
  vector<string> answer;
  vector<int> tones;
  REP(i, tone_str.size()) tones.push_back(to_int(tone_str[i]));
  REP(i, tones.size()){
    int offset = tones[i];
    vector<int> relative = tones;
    REP(i, relative.size()) relative[i] = (relative[i] - offset + 12) % 12;
    sort(relative.begin(), relative.end());
    REP(j, 5){
      vector<int> code;
      for(int k = 0; code_tone[j][k] != -1; k++){
        code.push_back(code_tone[j][k]);
      }
      if(code == relative) answer.push_back(to_str(offset) + code_name[j]);
      for(int k = 0; k < 2; k++){
        vector<int> code2 = code;
        code2.erase(remove(code2.begin(), code2.end(), 7)); code2.push_back(7 + (2 * k - 1));
        sort(code2.begin(), code2.end());
        if(code2 == relative) answer.push_back(to_str(offset) + code_name[j] + special_tension[k]);
      }
      for(int k = 0; k < 12; k++) if(tension_name[k] != ""){
        vector<int> code2 = code;
        code2.push_back(k);
        sort(code2.begin(), code2.end());
        if(code2 == relative) answer.push_back(to_str(offset) + code_name[j] + tension_name[k]);
      }
    }
  }
  return answer;
}

int main(){
  int T;
  cin >> T;
  while(T--){
    int R; cin >> R;
    vector<string> tone_str(R);
    REP(i, R) cin >> tone_str[i];
    vector<string> codes = solve(tone_str);

    if(codes.empty()) cout << "UNKNOWN" << endl;

    REP(i, codes.size()){
      cout << codes[i];
      if(i == codes.size() - 1) cout << endl;
      else cout << " ";
    }
  }
  return 0;
}

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

int main() {
    int N, D;
    cin >> N >> D;
    vector<vector<double>> X(N, vector<double>(D));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < D; j++) {
            cin >> X.at(i).at(j);
        }
    }
    double sum;
    int c = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            sum = 0;
            for (int k = 0; k < D; k++) {
                int A = X.at(i).at(k) - X.at(j).at(k);
                sum += A * A;
            }
            sum = sqrt(sum);
            if ( ceil(sum) == sum ) {
                c++;
            }
        }
    }
    cout << c << endl;
}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int n;
  cin >> n;
  int k, q;
  cin >> k >> q;

  vector<ll> a(n), b(n);

  rep(i, n){
    cin >> a[i];
    b[i] = a[i];
  }

  sort(b.begin(), b.end());

  a.push_back(-1);

  ll ans = 1e10;
  rep(i, n){

    if(i + q - 1 >= n)  break;

    ll num = b[i];

    vector<ll> tmp, ok;
    rep(j, n+1){
      if(num <= a[j]){
        tmp.push_back(a[j]);
      }else{
        sort(tmp.begin(), tmp.end());
        rep(t, tmp.size() - k + 1){
          ok.push_back(tmp[t]);
        }
        tmp = {};

      }
    }

    if(ok.size() >= q){
      sort(ok.begin(), ok.end());
      chmin(ans, ok[q-1]-ok[0]);
    }

  }

  cout << ans << endl;



  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<math.h>
#define Lens 200005
#define Inf -1<<21
using namespace std;
int N;
int a[Lens];
int main()
{
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> a[i];
	}
	int largest = a[1] - a[0];
	int mini = min(a[0],a[1]);
	for (int i = 2; i < N; i++)
	{
		if (a[i] < mini)
			mini = a[i];
		else if (a[i] - mini > largest)
			largest = a[i] - mini;
	}
	cout << largest << endl;
	return 0;
}


Measured memory_bytes: 3852
h,w = map(int, input().split())
s = []
for i in range(h):
    s.append(input())

for i in range(h):
    for j in range(w):
        if s[i][j] == '.':
            continue
        if i > 0 and s[i-1][j] == '#':
            continue
        if j > 0 and s[i][j-1] == '#':
            continue
        if j < w - 1 and s[i][j+1] == '#':
            continue
        if i < h - 1 and s[i+1][j] == '#':
            continue
        print('No')
        exit()
print('Yes')


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

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

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

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

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

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

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

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

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

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

fn main() {
    input! {
        a: f64,
        b: f64,
        x: f64,
    }

    let rem = a * a * b - x;

    let arg = if rem < x {
        let h = rem * 2. / a / a;
        h.atan2(a)
    } else {
        let h = x * 2. / a / b;
        b.atan2(h)
    };

    let ans = arg / (2. * std::f64::consts::PI) * 360.;

    println!("{:.12}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(x)    (x).begin(),(x).end()
typedef long long ll;
const int MOD = (int)1e9 + 7;

int main(){
  int n, k;
  cin >> n >> k;
  int count = 0;
  rep(i,n){
    int buf;
    cin >> buf;
    if(buf >= k)
      count++;
  }
  cout << count << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <regex>
#include <cmath>
#include <bitset>
#include <array>
#include <deque>
#include <list>
#include <stack>
#include <iterator>
#include <random>
#include <cctype>

#define DEBUG_OUTPUT 0

#if DEBUG_OUTPUT
#define debug(...) debug_output(__VA_ARGS__)
#define debug_output_matrix(...) debug_output_matrix_impl(__VA_ARGS__)
#else
#define debug(...)
#define debug_output_matrix(...)
#endif

using namespace std;

using s32 = int32_t;
using u32 = uint32_t;
using s64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;

// ==== I/O
const char newline = '\n';

template<class T>
void input(T& val) {
    cin >> val;
}

template<class Head, class... Args>
void input(Head& val, Args&... args){
    input(val);
    input(args...);
}

template<class T>
T input() {
    T val;
    input(val);
    return val;
}

template<class T>
std::vector<T> input_vector(int n) {
    std::vector<T> res;
    for(int i=0;i<n;i++){
        res.emplace_back(input<T>());
    }
    return res;
}

template<class T>
void output(const T& val){
    cout << val;
}
template<class T1,class T2>
void output(const T1& val, const T2& val2){
    output(val);
    if(val2 != newline)
        output(' ');
    output(val2);
}

template<class T1, class T2, class... Args>
void output(const T1& val, const T2& val2, Args&&... args){
    output(val);
    output(' ');
    output(val2, args...);
}

#if DEBUG_OUTPUT
template<class T>
void debug_output(const T& val){
    cerr << val;
}
template<class T1,class T2>
void debug_output(const T1& val, const T2& val2){
    debug_output(val);
    if(val2 != newline)
        output(' ');
    debug_output(val2);
}

template<class T1, class T2, class... Args>
void debug_output(const T1& val, const T2& val2, Args&&... args){
    debug_output(val);
    debug_output(' ');
    debug_output(val2, args...);
}
#endif

template<class T>
vector<vector<T>> make_matrix2(T val, int a, int b){
    return vector<vector<T>>(
        a, vector<T>(b, val)
    );
}

template<class T>
void debug_output_matrix_impl(const vector<vector<T>>& v) {
    cerr << "========" << endl;
    for(const auto& a: v){
        for(const auto& b : a){
            cerr << b << " ";
        }
        cerr << endl;
    }
    cerr << endl;
}

// === math
s64 gcd(s64 a, s64 b) {
    return b?gcd(b,a%b):a;
}
s64 lcm(s64 a, s64 b) {
    return a / gcd(a, b) * b;
}

// =======================

int main(){
    int X, Y;
    input(X, Y);

    for(int i=0;i<=X;i++){
        auto x = i;
        auto y = X - i;
        if(x * 2 + y * 4 == Y){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
 
using namespace std;
using namespace __gnu_pbds;
 
#define debug(s) cerr << #s << " = " << s << '\n'
#define all(v) (v).begin(), (v).end()
#define mem(a,val) memset(a, val, sizeof a)
 
#define ff first
#define ss second
typedef long long ll;
 
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

int main() {
  ll a, b, c, k;
  scanf("%lld %lld %lld %lld", &a, &b, &c, &k);
  ll sum = min(a, k);
  k -= min(a, k);
  k -= min(b, k);
  sum -= min(c, k);
  printf("%lld\n", sum);
}

Measured memory_bytes: 3824
#include<bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define pb push_back

using namespace std;

int x,y;

int main()
{
    cin >> x >> y;
    for (int i=0;i<=x;i++)
    {
        if (i*2+(x-i)*4==y){cout << "Yes\n";return 0;}
    }
    cout << "No\n";
    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main(){
	int a,b,c,d[100],e=0;
	cin>>a>>b>>c;
	for(int i=1;i<=a;i++){
		if(a%i==0&&b%i==0){
			d[e]=i;
			e++;
		}
	}
	cout<<d[e-c];
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

int main() {
  int n, k, s;
  std::cin >> n >> k >> s;
  std::vector<int> a(n);

  rep(i, n) {
    if (i < k) {
      a[i] = s;
    } else {
      if (s == 1)
        a[i] = s + 1;
      else
        a[i] = s - 1;
    }
  }
  rep(i, n) {
    if (i > 0)
      std::cout << " ";
    std::cout << a[i];
  }
  std::cout << std::endl;

  return 0;
}


Measured memory_bytes: 3720
N,M=list(map(int,input().split()))
import sys
A= list(map(int,sys.stdin.readline().split()))
A=[i*-1 for i in A]
import heapq
heapq.heapify(A)
for i in range(M):
    X=heapq.heappop(A)
    X=abs(X)//2*-1
    heapq.heappush(A,X)
print(abs(sum(A)))

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    sort(a.begin(),a.end(),greater<int>());
    ll ans = a[0];
    if ((n-1)%2 == 0){
      ans += a[(n-1)/2];
      for(int i=1;i<((n-1)/2);i++){
        ans += 2*a[i];
      }
    }
    else{
      for(int i=1;i<=(n-1)/2;i++){
        ans += 2*a[i];
      }
    }
    cout<<ans<<endl;
    return 0;
}


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

int N;
vector<int>V;
vector<vector<int> >ans;
void dfs(int t,int p){
    if(t==0){
        ans.push_back(V);
        return;
    }
    for(int i=min(t,p);i>0;i--){
        V.push_back(i);
        dfs(t-i,i);
        V.pop_back();
    }
}

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

    while(cin>>N,N){
        V.clear();
        ans.clear();
        dfs(N,N);
        sort(ans.begin(),ans.end());
        reverse(ans.begin(),ans.end());
        for(int i=0;i<ans.size();i++){
            for(int j=0;j<ans[i].size();j++){
                if(j)cout<<" ";
                cout<<ans[i][j];
            }
            cout<<endl;
        }
    }
}

Measured memory_bytes: 1800
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[]]*num
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

N,T = II()
A,B = Line(N,2)

m1 = [[0]*(T+1) for _ in range(N)]
m2 = [[0]*(T+1) for _ in range(N)]

for i in range(N):
    for t in range(T+1):
        if i==0:
            if t-0.5>=A[i]:
                m1[i][t] = B[i]
            else:
                pass
        else:
            if t-0.5>=A[i]:
                m1[i][t] = max(m1[i-1][t-A[i]]+B[i], m1[i-1][t])
            else:
                m1[i][t] = m1[i-1][t]

for i in range(N):
    for t in range(T+1):
        if i==0:
            m2[i][t] = B[i]
        else:
            val1 = m1[i-1][t] + B[i]
            if t-A[i]-0.5>=0:
                val2 = max(m2[i-1][t], m2[i-1][t-A[i]]+B[i])
            else:
                val2 = m2[i-1][t]
            m2[i][t] = max(val1,val2)

print(m2[N-1][T])

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}

ll BinarySearch(ll ng, ll ok, function<bool(ll)> judge){
    while(abs(ok - ng) > 1){
        ll mid = (ok + ng) / 2;
        if(judge(mid)) ok = mid;
        else ng = mid;
    }
    return ok;
}

signed main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> cost(n), food(n);
    for(auto& i : cost) cin >> i;
    for(auto& i : food) cin >> i;

    sort(all(cost));
    sort(rall(food));

    auto fn = [=](ll x){
        ll m = k;
        REP(i, n){
            m -= max(0LL, Div(cost[i]*food[i] - x, food[i]));
            if(m < 0) return false;
        }
        return true;
    };

    cout << BinarySearch(-1, INF, fn) << endl;

    return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <cmath>

int main(void){
	
	long long a, b, c, d;

	std::cin >> a >> b >> c >> d;

	std::cout << std::min(a, b) + std::min(c, d) << std::endl;


	return 0;
}

Measured memory_bytes: 256
S = list(input())
invS = []
for s in reversed(S):
    invS.append(s)
cnt = 0
loop = 0
i,j = 0,0
while i+j < len(S)-1 and i <= len(S)-1 and j <= len(S)-1 :
    if S[i] == invS[j]:
        i += 1
        j += 1
    elif S[i] == "x":
        cnt += 1
        i += 1
    elif invS[j] == "x":
        cnt += 1
        j += 1
    else:
        cnt = -1
        break
print(cnt)


Measured memory_bytes: 4788
#include "bits/stdc++.h"
using namespace std;

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
const int inf = 1000000001;
const ll INF = 2e18 * 2;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

int main() {
	string s;
	cin >> s;
	set<char> st;
	int i, j, k;
	for (i = 0; i < s.size(); i++) {
		st.insert(s[i]);
	}
	if (st.size() == 1) {
		cout << 0 << endl;
		return 0;
	}
	int ans = inf;
	for (i = 0; i < 26; i++) {
		string t = s;
		char a = 'a' + i;
		int cnt = 0;
		for (j = 0; j < s.size(); j++) {
			string t2(t.size() - 1, '?');
			for (k = 0; k < t.size() - 1; k++) {
				if (t[k] == a || t[k + 1] == a) {
					t2[k] = a;
				}
				else {
					t2[k] = t[k];
				}
			}
			st.clear();
			for (k = 0; k < t2.size(); k++) {
				st.insert(t2[k]);
			}
			if (st.size() == 1) {
				ans = min(ans, (int)(s.size() - t2.size()));
				break;
			}
			t = t2;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int h, w;
    cin >> h >> w;
    vector<string> a(h);
    rep(i, h) cin >> a[i];

    for (int i = h - 1; i >= 0; i--) {
        bool ok = true;
        rep(j, w) {
            if (a[i][j] != '.') {
                ok = false;
                break;
            }
        }
        if (ok) {
            a.erase(a.begin() + i);
        }
    }

    for (int i = w - 1; i >= 0; i--) {
        bool ok = true;
        rep(j, a.size()) {
            if (a[j][i] != '.') {
                ok = false;
                break;
            }
        }
        if (ok) {
            rep(j, a.size()) {
                a[j].erase(a[j].begin() + i); 
            }
        }
    }

    rep(i, a.size()) {
        put(a[i]);
    }

    return 0;
}

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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vld vector < ld >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < long , long >
# define pDD pair < D , D >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);
# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10f",n);
# define line cout<<"\n";

const ld pie = 3.14159265358979 ;
const ll mod = 1e9 + 7 ;

string vow = "aeiou";

void solve ( int test_case )
{
    ll n ; cin >> n ;

    ll ans = n*(n-1) / 2 ;
    cout << ans ; line
}

int main()
{
    int t = 1;
    //cin >> t;

    for ( int i=0 ; i<t ; i++ ) solve(i);
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)

	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	fmt.Fprintln(writer, f(n))

	writer.Flush()
}

func f(n int) int {
	ans := len(fmt.Sprintf("%d", n))
	for i := 1; i*i <= n; i++ {
		if n%i != 0 {
			continue
		}
		li := len(fmt.Sprintf("%d", i))
		ld := len(fmt.Sprintf("%d", n/i))
		if li < ld {
			li = ld
		}
		if ans > li {
			ans = li
		}

	}
	return ans
}


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

using namespace std;
using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define rep(i, N) for (ll i = 0; i < (N); i++)
#define For(i, a, b) for (ll i = (a); i < (b); i++)
#define all(A) (A).begin(), (A).end()

int main(){
    int N, R;
    cin >> N >> R;
    if (N >= 10) cout << R << endl;
    else cout << R + 100 * (10 - N) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
inline int read()
{
    int f=1,k=0;char c=getchar();
    while (c<'0'||c>'9')c=='-'&&(f=-1),c=getchar();
    while (c>='0'&&c<='9')k=k*10+c-'0',c=getchar();
    return k*f;
}
const int maxn=1e5+100;
int a[maxn];
signed main()
{
    int n=read(),k=read();
    for (int i=1;i<=n;i++)a[i]=read();
    int ans=1e9;
    for (int i=1;i+k-1<=n;i++)
    {
        int x=a[i],y=a[i+k-1];
        if (x<=0&&y<=0)ans=min(ans,-x);
        else if (x<=0&&y>=0)ans=min(ans,min(-x-x+y,y+y-x));
        else ans=min(ans,y);
    }
    if (!k)puts("0");else
    printf("%d\n",ans);
}


Measured memory_bytes: 640