akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int n, m, a, b;
char s[1002][1002];
void init() {
    for (int i = 1; i <= n; i ++) {
        for (int j = 1; j <= m; j ++) {
            s[i][j] = '.';
        }
    }
    if (n%2 == 1) {
        for (int col = 1; a > 0 && col + 1 <= m; col += 2) {
            //printf("ok\n");
            s[n][col] = '<';
            s[n][col+1] = '>';
            a --;
        }

    }
    if (m%2 == 1) {
        for (int row = 1; b > 0 && row + 1 <= n; row += 2) {
            s[row][m] = '^';
            s[row+1][m] = 'v';
            b --;
        }
    }
}
void prt() {
    for (int i = 1; i <= n; i ++) {
        for (int j = 1; j <= m; j ++) {
            printf("%c", s[i][j]);
        }
        printf("\n");
    }
}
void square() {
    for (int i = 1; i+1 <= n; i += 2) {
        for (int j = 1; j+1 <= m; j += 2) {
            if (a >= 2) {
                s[i+0][j+0] = '<'; s[i+0][j+1] = '>';
                s[i+1][j+0] = '<'; s[i+1][j+1] = '>';
                a -= 2;
            } else if (b >= 2) {
                s[i+0][j+0] = '^'; s[i+0][j+1] = '^';
                s[i+1][j+0] = 'v'; s[i+1][j+1] = 'v';
                b -= 2;               
            } else if (a == 1 &&  b == 1 && i+3 > n && j+3 > m && i+2 <= n && j+2 <= m) {
                s[i+0][j+0] = '<', s[i+0][j+1] = '>', s[i+0][j+2] = '^';
                s[i+1][j+0] = '^', s[i+1][j+1] = '.', s[i+1][j+2] = 'v';
                s[i+2][j+0] = 'v', s[i+2][j+1] = '<', s[i+2][j+2] = '>';
                a = b = 0;
            }  else if (a >= 1) {
                s[i+0][j+0] = '<'; s[i+0][j+1] = '>';
                a --;                
            } else if (b >= 1) {
                s[i+0][j+0] = '^'; s[i+1][j+0] = 'v';
                b --;
            } 
        }
    }
    if (a == 0 && b == 0) {
        printf("YES\n");
        prt();
    }  else {
        printf("NO\n");
    }
}
int main() {
    cin >> n >> m >> a >> b;
    init();
    square();
}

Measured memory_bytes: 2176
x,n = map(int,input().split())
if n>0:
    p = list(map(int,input().split()))

    tmp = -100
    diff = 10000000
    for i in range(0,102):
        if abs(x-i)<diff and i not in p:
            tmp = i
            diff = abs(x-i)
            
    print(tmp)
else:
    print(x)

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

