akhauriyash/Code-Regression huggingface dataset:
import heapq


class Delicious (object):
    def __init__(self, x, y, z):
        self.x = x
        self.y = y
        self.z = z

    def total(self):
        return(A[self.x] + B[self.y] + C[self.z])

    def __lt__(self, other):
        return self.total() > other.total()


X, Y, Z, K = map(int, input().split(" "))
A = sorted(map(int, input().split(" ")), reverse=True)
B = sorted(map(int, input().split(" ")), reverse=True)
C = sorted(map(int, input().split(" ")), reverse=True)

ds = []
heapq.heappush(ds, Delicious(0, 0, 0))

check = {}

for _ in range(K):
    d = heapq.heappop(ds)
    while (d.x, d.y, d.z) in check:
        d = heapq.heappop(ds)
    print(d.total())
    check[d.x, d.y, d.z] = True

    if d.x < X-1:
        heapq.heappush(ds, Delicious(d.x+1, d.y, d.z))
    if d.y < Y-1:
        heapq.heappush(ds, Delicious(d.x, d.y+1, d.z))
    if d.z < Z-1:
        heapq.heappush(ds, Delicious(d.x, d.y, d.z+1))


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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define tr(ds, it) for(auto it=ds.begin(); it!=ds.end(); it++)
#define rtr(ds, it) for(auto it=ds.rbegin(); it!=ds.rend(); it++)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef priority_queue <ll> pq;
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
#define o_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define graph vector<vi>

const ll mod = 998244353;
ll po(ll x, ll n ){ 
    ll ans=1;
     while(n>0){
         if(n&1) ans=(ans*x)%mod;
         x=(x*x)%mod;
         n/=2;
     }
     return ans;
}

ll fac[200005], ifac[200005];
void pre(){
    fac[0]=1;
    rep_a(i,1,200005) fac[i]=(i*fac[i-1])%mod;
    ifac[0]=1;
    rep_a(i,1,200005) ifac[i]=po(fac[i], mod-2);
}


ll ncr(ll n, ll r){
    return (fac[n]*((ifac[n-r]*ifac[r])%mod))%mod;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    int T=1;
    //cin >> T;
    while(T--){
        pre();
        ll n,m,k;
        cin>>n>>m>>k;
        ll ans=0;
        rep(i,k+1){
            ans+=((ncr(n-1, n-1-i)*po(m-1, n-1-i))%mod);
            ans%=mod;
        }
        ans*=m;
        ans%=mod;
        cout<<ans<<el;

    }

    return 0;
}

Measured memory_bytes: 6796
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = 99999999;
const ll linf = 999999999999999999;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

///////////////////////////////////////////////////////////////////////////

int main(){

	int x,a,b;
	cin >> x >> a >> b;

    if(b-a <= 0)P("delicious");
	else if(b-a <= x)P("safe");
	else P("dangerous");
	

	return  0;
}

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

count = 0

for i in range(len(a_list)):

    # print("i : {0}".format(i))
    # print("a_list[i] : {0}".format(a_list[i]))

    if (i + 1) % 2 != 0 and a_list[i] % 2 != 0 :
        # print('OK!')
        count += 1

print(count)

Measured memory_bytes: 9156
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>

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

const long long MAX = 5100000;
const long long INF = 1LL << 60;
const long long mod = 1000000007LL;
//const long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

ll solve(ll n, vector<int>& h) {
	stack<pair<int, int>> st;
	vector<ll> left(n);
	for (ll i = 0; i < n; i++) {
		ll cnt = 1;
		while (!st.empty() && st.top().first >= h[i]) {
			cnt += st.top().second;
			st.pop();
		}
		left[i] = cnt;
		st.emplace(h[i], cnt);
	}
	while (!st.empty()) st.pop();
	vector<ll> right(n);
	for (ll i = n - 1; i >= 0; i--) {
		ll cnt = 1;
		while (!st.empty() && st.top().first >= h[i]) {
			cnt += st.top().second;
			st.pop();
		}
		right[i] = cnt;
		st.emplace(h[i], cnt);
	}
	ll res = 0;
	for (ll i = 0; i < n; i++) {
		ll cnt = left[i] + right[i] - 1;
		chmax(res, h[i] * cnt);
	}
	return res;
}

int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/
	ll H, W; scanf("%lld %lld", &H, &W);
	vector<vector<int>> vs(H, vector<int>(W)); for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) scanf("%d", &vs[i][j]);
	vector<vector<int>> hh(H, vector<int>(W));
	for (int i = 0; i < W; i++) {
		if (vs[0][i]) hh[0][i] = 0;
		else hh[0][i] = 1;
	}
	ll res = 0;
	chmax(res, solve(W, hh[0]));
	for (ll i = 1; i < H; i++) {
		for (ll j = 0; j < W; j++) {
			if (vs[i][j]) hh[i][j] = 0;
			else hh[i][j] = hh[i - 1][j] + 1;
		}
		chmax(res, solve(W, hh[i]));
	}
	cout << res << endl;
	return 0;
}