int main() {
  int n, k, ans = 0;
  cin >> n >> k;
  vector<int> a(n);
  for(int i =0;i < n;i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  for(int i = 0;i < k;i++){
    ans += a[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using namespace std;

int main(){
  ll n,k;cin>>n>>k;
  int a,b;
  map<int,ll> mp;
  for(int i=1;i<=n;i++){
    cin>>a>>b;
    mp[a]+=b;
  }
  for(auto p : mp){
    auto x=p.first;
    auto y=p.second;
    k-=y;
    if(k<1){
      cout<<x;
      return 0;
    }
  }
}

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

int main() {
    int64_t A,B,C,K;
    cin >> A >> B >> C >> K;

    if(K <= A+B){
        if(K < A){
            cout << K << endl;
        }else{
            cout << A << endl;
        }
    }else{
        cout << 2*A+B-K << endl;
    }
}


Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1000000007LL;
int pos[200000];
int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		int P;
		cin >> P;
		pos[P - 1] = i;
	}
	int ans = 0;
	int len = 1;
	for (int i = 1; i < N; i++) {
		if (pos[i - 1] < pos[i]) len++;
		else ans = max(ans, len), len = 1;
	}
	ans = max(ans, len);
	cout << N - ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    map<int,int> mp;
    for(int i = 0; i < N; i++) mp[A[i]]++;
    int ans = 0;
    for(auto p : mp){
        if(p.second%2 == 1) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 5376
#include<iostream>
#include<vector>
#include <queue>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
ll powf(ll k) {
    return k * k * k * k * k;
}
int main() {
    ll x;
    cin >> x;
    int a, b;
    for (ll i = 0; i <= 200; i++) {
        ll five = powf(i);
        for (ll j = -75; j <= 200; j++) {
            ll fiveb = powf(j);
            if (five - fiveb == x) {
                a = i;
                b = j;
                goto LAST;
            }
        }
    }
LAST:
    cout << a << " " << b << endl;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n,k;
  cin>>n>>k;
  int w[n];
  for(int i=0;i<n;i++) cin>>w[i];
  int sum=0;
  for(int i=0;i<n;i++) sum+=w[i];
  int l=0,r=sum;
  while(l+1<r){
    int m=(l+r)/2;
    int t=0,tmp=0;
    bool f=0;
    for(int i=0;i<n;i++){
      f|=w[i]>m;
      if(tmp+w[i]>m){
	tmp=w[i];
	t++;
      }else tmp+=w[i];
    }
    if(tmp) t++;
    if(!f&&t<=k) r=m;
    else l=m;
  }
  cout<<r<<endl;
  return 0;
}

Measured memory_bytes: 3872
import sys
input = sys.stdin.readline
#import heapq
#from fractions import gcd
#from collections import defaultdict
#sys.setrecursionlimit(10**9)
#map(int,input().split())

def main():
    h,w=map(int,input().split())
    A=[]
    ans=[]
    n=0
    for i in range(h):
        a=list(map(int,input().split()))
        if i%2==0:
            for j in range(w):
                A.append([i+1,j+1,a[j]])
        else:
            for j in reversed(range(w)):
                A.append([i+1,j+1,a[j]])
    for i in range(h*w-1):
        if A[i][2]%2==1:
            ans.append([A[i][0],A[i][1],A[i+1][0],A[i+1][1]])
            A[i+1][2]+=1
            n+=1
    print(n)
    for l in ans:
        print(*l)

if __name__ == '__main__':
    main()

Measured memory_bytes: 101856
/**
 *   author: bholuakku
**/

#include <bits/stdc++.h>
#define For(i,a,b) for(i=(a); i<(b); i++)
#define rep(i,n) for(i=0; i<(n); i++)
#define Nfor(i,a,b) for(i=(a)-1; i>=(b); i--)
#define dep(i,n) for(i=(n-1);i>=0; i--)
#define mp make_pair
#define pb push_back
#define Auto(a) for(auto &val : a)
#define X first
#define Y second
#define MOD 1000000007
#define MOD1 998244353
#define iterate(A, i) for(auto i = A.begin(); i!=A.end(); i++)
#define mset(A,val,n) memset(A, val, n*sizeof(int))
#define Endl cout<<"\n"
#define Test cout<<"Hello\n"

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<bool> vb;
typedef vector<vector<bool> > vvb;
typedef pair<int, int> pii;
typedef vector<vector<pair<int, int> > > vvp;

int power(ll x, ll y, ll p) { ll res = 1; x = x % p; while (y>0){ if (y & 1) res = (res*x) % p; y = y>>1; x = (x*x)%p;} return res;}
int modInverse(ll n) {ll p = MOD;return power(n, p-2, p);}
int min(int a, int b, int c) { return min(a, min(b, c)); }
int max(int a, int b, int c) { return max(a, max(b, c)); }
inline void swap(int &a, int &b) { int t = a; a = b; b = t;}
bool cmp(int a, int b){return a>b;}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N, K, i, j;
    cin>>N>>K;
    vl A(N), dp(N); Auto(A) cin>>val;
    dp[0] = 0;
    rep(i, N){
        if(i==0) continue;
        dp[i] = LLONG_MAX;
        rep(j, K){
            j++;
            if(i-j>=0){
                dp[i] = min(dp[i], dp[i-j]+abs(A[i] - A[i-j]));
            }
            j--;
        }
    }
    cout<<dp[N-1];
    return 0;
}


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

using namespace std;

#define int long long
#define FR first
#define SC second
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, f, n) for(int i = (int)(f); i < (int)(n); i++)
#define each(a, b) for(auto& a : b)

typedef pair<int, int> P;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

#define MAX_N 1000000
bool is_prime[MAX_N+1];
int phi[MAX_N+1];
void euler_phi()
{
  for(int i = 0; i <= MAX_N; i++) {
    is_prime[i] = true;
    phi[i] = i;
  }
  for(int i = 2; i <= MAX_N; i++) {
    if(is_prime[i]) {
      phi[i] -= phi[i] / i;
      for(int j = i+i; j <= MAX_N; j+=i) {
	is_prime[j] = false;
	phi[j] -= phi[j] / i;
      }
    }
  }
}

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  euler_phi();

  int farey[MAX_N+1];
  farey[1] = 2;
  for(int i = 2; i <= MAX_N; i++) farey[i] = farey[i-1] + phi[i];

  int t; cin >> t;
  while(t--) {
    int n; cin >> n;
    cout << farey[n] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 19612
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define all(a) (a).begin(), (a).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int MOD = 1e9+7;
const ll LINF = 1e18;
const int INF = 1e9;
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;

int main()
{
    cin >> S;
    C++;
    for (int i = 0; i < 3; i++)
    {
        if(S[i]=='R')
        {
            if(C)
            {
                B=0;
                C=0;
            }
            B++;
        }
        else
        {
            C++;
        }
    }
    cout<<B;
    
    return 0;
}

Measured memory_bytes: 3632
#include<cstdio>
#define MAXN 100010
int du[MAXN],n,m;
int main()
{
	int u,v;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&u,&v);
		du[v]++,du[u]++;
	}
	for(int i=1;i<=n;i++)
		if(du[i]%2)
		{
			printf("NO\n");
			return 0;
		}
	printf("YES\n");
}

Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

int mount[10];

int main(){
    rep(i,10){
        cin>>mount[i];
    }
    sort(mount,mount+10,greater<int>());
    rep(i,3){
        out(mount[i]);
    }
}



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

int main() {
	ll x;
	cin >> x;
	ll ans = (x / 11) * 2;
	x -= (x / 11) * 11;
	if (x >= 7)ans += 2;
	else if(x==0){}
	else ans++;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main (){
    int x, y; 
    for(int i=1; i<=10000; i++){
        cin >> x >> y;
        if(x>y) swap(x,y);
        if(x==0 && y==0) return 0;
        else cout << x << " " << y << endl;
    }
    return 0;
}


Measured memory_bytes: 3084
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int bit = 0;
        for(int i=0;i<N;i++){
            bit|=sc.nextInt();
        }
        System.out.println(Integer.numberOfTrailingZeros(bit));
    }
}

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

template <typename M>
class SegmentTree {
    using F = std::function< M(M, M) >;
private:
    int n;
    F func;
    M M_init;
    std::vector<M> t;
public:
    // constructor
    SegmentTree(int &n, F func, const M &M_init): n(n), func(func), M_init(M_init) { t.assign(2*n, M_init); }
    SegmentTree(std::vector<M> &vec, F func, const M &M_init): n(vec.size()), func(func), M_init(M_init) {
        t.assign(2*vec.size(), M_init);
        for(int i = 0; i < vec.size(); ++i) t[i+vec.size()] = vec[i];
    }
    // set value at position p
    void set(int &p, M value) { t[p+n] = value; }
    // build
    void build() {
        for(int i = n-1; i > 1; --i) t[i] = func(t[i<<1], t[i<<1|1]);
    }

    void modify(int p, M val) {  // update value at position p
        for(t[p += n] = val; p > 1; p >>= 1) t[p>>1] = func(t[p], t[p^1]);
    }
    M query(int l, int r) {  // reply to query [l, r)
        M resl = M_init, resr = M_init;
        for(l += n, r += n; l < r; l >>= 1, r >>= 1) {
            if(l & 1) resl = func(resl, t[l++]);
            if(r & 1) resr = func(t[--r], resr);
        }
        return func(resl, resr);
    }
    M operator[](int &k) const { return query(k, k+1); }
};

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

signed main(){
    using namespace std;

    int n; cin >> n;
    SegmentTree<int> a(n, [](int p, int q){ return (q ? GCD(q, p%q) : p);}, 0LL);
    for(int i = 0; i < n; ++i) {int p; cin >> p; a.set(i,p);}
    a.build();

    int ans = -1;
    for (int i = 0; i < n; ++i) {
        if(i == 0) ans = max(ans, a.query(1, n));
        else if(i == n-1) ans = max(ans, a.query(0, n-1));
        else ans = max(ans, GCD(a.query(0,i), a.query(i+1, n)));
    }
    cout << ans << '\n';
}

Measured memory_bytes: 1024
using System;

class EntryPoint
{
    static void Main()
    {
        int S = int.Parse(Console.ReadLine());
        Time t = new Time();
        t.Watch(S);
    }
}

class Time
{
    public void Watch(int S)
    {
        int h = S / 3600;
        int m = (S % 3600) / 60;
        int s = (S % 3600) % 60;
        Console.WriteLine("{0}:{1}:{2}", h, m, s);
    }
}

Measured memory_bytes: 9088
#include<iostream>
#include<vector>
#include<cmath>

using namespace std;