Measured memory_bytes: 18452
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(size_t i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long

signed main(){
    string S;
    cin >>S;
    bool ans=true;
    REP(i,S.size()){
        if(S[i]=='L'&&i%2==0){
            ans=false;
            break;
        }
        if(S[i]=='R'&&i%2==1){
            ans=false;
            break;
        }
    }
    if(ans){
        cout <<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

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

int main(){
  int H,N;
  cin >> H >> N;

  int H_tmp= H;
  bool ans= false;
  for(int i=0; i<N; i++){
    int a;
    cin >> a;
    H_tmp-= a;
    if( H_tmp<=0 ){
      ans= true;
      break;
    }
  }

  if(ans){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

using namespace std;

int main() {

	char S[112345];
	int q, t, f;
	char c;
	deque<char> fila;

	scanf("%s", S);

	int tam = strlen(S);

	for (int i=0; i<tam; ++i)
		fila.push_back(S[i]);

	scanf("%d", &q);

	int rev=0;
	while (q--) {
		scanf("%d", &t);

		if (t==1) 
			++rev;
		if (t==2) {
			scanf("%d %c", &f, &c);

			if ( (f + rev)%2 == 1) 
				fila.push_front(c);
			else
				fila.push_back(c);
		}
	}

	if (rev%2 == 0) {
		for (int i=0; i<fila.size(); ++i)
			printf("%c", fila[i]);
	}
	else {
		for (int i=fila.size()-1; i>=0; --i)
			printf("%c", fila[i]);
	}

	puts("");



	return 0;
}

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

using namespace std;

int main()
{
    int i,j,k,n,m,x,y=100000,z,a,b;
    string s;
    cin>>s;
    
    for(i=0;i<=s.size()-3;i++)
    {
        x=((s[i]-48)*100)+((s[i+1]-48)*10)+(s[i+2]-48);
        y=min(y,abs(753-x));
    }

    cout<<y<<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://beta.atcoder.jp/contests/abc082/tasks/abc082_b

int main() {
    string s, t; cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<char>());
    cout << (s<t?"Yes":"No") << "\n";

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#define int long long
using namespace std;
const int INF = 1000000000000;
const int mod = 1000000007;
int cnt[345678];
signed main() {
	int k, n, a, mae = 0, ma = 0, ans = 0; cin >> k >> n;
	for (int h = 1; h <= n; h++) {
		cin >> a; cnt[h - 1] = a - mae;
		mae = a;
	}
	cnt[0] += k - a;
	for (int h = 0; h < n; h++) {
		ma = max(ma, cnt[h]); ans += cnt[h];
	}
	cout << ans - ma << endl;
	return 0;
}

Measured memory_bytes: 1792
N, W = list(map(int, input().split()))
WV = [list(map(int, input().split())) for _ in range(N)]

dp = [[0]*(W+1) for _ in range(N+1)]
for n in range(1, N+1):
    for w in range(1, W+1):
        if w-WV[n-1][0]>=0:
            dp[n][w] = max(dp[n-1][w], dp[n-1][w-WV[n-1][0]]+WV[n-1][1])
        else:
            dp[n][w] = dp[n-1][w]
print(dp[-1][-1])

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

typedef long long ll;
const int N = 1e5 + 77;
const int mod = (int)1e9 + 7;

int main()
{
  int n, m, x, y;
  bool possible = false;
  scanf("%d%d", &x, &y);
  for (int i = 0; i <= x; i++)
  {
    for (int j = 0; j <= x; j++)
    {
      if (i + j == x)
        possible |= i * 2 + j * 4 == y;
    }
  }
  if (possible)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}

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

int main(){
  string s;
  int i, n, count = 0;
  cin >> n >> s;
  for(i=2; i<n; i++){
    if(s[i] == 'C' && s[i-1] == 'B' && s[i-2] == 'A') count++;
  }
  cout << count;
	return 0;
}

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

int main() {
  int N, A;
  cin >> N >> A;

  if ( N%500 <= A ) {
    cout << "Yes" << endl;
  }
  // ここにプログラムを追記
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int a, b;
  scanf("%d %d", &a, &b);

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

  printf("%d %d %f\n", d, r, f);
  
  return 0;
}



Measured memory_bytes: 1968
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef  long long ll;
struct UnionFind
{
    vector<int> par;
   
    UnionFind(int n) : par(n,-1){}
    void init(int n) { par.assign(n,-1);}
 
    int root(int x){
        if(par[x]<0) return x;
        return par[x]=root(par[x]);
    }
 
    bool issame(int x, int y){
        return root(x)==root(y);
    }
    bool merge(int x, int y){
        x=root(x);
        y=root(y);
        if(x==y) return false;
        if(par[x]>par[y])swap(x,y);
        par[x]+=par[y];
        par[y]=x; //大きさが正になるよ
        return true;
    }
    int size(int x){
        return -par[root(x)];
    }
};
int main(){
    ll N,M;
    ll A[100010];
    ll B[100010];
    cin>>N>>M;
    for(int i=0;i<M;i++){
        cin>>A[i]>>B[i];
        A[i]--;
        B[i]--;
    }
   vector<long long> ans(M);
	ans[M - 1] = (long long)N * (N - 1) / 2;
 
	UnionFind Uni(N);
 
	for (int i = M - 1; i >= 1; i--)
	{
		ans[i - 1] = ans[i];
 
		if (Uni.issame(A[i],B[i])) continue;
			ans[i - 1] -= (long long)Uni.size(A[i]) * Uni.size(B[i]);
			Uni.merge(A[i], B[i]);
		}
	
 
	for (int i = 0; i < M; i++)
	{
		cout << ans[i] << endl;
	}
}

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

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

int main() {
    string s; cin >> s;
    vector<char> ans;
    rep(i, s.size()) {
        char x = s.at(i);
        if (x == '0' || x == '1') {
            ans.push_back(x);
        } else if (x == 'B' && ans.size() > 0) {
            ans.pop_back();
        }
    }
    rep(i, ans.size()) cout << ans.at(i);
    cout << endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int const nmax = 1e5;
vector <int> v[1 + nmax];

queue <int> que;

int from[1 + nmax];

int main() {

  int n, a, b, m;
  cin >> n >> m;
  for(int i = 1;i <= m;i++){
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  //computeFrom();
  from[1] = 1;
  que.push(1);
  while(!que.empty()){
    int nod = que.front();
    que.pop();
    for(int i = 0;i < v[nod].size();i++){
      if(from[v[nod][i]] == 0){
        from[v[nod][i]] = nod;
        que.push(v[nod][i]);
      }
    }
  }
  from[1] = 0;
  for(int i = 2;i <= n;i++){
    if(from[i] == 0){
      cout << "No";
      return 0;
    }
  }
  cout << "Yes\n";
  for(int i = 2;i <= n;i++){
    cout << from[i] << '\n';
  }
  return 0;
}


Measured memory_bytes: 10520
import java.util.Scanner;
class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        Dice dice=new Dice(scan.nextInt(),scan.nextInt(),scan.nextInt(),scan.nextInt(),scan.nextInt(),scan.nextInt());
        int a=scan.nextInt();
        for(int i=0;i<a;i++) {
        	int b=scan.nextInt();
        	int c=scan.nextInt();
        	
	        int ans=dice.ans(b,c);
	        System.out.println(ans);
	    }
}
}

class Dice{
	int Top;	//1
	int S;		//2
	int N;		//5
	int W;		//4
	int E;		//3
	int Bo;		//6
	int tmp;
	
	Dice(int a,int b,int c,int d,int e,int f){
		Top=a;
		S=b;
		N=e;
		W=d;
		E=c;
		Bo=f;
	}
	
	void TrunS() {
		tmp=Top;
		Top=N;
		N=Bo;
		Bo=S;
		S=tmp;
	}void TrunN() {
		tmp=Top;
		Top=S;
		S=Bo;
		Bo=N;
		N=tmp;
	}void TrunW() {
		tmp=Top;
		Top=E;
		E=Bo;
		Bo=W;
		W=tmp;
	}void TrunE() {
		tmp=Top;
		Top=W;
		W=Bo;
		Bo=E;
		E=tmp;
	}
	int ans(int a,int b) {
		int x=0;
		if(a==W) {
			TrunE();
		}else if(a==N) {
			TrunS();
		}else if(a==E) {
			TrunW();
		}else if(a==S) {
			TrunN();
		}else if(a==Bo) {
			TrunS();
			TrunS();
		}
		if(b==W) {
			x=S;
		}else if(b==E) {
			x=N;
		}else if(b==S) {
			x=E;
		}else if(b==N) {
			x=W;
		}
		return x;
	}
}


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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int N;
  cin >> N;
  vector< int > D(N);
  cin >> D;
  int64 ret = 0;
  for(int i = 0; i < N; i++) {
    for(int j = 0; j < i; j++) {
      ret += D[i] * D[j];
    }
  }
  cout << ret << endl;
}


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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

void solve() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << max(a * b, c * d) << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) solve();
}


Measured memory_bytes: 3616
def Donyoku(pattern):
    global w,k
    l=len(pattern)
    saisho=0
    now=[0]*l
    tasu=[0]*l
    for yoko in range(w):
        daijobu=True
        for i in range(l):
            hahen=pattern[i]
            tasu[i]=0
            for ha in hahen:
                tasu[i]+=ha[yoko]
            if(now[i]+tasu[i]>k):
                daijobu=False
            if(tasu[i]>k):
                return -1
        if(daijobu):
            for i in range(l):
                now[i]+=tasu[i]
        else:
            saisho+=1
            for i in range(l):
                now[i]=tasu[i]
        #print(now)
    return saisho
                
        


h,w,k=map(int,input().split())

choco=[]
for i in range(h):
    s=input()
    temp=[0]*w
    for j in range(w):
        temp[j]=int(s[j])
    choco.append(temp)


if(w==1):
    temp=[]
    for i in range(h):
        temp.append(choco[i][0])
    choco=[temp]
    w=h
    h=1

#print(choco)

ans=10**6
for i in range(2**(h-1)):
    wari=[]
    gen=0
    sude=0
    for j in range(h):
        if((i>>j) & 1):
            wari.append(choco[gen:j+1])
            gen=j+1
            sude+=1
    wari.append(choco[gen:h])
    #print(i,"番目の試行")
    #for wa in wari:
    #    print(wa)
    don=Donyoku(wari)
    ima=sude+don
    #print(ima)
    if(ima<ans and don!=-1):
        ans=ima

if(w==1 and h==1):
    print(0)
else:
    print(ans)

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

using namespace std;

#define int long long

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

#ifdef DBG
#define log(item) cout << #item << " " << item << endl
#define loga(array, val) cout << #array << "[" << val << "] " << array [ val ] << endl
#else
#define log(item)
#define loga(array, val)
#endif

typedef vector<int> VI;
typedef pair<int, int> PII;

int lcm(int a, int b){
    int r, x, tmp;
 
  x = a * b;
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return x/b;

}

//-------------------

int N;

vector<PII> tasks;

int comp(PII a, PII b){
    return a.second < b.second;
}

signed main(){
    cin >> N;

    rep(i, N){
        int a,b;
        cin >> a >> b;

        tasks.push_back({a, b});
    }

    sort(tasks.begin(), tasks.end(), comp);

    int current = 0;

    rep(i, N){
        PII t = tasks[i];
        current += t.first;
        if(current > t.second){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 6384
#include <stdio.h>
#include <iostream>
using namespace std;
int main(int argc, char const *argv[])
{
	int N;
	double y;
	int x=N%2;
	double z;
	cin >> N; 
	if(x==1){
		y=(N+3)/2;
	}
	else if (x==0){
		y=N/2;
	}
	z=(N-y)/N;
	printf("%f\n",z);
	return (0);
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>

using namespace std;

typedef long long ll;

ll N,M,Q;

vector<ll> L; vector<ll> R;
vector<ll> p; vector<ll> q;

vector<vector<ll>> sum;

void GetSumTable(vector<ll> L, vector<ll> R){
sum = vector<vector<ll>> ( N + 1, vector<ll> (N + 1,0));
  
  for(ll i = 0; i < (ll) L.size(); i++){
    sum[L[i]][R[i]]++;} //先に打刻しておく
         
  for(ll i = 1; i <= N; i++){
    for(ll j = 1; j <= N; j++){
      sum[i][j] += sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1];}}
  //累積和作成
 }

ll counts(ll p, ll q){
  
  return sum[q][q] - sum[p-1][q] - sum [q][ p - 1] + sum[p-1][p-1];}

      
      
      
  

int main(){ cin >> N >> M >>  Q;
  L.resize(M); R.resize(M); p.resize(Q); q.resize(Q);
           
     for(ll i = 0; i < M; i++){
       cin  >> L[i] >> R[i];}
     
     for(ll j = 0; j < Q; j++){
       cin >> p[j] >> q[j];}
           
     GetSumTable(L,R);
           
    for(ll k = 0; k < Q; k++){
      cout << counts(p[k],q[k]) << endl;}
           return 0;}
  

Measured memory_bytes: 9984
#include <bits/stdc++.h>
// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> PII;

#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for (int i=(a); i<(b); ++i)
#define FORD(i,a,b) for (int i=(a)-1; i>=(b); --i)

#define pb push_back
#define mp make_pair
#define st first
#define nd second

const int MOD = 1000000007;

LL SN[2100][2100];
LL SNpartial[2100][2100];

LL DP[2100][2100];

LL get(int R, int B) {
  if (R == 0 || B == 0) return 1;
  if (DP[R][B] > -1) return DP[R][B];

  LL if_blue = (SNpartial[B-1][B] - SNpartial[B-1][max(1,B-R)-1] + MOD) % MOD;
  LL if_red = get(R-1, B);

  DP[R][B] = (if_blue + if_red) % MOD;
  return DP[R][B];
}

int main() {
  // ios_base::sync_with_stdio(0);

  REP(i,2010) {
    SN[i][0] = SN[i][i] = 1;
    FOR(j,1,i) SN[i][j] = (SN[i-1][j-1] + SN[i-1][j]) % MOD;

    SNpartial[i][0] = 0;
    FOR(j,1,i+2) SNpartial[i][j] = (SNpartial[i][j-1] + SN[i][j-1]) % MOD;
  }

  REP(i,2100)REP(j,2100) DP[i][j] = -1;

  int R, B;
  scanf("%d%d", &R, &B);

  LL result = 0;
  REP(reds_in_beginning, R+1) {
    FOR(blue_from_t, max(1, B - (R - reds_in_beginning)), B+1) {
      result += SN[B-1][blue_from_t-1] * get(
        R - reds_in_beginning - (B - blue_from_t),
        B - blue_from_t
      ) % MOD;
      result %= MOD;
    }
  }

  printf("%d\n", (int)(result % MOD));
}


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

using namespace std;

long long n;

void process()
{
    long long x=100;
    int l=0;
    while (x<n)
    {
        x+=(x/100);
        l++;
    }
    cout<<l;
}

int main()
{
    cin>>n;
    process();
    return 0;
}


Measured memory_bytes: 3632
"""
author : halo2halo
date : 9, Jan, 2020
"""

import sys

# import numpy as np
import itertools

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

N, *W = map(int,read().split())
ans = sum(W)
for i in range(1, len(W)):
    ans = min(ans, abs(sum(W[:i]) - sum(W[i:])))
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#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 INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

struct GUIDEBOOK
{
	string city;
	int score;
	int num;
};

int main()
{
	int N;
	cin >> N;
	vector<GUIDEBOOK> G(N);
	REP(i, N){
		cin >> G[i].city >> G[i].score;
		G[i].num = i + 1;
	}

	sort(G.begin(),G.end(),
     [](const GUIDEBOOK &a, const GUIDEBOOK &b){
     	return (a.city == b.city) ? (a.score > b.score) : (a.city < b.city);}
    );

	REP(i, N) cout << G[i].num << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            //入力
            var a = Console.ReadLine();
            //var str = Console.ReadLine();
            //var strarr = str.Split(' ');
            //var b = strarr[0];
            //var c = strarr[1];
            //var s = Console.ReadLine();

            //var ans = a + int.Parse(b) + int.Parse(c);

            string str = "";
            foreach (char c in a)
            {
                if (c == '1')
                {
                    str += 9;
                }
                else if(c == '9') {
                    str += 1;
                
                }
            }

            Console.WriteLine("{0}", str);

        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
ll a[100005], b[100005], c[100005];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int A, B, m;
  cin >> A >> B >> m;
  for (int i = 1; i <= A; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= B; i++) {
    cin >> b[i];
  }
  ll ans = *(min_element(a + 1, a + 1 + A)) + *(min_element(b + 1, b + 1 + B));
  for (int i = 1; i <= m; i++) {
    ll x, y, c;
    cin >> x >> y >> c;
    ans = min(ans, a[x] + b[y] - c);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000

int R,C;

int get(int x,int y){
	if(x==0)return y;
	if(y==C)return C+x;
	if(x==R)return R+C+(C-y);
	return C+R+C+(R-x);
}

int main(){
	
	int N;
	cin>>R>>C>>N;
	
	vector<pair<int,int>> P;
	
	for(int i=0;i<N;i++){
		int x1,x2,y1,y2;
		cin>>x1>>y1>>x2>>y2;
		
		if(x1!=0&&x1!=R&&y1!=0&&y1!=C)continue;
		if(x2!=0&&x2!=R&&y2!=0&&y2!=C)continue;
		
		P.emplace_back(get(x1,y1),i);
		P.emplace_back(get(x2,y2),i);
	}
	
	sort(P.begin(),P.end());
	vector<int> A(0);
	for(int i=0;i<P.size();i++){
		if(A.size()==0||A.back()!=P[i].second){
			A.push_back(P[i].second);
		}
		else{
			A.pop_back();
		}
	}
	
	if(A.size()==0)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	
    return 0;
}



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

int main(){
  int x,y;
  cin>>x>>y;
  rep(i,x+1)rep(j,x+1-i){
    if(y==i*2+j*4 && i+j==x){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
int main(){
	int n;
	cin>>n;
	vector<long long> a(n);
	for(int i=0;i<n;i++)cin>>a[i];
	long long sum=0;
	for(int i=1;i<n;i++){
		sum+=a[i];
		sum%=mod;
	}
	long long ans=0;
	for(int i=0;i<n-1;i++){
		long long temp=a[i]*sum;
		temp%=mod;
		ans+=temp;
		ans%=mod;
		sum=((sum%mod)-(a[i+1]%mod)+mod)%mod;
	}
	cout<<ans<<'\n';
}

Measured memory_bytes: 4820
/* 実行時間1s制限の場合10^6 1,000,000 : 余裕をもって間に合う10^7
  10,000,000 : おそらく間に合う10^8 100,000,000 : 非常にシンプルな処理
  でないと厳しい
 */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#include <bits/stdc++.h>
#define M_PI 3.14159265358979323846
using namespace std;

typedef long long ll; // long longはデータモデル(LLP64, LP64, ...)によらず64bit.
ll gcd(ll a, ll b) {return b ? gcd(b, a%b) : a;}  // Greatest Common Divisor ユークリッドの互除法（aが長辺）
vector<pair<ll,int>> factorize(ll n) {            // a,bの公約数 = GCD(a, b)の約数
    vector<pair<ll,int>> res;
    for (ll i = 2; i*i <= n; i++) { // √nまで探せばよい
        if (n%i) continue;
        res.emplace_back(i, 0);     // 割り切れたら
        while (n%i == 0) {
            n /= i;
            res.back().second++;
        }
    }
    if (n != 1) res.emplace_back(n, 1); // この時点で1でなかったら、残りは素数.
    return res;
}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}         // Least Commont Multiple オーバーフローしないように先に割る
ll ceil(ll a, ll b) {return (a+b-1)/b;}

const ll INF = LONG_MAX;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(int argc, char* argv[])
{
#ifdef LOCAL
    // 以降 cin の入力元が 'xxx.txt' になる
    // std::ifstream in(argv[1]);
    //std::cin.rdbuf(in.rdbuf());
    //std::ifstream in(string(argv[0]) + ".txt");
    std::ifstream in("in.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    char a, b;
    cin >> a >> b;

    if(a<b) cout << '<';
    else if(a==b) cout << '=';
    else cout << '>';


    return 0;
}

/*
  - 1e9 : 10^9
  - container一般
    - 合計
      accumulate(a.begin(), a.end(), 0LL)  0LLはオーバーフロー用
  - vector
    vector<int> A(N, 0); // 0で初期化(省略可)
    vector<vector<int>> vec(n_rows, vector<int>(n_cols, value));  // 2次元配列初期化
    - loop
      for  (int i = 0; i < A.size(); i++) {}
      for  (int elem : A) {}
    - sort
      std::sort(v.begin(), v.end());  // 昇順
      std::sort(v.begin(), v.end(), std::greater<int>()); //降順
      - vector<vector<int>> cnt(h, vector<int>(w))
    - sort(struct)
        struct st_t {
            string name;
            int p;
            bool operator<(const st_t& another) const {
                if (name == another.name)
                {
                    return p > another.p;
                }
                return name < another.name;
            }
        };
        vector<st_t> st(n);
        sort(st.begin(), st.end());
  - pair
    - pairのソートの定義 : firstが優先的に比較。同じだったらsecond。
    - pair<pair<string,int>,int> p[110];
      std::sort(p,p+a);
        こうすると、first.first -> first.second -> secondの順にソートされる
    - sort
      - sort(a.begin(), cb.end(), greater<pair<int, int>>());
  - map
    - for (auto x : map) {}  // x.first:key  x.second:value.
  - priority_queue<int> q;
    - q.top()に最大値が入っている
  - string
    - loop
      for (char& c : s) {}
 */



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int Q;
  string S;
  cin >> N >> Q;
  cin >> S;
  vector<int> vec (2*Q);
  vector<int> num (N+1);
  int count = 0;
  for (int i = 0; i < 2*Q ; i++) {
    cin >> vec.at(i);
  }
  //for (int i = 0; i < 2*Q ; i++) {
    //cout << vec.at(i) << endl;
  //}
  
  //for (int i = 0; i < Q ; i++){
    for (int j = 0 ; j < N-1; j++){
      if(S.at(j)=='A'){
        if (S.at(j+1)=='C'){
          count++;
        }
      }
      num.at(j+1)=count;
    }
  //for (int i = 0; i < N ; i++) {
    //cout << num.at(i) << endl;
  //}
  
  for (int i = 0; i < Q ; i++) {
    cout <<num.at(vec.at(2*i+1)-1)-num.at(vec.at(2*i)-1)<<endl;
    
  }
    
    
}

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

int main(void) {
    char str[105];
    while(1){
        
        cin.getline(str, sizeof(str));

        if(str[0] == '.') break;
        stack<char> s;
        s.push('0');
        int flag = 1;
        for(int i = 0; str[i] != '\0'; i++){
            if(str[i] == '(') s.push(')');
            if(str[i] == '[') s.push(']');
            if(str[i] == ')'){
                if(s.top() == ')'){
                    s.pop();
                }else{
                    flag = 0;
                    break;
                }
            }

            if(str[i] == ']'){
                if(s.top() == ']'){
                    s.pop();
                }else{
                    flag = 0;
                    break;
                }
            }
        }
        
        if(flag == 1 && s.top() == '0') cout << "yes" << endl;
        else cout << "no" << endl;
    }
    return 0;

}

Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,num,cnt=0,t;
cin>>N;
vector<pair<int,int>>a(N);
for(int i=0;i<N;i++){
        num=i+1;
    while(num%2==0){
        num/=2;
        cnt++;
    }
if(num==1)cnt++;
a[i].first=cnt;
a[i].second=i+1;
cnt=0;
}
sort(a.begin(),a.end());
cout<<(a[N-1].second);
return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
typedef pair<string, string> pss;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  printf("%d\n", (100*(n-m) + 1900*m) << m);
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

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

	double v = a * a * b;

	double start = 0;
	double end = 90;
	double e = 1e-6;
	double angl;
	while (abs(start - end) > e) {
		angl = (start + end) / 2;
		double r = (angl * M_PI) / 180;

		double vx;
		if (x <= v / 2) {
			double r = (angl * M_PI) / 180;
			double d = b / tan(r);
			vx = (a * b * d) / 2;
		}
		else {
			double r = ((90 - angl) * M_PI) / 180;
			double d = a / tan(r);
			vx = (2 * b - d) / 2 * a * a;
		}


		if (vx == x) {
			break;
		}

		if (vx > x) {
			start = angl;
		}
		else {
			end = angl;
		}
	}

	cout << setprecision(10) << angl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, d;
  cin >> a >> b;
  c = a % 500;
  if (b >= c) {
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }
}

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

long long n,a,b,s[100010],now[100010];

bool check(long long val)
{
	for(long long i=1;i<=n;i++) now[i]=s[i]-val*b;
	long long num=0;
	for(long long i=1;i<=n;i++) if(now[i]>0) num+=now[i]%(a-b)==0?now[i]/(a-b):now[i]/(a-b)+1;
	return num<=val;
}

int main()
{
	cin>>n>>a>>b;
	for(long long i=1;i<=n;i++) scanf("%I64d",&s[i]);
	long long l=1,r=1000000010,ans=0;
	while(l<=r){
		long long mid=(l+r)/2;
		if(check(mid)) ans=mid,r=mid-1;
		else l=mid+1;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<vector>
#define MAX 101
#define INF 1000001
using namespace std;

int n, isSelected[MAX], dist[MAX];
vector<pair<int, int>> ver[MAX];

void initDijkstra(void);
void dijkstra(void);
bool doesFinished(void);

int main() {
	int i, j, id, k, v, c;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> id >> k;
		for (j = 0; j < k; j++) {
			cin >> v >> c;
			ver[id].push_back(make_pair(v, c));
		}
	}

	initDijkstra();

	while (!doesFinished())dijkstra();

	for (i = 0; i < n; i++) {
		cout << i << " " << dist[i] << endl;
	}

	return 0;
}

void initDijkstra(void) {

	dist[0] = 0;
	isSelected[0] = 1;
	for (int i = 1; i < n; i++)dist[i] = INF;

	vector<pair<int, int>>::iterator itv;

	for (itv = ver[0].begin(); itv != ver[0].end(); itv++) {
		dist[itv->first] = itv->second;
	}

}

void dijkstra(void) {
	int i, minu = -1, mindist = INF;
	vector<pair<int, int>>::iterator itv;

	for (i = 0; i < n; i++) {
		if (isSelected[i] == 0)continue;
		for (itv = ver[i].begin(); itv != ver[i].end(); itv++){
			if (isSelected[itv->first] == 1)continue;
			if (dist[itv->first] < mindist) {
				mindist = dist[itv->first];
				minu = itv->first;
			}
		}
	}
	isSelected[minu] = 1;
	//dist[minu] = dist[minp] + mindist;
	for (itv = ver[minu].begin(); itv != ver[minu].end(); itv++) {
		if (isSelected[itv->first] == 1)continue;
		dist[itv->first] = min(dist[minu] + itv->second, dist[itv->first]);
	}
}

bool doesFinished(void) {
	for (int i = 0; i < n; i++) {
		if (isSelected[i] == 0)return false;
	}
	return true;
}

Measured memory_bytes: 3112
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
    public static void Main()
    {
        var n = ReadLine().Split(' ');
        var a = long.Parse(n[0]);
        var b = decimal.Parse(n[1]);
        if(a == 0 || b == 0)
        {
            WriteLine("0");
            return;
        }
        decimal result = Floor(a * b);
        WriteLine(result);
    }
}

Measured memory_bytes: 18148
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define deb(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
typedef long long int ll;
typedef string str;

ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;     
  
    x = x % p;   
    while (y) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;  
        x = (x*x) % p; 
    } 
    return res; 
} 
 
ll nCrModP(ll n, ll r, ll p) 
{ 
    if (!r) 
      return 1; 
  
	ll fac[n+1]; 
   	fac[0] = 1; 
    for (ll i=1 ; i<=n; i++) 
        fac[i] = fac[i-1]*i%p; 
  
    return (fac[n]* power(fac[r], p-2,p) % p * power(fac[n-r], p-2,p) % p) % p; 
}

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

void fast(){
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int main ()
{
	// ios::sync_with_stdio(0);
 //    cin.tie(0);
 //    cout.tie(0);
	ll t,n,m,k,i,j,x,y;
	str s,st;
	cin >> n >> m >> k;
	vector <ll> a,b;
	cin >> x;
	a.pb(x);
	for(i=1;i<n;i++)
	{
		cin >> x;
		a.pb(a[i-1]+x);
	}
	cin >> y;
	b.pb(y);
	for(i=1;i<m;i++)
	{
		cin >> y;
		b.pb(b[i-1]+y);
	}
	t=0;
	for(i=0;i<n && k-a[i]>=0;i++)
	{ 
		// cout << "hi]]\n";
		if(k-a[i]>=b[0])
		{
			auto it=lower_bound(b.begin(),b.end(),k-a[i]);
			x=it-b.begin();
			if(it!=b.end() && k-a[i]==b[x])
			{
				t=max(t,i+x+2);
			}
			else if(it!=b.end())
			{
				t=max(t,i+x+1);
			}
			else if(it==b.end())
			{
				t=max(t,i+1+m);
			}
		}
		else
		{
			t=max(t,i+1);
		}
	}
	for(i=0;i<m && k-b[i]>=0;i++)
	{ 
		 // cout << a[0] << "\n";
		if(k-b[i]>=a[0])
		{
			auto it=lower_bound(a.begin(),a.end(),k-b[i]);
			x=it-a.begin();
			if(it!=a.end() && k-b[i]==a[x])
			{
				t=max(t,i+x+2);
			}
			else if(it!=a.end())
			{
				t=max(t,i+x+1);
			}
			else if(it==a.end())
			{
				t=max(t,i+1+n);
			}
		}
		else
		{
			t=max(t,i+1);
		}
	}
	cout << t << "\n";
	return 0;
}

Measured memory_bytes: 7904
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
const int MAX_N=1e5;

int N,a[MAX_N];

int b[MAX_N],sm[MAX_N+1];
ll bit[MAX_N+2];
void init(){
	memset(bit,0,sizeof(bit));
}

int que(int x){
	int ret=0;
	while(x){
		ret+=bit[x];
		x-=x&(-x);
	}
	return ret;
}

void add(int x,int y){
	while(x<=N+1){
		bit[x]+=y;
		x+=x&(-x);
	}
}

ll C(int x){
	REP(i,N){
		if (a[i]<x){
			b[i]=1;
		}else{
			b[i]=-1;
		}
	}
	int mn=0;
	sm[0]=0;
	REP(i,N){
		sm[i+1]=sm[i]+b[i];
		mn=min(mn,sm[i+1]);
	}
	REP(i,N+1){
		sm[i]+=-mn+1;
	}
	init();
	ll ret=0;
	REP(i,N+1){
		ret+=que(sm[i]-1);
		add(sm[i],1);
	}
	return ret;
}
int main(){
	cin>>N;
	REP(i,N){
		cin>>a[i];
	}
	{
		vector<int> vec(N);
		REP(i,N){
			vec[i]=a[i];
		}
		sort(vec.begin(),vec.end());
		int lb=0,ub=N;
		while(ub-lb>1){
			int mid=(lb+ub)>>1;
			if (C(vec[mid])<=(ll)N*(N+1)/4){
				lb=mid;
			}else{
				ub=mid;
			}
		}
		cout<<vec[lb]<<endl;
	}
	return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>

int main(){
	int i, N, tmp, cnt;
	char c1, c2;

	scanf("%d%*c", &N);

	for(i = 0;i < N;i++){
		cnt = 0;
		while(1){
			c1 = getc(stdin);
			if(c1 == '\n')
				break;
			c2 = getc(stdin);
			if(c2 == '\n')
				break;
			
			tmp = (c1 + c2) - (2 * '0');
			if(tmp > 9){
				tmp %= 10;
				ungetc((char)(tmp + '0'), stdin);
				ungetc('1', stdin);
			}else{
				ungetc((char)(tmp + '0'), stdin);
			}
			cnt++;
		}
		printf("%s\n",(cnt % 2) ? "Fabre wins." : "Audrey wins.");
	}
	return 0;
}

Measured memory_bytes: 588
let i_inp : unit -> int = fun () ->
  int_of_string (input_line stdin)

let i_inp_list : unit -> int list = fun () ->
  let inp_split = Str.split (Str.regexp " ") (input_line stdin) in
  List.map (fun x -> int_of_string x) (inp_split)
  
let () =
  let _ = i_inp () in
  let l = i_inp_list () in
  let rec loop l =
    match l with
      [] -> 0
    | p1 :: [] -> 0
    | p1 :: p2 :: [] -> 0
    | p1 :: p2 :: p3 :: l' ->
       if not ((p2 < p1 && p2 < p3) || (p1 < p2 && p3 < p2)) then
         1 + loop (p2 :: p3 :: l')
       else
         loop (p2 :: p3 :: l')
  in
  let n = loop l in
  print_int n;
  print_newline ()
    


Measured memory_bytes: 384
#include <stdio.h>

int main(void) {
	
	int a,b;
	scanf("%d %d",&a,&b);
	
	if((a - b) == 0){
		printf("a == b\n");
	}else if(a - b > 0){
		printf("a > b\n");
	}else{
		printf("a < b\n");
	}
	
	return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allg(v) v.begin(), v.end(), greater<int>()



signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, m;
  cin >> n >> m;
  
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(m);
  vector<int> d(m);
  rep(i, 0, n) cin >> a[i] >> b[i];
  rep(i, 0, m) cin >> c[i] >> d[i];
 
  rep(i, 0, n) {
    int mini = 1e9+7, ans = m;
    for(int j = m-1; j >= 0; j--) {
      int dis = abs(a[i]-c[j]) + abs(b[i]-d[j]);
      if(dis <= mini) {
        mini = dis;
        ans = j+1;
      }
    }
    cout << ans << "\n";
  }
  
}

Measured memory_bytes: 256
#pragma optimize("O3")
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

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

int main(void) {
	int num, i, a = 0, b = 0;
	string s, k = "keyence";
	cin >> s;
	rep(i, 7) {
		if (s[i] != k[i])
			break;
		a++;
	}
	rep(i, 7) {
		if (s[s.size() - 1 - i] != k[6 - i])
			break;
		b++;
	}
	if (a + b >= 7)
		printf("YES\n");
	else
		printf("NO\n");
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)

const ll MOD = (ll)1e9 + 7;
const ll HIGHINF = (ll)1e18;

struct Node {
  int key;
  Node *prev, *next;
};

Node *nil;

Node* listSearch(int key) {
  Node *cur = nil->next;
  while (cur != nil && cur->key != key) cur = cur->next;
  return cur;
}

void init() {
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void printList() {
  Node *cur = nil->next;
  int isf = 0;
  while (1) {
    if (cur==nil) break;
    if (isf++ > 0) printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
  }
  printf("\n");
}

void deleteNode(Node *t) {
  if (t == nil) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst() {
  deleteNode(nil->next);
}

void deleteLast() {
  deleteNode(nil->prev);
}

void deleteKey(int key) {
  deleteNode(listSearch(key));
}

void insert(int key) {
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main() {
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for (i=0; i<n; i++) {
    scanf("%s%d", com, &key);
    if (com[0] == 'i') {insert(key); np++; size++;}
    else if (com[0] == 'd') {
      if (strlen(com) > 6) {
        if (com[6] == 'F') deleteFirst();
        else if (com[6] == 'L') deleteLast();
      } else {
        deleteKey(key); nd++;
      }
      size--;
    }
  }
  printList();
  return 0;
}



Measured memory_bytes: 34412
#include <bits/stdc++.h>
using namespace std;
typedef bool boolean;

#define ll long long

void exgcd(int a, int b, int& x, int& y) {
	if (!b) {
		x = 1, y = 0;
	} else {
		exgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
}

int inv(int a, int n) {
	int x, y;
	exgcd(a, n, x, y);
	return (x < 0) ? (x + n) : (x);
}

const int Mod = 1e9 + 7;

template <const int Mod = :: Mod>
class Z {
	public:
		int v;

		Z() : v(0) {	}
		Z(int x) : v(x){	}
		Z(ll x) : v(x % Mod) {	}

		friend Z operator + (const Z& a, const Z& b) {
			int x;
			return Z(((x = a.v + b.v) >= Mod) ? (x - Mod) : (x));
		}
		friend Z operator - (const Z& a, const Z& b) {
			int x;
			return Z(((x = a.v - b.v) < 0) ? (x + Mod) : (x));
		}
		friend Z operator * (const Z& a, const Z& b) {
			return Z(a.v * 1ll * b.v);
		}
		friend Z operator ~(const Z& a) {
			return inv(a.v, Mod);
		}
		friend Z operator - (const Z& a) {
			return Z(0) - a;
		}
		Z& operator += (Z b) {
			return *this = *this + b;
		}
		Z& operator -= (Z b) {
			return *this = *this - b;
		}
		Z& operator *= (Z b) {
			return *this = *this * b;
		}
		friend boolean operator == (const Z& a, const Z& b) {
			return a.v == b.v;
		} 
};

Z<> qpow(Z<> a, int p) {
	Z<> rt = Z<>(1), pa = a;
	for ( ; p; p >>= 1, pa = pa * pa) {
		if (p & 1) {
			rt = rt * pa;
		}
	}
	return rt;
}

typedef Z<> Zi;

const int N = 44, Smx = 1 << 18;

#define Z qaq

int n, X, Y, Z; 
Zi f[2][Smx + 1];

int main() {
	scanf("%d%d%d%d", &n, &X, &Y, &Z);
	int cur = 0, S = (1 << (X + Y + Z));
	f[cur][0] = 1;
	Y += Z, X += Y;
	int finmsk = (1 << (X - 1)) | (1 << (Y - 1)) | (1 << (Z - 1));
	for (int i = 0; i < n; i++) {
		memset(f[cur ^= 1], 0, sizeof(f[0]));
		for (int s = 0; s < S; s++) {
			Zi v = f[cur ^ 1][s];
			if (!v.v)
				continue;
			for (int c = 0; c < 10; c++) {
				int ns = ((s << (c + 1)) | (1 << c)) & (S - 1);
				if ((ns & finmsk) == finmsk) {
					ns = S;
				}
				f[cur][ns] += v;
			}
		}
		f[cur][S] += f[cur ^ 1][S] * 10;
	}
	printf("%d", f[cur][S].v);
	return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (ll i = 0; i < n; i++)
#define IREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define REPEACH(i,k) for(auto& i:k)
#define FOR(a, b) for (ll i = a; i < b + 1; i++)
#define MOD 1000000007
using namespace std;
typedef long long ll;

signed main(){
  long double a,b,x;
  cin >> a >> b >> x;
  /*  x/=a;
  x*=2;
  x/=a;
  x-=b;
  x=b-x;*/
  if ((x * 2 / a) / a<=b){
    x=((x/a)*2)/b;
    long double ans=atan(b/x);
    ans = 180.0 * ans / (atan(1.0) * 4.0);
    cout << fixed << setprecision(10) << ans << endl;
  }
  else{
    x = b - ((x * 2 / a) / a - b);
    long double ans = atan(x / a);
    ans = 180.0 * ans / (atan(1.0) * 4.0);
    cout << fixed << setprecision(10) << ans << endl;
  }
}

Measured memory_bytes: 256