int main(){
    long N;
    cin>>N;
    vector<long> vec(N);
    for(int i = 0; i < N; i++)
    {
        int tmp;
        cin>>tmp;
        vec[tmp]++;
    }
    vec[0]++;
    for(int i=1-N%2;i<N;i+=2){
        if(vec[i]!=2){
            cout<<0<<endl;
            return 0;
        }

    }

    long long ans=1;

    long long wari=pow(10,9)+7;

    for(int i=0;i<N/2;++i){
        ans=ans*2%wari;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int gcd(int n,int m){
  if(n>m) return gcd(m,n);
  else if(n==0) return m;
  else return gcd(m-n*(m/n),n);
}
int main(){
  int a,b=0;
  cin>>a;
  for(;cin>>a;) b=gcd(a,b);
  cout<<b<<endl;
}

Measured memory_bytes: 256
function Main(input) {
  input = input.split("\n");
  var N = parseInt(input[0].split(" ")[0]);
  var H =Array(N);
  for(var i=0; i <N; i++) H[i] = parseInt(input[1].split(" ")[i]);

  var count=0;
  for(var i=0; i <N; i++){
    flag = true;
    for(var j=0; j < i; j++){
      if(H[i] < H[j]) flag =false;
    }
    if(flag == true) count++;
  }
  console.log(count);
  return;
}

var input=Main(require("fs").readFileSync("/dev/stdin", "utf8"));
// var input=`5
// 9 5 6 8 4`
// Main(input);


Measured memory_bytes: 7372
#include <bits/stdc++.h>   
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
string Yes[2] = {"Yes", "No"};
     
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
template <typename T>
T pow(T a, ll n, T e = 1) {
    T ret = e;
    while (n) {
        if (n & 1) ret *= a;
        a *= a;
        n >>= 1;
    }
    return ret;
}
 
template <int mod>
struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long x_) {
        if ((x = x_ % mod + mod) >= mod) x -= mod;
    }
    ModInt& operator+=(ModInt rhs) {
        if ((x += rhs.x) >= mod) x -= mod;
        return *this;
    }
    ModInt& operator-=(ModInt rhs) {
        if ((x -= rhs.x) < 0) x += mod;
        return *this;
    }
    ModInt& operator*=(ModInt rhs) {
        x = (unsigned long long)x * rhs.x % mod;
        return *this;
    }
    ModInt& operator/=(ModInt rhs) {
        x = (unsigned long long)x * rhs.inv().x % mod;
        return *this;
    }
 
    ModInt operator-() const { return -x < 0 ? mod - x : -x; }
    ModInt operator+(ModInt rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(ModInt rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(ModInt rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(ModInt rhs) const { return ModInt(*this) /= rhs; }
    bool operator==(ModInt rhs) const { return x == rhs.x; }
    bool operator!=(ModInt rhs) const { return x != rhs.x; }
    ModInt inv() const { return pow(*this, mod - 2); }
 
    friend ostream& operator<<(ostream& s, ModInt<mod> a) {
        s << a.x;
        return s;
    }
    friend istream& operator>>(istream& s, ModInt<mod>& a) {
        s >> a.x;
        return s;
    }
};

using mint = ModInt<1000000007>;
using Graph = vector<vector<int>>;
Graph G;

/*------------------------------------------------------------------*/
vector<int> score;

void dfs(const Graph &G, int v, int p){
    for(auto next_v : G[v]){
        if(next_v == p) continue;
        score[next_v] += score[v];
        dfs(G, next_v, v);
    }
}


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

    int n, q; cin >> n >> q;
    Graph G(n);
    rep(i, n - 1){
        int a, b; cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    score = vector<int>(n, 0);
    rep(i, q){
        int p, x; cin >> p >> x;
        p--;
        score[p] += x;
    }
    dfs(G, 0, -1);
    rep(i, n) cout << score[i] << " ";
    cout << endl;
}


Measured memory_bytes: 27480
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define pf push_front
#define ins insert

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

int ans=1,n;

main(){
	cin>>n;
	int a[n];
	rep(i,n){
		cin>>a[i];
		ans*=3;
	}
	int sub=1;
	rep(i,n){
		if(a[i]%2==0)sub*=2;
	}
	dump(ans-sub);
}

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

int main(){
    unsigned long N;
    cin >> N;
    vector<unsigned long> C(N), V(N), ans(N);
    for(auto& i : V)cin >> i;
    for(auto& i : C)cin >> i;
    transform(V.begin(), V.end(), C.begin(), ans.begin(), [](auto a, auto b){return max(a, b) - b;});
    cout << accumulate(ans.begin(), ans.end(), 0UL) << endl;
}

Measured memory_bytes: 256
#include<cstdio>

#define N 100006

using namespace std;

int a[N],b[N];

int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n+1;++i) scanf("%d",&a[i]);
	for(int i=1;i<=n;++i) scanf("%d",&b[i]);
	long long tot=0;
	for(int i=1;i<=n+1;++i) tot+=a[i];
	long long sum=0;
	for(int i=1;i<=n;++i)
	{
		if(b[i]>=a[i]) 
		{
			b[i]-=a[i];
			a[i]=0;
			if(b[i]>=a[i+1]) 
			{
				b[i]-=a[i+1];
				a[i+1]=0;
			}
			else 
			{
				a[i+1]-=b[i];
				b[i]=0;
			}
		}
		else
		{
			a[i]-=b[i];
			b[i]=0;
		}
	}	
	for(int i=1;i<=n+1;++i) sum+=a[i];
	printf("%lld",tot-sum);		
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define rep(i,n) for(int i=0;i<(n);i++)
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; }
typedef long long ll;
#define PI 3.14159265358979323846264338327950L
const int mod=1000000007,MAX=200005,INF=1<<30;

int main() {
  	string s,t;
  	cin>>s>>t;
  
  	int ans=10100000;
  
  	for(int i=0;i<=s.size()-t.size();i++){
    	int ch=0;
    	for(int j=0;j<t.size();j++){
        	if(s[i+j]!=t[j]){
            	ch++;
            }
          }
  	ans=min(ans,ch);
        }

    
  
  cout<<ans<<endl;

    }



Measured memory_bytes: 3616
def solve():
    N, A, B = map(int, input().split())
    X = A ^ B
    #print(X)
    x = X
    s = 0
    while x > 0:
        s += x % 2
        x //= 2
    #print(s)
    if s % 2 == 0:
        print("NO")
        return
    print("YES")
    g = []
    for i in range(2 ** N):
        g.append(i ^ (i >> 1))
    #print(g)
    i = 0
    while True:
        print(g[i] ^ A, end = " ")
        if i % 2 == 0:
            j = 2 ** N - 1 - i
        elif j < 2 ** (N - 1):
            j += 1
        else:
            j -= 1
        if g[j] == X:
            break
        i = j
    if i < 2 ** (N - 1):
        for k in range(i + 1, j + 1):
            print(g[k] ^ A, end = " ")
    else:
        for k in range(i - 1, j - 1, -1):
            print(g[k] ^ A, end = " ")
    return
        
solve()

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

const int nax=2e5+5;
ll a[nax];

int main()
{
    int n; cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    int idx=-1;
    ll s=0;
    for(int i=1;i<=n;i++) s+=a[i];
    ll akt=0;
    for(int i=1;i<=n;i++)
    {
        akt+=a[i];
        if(akt*2>=s)
        {
            idx=i; break;
        }
    }
    ll res=min(akt*2-s,(s-(akt-a[idx])*2));
    cout<<res;
    return 0;
}


Measured memory_bytes: 1792
import numpy as np
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

from numba import njit


def getInputs():
    D = int(readline())
    CS = np.array(read().split(), np.int32)
    C = CS[:26]
    S = CS[26:].reshape((-1, 26))
    return D, C, S


@njit('(i8, i4[:], i4[:, :], i4[:], )', cache=True)
def _compute_score1(D, C, S, out):
    score = 0
    last = np.zeros(26, np.int32)
    for d in range(D):
        i = out[d]
        score += S[d, i]
        last[i] = d + 1
        for i in range(26):
            score -= C[i] * (d + 1 - last[i])
    return last, score


def step1(D, C, S):
    out = np.zeros(D, np.int32)
    LAST = 0
    for d in range(D):
        max_score = -10000000
        best_i = 0
        
        for i in range(26):
            out[d] = i
            last, score = _compute_score1(D, C, S, out)
            if max_score < score:
                max_score = score
                LAST = last
                best_i = i

        out[d] = best_i

    return out, LAST, max_score


D, C, S = getInputs()
out, _, score = step1(D, C, S)
out += 1
print('\n'.join(out.astype(str).tolist()))

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

int main(void){
    ll k;
    cin >> k;
    ll x = 7;
    int cnt = 1;
    while(cnt <= 1000000 + 7){
        if(x % k == 0){
            cout << cnt << endl;
            return 0;
        }
        x = (x % k) * 10 + 7;
        ++cnt;
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3632
import java.io.BufferedInputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scan = new Scanner(new BufferedInputStream(System.in));
		List<String> output = new ArrayList<String>();
		while (scan.hasNext()) {
			String input = scan.nextLine();
			if ("0 0".equals(input)) {
				break;
			} else {
				String[] in = input.split(" ");
				int x = Integer.parseInt(in[0]);
				int y = Integer.parseInt(in[1]);
				if (x >= 0 && x <= 10000 && y >= 0 && y <= 10000) {
					if (x < y) {
						String inVal = String.valueOf(x) + " " + String.valueOf(y);
						output.add(inVal);
					} else if (x > y) {
						String inVal = String.valueOf(y) + " " + String.valueOf(x);
						output.add(inVal);
					} else {
						output.add(input);
					}
				}
			}
		}
		if (output.size() <= 3000) {
			for (String out : output) {
				System.out.println(out);
			}
		}
	}
}

Measured memory_bytes: 38140
// AOJ 0564: Bug Party
// 2018.1.27 bal4u

#include <stdio.h>
#include <stdlib.h>

typedef struct { int a, b; } T;
T tbl[300002];
long long sa[300002];
int n;

#define MAX 300002
int que[MAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void max_heapify(int i)
{
	int l, r, max;
	int qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l] > que[i]) max = l; else max = i;
	if (r < qsize && que[r] > que[max]) max = r;
	if (max != i) {
		qt = que[i], que[i] = que[max], que[max] = qt;
		max_heapify(max);
	}
}

int deq()
{
	int t;

//	if (qsize == 0) return 0;
	t = que[0];
	que[0] = que[--qsize];
	max_heapify(0);
	return t;
}

void enq(int t)
{
	int i, max;
	int qt;

	i = qsize++;
	que[i] = t;
	while (i > 0 && que[max = PARENT(i)] < que[i]) {
		qt = que[i]; que[i] = que[max], que[max] = qt;
		i = max;
	}
}

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int cmp(T *a, T *b) { if (b->b - a->b) return b->b - a->b; return a->a - b->a; }

int check(int k)
{
	int i;
	long long s;
	
	if (!k) return 1;
	qsize = 0;
	for (i = 0; i < k-1; i++) enq(tbl[i].a);
	s = sa[k-1];
	for ( ; i < n; i++) {
		if (s + tbl[i].a <= (long long)k*tbl[i].b) return 1;
		s += tbl[i].a, enq(tbl[i].a);
		s -= deq();
	}
	return 0;
}
	
int main()
{
	int i, lo, hi, m;
	
	n = in();
	for (i = 0; i < n; i++) tbl[i].a = in(), tbl[i].b = in();
	qsort(tbl, n, sizeof(T), cmp);
	for (i = 0; i < n; i++) sa[i+1] = sa[i] + tbl[i].a;

	lo = 0, hi = n+1;
	while (lo + 1 < hi) {
		m = (lo + hi) >> 1;
		if (check(m)) lo = m; else hi = m;
	}
	printf("%d\n", lo);
	return 0;
}



Measured memory_bytes: 7624
#include <iostream>
#include <stdio.h>
#include <string>
#include <map>
#include <stack>
#include <vector>
#include <string.h>
#include <set>
#include <queue>
#include <cmath>
#include <algorithm>

using namespace std;

bool check(vector<int> v)
{
	if (v.size() == 0 || v.size() == 1)
		return true;
	else
	{
		for (int i = 0;i < v.size() - 1;i ++)
		{
			if (v[i] > v[i + 1])
				return false;
		}
		return true;
	}
}

int input[20];

int main()
{
	int i , j , mask , n;
	while (scanf("%d" , &n) != EOF)
	{
		for (i = 0;i < n;i ++)
		{
			bool ok = false;

			for (j = 0;j < 10;j ++)
				scanf("%d" , &input[j]);

			for (mask = 0;mask < (1 << 10);mask ++)
			{
				vector<int> v1 , v2;
				for (j = 0;j < 10;j ++)
				{
					if (mask & (1 << j))
						v1.push_back(input[j]);
					else
						v2.push_back(input[j]);
				}
				if (check(v1) && check(v2))
				{
					ok = true;
					break;
				}
			}

			if (ok)
				printf("YES\n");
			else
				printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define REP(i, j, n) for (ll i = j; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
const ll INF = 1001001001001;

map<ll, ll> prime_factor(ll n)
{
    map<ll, ll> ret;
    for (ll i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}




int main()
{
    ll n;
    cin >> n;
    ll ans = INF;
   for (ll i=1;i*i<=n;++i){
       if(n%i!=0) continue;
       ll j = n/i;
       ans = min(ans,i+j-2);
   }
   cout<<ans<<endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
A=[]
B=[]
for i in range(M):
    a, b = map(int, input().split())
    if a == 1:
        A.append(b)
    if b == N:
        B.append(a)
if len(set(A) & set(B))>0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 21824
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/rope>

using namespace __gnu_pbds; 
using namespace __gnu_cxx;
using namespace std;
using ll = long long;

#define eb emplace_back
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define len(v) ((int)v.size())
#define all(v) v.begin(), v.end()
#define precision(n) fixed<<setprecision(n)

#ifdef LOCAL
    #include "debug.h"
#else
    #define debug(...) 42
#endif

void io(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);    
    #ifdef LOCAL
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
}

template<typename T> using oset = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update >;
template<typename T> using MinPriorityQueue = priority_queue <T, vector <T>, greater <T> >;
template<typename T> void done(T ans) {cout << ans << "\n"; exit(0);}


template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
  for(auto& i:x)
    input>>i;
  return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
  for(auto& i:x)
    output<<i<<' ';
  return output;
}
const int mod = 998244353;
const int N = 3e5 + 5;



int main() {
    io();
    int sum = 0;
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    if(k >= a) {
        sum += a;
        k -= a;
    }
    else {
        sum += k;
        cout << sum;
        return 0;
    }
    if(k >= b) {
        k -= b;
    }
    else {
        cout << sum;
        return 0;
    }
    if(k >= c) {
        sum -= c;
        k -= c;
    }
    else {
        sum -= k;
        cout << sum;
        return 0;
    }
    cout << sum;
}


Measured memory_bytes: 3652
from itertools import product


H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]
m = list(product([0, 1, -1], repeat=2))
for i in range(H):
    for j in range(W):
        if S[i][j] == '.':
            S[i][j] = 0
            for ii, jj in m:
                iii = i + ii
                jjj = j + jj
                if 0 <= iii < H and 0 <= jjj < W:
                    if S[iii][jjj] == '#':
                        S[i][j] += 1
            S[i][j] = str(S[i][j])
for s in S:
    print(('').join(s))

Measured memory_bytes: 3188
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string s;
    int K;
    cin >> s >> K;
    int cnt = 1;
    for (int i = 0; i < s.size(); i++){
        if (cnt <= K){
            if (s[i] == '1'){
                cnt++;
            } else {
                cout << s[i] - '0' << endl;
                return 0;
            }
        } else {
            cout << 1 << endl;
            return 0;
        }
    }
    cout << 1 << endl;
    return 0;
}



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

typedef long long ll;
const int MOD = 1000000007;

int main(){
  ll N; cin >> N;
  vector<ll> A(N);
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  ll sum = *(A.end() - 1);
  for(int i = 2; i < N; i++){
    int tmp = i / 2;
    sum += A[N-1-tmp];
  }
  cout << sum << endl;
}


Measured memory_bytes: 4816
def strip_left(str):
  if len(str) == 1:
    return ""
  else:
    return str[1:]

def role(str):
  if len(str) == 0:
    return 'z'
  else:
    return str[0].upper()


def solve(a,b,c):
  p = 'A'
  sa = a
  sb = b
  sc = c
  while True:
    if p == 'A':
      next_p = role(sa)
      sa = strip_left(sa)
      if next_p == 'z':
        return 'A'
      p = next_p
    elif p == 'B':
      next_p = role(sb)
      sb = strip_left(sb)
      if next_p == 'z':
        return 'B'
      p = next_p
    else:
      next_p = role(sc)
      sc = strip_left(sc)
      if next_p == 'z':
        return 'C'
      p = next_p

if __name__ == "__main__":
  a,b,c = [input() for _ in range(3)]
  print(solve(a,b,c))


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

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

//main code

int main(int argc, char const* argv[])
{
    LL n;
    cin >> n;
    VL a(n),sum(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sum[0] = a[0];
    for (int i = 1; i < n; i++) {
        sum[i] = sum[i-1] + a[i];
    }

    LL ans = INT64_MAX;
    for (int i = 0; i < n - 1; i++) {
        ans = min(ans,abs(sum[n-1] - sum[i]*2));
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3328
import java.util.*;

public class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String ans = "NO";
        if (n == 7 || n == 5 || n == 3)
            ans = "YES";
        System.out.println(ans);
    }

}


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

#define PI acos(-1)
#define int long long int
#define pb push_back
#define pi pair<int, int>
#define fir first
#define sec second
#define MAXN 1000001
#define mod 1000000007

vector<int> cnt(MAXN);

void crivo()
{
  cnt[0] = 0;
  for (int i = 1; i < MAXN; i++)
    for (int j = 1; j * i < MAXN; j++)
      cnt[j * i]++;
}
signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  crivo();
  int ans = 0;
  for (int c = 1; c < n; c++)
    ans += cnt[n - c];
  cout << ans << endl;
}

Measured memory_bytes: 11024
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define ln '\n'
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    ll ans = 0;
    for (int i = 1; i <= N; i++) {
        if (i % 3 == 0 or i%5== 0) continue;
        ans += i;
    }

    cout << ans << ln;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;

  cin >> A >> B;

  if(A > 12){
    cout << B << endl;
  }else if(A > 5){
    cout << B / 2 << endl;
  }else{
    cout << 0 << endl;
  }
  
  return 0;
}

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

int main() {
  long N,A,B;
  cin >> N >> A >> B;
  
  long ans;
  ans = N / (A + B) * A;
  ans += min(N % (A + B),A);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import deque
import copy

def main():
    h, w = map(int, input().split())
    a = [[j == "#" for j in input()] for _ in range(h)]


    # スタート地点をqueueに追加
    que = deque([(i, j) for i in range(h) for j in range(w) if a[i][j]])

    count = 0
    while True:
        count += 1
        nque = deque()
        while que:
            y, x = que.popleft()
            if x > 0 and not a[y][x-1]:
                a[y][x-1] = True
                nque.append((y,x-1))
            if x < w-1 and not a[y][x+1]:
                a[y][x+1] = True
                nque.append((y,x+1))
            if y > 0 and not a[y-1][x]:
                a[y-1][x] = True
                nque.append((y-1,x))
            if y < h-1 and not a[y+1][x]:
                a[y+1][x] = True
                nque.append((y+1,x))

        if nque:
            que = copy.copy(nque)
        else:
            break

    print(count - 1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 115492
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin>>S;
  if(S=="AAA"){
    cout<<"No"<<endl;
}
  else if(S=="BBB"){
    cout<<"No"<<endl;
}
  else {
    cout<<"Yes"<<endl;
}
}

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

using namespace std;
typedef long long ll;
#define PB push_back
#define MP make_pair
#define FF first
#define SS second

//void setIO(string s) {
//    ios_base::sync_with_stdio(0); cin.tie(0);
//    freopen((s+".in").c_str(),"r",stdin);
//    freopen((s+".out").c_str(),"w",stdout);
//}

void sieve() {
    vector<int> spf;
    int MAXN = 100001;
    spf[1] = 1;
    for (int i = 2; i < MAXN; i++)
        spf[i] = i;
    for (int i = 4; i < MAXN; i += 2)
        spf[i] = 2;
    for (int i = 3; i * i < MAXN; i++) {
        if (spf[i] == i) {
            for (int j = i * i; j < MAXN; j += i)
                if (spf[j] == j)
                    spf[j] = i;
        }
    }
}


vector<int> factors(int n) {
    vector<int> vi;
    for (int i = 1; i <= sqrt(n); ++i) {
        if (n % i == 0) {
            vi.push_back(i);
            if (i != sqrt(n)) {
                vi.push_back(n / i);
            }
        }
    }
    sort(vi.begin(), vi.end());
}

int factorial(int n) {
    if (n == 1)
        return 1;
    return n * factorial(n - 1);
}

int nCr(int n, int r) {
    return factorial(n) / (factorial(r) * factorial(n - r));
}


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int a;
    cin >> a;
    cout << a  + a * a + a * a * a << "\n";
}



Measured memory_bytes: 3640
using System;
using System.Linq;

namespace AtCoder_Begginer_Contest1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] ST = Console.ReadLine().Split();
            string S = ST[0];
            string T = ST[1];
            string ans = T + S;
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i, n) cin >> s[i];
    for (int i = 1; i < n; i++) {
        for (int j = 0; j < i; j++) {
            if (s[i] == s[j]) {
                cout << "No" << endl;
                return 0;
            }
        }
        if (s[i-1][s[i-1].size()-1] != s[i][0]) {
            cout << "No" << endl;
            return 0;
        } 
    }

    cout << "Yes" << endl;

    return 0;
}

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

int main() {
	string sp,st,hw,ew;
	map<string,int> sd;
	int s=0,e=0,k=0,h=0,m=0;
    getline(cin,st);
	st=st+"  ";
	while(e!=st.size()) {
	 for(e; st[e]!=' ' ;e++);
	 sp.append(st,s,e-s);
	 if (sp.length()>h) { h=sp.length(); hw=sp; }
	 if (sd.find(sp)==sd.end()) sd.insert(map<string,int>::value_type(sp,1));
	 else {sd[sp]++ ; if (sd[sp]>m) m=sd[sp]; }
	 e++; s=e; sp=""; 
	}
	map<string,int>::iterator it=sd.begin();
	for (h=0;it!=sd.end();it++) if (h<(*it).second) { h=(*it).second; ew=(*it).first;}
	cout << ew << " " << hw << endl;
	return 0;
}

Measured memory_bytes: 1196
#include<stdio.h>

#define MAX 500000
#define INFTY 1000000000

int L[MAX], R[MAX];
int count;

void merge(int*, int, int, int);
void mergeSort(int*, int, int);


int main(){

  int i;
  int A[MAX], n;
  
   count = 0;
   
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ) {
    scanf("%d", &A[i]);
    if (A[i] >= INFTY ){
      return 1;
    }
  }
  
  mergeSort(A, 0, n);

  for ( i = 0; i < n; i++ ) {
    if ( i ) printf(" ");
    printf("%d", A[i]);
    }
  printf("\n");

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

  return 0;
}


void merge(int A[], int left, int mid, int right){
  
  int i, j, k;

  int n1, n2;

   n1 = mid - left;
   n2 = right - mid;
   
   for ( i = 0; i < n1; i++ ){
     L[i] = A[left + i];
   }
   
   for ( i = 0; i < n2; i++ ){
     R[i] = A[mid + i];
   }
   
  L[n1] = INFTY;
  R[n2] = INFTY;
  
  i = 0;
  j = 0;
  
  for ( k = left; k < right; k++ ){
    
    count++;
    
    if ( L[i] <= R[j] ){
      A[k] = L[i];
      i = i + 1;
    }
    else {
      A[k] = R[j];
      j = j + 1;
    }
  }
}


void mergeSort(int A[], int left, int right ){
  
  int mid;
  
  if ( left + 1 < right ){
    
    mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
    
  }
}

Measured memory_bytes: 4512
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
 
 int main()
 {
   string s;
   map<char,int> mymap;
   mymap['I']=1;
   mymap['V']=5;
   mymap['X']=10;
   mymap['L']=50;
   mymap['C']=100;
   mymap['D']=500;
   mymap['M']=1000;
   while(cin>>s)
   {
     int sum=0;
     for(int i=0;i<s.length();i++)
     {
       if(i+1<s.length()&&mymap[s[i]]<mymap[s[i+1]]) sum-=mymap[s[i]];
       else sum+=mymap[s[i]];  
     }
     cout<<sum<<endl;
   }
   //while(1);
   return 0;
 }

Measured memory_bytes: 3184
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]float64, n)
	for i := range a {
		fmt.Scan(&a[i])
	}

	sum := 0.0
	for _, v := range a {
		sum += 1 / v
	}
	fmt.Println(1 / sum)
}


Measured memory_bytes: 512
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;



int main() {
    int n;
    string s;
    cin >> n >> s;
    rep(i, s.size()){
        char c = s[i];
        if ((c + n) > (int)'Z'){
            cout << (char)((c + n - 26));
        }else{
            cout << (char)((c + n));
        }
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds; 
using namespace std;
#define int long long
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define mii map<int,int>
#define mp make_pair
#define pb push_back
#define rep(i,b) for(ll (i)=0;i<(b);i++)
#define all(c) (c).begin(), (c).end()
#define F first
#define S second
#define CLR(p) memset(p, 0, sizeof(p))
#define SET(p) memset(p, -1, sizeof(p))
#define DEBUG true
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
//typedef long long int ll;
typedef tree<int, null_type, less<int>, rb_tree_tag, 
tree_order_statistics_node_update> new_data_set; 
const int MAX=1e6+5;
#define MOD 1000000007
/*std::cout << std::fixed;
std::cout << std::setprecision(6);*/
//(a%mod-b%mod+mod)%mod



/************************************


 
*************************************/

vector<vector<ll>>v;
ll T=0;
ll cnt1=0,cnt0=0;
vector<ll>dep;
bool visited[MAX];
vector<ll>par;
vector<ll>tin,tout;
vector<ll>col;
ll f=0,k=1;
map<pll,ll>m;
ll dp1[MAX],dp2[MAX];
ll red,blue;
ll ans;
ll dp[MAX];

ll lca(ll u,ll v){
	while(u!=v){
		ll l1,l2;
		l1 = log2(u);
		l2 = log2(v);
		//cout<<l1<<"$$"<<l2<<endl;
		if(l1<l2)
			swap(u,v);
		u /=2;
	}
	return u;
}

bool comp1(const pair<int,pll>&a,const pair<int,pll>&b){
	return (a.F<b.F);
}
// vector<int>r,g,b;
ll sum=INT64_MAX;

// ll s(int x,int y,int z){
// 	return ((ll)((x-y)*(x-y))+(ll)((y-z)*(y-z))+(ll)((z-x)*(z-x)));
// }




signed main(){
	boost;
	int t=1;
	// cin>>t;
	while(t--){
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		while(a>0&&c>0){
			if(f==0){
				c-=b;
				f=1;
			}
			else{
				f=0;
				a-=d;
			}
			// cout<<a<<" "<<c<<endl;
		}
		if(a>0){
			cout<<"Yes\n";
		}
		else cout<<"No\n";

	}

	return 0;
}

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

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

  if (n % 10 == 0)
    cout << "pon" << endl;
  else if (n % 10 == 1)
    cout << "pon" << endl;
  else if (n % 10 == 2)
    cout << "hon" << endl;
  else if (n % 10 == 3)
    cout << "bon" << endl;
  else if (n % 10 == 4)
    cout << "hon" << endl;
  else if (n % 10 == 5)
    cout << "hon" << endl;
  else if (n % 10 == 6)
    cout << "pon" << endl;
  else if (n % 10 == 7)
    cout << "hon" << endl;
  else if (n % 10 == 8)
    cout << "pon" << endl;
  else if (n % 10 == 9)
    cout << "hon" << endl;
}

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

#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;

using namespace std;



void oneCase() {
    vector<vector<int>> d(10, vector<int>(10, 1e9));
    int n = 10;
    int h, w;
    cin >> h >> w;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            cin >> d[i][j];
        }
    }
    for (int k = 0; k < n; ++k) {
        for (int l = 0; l < n; ++l) {
            for (int r = 0; r < n; ++r) {
                d[l][r] = min(d[l][r], d[l][k] + d[k][r]);
            }
        }
    }
    int res =0 ;
    for (int i = 0; i < h * w; ++i) {
        int a;
        cin >> a;
        if (a != -1) {
            res += d[a][1];
        }
    }
    cout << res << "\n";
}

int main() {
//    std::ios::sync_with_stdio(false);
//    std::cin.tie(nullptr);

    int t = 1;
//    cin >> t;
    while (t--) {
       oneCase();
    }

    return 0;
}


Measured memory_bytes: 256
import numpy as np
 
N,M = map(int,input().split())
A = np.array(input().split(),np.int64)
 
A = np.sort(A)
S = np.zeros(N+1,np.int64)
S[1:]= np.cumsum(A)
 
hi = 200001
lo = -1
 
while hi-lo > 1:
    mid = (hi+lo)//2
    above_mid = (N-np.searchsorted(A,mid-A,side='left')).sum()
    if above_mid >= M:
        lo = mid
    else:
        hi = mid
 
X = np.searchsorted(A,hi-A,side='left')
 
above_hi = (N-X).sum()
happiness = (S[-1]-S[X]).sum()
happiness += (A*(N-X)).sum()
happiness += (M-above_hi)*lo
 
print(happiness)

Measured memory_bytes: 22580